mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
optimize performance when rendering stripes
This commit is contained in:
Binary file not shown.
@@ -44,9 +44,13 @@ public class HookupWire extends AbstractCurvedComponent<Void> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color COLOR = Color.green;
|
||||
public static Color STRIPE_COLOR = Color.yellow;
|
||||
public static double INSULATION_THICKNESS_PCT = 0.3;
|
||||
|
||||
protected AWG gauge = AWG._22;
|
||||
|
||||
protected boolean striped = false;
|
||||
protected Color stripeColor = STRIPE_COLOR;
|
||||
|
||||
@Override
|
||||
protected Color getDefaultColor() {
|
||||
@@ -76,22 +80,19 @@ public class HookupWire extends AbstractCurvedComponent<Void> {
|
||||
}
|
||||
Shape s = stroke.createStrokedShape(curve);
|
||||
g2d.fill(s);
|
||||
|
||||
if (getStriped()) {
|
||||
stroke = ObjectCache.getInstance().fetchStroke(thickness, new float[] { thickness / 2, thickness * 2 }, thickness * 10, BasicStroke.CAP_BUTT);
|
||||
Shape stripe = stroke.createStrokedShape(curve);
|
||||
g2d.setColor(getStripeColor());
|
||||
drawingObserver.stopTracking();
|
||||
g2d.fill(stripe);
|
||||
drawingObserver.startTracking();
|
||||
}
|
||||
|
||||
if (componentState == ComponentState.NORMAL) {
|
||||
g2d.setColor(color.darker());
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
|
||||
// switch (getStyle()) {
|
||||
// case SOLID:
|
||||
// stroke = ObjectCache.getInstance().fetchBasicStroke(thickness - 2);
|
||||
// break;
|
||||
// case DASHED:
|
||||
// stroke =
|
||||
// ObjectCache.getInstance().fetchStroke(thickness - 2, new float[] {thickness * 2, thickness * 3},
|
||||
// thickness * 4);
|
||||
// break;
|
||||
// case DOTTED:
|
||||
// stroke = ObjectCache.getInstance().fetchStroke(thickness - 2, new float[] {thickness / 4, thickness * 3}, 0);
|
||||
// }
|
||||
// g2d.setStroke(stroke);
|
||||
g2d.draw(s);
|
||||
}
|
||||
}
|
||||
@@ -112,4 +113,24 @@ public class HookupWire extends AbstractCurvedComponent<Void> {
|
||||
|
||||
@Override
|
||||
public void setValue(Void value) {}
|
||||
|
||||
@EditableProperty(name = "Stripe")
|
||||
public boolean getStriped() {
|
||||
return striped;
|
||||
}
|
||||
|
||||
public void setStriped(boolean striped) {
|
||||
this.striped = striped;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Stripe Color")
|
||||
public Color getStripeColor() {
|
||||
if (stripeColor == null)
|
||||
stripeColor = STRIPE_COLOR;
|
||||
return stripeColor;
|
||||
}
|
||||
|
||||
public void setStripeColor(Color stripeColor) {
|
||||
this.stripeColor = stripeColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,16 +107,20 @@ public class TwistedWire extends AbstractCurvedComponent<Void> {
|
||||
g2d.fill(firstLeadArea);
|
||||
|
||||
if (stripe1 && componentState == ComponentState.NORMAL) {
|
||||
drawingObserver.stopTracking();
|
||||
g2d.setColor(stripeColor);
|
||||
g2d.fill(firstLeadStripeArea);
|
||||
drawingObserver.startTracking();
|
||||
}
|
||||
|
||||
g2d.setColor(curveColor2);
|
||||
g2d.fill(secondLeadArea);
|
||||
|
||||
if (stripe2 && componentState == ComponentState.NORMAL) {
|
||||
drawingObserver.stopTracking();
|
||||
g2d.setColor(stripeColor2);
|
||||
g2d.fill(secondLeadStripeArea);
|
||||
drawingObserver.startTracking();
|
||||
}
|
||||
|
||||
if (componentState == ComponentState.NORMAL) {
|
||||
@@ -215,7 +219,7 @@ public class TwistedWire extends AbstractCurvedComponent<Void> {
|
||||
return super.getStyle();
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Stripe 1")
|
||||
@EditableProperty(name = "Stripe Color 1")
|
||||
public Color getStripeColor() {
|
||||
return stripeColor;
|
||||
}
|
||||
@@ -224,7 +228,7 @@ public class TwistedWire extends AbstractCurvedComponent<Void> {
|
||||
this.stripeColor = stripeColor;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Stripe 2")
|
||||
@EditableProperty(name = "Stripe Color 2")
|
||||
public Color getStripeColor2() {
|
||||
return stripeColor2;
|
||||
}
|
||||
@@ -233,7 +237,7 @@ public class TwistedWire extends AbstractCurvedComponent<Void> {
|
||||
this.stripeColor2 = stripeColor2;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Show Stripe 1")
|
||||
@EditableProperty(name = "Stripe 1")
|
||||
public boolean getStripe1() {
|
||||
return stripe1;
|
||||
}
|
||||
@@ -250,7 +254,7 @@ public class TwistedWire extends AbstractCurvedComponent<Void> {
|
||||
}
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Show Stripe 2")
|
||||
@EditableProperty(name = "Stripe 2")
|
||||
public boolean getStripe2() {
|
||||
return stripe2;
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user