mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Improved performance of the application when using dashed and dotted
style for 'Hookup Wire' component
This commit is contained in:
@@ -3362,6 +3362,10 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Added 'Font Size Override' property to most components that display text to allow control over font size</description>
|
<description>Added 'Font Size Override' property to most components that display text to allow control over font size</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Improved performance of the application when using dashed and dotted style for 'Hookup Wire' component</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Technical change: replace mechanism for dynamic JAR loading to ensure compatibility with Java 11 and newer</description>
|
<description>Technical change: replace mechanism for dynamic JAR loading to ensure compatibility with Java 11 and newer</description>
|
||||||
|
|||||||
@@ -17,8 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.diylc.components.connectivity;
|
package org.diylc.components.connectivity;
|
||||||
|
|
||||||
|
import java.awt.AlphaComposite;
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Composite;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.Stroke;
|
import java.awt.Stroke;
|
||||||
@@ -66,22 +68,40 @@ public class HookupWire extends AbstractCurvedComponent<Void> implements IContin
|
|||||||
: color;
|
: color;
|
||||||
g2d.setColor(curveColor);
|
g2d.setColor(curveColor);
|
||||||
Stroke stroke = null;
|
Stroke stroke = null;
|
||||||
|
Stroke tracingStroke = null;
|
||||||
switch (getStyle()) {
|
switch (getStyle()) {
|
||||||
case SOLID:
|
case SOLID:
|
||||||
stroke = ObjectCache.getInstance().fetchBasicStroke(thickness);
|
stroke = ObjectCache.getInstance().fetchBasicStroke(thickness);
|
||||||
|
tracingStroke = stroke;
|
||||||
break;
|
break;
|
||||||
case DASHED:
|
case DASHED:
|
||||||
stroke =
|
stroke =
|
||||||
ObjectCache.getInstance().fetchStroke(thickness, new float[] {thickness * 2, thickness * 3}, thickness * 4, BasicStroke.CAP_SQUARE);
|
ObjectCache.getInstance().fetchStroke(thickness, new float[] {thickness * 2, thickness * 3}, thickness * 4, BasicStroke.CAP_SQUARE);
|
||||||
|
tracingStroke = ObjectCache.getInstance().fetchBasicStroke(thickness);
|
||||||
break;
|
break;
|
||||||
case DOTTED:
|
case DOTTED:
|
||||||
stroke = ObjectCache.getInstance().fetchStroke(thickness, new float[] {thickness / 4, thickness * 3}, 0, BasicStroke.CAP_ROUND);
|
stroke = ObjectCache.getInstance().fetchStroke(thickness, new float[] {thickness / 4, thickness * 3}, 0, BasicStroke.CAP_ROUND);
|
||||||
|
tracingStroke = ObjectCache.getInstance().fetchBasicStroke(thickness);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Shape s = stroke.createStrokedShape(curve);
|
Shape s = stroke.createStrokedShape(curve);
|
||||||
drawingObserver.startTracking();
|
|
||||||
g2d.fill(s);
|
if (stroke == tracingStroke) {
|
||||||
drawingObserver.stopTracking();
|
g2d.fill(s);
|
||||||
|
drawingObserver.stopTracking();
|
||||||
|
} else {
|
||||||
|
// draw without tracking
|
||||||
|
drawingObserver.stopTracking();
|
||||||
|
g2d.fill(s);
|
||||||
|
// track with a simplified stroke without the dashes and dots to improve performance;
|
||||||
|
Shape traceShape = tracingStroke.createStrokedShape(curve);
|
||||||
|
drawingObserver.startTracking();
|
||||||
|
Composite oldComposite = g2d.getComposite();
|
||||||
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.DST, 0f));
|
||||||
|
g2d.fill(traceShape);
|
||||||
|
g2d.setComposite(oldComposite);
|
||||||
|
drawingObserver.stopTracking();
|
||||||
|
}
|
||||||
|
|
||||||
if (getStriped()) {
|
if (getStriped()) {
|
||||||
stroke = ObjectCache.getInstance().fetchStroke(thickness, new float[] { thickness / 2, thickness * 2 }, thickness * 10, BasicStroke.CAP_BUTT);
|
stroke = ObjectCache.getInstance().fetchStroke(thickness, new float[] { thickness / 2, thickness * 2 }, thickness * 10, BasicStroke.CAP_BUTT);
|
||||||
@@ -90,8 +110,6 @@ public class HookupWire extends AbstractCurvedComponent<Void> implements IContin
|
|||||||
g2d.fill(stripe);
|
g2d.fill(stripe);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawingObserver.stopTracking();
|
|
||||||
|
|
||||||
if (componentState == ComponentState.NORMAL) {
|
if (componentState == ComponentState.NORMAL) {
|
||||||
g2d.setColor(color.darker());
|
g2d.setColor(color.darker());
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||||
|
|||||||
Reference in New Issue
Block a user