private int snap(int snapMe){
return java.lang.Math.round( snapMe/parent.SnapSlider.getValue() )*parent.SnapSlider.getValue();
}
@Override public void mouseDragged(MouseEvent e) {
Frame selected = getSelectedFrame();
if(selected==null) return;
if((e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == MouseEvent.BUTTON3_DOWN_MASK) {
if(parent.isSettingOffsetDirectly())
handleEditOffset(selected,e);
if(parent.isSettingOffsetWithRelativePos())
freeOffsetEnd = getViewPoint(e);
if(parent.isSettingPivot())
selected.setPivot(new Point(getViewX(e),getViewY(e)));
if(parent.isRectangleLocked()) {
int x = snap(getViewX(e)), y = snap(getViewY(e));
selected.setRectangle(new Rectangle(x,y,parent.lockRectButton.lastRect.width,parent.lockRectButton.lastRect.height));
selected.setImageFile(editorFrame.getData().getProject().getRelativeFile(imageFile));
int PivotDX = parent.lockRectButton.lastPivot.x - parent.lockRectButton.lastRect.x;
int PivotDY = parent.lockRectButton.lastPivot.y - parent.lockRectButton.lastRect.y;
selected.setPivot(new Point(x+PivotDX,y+PivotDY));
}
if(parent.isEditingRectangle()){
Rectangle rect = selected.getRectangle();
int x = snap(rect.x), y = snap(rect.y);
int dx = snap(getViewX(e)-x), dy = snap(getViewY(e)-y);
Rectangle newRectangle = new Rectangle(x,y,dx,dy);
selected.setRectangle(newRectangle);
selected.setImageFile(editorFrame.getData().getProject().getRelativeFile(imageFile));
}
if(parent.isSettingOffsetWithTemporaryPivot()) {
if(parent.temporaryPivotOffsetButton.getPivot2()!=null) {
parent.temporaryPivotOffsetButton.setPivot2(getViewPoint(e));
selected.setOffset(parent.temporaryPivotOffsetButton.getOffset());
}
else
parent.temporaryPivotOffsetButton.setPivot1(getViewPoint(e));
}
}