import org.simantics.diagram.elements.DiagramNodeUtil;
import org.simantics.diagram.export.ImagePrinter;
import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.g2d.canvas.Hints;
import org.simantics.g2d.canvas.impl.CanvasContext;
import org.simantics.g2d.scenegraph.ICanvasSceneGraphProvider;
import org.simantics.layer0.Layer0;
thread.start();
final CanvasContext ctx = new CanvasContext(thread);
+ ctx.getDefaultHintContext().setHint(Hints.KEY_DISABLE_GRAPH_MODIFICATIONS, Boolean.TRUE);
final AtomicReference<ICanvasSceneGraphProvider> sgProvider = new AtomicReference<ICanvasSceneGraphProvider>();
final ISessionContext sessionContext = Simantics.getSessionContext();
final DataContainer<String> result = new DataContainer<String>(null);
if(!painterThread.currentThreadAccess()) throw new IllegalStateException("The callable should be called from the contextThread");
final CanvasContext ctx = new CanvasContext(loaderThread);
+ ctx.getDefaultHintContext().setHint(Hints.KEY_DISABLE_GRAPH_MODIFICATIONS, Boolean.TRUE);
final AtomicReference<ICanvasSceneGraphProvider> sgProvider = new AtomicReference<ICanvasSceneGraphProvider>();
final DataContainer<String> result = new DataContainer<String>(null);
final DataContainer<Exception> exception = new DataContainer<Exception>(null);
if (ftr != null) {
IFlagType ft = ftr.read(g, flag, modelingRules);
- FlagInfo info = ft.getInfo(g);
+ FlagInfo info = ft.getInfo(g, canvas);
Shape shape = info.getShape();
if (shape != null) {
import org.simantics.db.ReadGraph;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.g2d.canvas.ICanvasContext;
import org.simantics.g2d.elementclass.FlagClass;
import org.simantics.g2d.utils.Alignment;
* @param graph database read access
* @return all info gathered up about the flag
* @throws DatabaseException
+ * @Deprecated implement {@link #getInfo(ReadGraph, ICanvasContext)} instead
*/
- FlagInfo getInfo(ReadGraph graph) throws DatabaseException;
+ default FlagInfo getInfo(ReadGraph graph) throws DatabaseException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Reads and calculates information about this flags graphical
+ * representation.
+ *
+ * @param graph database read access
+ * @param context the canvas context with which the info is loaded
+ * @return all info gathered up about the flag
+ * @throws DatabaseException
+ */
+ default FlagInfo getInfo(ReadGraph graph, ICanvasContext context) throws DatabaseException {
+ return getInfo(graph);
+ }
}
* Set to true when the canvas is rendering to a printer
*/
public static final Key KEY_PRINT = new KeyOf(Boolean.class, "PRINTING");
-
-
+
+ /**
+ * Set this hint to <code>true</code> to prevent any modifications from
+ * being made to the diagram model by the diagram loading logic. Using this
+ * may be necessary for printing.
+ */
+ public static final Key KEY_DISABLE_GRAPH_MODIFICATIONS = new KeyOf(Boolean.class, "DISABLE_GRAPH_MODIFICATIONS");
+
private interface Dirty {}
/**
ICanvasSceneGraphProvider[] sgProvider = { null };
CanvasContext ctx = new CanvasContext(thread);
+ ctx.getDefaultHintContext().setHint(Hints.KEY_DISABLE_GRAPH_MODIFICATIONS, Boolean.TRUE);
try {
final Semaphore done = new Semaphore(0);