public static Path2D enlargeSlightlyInPlace(Path2D path2d) { AffineTransform aLittleLarger = new AffineTransform(); double centerX = path2d.getBounds2D().getCenterX(); double centerY = path2d.getBounds2D().getCenterY(); aLittleLarger.translate(centerX, centerY); aLittleLarger.scale(1.01, 1.01); aLittleLarger.translate(-centerX, -centerY); path2d.transform(aLittleLarger); return path2d; }
/** {@inheritDoc} */ protected final void transform(final AffineTransform transform) { path.transform(transform); } }
/** {@inheritDoc} */ protected final void transform(final AffineTransform transform) { path.transform(transform); } }
double startX = 100; double startY = 100; double endX = 500; double endY = 500; AffineTransform rotation = new AffineTransform(); double angle = Math.toRadians(90); rotation.rotate(angle, 200, 200); Path2D path = new Path2D.Double(); path.moveTo(startX, startY); path.lineTo(endX, endY); path.transform(rotation); double [] values = new double[6]; for(PathIterator it = path.getPathIterator(null); !it.isDone();) { it.currentSegment(values); System.out.println("["+values[0] + ", " + values[1] + "]"); it.next(); }
sFeint.transform(AffineTransform.getTranslateInstance(0, -echelonBounds.getHeight()-2));
sFeint.transform(AffineTransform.getTranslateInstance(0, -echelonBounds.getHeight()-2));
pixel.lineTo(1, 0); pixel.lineTo(0, 0); pixel.transform(AffineTransform.getScaleInstance(1+lap, 1+lap)); for (int i = 0; i < img.getWidth(); i++) for (int j = 0; j < img.getHeight(); j++) {
arrow.lineTo(0, -200); arrow.closePath(); arrow.transform(AffineTransform.getTranslateInstance(250, 250)); // !! shift it here return arrow; AffineTransform transform = new AffineTransform(m00, m10, m01, m11, m02, m12); arrow.transform(transform); arrow.transform(at.createInverse()); } catch (NoninvertibleTransformException e1) { e1.printStackTrace();
@Override public void actionPerformed(ActionEvent e) { path2D.transform(AffineTransform.getTranslateInstance(CAR_DELTA_X, CAR_DELTA_Y)); repaint();
/** * Transforms the given shape using the given projection, then apply a correction for fitting * the shape in the test viewer. This method also set the {@link #projection} to the resulting * concatenated transform. */ private Shape createReferenceShape(final Shape shape, MathTransform2D tr) throws TransformException { final Path2D path = transform(shape, tr); Rectangle2D bounds = path.getBounds2D(); final AffineTransform adjust = AffineTransform.getTranslateInstance(SHAPE_X, SHAPE_Y); adjust.scale(2*SHAPE_WIDTH / bounds.getWidth(), 2*SHAPE_HEIGHT / bounds.getHeight()); adjust.translate(-bounds.getX(), -bounds.getY()); path.transform(adjust); tr = MathTransforms.concatenate(tr, (MathTransform2D) org.geotoolkit.referencing.operation.MathTransforms.linear(adjust)); projection = tr; return path; }
int deltaX = e.getX() - point.x; int deltaY = e.getY() - point.y; myShape.transform(AffineTransform.getTranslateInstance(deltaX, deltaY)); point = e.getPoint(); repaint();
double ty = (getPreferredSize().getHeight() - star.getBounds().getHeight()) / 2; AffineTransform at = AffineTransform.getTranslateInstance(tx, ty); star.transform(at ); double anchory = getPreferredSize().getHeight() / 2; AffineTransform at = AffineTransform.getRotateInstance(BASE_THETA, anchorx, anchory); star.transform(at); repaint();
// java.awt.geom.Path2D implements java.awt.Shape java.awt.geom.Path2D path = new Path2D.Double(); path.moveTo(0, 0); path.lineTo(2, 0); path.lineTo(2, 2); path.lineTo(2, 0); path.closePath(); path.transform(AffineTransform.getScaleInstance(20, 20));
int ty = p.y - pPressed.y; AffineTransform at = AffineTransform.getTranslateInstance(tx, ty); myPath.transform(at); pPressed = p; repaint();
path1.quadTo(1.00, 1.00, 1.00, 0.50); path1.lineTo(0.67, 0.50); path1.transform(AffineTransform.getScaleInstance(0.8 * wTile, 0.6 * hTile)); path1.transform(AffineTransform.getTranslateInstance(x, y)); g.fill(path1); x += wTile; path1.transform(AffineTransform.getTranslateInstance(wTile, 0.0)); g.draw(path1); x += wTile; path2.curveTo(1.0, 0.6, 1.0, 0.8, 0.9, 0.9); path2.closePath(); path2.transform(AffineTransform.getScaleInstance(0.8*wTile, 0.6*hTile)); path2.transform(AffineTransform.getTranslateInstance(x, y)); g.fill(path2); x += wTile; path2.transform(AffineTransform.getTranslateInstance(wTile, 0.0)); g.draw(path2);
path.transform(AffineTransform.getTranslateInstance( (!props.isDimmensionsSwapped() ? -bounds.width/2f : -bounds.height/2f) + (scaledOffset+1)*props.getLeft(), (props.isDimmensionsSwapped() ? -bounds.width/2f : -bounds.height/2f) + (scaledOffset+1)*props.getTop())); path.transform(AffineTransform.getRotateInstance( props.getRotation())); path.transform(AffineTransform.getTranslateInstance( bounds.width/2f+bounds.x, bounds.height/2f+bounds.y));
final Path2D path = (Path2D) shape; if (allowOverwrite) { path.transform(transform); } else { shape = path.createTransformedShape(transform);
final Path2D path = (Path2D) shape; if (allowOverwrite) { path.transform(transform); } else { shape = path.createTransformedShape(transform);