]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Converting ISymbolItems to SVG without selection elements 71/4771/2
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 14 Sep 2021 11:05:33 +0000 (14:05 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 14 Sep 2021 11:27:54 +0000 (11:27 +0000)
gitlab #748

Change-Id: I6d1c9b8081831e79169ab6368fb5ed426b2b2a6a

bundles/org.simantics.diagram/scl/Simantics/Diagram/SymbolLibrary.scl
bundles/org.simantics.diagram/src/org/simantics/diagram/scl/SymbolLibrary.java

index ce97a9349b4910cc24eb6a76f47eebbd5c40a5bc..2737ceb4175be1cec6b484352ced35ac7770b278 100644 (file)
@@ -45,5 +45,7 @@ importJava "org.simantics.diagram.scl.SymbolLibrary" where
   
   @JavaName create
   itemToContext :: ISymbolItem -> <Proc> ICanvasContext
+  @JavaName create
+  itemToContextWithSel :: ISymbolItem -> Boolean -> <Proc> ICanvasContext
   
   getItemResource :: ISymbolItem -> <Proc> Resource
\ No newline at end of file
index 9ab2bcd6ce3497ed6ae339e485ab87531d383437..35d414cd12e13d507377dc66623a5828a1e45676 100644 (file)
@@ -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());