Stroke-Objekt wird in Formen zwischengespeichert

This commit is contained in:
ngb
2022-06-19 22:25:14 +02:00
parent 1ee03958d2
commit 6bc618a2df

View File

@@ -16,6 +16,8 @@ public abstract class StrokedShape extends Constants implements Drawable {
protected Options.StrokeType strokeType = SOLID; protected Options.StrokeType strokeType = SOLID;
protected Stroke stroke = null;
public Color getStrokeColor() { public Color getStrokeColor() {
return strokeColor; return strokeColor;
} }
@@ -54,6 +56,7 @@ public abstract class StrokedShape extends Constants implements Drawable {
public void setStrokeWeight( double weight ) { public void setStrokeWeight( double weight ) {
this.strokeWeight = weight; this.strokeWeight = weight;
this.stroke = null;
} }
public Options.StrokeType getStrokeType() { public Options.StrokeType getStrokeType() {
@@ -67,6 +70,7 @@ public abstract class StrokedShape extends Constants implements Drawable {
*/ */
public void setStrokeType( Options.StrokeType type ) { public void setStrokeType( Options.StrokeType type ) {
this.strokeType = DASHED; this.strokeType = DASHED;
this.stroke = null;
} }
@Override @Override
@@ -77,27 +81,33 @@ public abstract class StrokedShape extends Constants implements Drawable {
* @return * @return
*/ */
protected Stroke createStroke() { protected Stroke createStroke() {
if( stroke == null ) {
switch( strokeType ) { switch( strokeType ) {
case DOTTED: case DOTTED:
return new BasicStroke( stroke = new BasicStroke(
(float) strokeWeight, (float) strokeWeight,
BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND, BasicStroke.JOIN_ROUND,
10.0f, new float[]{1.0f, 5.0f}, 0.0f); 10.0f, new float[]{1.0f, 5.0f}, 0.0f);
break;
case DASHED: case DASHED:
return new BasicStroke( stroke = new BasicStroke(
(float) strokeWeight, (float) strokeWeight,
BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND, BasicStroke.JOIN_ROUND,
10.0f, new float[]{5.0f}, 0.0f); 10.0f, new float[]{5.0f}, 0.0f);
break;
case SOLID: case SOLID:
default: default:
return new BasicStroke( stroke = new BasicStroke(
(float) strokeWeight, (float) strokeWeight,
BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND); BasicStroke.JOIN_ROUND);
break;
} }
} }
return stroke;
}
public void resetStroke() { public void resetStroke() {
setStrokeColor(STD_STROKECOLOR); setStrokeColor(STD_STROKECOLOR);