X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Futils%2FCanvasUtils.java;fp=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Futils%2FCanvasUtils.java;h=7059c946618445d3b1930e967edc2ba798db8bce;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=1a089b02ba6493d50edbaf10ba43429c912b0170;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/utils/CanvasUtils.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/utils/CanvasUtils.java index 1a089b02b..7059c9466 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/utils/CanvasUtils.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/utils/CanvasUtils.java @@ -1,135 +1,135 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.g2d.utils; - -import java.util.function.Supplier; - -import org.simantics.g2d.canvas.Hints; -import org.simantics.g2d.canvas.ICanvasContext; -import org.simantics.g2d.diagram.DiagramHints; -import org.simantics.g2d.diagram.IDiagram; -import org.simantics.scenegraph.g2d.events.command.Command; -import org.simantics.scenegraph.g2d.events.command.CommandEvent; -import org.simantics.scenegraph.g2d.events.command.Commands; -import org.simantics.utils.threads.IThreadWorkQueue; -import org.simantics.utils.threads.ThreadUtils; - -/** - * @author Toni Kalajainen - * @author Tuukka Lehtonen - */ -public class CanvasUtils { - - /** - * Enqueue a command in the event queue of the specified canvas context. - * - * @param ctx queue context - * @param commandId ID of the command to queue - * - * @see #sendCommand(ICanvasContext, Command) - */ - public static void sendCommand(ICanvasContext ctx, String commandId) - { - sendCommand(ctx, new Command(commandId)); - } - - /** - * Enqueue a command in the event queue of the specified canvas context. - * - * @param ctx queue context - * @param cmd the command to queue - */ - public static void sendCommand(ICanvasContext ctx, Command cmd) - { - CommandEvent e = new CommandEvent(ctx, System.currentTimeMillis(), cmd); - ctx.getEventQueue().queueEvent(e); - } - - /** - * A utility for scheduling a zoom-to-fit operation when an Eclipse - * workbench editor is initially opened. - * - *
- * There are two asynchronous calls, first into the workbench (SWT) UI
- * thread and then into the canvas context thread. This will guarantee that
- * the parenting SWT control has been resized to its actual size instead of
- * the initial (0,0) size which widgets start out at. In order to perform a
- * zoom-to-fit operation we simply have to know the bounds of the parenting
- * control. Thus, we need to ensure that this information is available and
- * correct.
- *
- * @param swtThread
- * @param disposed
- * @param canvasContext
- * @param diagramToFit
- */
- public static void scheduleZoomToFit(IThreadWorkQueue swtThread, final Supplier
- * There are two asynchronous calls, first into the workbench (SWT) UI
- * thread and then into the canvas context thread. This will guarantee that
- * the parenting SWT control has been resized to its actual size instead of
- * the initial (0,0) size which widgets start out at. In order to perform a
- * zoom-to-fit operation we simply have to know the bounds of the parenting
- * control. Thus, we need to ensure that this information is available and
- * correct.
- *
- * @param swtThread
- * @param disposed
- * @param canvasContext
- * @param diagramToFit
- * @param zoomToFit
- */
- public static void scheduleZoomToFit(IThreadWorkQueue swtThread, final Supplier
+ * There are two asynchronous calls, first into the workbench (SWT) UI
+ * thread and then into the canvas context thread. This will guarantee that
+ * the parenting SWT control has been resized to its actual size instead of
+ * the initial (0,0) size which widgets start out at. In order to perform a
+ * zoom-to-fit operation we simply have to know the bounds of the parenting
+ * control. Thus, we need to ensure that this information is available and
+ * correct.
+ *
+ * @param swtThread
+ * @param disposed
+ * @param canvasContext
+ * @param diagramToFit
+ */
+ public static void scheduleZoomToFit(IThreadWorkQueue swtThread, final Supplier
+ * There are two asynchronous calls, first into the workbench (SWT) UI
+ * thread and then into the canvas context thread. This will guarantee that
+ * the parenting SWT control has been resized to its actual size instead of
+ * the initial (0,0) size which widgets start out at. In order to perform a
+ * zoom-to-fit operation we simply have to know the bounds of the parenting
+ * control. Thus, we need to ensure that this information is available and
+ * correct.
+ *
+ * @param swtThread
+ * @param disposed
+ * @param canvasContext
+ * @param diagramToFit
+ * @param zoomToFit
+ */
+ public static void scheduleZoomToFit(IThreadWorkQueue swtThread, final Supplier