import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.image.VolatileImage;
import java.lang.reflect.Method;
import org.simantics.g2d.dnd.DragInteractor;
import org.simantics.g2d.dnd.DropInteractor;
import org.simantics.g2d.internal.DebugPolicy;
+import org.simantics.g2d.participant.TransformUtil;
import org.simantics.scenegraph.g2d.G2DRenderingHints;
import org.simantics.scenegraph.g2d.events.Event;
import org.simantics.scenegraph.g2d.events.IEventQueue;
private transient boolean closed = false;
protected ICanvasContext canvasContext;
+ private boolean useVolatileImage = true;
+
// Marks the content dirty
protected IContentListener contentListener = new IContentListener() {
@Override
holder.addMouseMotionListener(mouseAdapter);
holder.addMouseWheelListener(mouseAdapter);
holder.addFocusListener(focusAdapter);
+
+ TransformUtil util = canvasContext.getAtMostOneItemOfClass(TransformUtil.class);
+ if (util != null) {
+ mouseAdapter.initDragGestureListener(holder, (control) -> util.controlToCanvas(control, null));
+ }
+
}
};
if (AWTThread.getThreadAccess().currentThreadAccess())
public IHintContext getHintContext() {
return hintCtx;
}
+
+ public void setUseVolatileImage(boolean useVolatileImage) {
+ this.useVolatileImage = useVolatileImage;
+ }
+
+ public boolean isUseVolatileImage() {
+ return useVolatileImage;
+ }
private void paintScenegraph(Graphics2D g2d, Rectangle controlBounds) {
Color bg = getBackground();
startmem = Runtime.getRuntime().freeMemory();
start = System.nanoTime();
}
- VolatileImage buffer = paintToVolatileImage(g2d, b);
+ VolatileImage buffer = null;
+ if (useVolatileImage)
+ buffer = paintToVolatileImage(g2d, b);
if (closed)
return;
if (DebugPolicy.PERF_CHASSIS_RENDER_FRAME) {