BasicStroke bs = null;
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);
}
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();