mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
This commit is contained in:
Binary file not shown.
+5
-2
@@ -205,6 +205,8 @@ public class DrawingManager {
|
|||||||
// Do not track the area if component is not invalidated and was
|
// Do not track the area if component is not invalidated and was
|
||||||
// drawn in the same state.
|
// drawn in the same state.
|
||||||
boolean trackArea = lastDrawnStateMap.get(component) != state;
|
boolean trackArea = lastDrawnStateMap.get(component) != state;
|
||||||
|
|
||||||
|
synchronized (g2d) {
|
||||||
g2dWrapper.startedDrawingComponent();
|
g2dWrapper.startedDrawingComponent();
|
||||||
if (!trackArea) {
|
if (!trackArea) {
|
||||||
g2dWrapper.stopTracking();
|
g2dWrapper.stopTracking();
|
||||||
@@ -215,8 +217,8 @@ public class DrawingManager {
|
|||||||
}
|
}
|
||||||
// Draw the component through the g2dWrapper.
|
// Draw the component through the g2dWrapper.
|
||||||
try {
|
try {
|
||||||
component.draw(g2dWrapper, state, drawOptions.contains(DrawOption.OUTLINE_MODE),
|
component.draw(g2dWrapper, state,
|
||||||
project, g2dWrapper);
|
drawOptions.contains(DrawOption.OUTLINE_MODE), project, g2dWrapper);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error drawing " + component.getName(), e);
|
LOG.error("Error drawing " + component.getName(), e);
|
||||||
failedComponents.add(component);
|
failedComponents.add(component);
|
||||||
@@ -227,6 +229,7 @@ public class DrawingManager {
|
|||||||
lastDrawnStateMap.put(component, state);
|
lastDrawnStateMap.put(component, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw control points.
|
// Draw control points.
|
||||||
if (drawOptions.contains(DrawOption.CONTROL_POINTS)) {
|
if (drawOptions.contains(DrawOption.CONTROL_POINTS)) {
|
||||||
|
|||||||
+21
-3
@@ -24,6 +24,7 @@ import java.awt.geom.Area;
|
|||||||
import java.awt.geom.CubicCurve2D;
|
import java.awt.geom.CubicCurve2D;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
import java.awt.geom.Line2D;
|
import java.awt.geom.Line2D;
|
||||||
|
import java.awt.geom.NoninvertibleTransformException;
|
||||||
import java.awt.geom.PathIterator;
|
import java.awt.geom.PathIterator;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.geom.QuadCurve2D;
|
import java.awt.geom.QuadCurve2D;
|
||||||
@@ -64,6 +65,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
|||||||
private AffineTransform originalTx;
|
private AffineTransform originalTx;
|
||||||
private Font originalFont;
|
private Font originalFont;
|
||||||
private AffineTransform currentTx;
|
private AffineTransform currentTx;
|
||||||
|
private AffineTransform initialTx;
|
||||||
private Area currentArea;
|
private Area currentArea;
|
||||||
private Shape lastShape;
|
private Shape lastShape;
|
||||||
|
|
||||||
@@ -91,6 +93,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
|||||||
originalComposite = canvasGraphics.getComposite();
|
originalComposite = canvasGraphics.getComposite();
|
||||||
originalFont = canvasGraphics.getFont();
|
originalFont = canvasGraphics.getFont();
|
||||||
currentTx = new AffineTransform();
|
currentTx = new AffineTransform();
|
||||||
|
initialTx = canvasGraphics.getTransform();
|
||||||
lastShape = null;
|
lastShape = null;
|
||||||
startTracking();
|
startTracking();
|
||||||
}
|
}
|
||||||
@@ -294,8 +297,11 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
|||||||
if (drawingComponent && trackingAllowed) {
|
if (drawingComponent && trackingAllowed) {
|
||||||
FontMetrics fontMetrics = canvasGraphics.getFontMetrics();
|
FontMetrics fontMetrics = canvasGraphics.getFontMetrics();
|
||||||
Rectangle2D rect = fontMetrics.getStringBounds(str, canvasGraphics);
|
Rectangle2D rect = fontMetrics.getStringBounds(str, canvasGraphics);
|
||||||
appendShape(new Rectangle2D.Double(rect.getX() + x, rect.getY() + y, rect.getWidth(),
|
Point2D point = new Point2D.Double(x, y);
|
||||||
rect.getHeight()));
|
//currentTx.transform(point, point);
|
||||||
|
Rectangle2D finalRec = new Rectangle2D.Double(rect.getX() + point.getX(), rect.getY() + point.getY(), rect
|
||||||
|
.getWidth(), rect.getHeight());
|
||||||
|
appendShape(finalRec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,7 +440,19 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
|
|||||||
@Override
|
@Override
|
||||||
public void setTransform(AffineTransform Tx) {
|
public void setTransform(AffineTransform Tx) {
|
||||||
canvasGraphics.setTransform(Tx);
|
canvasGraphics.setTransform(Tx);
|
||||||
currentTx = Tx;
|
currentTx = new AffineTransform(Tx);
|
||||||
|
try {
|
||||||
|
// Invert the tx that was set before we started drawing the component.
|
||||||
|
// We're left only component tx.
|
||||||
|
AffineTransform inverseInitialTx = initialTx.createInverse();
|
||||||
|
Point2D p = new Point2D.Double(currentTx.getTranslateX(), currentTx.getTranslateY());
|
||||||
|
inverseInitialTx.transform(p, p);
|
||||||
|
currentTx.concatenate(inverseInitialTx);
|
||||||
|
double[] matrix = new double[6];
|
||||||
|
currentTx.getMatrix(matrix);
|
||||||
|
currentTx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], p.getX(), p.getY());
|
||||||
|
} catch (NoninvertibleTransformException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
|
|
||||||
private static final Logger LOG = Logger.getLogger(Presenter.class);
|
private static final Logger LOG = Logger.getLogger(Presenter.class);
|
||||||
|
|
||||||
public static final VersionNumber CURRENT_VERSION = new VersionNumber(3, 0, 9);
|
public static final VersionNumber CURRENT_VERSION = new VersionNumber(3, 1, 0);
|
||||||
public static final String DEFAULTS_KEY_PREFIX = "default.";
|
public static final String DEFAULTS_KEY_PREFIX = "default.";
|
||||||
|
|
||||||
public static final List<IDIYComponent<?>> EMPTY_SELECTION = Collections.emptyList();
|
public static final List<IDIYComponent<?>> EMPTY_SELECTION = Collections.emptyList();
|
||||||
|
|||||||
Reference in New Issue
Block a user