public static Rectangle2D getAnchor(Graphics2D graphics, Rectangle2D anchor) { if(graphics == null) { return anchor; } AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM); if(tx != null && !tx.isIdentity() && tx.createTransformedShape(anchor) != null) { anchor = tx.createTransformedShape(anchor).getBounds2D(); } return anchor; }
if (tx.isIdentity()) { return normalizedShape;
/** * Creates a transform for the specified matrix as a Java2D object. This method is provided for * interoperability with <A * HREF="http://java.sun.com/products/java-media/2D/index.jsp">Java2D</A>. * * @param matrix The affine transform as a matrix. * @return The transform for the given matrix. */ public static LinearTransform create(final AffineTransform matrix) { if (matrix.isIdentity()) { return IdentityTransform.create(2); } return new AffineTransform2D(matrix); }
/** * Returns an iterator object that iterates along the <code>Shape</code> boundary and provides * access to the geometry of the <code>Shape</code> outline. */ public PathIterator getPathIterator(AffineTransform at) { if (!isIdentity()) { if (at == null || at.isIdentity()) { return shape.getPathIterator(this); } at = new AffineTransform(at); at.concatenate(this); } return shape.getPathIterator(at); }
/** * Returns an iterator object that iterates along the <code>Shape</code> boundary and provides * access to a flattened view of the <code>Shape</code> outline geometry. */ public PathIterator getPathIterator(AffineTransform at, final double flatness) { if (!isIdentity()) { if (at == null || at.isIdentity()) { return shape.getPathIterator(this, flatness); } at = new AffineTransform(at); at.concatenate(this); } return shape.getPathIterator(at, flatness); }
/** Returns a {@link ROI} object based on the input {@link RenderedImage} representing ROI */ public static ROI scaleROI(RenderedImage roiRaster, Rectangle bounds) { if (roiRaster == null) { return null; } int x = bounds.x; int y = bounds.y; int w = bounds.width; int h = bounds.height; // Scale factors for input data final double scaleX = w / (1.0 * roiRaster.getWidth()); final double scaleY = h / (1.0 * roiRaster.getHeight()); AffineTransform tr = AffineTransform.getScaleInstance(scaleX, scaleY); // Translation Factors final int transX = x; final int transY = y; tr.concatenate(AffineTransform.getTranslateInstance(transX, transY)); // Log the Scale/Translate operation if (!tr.isIdentity()) { LOGGER.fine("Scaling ROI"); } // Input Mask is scaled to the image size, rescaled to Bytes and then used as ROI return new ImageWorker(roiRaster).affine(tr, null, null).binarize(1).getImageAsROI(); }
if (tr.isIdentity()) { return true;
if (result != null && transform != null && !transform.isIdentity()) { result = new TransformedShape(result, transform);
} else if ((at == null) || at.isIdentity()) { combined = affineTransform; } else {
/** * @param ls * @param at */ public void init(LineString ls, AffineTransform at) { if ((at == null) || (at.isIdentity())) { this.at = null; } else { this.at = at; } CoordinateSequence coordinates = ls.getCoordinateSequence(); if (coordinates instanceof LiteCoordinateSequence) { // array already there for us allCoords = ((LiteCoordinateSequence) coordinates).getXYArray(); actualCoords = coordinates.size(); } else { // build the array actualCoords = coordinates.size(); allCoords = new double[actualCoords * 2]; for (int t = 0; t < actualCoords; t++) { allCoords[t * 2] = coordinates.getOrdinate(t, 0); allCoords[t * 2 + 1] = coordinates.getOrdinate(t, 1); } } done = false; currentCoord = 0; }
/** * Returns {@code true} if the backing affine transform is the identity transform. */ @Override public boolean isIdentity() { return transform.isIdentity(); }
if (Px.isIdentity() && (width != defaultWidth || height != defaultHeight)) {
if (!at.isIdentity())
if ((cropBox.getLowerLeftX() < 0 || cropBox.getLowerLeftY() < 0) && transform.isIdentity())
if (!at.isIdentity())
public void transform(Grob g, Transform t, boolean override) { if (override) { currentTransform = new Transform(); } if (!transform.getAffineTransform().isIdentity()) { Transform revertedTransform = transform.clone(); revertedTransform.invert(); g.transform(revertedTransform); } currentTransform.append(t); Rect bounds = g.getBounds(); double dx = bounds.getX() + bounds.getWidth() / 2; double dy = bounds.getY() + bounds.getHeight() / 2; transform = currentTransform.clone(); if (context.transform() == Transform.Mode.CENTER) { Transform n = new Transform(); n.translate(dx, dy); transform.prepend(n); n = new Transform(); n.translate(-dx, -dy); transform.append(n); } g.transform(transform); } }
/** Expects world coords; with precision depending on magnification. */ public Node<T> findClosestNodeW(final Collection<Node<T>> nodes, final float wx, final float wy, final double magnification) { float lx = wx, ly = wy; if (!this.at.isIdentity()) { final Point2D.Double po = inverseTransformPoint(wx, wy); lx = (float)po.x; ly = (float)po.y; } return findClosestNode(nodes, lx, ly, magnification); }
/** {@inheritDoc} */ protected void concatenateTransformationMatrix(AffineTransform at) { if (!at.isIdentity()) { concatenateTransformationMatrixMpt(ptToMpt(at), false); } }
/** Returns a new Rectangle which encloses completly the given rectangle after transforming it with this Displayable's AffineTransform. The given rectangle's fields are untouched.*/ final public Rectangle transformRectangle(final Rectangle r) { if (this.at.isIdentity()) return (Rectangle)r.clone(); return new Area(r).createTransformedArea(this.at).getBounds(); }
@Override public Collection<Displayable> findLinkTargets(final AffineTransform aff) { if (null == aw) return super.findLinkTargets(aff); Area a = aw.getArea(); if (!aff.isIdentity()) { a = a.createTransformedArea(aff); } return this.la.getDisplayables(Patch.class, a, true); }