add striped option for twisted pair

This commit is contained in:
Branislav Stojkovic
2019-02-02 23:24:06 +01:00
parent efceedc924
commit 921b503057
10 changed files with 141 additions and 39 deletions
@@ -64,12 +64,12 @@ public class ObjectCache {
return stroke;
}
public Stroke fetchStroke(float width, float[] dash, float phase) {
String key = width + "|" + Arrays.toString(dash) + "|" + phase;
public Stroke fetchStroke(float width, float[] dash, float phase, int cap) {
String key = width + "|" + Arrays.toString(dash) + "|" + phase + "|" + phase;
if (dashStrokeMap.containsKey(key)) {
return dashStrokeMap.get(key);
}
Stroke stroke = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, dash, phase);
Stroke stroke = new BasicStroke(width, cap, BasicStroke.JOIN_ROUND, 0, dash, phase);
dashStrokeMap.put(key, stroke);
return stroke;
}
@@ -408,7 +408,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
BasicStroke bs = (BasicStroke) s;
// make thin lines even thinner to compensate for zoom factor
if (bs.getLineWidth() <= 2 && !(s instanceof ZoomableStroke))
s = ObjectCache.getInstance().fetchStroke((float) (bs.getLineWidth() / zoom), bs.getDashArray(), bs.getDashPhase());
s = ObjectCache.getInstance().fetchStroke((float) (bs.getLineWidth() / zoom), bs.getDashArray(), bs.getDashPhase(), bs.getEndCap());
}
canvasGraphics.setStroke(s);
}