public static Area enlargeSlightlyInPlace(Area area, float scale) { AffineTransform aLittleLarger = new AffineTransform(); double centerX = area.getBounds2D().getCenterX(); double centerY = area.getBounds2D().getCenterY(); aLittleLarger.translate(centerX, centerY); aLittleLarger.scale(scale, scale); aLittleLarger.translate(-centerX, -centerY); area.transform(aLittleLarger); return area; }
public Display(String title, int width, int height, Area area) { this(title, width, height); double scaleX = (width * 0.9) / area.getBounds().getWidth(); double scaleY = (height * 0.9) / area.getBounds().getHeight(); double scale = Math.min(scaleX, scaleY); AffineTransform affineTransform = new AffineTransform(); affineTransform.translate(width / 2, height / 2); affineTransform.scale(scale, scale); affineTransform.translate(-area.getBounds2D().getCenterX(), -area.getBounds2D().getCenterY()); area.transform(affineTransform); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = (Graphics2D) image.getGraphics(); graphics.fill(area); this.bufferedImage = image; }
@Override public void run() { a.transform(atb); } }));
/** {@inheritDoc} */ protected void transform(final AffineTransform transform) { area.transform(transform); } }
/** {@inheritDoc} */ protected void transform(final AffineTransform transform) { area.transform(transform); } }
/** Translates the region over the given distance. @param dx The distance in the x-dimension over which to translate. @param dy The distance in the y-dimension over which to translate. */ public void translate(final int dx, final int dy) { area.transform(new AffineTransform(1,0,0,1,dx,dy)); }
final Area area = (Area) shape; if (overwrite) { area.transform(transform); } else { shape = area.createTransformedArea(transform);
private Shape getShadowMask( Shape parentMask ) { Area area = new Area(parentMask); AffineTransform tx = new AffineTransform(); tx.translate(SHADOW_SIZE, SHADOW_SIZE );//Math.sin(ANGLE)*(getHeight()+SHADOW_SIZE), 0); area.transform(tx); area.subtract(new Area(parentMask)); return area; }
@Override protected void transformData(final AffineTransform aff) { if (null == aw) return; aw.getArea().transform(aff); } }
/** A little square for each pixel in @param layer.*/ @Override synchronized public Area getAreaAt(final Layer layer) { final Area a = new Area(); for (int i=0; i<n_points; i++) { if (p_layer[i] != layer.getId()) continue; a.add(new Area(new Rectangle2D.Float((float)p[0][i], (float)p[1][i], 1, 1))); } a.transform(this.at); return a; }
static public final Area getArea(final ShapeRoi sroi) { if (null == sroi) return null; final AffineTransform at = new AffineTransform(); final Rectangle bounds = sroi.getBounds(); at.translate(bounds.x, bounds.y); final Area area = new Area(sroi.getShape()); area.transform(at); return area; }
/** In world coordinates. Returns an empty area when there aren't any nodes in @param layer. */ @Override public Area getAreaAt(final Layer layer) { synchronized (node_layer_map) { final Area a = new Area(); final Set<Node<T>> nodes = node_layer_map.get(layer); if (null == nodes) return a; // empty for (final Node<T> nd : nodes) a.add(nd.getArea()); // all local a.transform(this.at); return a; } }
@Override public Object process(final Node<T> nd) { final Area a = nd.getArea(); a.transform(Tree.this.at); final Collection<Displayable> col = layer_set.find(c, nd.la, a, false, true); if (col.isEmpty()) return null; synchronized (m) { m.put(nd, col); } return null; } });
private final Set<Displayable> getUnder(final Node<Float> node, final Class<?> c, final boolean instance_of) { final Area a = node.getArea(); a.transform(this.at); final HashSet<Displayable> targets = new HashSet<Displayable>(layer_set.find(c, node.la, a, false, instance_of)); targets.remove(this); return targets; }
/** Whether the area of the root node intersects the world coordinates {@code wx}, {@code wy} at {@link Layer} {@code la}. */ public boolean intersectsOrigin(final double wx, final double wy, final Layer la) { if (null == root || root.la != la) return false; final Area a = root.getArea(); a.transform(this.at); return a.contains(wx, wy); }
public boolean intersectsOrigin(final Area area, final Layer la) { if (null == root || root.la != la) return false; final Area a = root.getArea(); a.transform(this.at); return M.intersects(area, a); }
private Area[] buildTicker() { Area[] ticker = new Area[barsCount]; double fixedAngle = 2.0 * Math.PI / ((double) barsCount); for (int i = 0; i < barsCount; i++) { Area primitive = buildSectorPrimitive(barsCount, 60, 100, 0.9f); AffineTransform toCircle = AffineTransform.getRotateInstance( -(double) i * fixedAngle, 0.0d, 0.0d); primitive.transform(toCircle); ticker[i] = primitive; } return ticker; }
@Override public void run() { // WARNING potential concurrent modification exception of 'nodes' for (final AreaNode nd : (Collection<AreaNode>) nodes) { nd.translate(dx, dy); // just the x,y itself if (null != nd.aw) nd.aw.getArea().transform(aff); } } }));
@Override synchronized public Area getAreaAt(final Layer layer) { final Area a = new Area(); for (int i=0; i<n_points; i++) { if (p_layer[i] != layer.getId()) continue; a.add(new Area(new Ellipse2D.Float((float)(p[0][i] - p_width[i]/2), (float)(p[1][i] - p_width[i]/2), (float)p_width[i], (float)p_width[i]))); } a.transform(this.at); return a; }
public void translate(double tx, double ty) { if (_transform == null) { _transform = new Transform(_gc.getDevice()); } _transform.translate((int) tx, (int) ty); _gc.setTransform(_transform); if (_clippingArea != null) { AffineTransform t = new AffineTransform(); t.translate(-tx, -ty); _clippingArea.transform(t); } }