public class DiagramNodeUtil {
public static ICanvasContext getCanvasContext(IG2DNode node) {
- G2DSceneGraph sg = NodeUtil.getPossibleRootNode(node);
+ G2DSceneGraph sg = node.getRootNode2D();
if (sg == null)
return null;
Component rootPane = sg.getRootPane();
}
public static ICanvasContext getPossibleCanvasContext(IG2DNode node) {
- G2DSceneGraph sg = NodeUtil.getPossibleRootNode(node);
+ G2DSceneGraph sg = node.getRootNode2D();
if (sg == null)
return null;
Component rootPane = sg.getRootPane();
}
public static final Set<String> getTexts(Set<TextNode> nodes) {
- Set<String> result = new HashSet<String>();
+ Set<String> result = new HashSet<String>(nodes.size());
for(TextNode n : nodes) result.add(n.getText());
return result;
}
String currentText = span.getText();
SingleElementNode sne = node.getSingleElementNode();
+ if (sne == null)
+ return;
+
Function1<String,String> fullTextFunction = sne.getParameter("textEditorFullText");
if(fullTextFunction != null)
es.currentText = fullTextFunction.apply(es.base.textElementId);
void applyEdit() {
SingleElementNode sne = node.getSingleElementNode();
- EditorState es = currentState();
- Function2<String,String,Object> editor = sne.getParameter("textEditor");
- if(editor != null) {
- editor.apply(es.base.textElementId, es.currentText);
+ if (sne != null) {
+ EditorState es = currentState();
+ Function2<String,String,Object> editor = sne.getParameter("textEditor");
+ if(editor != null) {
+ editor.apply(es.base.textElementId, es.currentText);
+ }
}
}
public void render(Graphics2D g2d) {
if (!parametersProcessed) {
SingleElementNode sne = getSingleElementNode();
- Boolean enableEditing = sne.getParameter("enableEditing");
- if (enableEditing != null && enableEditing) {
- esm = new EditorStateManager(this);
- addEventHandler(this);
+ if (sne != null) {
+ Boolean enableEditing = sne.getParameter("enableEditing");
+ if (enableEditing != null && enableEditing) {
+ esm = new EditorStateManager(this);
+ addEventHandler(this);
+ }
+ parametersProcessed = true;
}
- parametersProcessed = true;
}
super.render(g2d);
}
private boolean isSelected(IG2DNode node) {
- ICanvasContext ctx = DiagramNodeUtil.getCanvasContext(this);
+ ICanvasContext ctx = DiagramNodeUtil.getPossibleCanvasContext(this);
+ if (ctx == null)
+ return false;
IElement ie = DiagramNodeUtil.getElement(ctx, node);
if (ie == null)
return false;
}
SingleElementNode getSingleElementNode() {
- ICanvasContext ctx = DiagramNodeUtil.getCanvasContext(this);
- // FIXME: needed only because eventdelegator registrations are done before adding node to scene graph.
- if (ctx == null)
- return null;
return (SingleElementNode)NodeUtil.getNearestParentOfType(this, SingleElementNode.class);
}