mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
align rulers with extra space
This commit is contained in:
@@ -352,5 +352,10 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
|||||||
*
|
*
|
||||||
* @param xAxisFirst
|
* @param xAxisFirst
|
||||||
*/
|
*/
|
||||||
void renumberSelectedComponents(boolean xAxisFirst);
|
void renumberSelectedComponents(boolean xAxisFirst);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return size of extra space around the canvas
|
||||||
|
*/
|
||||||
|
double getExtraSpace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2503,4 +2503,20 @@ public class Presenter implements IPlugInPort {
|
|||||||
ConfigurationManager.getInstance().writeValue(BLOCKS_KEY, blocks);
|
ConfigurationManager.getInstance().writeValue(BLOCKS_KEY, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getExtraSpace() {
|
||||||
|
if (!ConfigurationManager.getInstance().readBoolean(EXTRA_SPACE_KEY, true))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
double extraSpace = drawingManager.getExtraSpace(currentProject);
|
||||||
|
boolean metric = ConfigurationManager.getInstance().readBoolean(Presenter.METRIC_KEY, true);
|
||||||
|
|
||||||
|
extraSpace /= Constants.PIXELS_PER_INCH;
|
||||||
|
|
||||||
|
if (metric)
|
||||||
|
extraSpace *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
|
||||||
|
|
||||||
|
return extraSpace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -34,6 +34,7 @@ import java.awt.event.MouseAdapter;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseWheelEvent;
|
import java.awt.event.MouseWheelEvent;
|
||||||
import java.awt.event.MouseWheelListener;
|
import java.awt.event.MouseWheelListener;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
@@ -175,6 +176,9 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
(canvasPanel.getHeight() - visibleRect.height) / 2);
|
(canvasPanel.getHeight() - visibleRect.height) / 2);
|
||||||
canvasPanel.scrollRectToVisible(visibleRect);
|
canvasPanel.scrollRectToVisible(visibleRect);
|
||||||
canvasPanel.revalidate();
|
canvasPanel.revalidate();
|
||||||
|
|
||||||
|
double extraSpace = CanvasPlugin.this.plugInPort.getExtraSpace();
|
||||||
|
getScrollPane().setZeroLocation(new Point2D.Double(extraSpace, extraSpace));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -292,8 +296,11 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
plugInPort.setMetric(isMetric);
|
plugInPort.setMetric(isMetric);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
double extraSpace = plugInPort.getExtraSpace();
|
||||||
|
scrollPane.setZeroLocation(new Point2D.Double(extraSpace, extraSpace));
|
||||||
|
|
||||||
// disable scrolling
|
// disable built-in scrolling mechanism, we'll do it manually
|
||||||
scrollPane.setWheelScrollingEnabled(false);
|
scrollPane.setWheelScrollingEnabled(false);
|
||||||
|
|
||||||
scrollPane.addMouseWheelListener(new MouseWheelListener() {
|
scrollPane.addMouseWheelListener(new MouseWheelListener() {
|
||||||
@@ -679,6 +686,9 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
|
|
||||||
canvasPanel.scrollRectToVisible(visibleRect);
|
canvasPanel.scrollRectToVisible(visibleRect);
|
||||||
canvasPanel.revalidate();
|
canvasPanel.revalidate();
|
||||||
|
|
||||||
|
double extraSpace = CanvasPlugin.this.plugInPort.getExtraSpace();
|
||||||
|
getScrollPane().setZeroLocation(new Point2D.Double(extraSpace, extraSpace));
|
||||||
|
|
||||||
zoomLevel = (Double) params[0];
|
zoomLevel = (Double) params[0];
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user