Skip to content
Snippets Groups Projects
Commit 4549dff4 authored by Marko Luukkainen's avatar Marko Luukkainen
Browse files

Retrieving symbol graphics with SymbolLibrary SCL API does not work.

Using CurrentThread instead of AWTThread fixes the problem.

refs #1252
parent 458cc629
Branches
No related tags found
No related merge requests found
......@@ -36,6 +36,7 @@ import org.simantics.g2d.tooltip.TooltipParticipant;
import org.simantics.scenegraph.g2d.events.command.CommandKeyBinding;
import org.simantics.utils.datastructures.hints.IHintContext;
import org.simantics.utils.threads.AWTThread;
import org.simantics.utils.threads.CurrentThread;
import org.simantics.utils.threads.IThreadWorkQueue;
public class SymbolLibrary {
......@@ -48,23 +49,23 @@ public class SymbolLibrary {
IDiagram diagram = Diagram.spawnNew(DiagramClass.DEFAULT);
diagram.setHint(FlowLayout.HGAP, 5.0);
diagram.setHint(FlowLayout.VGAP, 5.0);
IThreadWorkQueue thread = AWTThread.getThreadAccess();
// Note: Current thread seems to work with simupedia. Thus we do not need work thread system as with o.s.modeling.SCLScenegraph.
IThreadWorkQueue thread = CurrentThread.getThreadAccess(); //AWTThread.getThreadAccess();
CanvasContext ctx = new CanvasContext(thread);
initializeCanvasContext(ctx,selection);
IHintContext hintCtx = ctx.getDefaultHintContext();
hintCtx.setHint(DiagramHints.KEY_DIAGRAM, diagram);
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);
hintCtx.setHint(DiagramHints.KEY_DIAGRAM, diagram);
return ctx;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment