mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 09:42:08 +10:00
painting optimization
This commit is contained in:
+5
-1
@@ -62,6 +62,7 @@ class G2DWrapper extends Graphics2D {
|
|||||||
private Font originalFont;
|
private Font originalFont;
|
||||||
private AffineTransform currentTx;
|
private AffineTransform currentTx;
|
||||||
private Area currentArea;
|
private Area currentArea;
|
||||||
|
private Shape lastFilledShape;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a wrapper around specified {@link Graphics2D} object.
|
* Creates a wrapper around specified {@link Graphics2D} object.
|
||||||
@@ -87,6 +88,7 @@ class G2DWrapper extends Graphics2D {
|
|||||||
originalComposite = canvasGraphics.getComposite();
|
originalComposite = canvasGraphics.getComposite();
|
||||||
originalFont = canvasGraphics.getFont();
|
originalFont = canvasGraphics.getFont();
|
||||||
currentTx = new AffineTransform();
|
currentTx = new AffineTransform();
|
||||||
|
lastFilledShape = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,6 +119,7 @@ class G2DWrapper extends Graphics2D {
|
|||||||
Area area = new Area(s);
|
Area area = new Area(s);
|
||||||
area.transform(currentTx);
|
area.transform(currentTx);
|
||||||
currentArea.add(area);
|
currentArea.add(area);
|
||||||
|
lastFilledShape = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,7 +128,8 @@ class G2DWrapper extends Graphics2D {
|
|||||||
* @param s
|
* @param s
|
||||||
*/
|
*/
|
||||||
private void appendShapeOutline(Shape s) {
|
private void appendShapeOutline(Shape s) {
|
||||||
if (!drawingComponent) {
|
// Do not add shape outline if the same shape has been filled recently.
|
||||||
|
if (!drawingComponent || s.equals(lastFilledShape)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PathIterator pathIterator = s.getPathIterator(null);
|
PathIterator pathIterator = s.getPathIterator(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user