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;
}
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);
}
}
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);
}
}
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();
}
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);
}
Aggregations