/** * Updates the value of this transformation * to that of a scale transformation composed * with the current value. * * @param xScale the value to scale by in the x direction * @param yScale the value to scale by in the y direction * @return this transformation, with an updated matrix */ public AffineTransformation scale(double xScale, double yScale) { compose(scaleInstance(xScale, yScale)); return this; }
public static Geometry reflectInX(Geometry g) { Coordinate centre = envelopeCentre(g); AffineTransformation trans = AffineTransformation.scaleInstance(1, -1, centre.x, centre.y); return trans.transform(g); }
public static Geometry scale(Geometry g, double scale) { Coordinate centre = envelopeCentre(g); AffineTransformation trans = AffineTransformation.scaleInstance(scale, scale, centre.x, centre.y); return trans.transform(g); }
public static Geometry reflectInY(Geometry g) { Coordinate centre = envelopeCentre(g); AffineTransformation trans = AffineTransformation.scaleInstance(-1, 1, centre.x, centre.y); return trans.transform(g); }
private static AffineTransformation viewportTrans(Envelope srcEnv, Envelope viewEnv) { // works even if W or H are zero, thanks to Java infinity value. double scaleW = viewEnv.getWidth() / srcEnv.getWidth(); double scaleH = viewEnv.getHeight() / srcEnv.getHeight(); // choose minimum scale to ensure source fits viewport double scale = Math.min(scaleW, scaleH); Coordinate centre = srcEnv.centre(); Coordinate viewCentre = viewEnv.centre(); // isotropic scaling AffineTransformation trans = AffineTransformation.scaleInstance(scale, scale, centre.x, centre.y); // translate using envelope centres trans.translate(viewCentre.x - centre.x, viewCentre.y - centre.y); return trans; }
public void testScale1() throws IOException, ParseException { AffineTransformation t = AffineTransformation.scaleInstance(2, 3); checkTransformation(10, 0, t, 20, 0); checkTransformation(0, 10, t, 0, 30); checkTransformation(-10, -10, t, -20, -30); }