MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / scaleShape

Method scaleShape

ij/src/main/java/ij/plugin/RoiScaler.java:123–142  ·  view source on GitHub ↗
(ShapeRoi roi, double xscale, double yscale, boolean centered)

Source from the content-addressed store, hash-verified

121 }
122
123 private static Roi scaleShape(ShapeRoi roi, double xscale, double yscale, boolean centered) {
124 Rectangle r = roi.getBounds();
125 Shape shape = roi.getShape();
126 AffineTransform at = new AffineTransform();
127 at.scale(xscale, yscale);
128 if (!centered)
129 at.translate(r.x, r.y);
130 Shape shape2 = at.createTransformedShape(shape);
131 Roi roi2 = new ShapeRoi(shape2);
132 if (centered) {
133 int xbase = (int)(centered?r.x-(r.width*xscale-r.width)/2.0:r.x);
134 int ybase = (int)(centered?r.y-(r.height*yscale-r.height)/2.0:r.y);
135 roi2.setLocation(xbase, ybase);
136 }
137 roi2.copyAttributes(roi);
138 double width = roi.getStrokeWidth();
139 if (width!=0)
140 roi2.setStrokeWidth(width*xscale);
141 return roi2;
142 }
143
144 private static Roi scaleText(TextRoi roi, double xscale, double yscale, boolean centered) {
145 Rectangle bounds = roi.getBounds();

Callers 1

scaleMethod · 0.95

Calls 8

getStrokeWidthMethod · 0.80
getBoundsMethod · 0.65
getShapeMethod · 0.65
scaleMethod · 0.45
translateMethod · 0.45
setLocationMethod · 0.45
copyAttributesMethod · 0.45
setStrokeWidthMethod · 0.45

Tested by

no test coverage detected