importJava "org.simantics.diagram.scl.SymbolLibrary" where
@JavaName create
- itemToContext :: ISymbolItem -> <Proc> ICanvasContext
\ No newline at end of file
+ itemToContext :: ISymbolItem -> <Proc> ICanvasContext
+
+ getItemResource :: ISymbolItem -> <Proc> Resource
\ No newline at end of file
import java.awt.Color;
+import org.simantics.db.Resource;
import org.simantics.diagram.symbollibrary.ISymbolItem;
import org.simantics.g2d.canvas.Hints;
import org.simantics.g2d.canvas.ICanvasContext;
ElementClass ec = item.getElementClass(diagram);
StaticSymbol ss = ec.getSingleItem(StaticSymbol.class);
Image source = ss == null ? DefaultImages.UNKNOWN2.get() : ss.getImage();
+ //ImageProxy proxy = new ImageProxy(source);
IElement element = Element.spawnNew(ec);
element.setHint(ElementHints.KEY_OBJECT, item);
element.setHint(GalleryItemSGNode.KEY_IMAGE, source);
diagram.addElement(element);
+ //element.getElementClass().getSingleItem(GalleryItemSGNode.class).update(element);
+
return ctx;
}
+ public static Resource getItemResource(ISymbolItem item) {
+ return item.getAdapter(Resource.class);
+ }
+
private static void initializeCanvasContext(final CanvasContext canvasContext) {
// Create canvas context and a layer of interactors
final IHintContext h = canvasContext.getDefaultHintContext();