import org.simantics.g2d.element.SceneGraphNodeKey;
import org.simantics.g2d.element.handler.SceneGraph;
import org.simantics.g2d.image.Image;
+import org.simantics.scenegraph.INode;
import org.simantics.scenegraph.Node;
import org.simantics.scenegraph.g2d.G2DParentNode;
import org.simantics.scenegraph.g2d.nodes.SingleElementNode;
// }
// Rendering is single-threaded, this is used while rendering.
- Rectangle2D tempBounds = new Rectangle2D.Double(0, 0, 0, 0);
+ //Rectangle2D tempBounds = new Rectangle2D.Double(0, 0, 0, 0);
@Override
public Node init(G2DParentNode parent) {
// Optimization for 0..1 element composites
for (IElement e : elements) {
ElementClass ec = e.getElementClass();
- G2DParentNode node = parent.getOrCreateNode("composite_image_"+this.hashCode(), G2DParentNode.class);
+ G2DParentNode node = getOrCreateParentNode(parent);
List<SceneGraph> nodeHandlers = ec.getItemsByClass(SceneGraph.class);
for (SceneGraph n : nodeHandlers) {
// n.init(e, parent);
// For N element composites
- // Removed this grouping node as unnecessary, just use the given parent node
- G2DParentNode node = parent.getOrCreateNode("composite_image_"+this.hashCode(), G2DParentNode.class);
-
+ G2DParentNode node = getOrCreateParentNode(parent);
// Rectangle2D bounds = tempBounds;
int zIndex = 0;
return node; // Valid node must be returned because transform is set afterwards
}
-// public static class TypeProxyElement extends ProxyElement {
-// IHintContext instanceHints;
-// public TypeProxyElement(IElement orig, IHintContext instanceHints) {
-// super(orig);
-// this.instanceHints = instanceHints;
-// }
-// @Override
-// public <E> E getHint(Key key) {
-// // TODO: need some mechanism to tell whether it is allowed to look for this key in the instance hints or not
-// // This version is broken because some hints MUST come from the original element.
-// E e = null;
-// if (instanceHints != null)
-// e = instanceHints.getHint(key);
-// if (e == null)
-// e = orig.getHint(key);
-// return e;
-// }
-// @Override
-// public Map<Key, Object> getHints() {
-// throw new UnsupportedOperationException();
-// }
-// @Override
-// public <E extends Key> Map<E, Object> getHintsOfClass(Class<E> clazz) {
-// throw new UnsupportedOperationException();
-// }
-// @Override
-// public void setHint(Key key, Object value) {
-// if (instanceHints != null)
-// instanceHints.setHint(key, value);
-// else
-// orig.setHint(key, value);
-// }
-// }
+ private G2DParentNode getOrCreateParentNode(G2DParentNode parent) {
+ G2DParentNode node = (G2DParentNode)parent.getNode("composite_image_"+this.hashCode());
+ if (node == null) {
+ for (INode n : parent.getNodes())
+ n.remove();
+ // Removed this grouping node as unnecessary, just use the given parent node
+ node = parent.getOrCreateNode("composite_image_"+this.hashCode(), G2DParentNode.class);
+ }
+ return node;
+ }
}
import org.simantics.databoard.Bindings;
import org.simantics.db.AsyncReadGraph;
import org.simantics.db.Resource;
+import org.simantics.db.common.primitiverequest.PossibleAdapter;
+import org.simantics.db.common.procedure.adapter.AsyncProcedureAdapter;
import org.simantics.db.common.procedure.adapter.ProcedureAdapter;
import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
import org.simantics.db.common.procedure.guarded.GuardedAsyncProcedureWrapper;
import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;
import org.simantics.g2d.element.handler.impl.StaticSymbolImageInitializer;
import org.simantics.g2d.element.handler.impl.StaticSymbolImpl;
-import org.simantics.g2d.element.handler.impl.Terminals;
import org.simantics.g2d.element.handler.impl.TextImpl;
-import org.simantics.g2d.elementclass.ImageClass;
import org.simantics.g2d.elementclass.PlainElementPropertySetter;
import org.simantics.g2d.tooltip.TerminalTooltipProvider;
import org.simantics.g2d.tooltip.TooltipParticipant;
// This is needed for terminal tooltips.
e.setHint(TooltipParticipant.TOOLTIP_KEY, TerminalTooltipProvider.INSTANCE);
+ graph.asyncRequest(new PossibleAdapter<ElementFactory>(element, ElementFactory.class), new AsyncProcedureAdapter<ElementFactory>() {
+ @Override
+ public void execute(AsyncReadGraph graph, ElementFactory factory) {
+ if (factory != null) {
+ graph.asyncRequest(new GetElementClassRequest(factory, element, canvas, diagram));
+ }
+ }
+ });
+
ElementFactoryUtil.readParameters(graph, element, e);
GuardedAsyncProcedureWrapper<IElement> guard = new GuardedAsyncProcedureWrapper<IElement>(procedure, 1);