*******************************************************************************/
package org.simantics.maps.eclipse;
+import java.awt.Color;
import java.awt.geom.AffineTransform;
import org.simantics.g2d.canvas.Hints;
import org.simantics.g2d.canvas.impl.SGNodeReflection.SGInit;
import org.simantics.maps.sg.MapNode;
import org.simantics.maps.sg.MapScaleNode;
+import org.simantics.maps.sg.commands.MapCommands;
import org.simantics.scenegraph.g2d.G2DParentNode;
import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler;
import org.simantics.scenegraph.g2d.events.command.CommandEvent;
*/
public static final Key KEY_MAP_ENABLED = new KeyOf(Boolean.class);
+ public static final Key KEY_MAP_BACKGROUND_COLOR = new KeyOf(Object.class);
+
public static final double ZOOM_IN_LIMIT = 10000000.0;
public static final double ZOOM_OUT_LIMIT = 10.0;
public void addedToContext(ICanvasContext ctx) {
super.addedToContext(ctx);
getHintStack().addKeyHintListener(getThread(), KEY_MAP_ENABLED, mapListener);
+ getHintStack().addKeyHintListener(getThread(), KEY_MAP_BACKGROUND_COLOR, mapListener);
}
@Override
public void removedFromContext(ICanvasContext ctx) {
getHintStack().removeKeyHintListener(getThread(), KEY_MAP_ENABLED, mapListener);
+ getHintStack().removeKeyHintListener(getThread(), KEY_MAP_BACKGROUND_COLOR, mapListener);
super.removedFromContext(ctx);
}
updateNode();
setDirty();
return true;
+ } else if (e.command.equals( MapCommands.MAP_BACKGROUND_COLOR_CHANGE )) {
+ ICanvasContext context = (ICanvasContext) e.getContext();
+ Color s = context.getHintStack().getHint(MapCommands.KEY_MAP_BACKGROUND_COLOR);
+ setBackgroundColor(s);
+ setDirty();
+ return true;
} else if (e.command.equals( Commands.MAP_DISABLE )) {
setEnabled(false);
updateNode();
updateNode();
setDirty();
return true;
+ } else if (e.command.equals( Commands.ENABLE_PAINTING )) {
+ enablePainting();
+ updateNode();
+ setDirty();
+ return true;
}
return false;
}
protected void updateNode() {
node.setEnabled(isPaintingEnabled());
+ node.setEnabled(isMapEnabled());
+ node.setBackgroundColor(getBackgroundColor());
}
boolean isPaintingEnabled() {
setHint(KEY_MAP_ENABLED, enabled);
}
+ private void enablePainting() {
+ setHint(Hints.KEY_DISABLE_PAINTING, false);
+ }
+
+ private void setBackgroundColor(Color backgroundColor) {
+ setHint(KEY_MAP_BACKGROUND_COLOR, backgroundColor);
+ }
+
+ private Color getBackgroundColor() {
+ return getHint(KEY_MAP_BACKGROUND_COLOR);
+ }
}