package org.simantics.modeling;
import java.awt.BasicStroke;
+import java.awt.Color;
import java.awt.Dimension;
import java.awt.RenderingHints;
import java.awt.RenderingHints.Key;
import org.simantics.diagram.elements.TextGridNode;
import org.simantics.diagram.elements.TextNode;
import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.g2d.canvas.Hints;
import org.simantics.g2d.canvas.ICanvasContext;
import org.simantics.g2d.diagram.DiagramHints;
import org.simantics.g2d.diagram.IDiagram;
}
return "No nodes in scenegraph!";
}
+
+ /**
+ * Returns background color of a canvasContext or null.
+ * @param ctx
+ * @return color in RGBA List<Integer> format, or null.
+ */
+ public static List<Integer> getBackgroundColor(ICanvasContext ctx) {
+ Color color = ctx.getDefaultHintContext().getHint(Hints.KEY_BACKGROUND_COLOR);
+ if (color == null)
+ return null;
+ ArrayList<Integer> rgba = new ArrayList<>(4);
+ rgba.add(color.getRed());
+ rgba.add(color.getGreen());
+ rgba.add(color.getBlue());
+ rgba.add(color.getAlpha());
+ return rgba;
+ }
public static String sceneGraphTest (ICanvasContext ctx, String module, String value) {
parentBuilder.append(SELECTION_SECTION, "\n</g>");
parentBuilder.append(MAIN_SECTION, "\n</g>");
- } else if (node instanceof SelectionNode) {
+ } else if (isSelection0(node)) {
SelectionNode n = (SelectionNode)node;
SingleElementNode parentSEN = (SingleElementNode)NodeUtil.getNearestParentOfType(node, SingleElementNode.class);
parentBuilder2.append(SELECTION_MASK_SECTION,"\n</g>");
}
+ } else if (node instanceof SelectionNode) {
+
+ Element doc = renderSVGNode(svgGenerator, (IG2DNode)node);
+ String svg = printSVGDocument(doc);
+ parentBuilder.append(MAIN_SECTION, "<g>");
+ parentBuilder.append(MAIN_SECTION, svg);
+ parentBuilder.append(MAIN_SECTION, "\n</g>");
+
} else if (node instanceof SVGNode) {
SVGNode svg = (SVGNode)node;
parentBuilder.append(MAIN_SECTION, svg.getSVGText());
}
+ private boolean isSelection0(IG2DNode node) {
+
+ if(node instanceof SelectionNode) {
+ SelectionNode sn = (SelectionNode)node;
+ return sn.getSelectionId() == 0;
+ } else {
+ return false;
+ }
+
+ }
+
private RenderSVGContext getParentBuilder(IG2DNode node) {
INode parentSEN = NodeUtil.getNearestParentOfType(node, SingleElementNode.class);