From: Marko Luukkainen Date: Tue, 14 Sep 2021 11:05:33 +0000 (+0300) Subject: Converting ISymbolItems to SVG without selection elements X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F71%2F4771%2F2;p=simantics%2Fplatform.git Converting ISymbolItems to SVG without selection elements gitlab #748 Change-Id: I6d1c9b8081831e79169ab6368fb5ed426b2b2a6a --- diff --git a/bundles/org.simantics.diagram/scl/Simantics/Diagram/SymbolLibrary.scl b/bundles/org.simantics.diagram/scl/Simantics/Diagram/SymbolLibrary.scl index ce97a9349..2737ceb41 100644 --- a/bundles/org.simantics.diagram/scl/Simantics/Diagram/SymbolLibrary.scl +++ b/bundles/org.simantics.diagram/scl/Simantics/Diagram/SymbolLibrary.scl @@ -45,5 +45,7 @@ importJava "org.simantics.diagram.scl.SymbolLibrary" where @JavaName create itemToContext :: ISymbolItem -> ICanvasContext + @JavaName create + itemToContextWithSel :: ISymbolItem -> Boolean -> ICanvasContext getItemResource :: ISymbolItem -> Resource \ No newline at end of file diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/scl/SymbolLibrary.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/scl/SymbolLibrary.java index 9ab2bcd6c..35d414cd1 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/scl/SymbolLibrary.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/scl/SymbolLibrary.java @@ -41,12 +41,16 @@ import org.simantics.utils.threads.IThreadWorkQueue; public class SymbolLibrary { public static ICanvasContext create(ISymbolItem item) { + return create(item, true); + } + + public static ICanvasContext create(ISymbolItem item, boolean selection) { IDiagram diagram = Diagram.spawnNew(DiagramClass.DEFAULT); diagram.setHint(FlowLayout.HGAP, 5.0); diagram.setHint(FlowLayout.VGAP, 5.0); IThreadWorkQueue thread = AWTThread.getThreadAccess(); CanvasContext ctx = new CanvasContext(thread); - initializeCanvasContext(ctx); + initializeCanvasContext(ctx,selection); IHintContext hintCtx = ctx.getDefaultHintContext(); hintCtx.setHint(DiagramHints.KEY_DIAGRAM, diagram); @@ -69,7 +73,7 @@ public class SymbolLibrary { return item.getAdapter(Resource.class); } - private static void initializeCanvasContext(final CanvasContext canvasContext) { + private static void initializeCanvasContext(final CanvasContext canvasContext, boolean selection) { // Create canvas context and a layer of interactors final IHintContext h = canvasContext.getDefaultHintContext(); @@ -93,7 +97,7 @@ public class SymbolLibrary { canvasContext.add( pi ); canvasContext.add( new Selection() ); canvasContext.add( new DiagramParticipant() ); - canvasContext.add( new ElementPainter() ); + canvasContext.add( new ElementPainter(selection) ); canvasContext.add( new ElementInteractor() ); canvasContext.add( new TooltipParticipant());