BasicStroke oldStroke = (BasicStroke) g2d.getStroke();
BasicStroke bs = null;
+ double scale = 1.0;
if (scaleStroke) {
- double scale = GeometryUtils.getScale(g2d.getTransform());
- scale = Math.max(10000, Math.min(scale, 50000));
- double str = stroke != null ? Math.abs(stroke) : 1.0;
- bs = GeometryUtils.scaleStroke(STROKE, (float) (str / scale));
+ AffineTransform tr = g2d.getTransform();
+ scale = DistrictNetworkNodeUtils.getScale(tr);
+ bs = GeometryUtils.scaleStroke(STROKE, getStrokeWidth(scale));
} else {
bs = STROKE;
}
if (isSelected()) {
g2d.setColor(SELECTION_COLOR);
- g2d.setStroke(GeometryUtils.scaleStroke(bs, 4f));
+ g2d.setStroke(GeometryUtils.scaleAndOffsetStrokeWidth(bs, 1.f, (float)(2 * STROKE.getLineWidth() / scale)));
g2d.draw(path);
}
// Draw arrow
if (arrowLength != null) {
g2d.setColor(Color.BLACK);
- g2d.setStroke(new BasicStroke(bs.getLineWidth(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+ float lw = STROKE.getLineWidth() / (float)scale;
+ g2d.setStroke(new BasicStroke(lw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
double l = arrowLength;
- double w = 2 * (double) bs.getLineWidth() * Math.signum(l);
+ double w = 2 * (double) lw * Math.signum(l);
if (Math.abs(w) > Math.abs(l)) w = l;
- double offset = 2 * (double) bs.getLineWidth();
+ double offset = 2 * (double) lw;
double centerX = (startX + endX) / 2, centerY = (startY + endY) / 2;
double deltaX = endX - startX, deltaY = endY - startY;
// Render SVG symbol
double viewScaleRecip = 10;
if (scaleStroke) {
- double scale = GeometryUtils.getScale(g2d.getTransform());
- scale = Math.max(10000, Math.min(scale, 50000));
viewScaleRecip /= scale;
}
g2d.setTransform(ot);
}
+ public float getStrokeWidth(AffineTransform tr, boolean selection) {
+ double scale = DistrictNetworkNodeUtils.getScale(tr);
+ float width = STROKE.getLineWidth() * getStrokeWidth(scale);
+ if (selection) width = width + (float) (2 * STROKE.getLineWidth() / scale);
+ return width;
+ }
+
+ private float getStrokeWidth(double scale) {
+ if (scaleStroke) {
+ double str = stroke != null ? Math.abs(stroke) : 1.0;
+ float strokeWidth = (float) (str / scale);
+ return strokeWidth;
+ }
+ else {
+ return 1.f;
+ }
+ }
+
+ public Path2D getPath() {
+ return path;
+ }
+
private Point2D getCenterPoint() {
if (centerPoint == null)
centerPoint = new Point2D.Double();