X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.maps%2Fsrc%2Forg%2Fsimantics%2Fmaps%2Feclipse%2FMapPainter.java;h=5e989546723e2966866dcb5ea78d0683cc5d8efd;hb=b018055e3c5809d33161154aebdc47f733721cdb;hp=ef88e1c55ea9fdf266506ffbcd82c41b6a75a954;hpb=6b98761b9c2e9835629d2c0aabefe92657d6d36b;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.maps/src/org/simantics/maps/eclipse/MapPainter.java b/org.simantics.district.maps/src/org/simantics/maps/eclipse/MapPainter.java index ef88e1c5..5e989546 100644 --- a/org.simantics.district.maps/src/org/simantics/maps/eclipse/MapPainter.java +++ b/org.simantics.district.maps/src/org/simantics/maps/eclipse/MapPainter.java @@ -23,7 +23,8 @@ import org.simantics.g2d.canvas.impl.SGNodeReflection.SGCleanup; import org.simantics.g2d.canvas.impl.SGNodeReflection.SGInit; import org.simantics.g2d.participant.MouseUtil; import org.simantics.maps.sg.MapAttributionNode; -import org.simantics.maps.sg.MapLocationZoomInfoNode; +import org.simantics.maps.sg.MapInfoNode; +import org.simantics.maps.sg.MapLocationInfoNode; import org.simantics.maps.sg.MapNode; import org.simantics.maps.sg.MapScaleNode; import org.simantics.maps.sg.commands.MapCommands; @@ -76,13 +77,13 @@ public class MapPainter extends AbstractCanvasParticipant { } }; - protected MapNode node = null; - protected MapScaleNode scaleNode = null; + private MapNode mapNode; + private MapLocationInfoNode locationInfoNode; + private MapScaleNode scaleNode; + private MapInfoNode attributionNode; private AffineTransform transform; - private MapLocationZoomInfoNode locationZoomInfoNode; - private ScheduledFuture schedule; public MapPainter(AffineTransform transform) { @@ -139,7 +140,7 @@ public class MapPainter extends AbstractCanvasParticipant { public boolean handleEvent(Event e) { if (e instanceof MouseMovedEvent) { // here we should somehow re-render ? - if (locationZoomInfoNode.isEnabled()) { + if (locationInfoNode != null && locationInfoNode.isEnabled()) { if (schedule == null || schedule.isDone()) { LOGGER.debug("current setDirty time" + System.currentTimeMillis()); schedule = ThreadUtils.getNonBlockingWorkExecutor().schedule(() -> { @@ -155,38 +156,42 @@ public class MapPainter extends AbstractCanvasParticipant { @SGInit public void initSG(G2DParentNode parent) { - node = parent.addNode("map", MapNode.class); - node.setTransform(transform); - node.setEnabled(true); - node.setZIndex(Integer.MIN_VALUE + 999); // Just under the grid - + // Just under the grid + mapNode = parent.addNode("map", MapNode.class); + mapNode.setTransform(transform); + mapNode.setEnabled(true); + mapNode.setZIndex(Integer.MIN_VALUE + 999); + + // On top of pretty much everything + attributionNode = parent.addNode("mapAttribution", MapAttributionNode.class); + attributionNode.setTransform(transform); + attributionNode.setZIndex(Integer.MAX_VALUE - 999); + attributionNode.setEnabled(true); + scaleNode = parent.addNode("mapScale", MapScaleNode.class); scaleNode.setTransform(transform); + scaleNode.setZIndex(Integer.MAX_VALUE - 998); scaleNode.setEnabled(true); - scaleNode.setZIndex(Integer.MAX_VALUE - 999); // Just under the grid - - locationZoomInfoNode = parent.addNode("locationZoomInfo", MapLocationZoomInfoNode.class); - locationZoomInfoNode.setTransform(transform); - locationZoomInfoNode.setEnabled(true); - MouseUtil mouseUtil = getContext().getAtMostOneItemOfClass(MouseUtil.class); - locationZoomInfoNode.setMouseUtil(mouseUtil); - locationZoomInfoNode.setZIndex(Integer.MAX_VALUE - 999); // Just under the grid - - MapAttributionNode addNode = parent.addNode("mapAttribution", MapAttributionNode.class); - addNode.setTransform(transform); - addNode.setEnabled(true); - addNode.setZIndex(Integer.MAX_VALUE - 999); + + locationInfoNode = parent.addNode("mapLocationInfo", MapLocationInfoNode.class); + locationInfoNode.setTransform(transform); + locationInfoNode.setZIndex(Integer.MAX_VALUE - 997); + locationInfoNode.setEnabled(true); + locationInfoNode.setMouseUtil(getContext().getAtMostOneItemOfClass(MouseUtil.class)); } @SGCleanup public void cleanupSG() { - node.remove(); + mapNode.remove(); + attributionNode.remove(); + scaleNode.remove(); + locationInfoNode.remove(); } protected void updateNode() { - node.setEnabled(isPaintingEnabled()); - node.setEnabled(isMapEnabled()); - node.setBackgroundColor(getBackgroundColor()); + mapNode.setEnabled(isPaintingEnabled()); + mapNode.setEnabled(isMapEnabled()); + mapNode.setBackgroundColor(getBackgroundColor()); } boolean isPaintingEnabled() {