Search in sources :

Example 11 with Point2D

use of java.awt.geom.Point2D in project dbeaver by serge-rider.

the class ImageViewUtil method transformPoint.

/**
     * Given an arbitrary point, get the point with the given transform.
     *
     * @param af affine transform
     * @param pt point to be transformed
     * @return point after tranform
     */
public static Point transformPoint(AffineTransform af, Point pt) {
    Point2D src = new Point2D.Float(pt.x, pt.y);
    Point2D dest = af.transform(src, null);
    Point point = new Point((int) Math.floor(dest.getX()), (int) Math.floor(dest.getY()));
    return point;
}
Also used : Point2D(java.awt.geom.Point2D) Point(org.eclipse.swt.graphics.Point)

Example 12 with Point2D

use of java.awt.geom.Point2D in project antlrworks by antlr.

the class GPathElement method getBounds.

public Rectangle getBounds() {
    if (nodeOrLink != null) {
        return nodeOrLink.getBounds();
    } else {
        Point2D a = getBeginPoint();
        int x1 = (int) a.getX();
        int y1 = (int) a.getY();
        int x2 = (int) target.getCenterX();
        int y2 = (int) target.getCenterY();
        return new Rectangle(x1, y1, x2 - x1, y2 - y1);
    }
}
Also used : Point2D(java.awt.geom.Point2D)

Example 13 with Point2D

use of java.awt.geom.Point2D in project gephi by gephi.

the class SplineDisplay method resetSelection.

private void resetSelection() {
    Point2D oldSelected = selected;
    selected = null;
    if (oldSelected != null) {
        Rectangle bounds = getDraggableArea(oldSelected).getBounds();
        repaint(bounds.x, bounds.y, bounds.width, bounds.height);
    }
}
Also used : Point2D(java.awt.geom.Point2D) Rectangle(java.awt.Rectangle)

Example 14 with Point2D

use of java.awt.geom.Point2D in project binnavi by google.

the class ZoomFunctions method zoomToNode.

public static <NodeType extends ZyGraphNode<?>> void zoomToNode(final AbstractZyGraph<NodeType, ?> graph, final NodeType node, final int line, final boolean animate) {
    Preconditions.checkNotNull(node, "Error: Node argument can't be null");
    final IZyNodeRealizer realizer = node.getRealizer();
    Preconditions.checkNotNull(realizer, "Error: Node does not belong to the graph");
    final double offset = realizer.getNodeContent().getLineHeight() * line;
    final Point2D oldViewPoint = graph.getView().getViewPoint2D();
    graph.getView().setCenter(realizer.getCenterX(), (realizer.getCenterY() - (realizer.getHeight() / 2)) + offset);
    if (animate) {
        final Point2D newCenter = graph.getView().getCenter();
        graph.getView().setViewPoint((int) oldViewPoint.getX(), (int) oldViewPoint.getY());
        graph.getView().focusView(graph.getView().getZoom(), newCenter, graph.getSettings().getLayoutSettings().getAnimateLayout());
    }
    graph.updateViews();
}
Also used : Point2D(java.awt.geom.Point2D) IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)

Example 15 with Point2D

use of java.awt.geom.Point2D in project binnavi by google.

the class ZoomHelpers method getMinimumZoom.

/**
   * Calculates the smallest valid zoom level.
   * 
   * @return The smallest valid zoom level.
   */
public static double getMinimumZoom(final Graph2DView view) {
    double zoomlevel = view.getZoom();
    if (zoomlevel < 0) {
        zoomlevel = 1;
    }
    final Point2D viewPoint = view.getViewPoint2D();
    final Rectangle2D box = view.getGraph2D().getBoundingBox();
    // why? => to gain the
    view.zoomToArea(box.getX(), box.getY(), box.getWidth(), box.getHeight());
    // minimum zoom level
    // in the next line
    final double minZoom = view.getZoom();
    // why? => to reset the original zoom level after the minimum zoom
    view.setZoom(zoomlevel);
    // level was calulated
    // why? => to reset the original view
    view.setViewPoint2D(viewPoint.getX(), viewPoint.getY());
    // point
    return minZoom - (minZoom / 2);
}
Also used : Point2D(java.awt.geom.Point2D) Rectangle2D(java.awt.geom.Rectangle2D)

Aggregations

Point2D (java.awt.geom.Point2D)159 Rectangle2D (java.awt.geom.Rectangle2D)18 Color (java.awt.Color)12 RadialGradientPaint (java.awt.RadialGradientPaint)10 AffineTransform (java.awt.geom.AffineTransform)10 Line2D (java.awt.geom.Line2D)9 Paint (java.awt.Paint)8 Graphics2D (java.awt.Graphics2D)7 BufferedImage (java.awt.image.BufferedImage)7 Element (org.jdom2.Element)6 BasicStroke (java.awt.BasicStroke)5 IOException (java.io.IOException)5 LinearGradientPaint (java.awt.LinearGradientPaint)4 Point (java.awt.Point)4 Rectangle (java.awt.Rectangle)4 NodeRef (dr.evolution.tree.NodeRef)3 RenderableBlock (edu.mit.blocks.renderable.RenderableBlock)3 Arc2D (java.awt.geom.Arc2D)3 Test (org.junit.Test)3 AWSCredentials (com.amazonaws.auth.AWSCredentials)2