@SGInit
public void initSG(G2DParentNode parent) {
- node = parent.addNode("ruler", RulerNode.class);
+ node = parent.addNode("ruler", getNodeClass());
node.setZIndex(PAINT_PRIORITY);
updateNode();
}
+ protected Class<? extends RulerNode> getNodeClass() {
+ return RulerNode.class;
+ }
+
@SGCleanup
public void cleanupSG() {
node.remove();
addKeyBindingParticipants(ctx);
// Grid & Ruler & Background
- ctx.add(new GridPainter());
- ctx.add(new RulerPainter());
- ctx.add(new BackgroundPainter());
+ addGridRulerBackgroundParticipants(ctx);
h.setHint(Hints.KEY_DISPLAY_PAGE, diagramPreferences.get(DiagramPreferences.P_DISPLAY_PAGE_SIZE));
h.setHint(Hints.KEY_DISPLAY_MARGINS, diagramPreferences.get(DiagramPreferences.P_DISPLAY_MARGINS));
ctx.setLocked(false);
}
+ protected void addGridRulerBackgroundParticipants(CanvasContext ctx) {
+ ctx.add(new GridPainter());
+ ctx.add(new RulerPainter());
+ ctx.add(new BackgroundPainter());
+ }
+
protected void loadPageSettings(ICanvasContext ctx) {
DiagramDesc diagramDesc = null;
//VIEWS.SharedLibraryContribution2 : SWT.TypedVariableTabContribution
// SEL.AbstractVariableTabContribution.HasPriority 1
-// SEL.AbstractTypedVariableTabContribution.HasType L0.SharedOntology
+// SEL.AbstractTypedTabContribution.HasType L0.SharedOntology
// SWT.TypedVariableTabContribution.HasView SharedLibraries
// L0.HasLabel "Shared Libraries"
// Vertical ruler
for(double x = offsetX%stepX-stepX; x < bounds.getMaxX(); x+=stepX) {
if(x > 20) {
- String str = formatValue((x-offsetX)/scaleX);
+ double val = (x-offsetX)/scaleX;
+ double modifiedValue = modifyHorizontalValue(val);
+ String str = formatValue(modifiedValue);
FontMetrics fm = g.getFontMetrics();
Rectangle2D r = fm.getStringBounds(str, g);
if((x-r.getWidth()/2) > previousText) {
for(double y = offsetY%stepY-stepY; y < bounds.getMaxY(); y+=stepY) {
if(y > 20) {
double val = (y-offsetY)/scaleY;
- if (MAP_Y_SCALING)
- val = Math.toDegrees(Math.atan(Math.sinh(Math.toRadians(val))));
- String str = formatValue(val);
+ double modifiedValue = modifyVerticalValue(val);
+ String str = formatValue(modifiedValue);
FontMetrics fm = g.getFontMetrics();
Rectangle2D r = fm.getStringBounds(str, g);
if(y-1+r.getHeight()/2 > previousText) {
g.setTransform(tr);
}
+ /**
+ * A method for subclasses to alter the actual X-value of the ruler
+ *
+ * @param value
+ * @return possibly modified X-value
+ */
+ protected double modifyHorizontalValue(double value) {
+ return value;
+ }
+
+ /**
+ * A method for subclasses to alter the actual Y-value of the ruler
+ *
+ * @param value
+ * @return possibly modified Y-value
+ */
+ protected double modifyVerticalValue(double value) {
+ return value;
+ }
+
private static final transient int MAX_DIGITS = 5;
private static final transient double EPSILON = 0.01;
private static final transient double TRIM_THRESHOLD_MAX_VALUE = Math.pow(10, 4);