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;
}
};
- 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) {
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(() -> {
@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() {