Example usage for java.awt.geom Point2D getY

List of usage examples for java.awt.geom Point2D getY

Introduction

In this page you can find the example usage for java.awt.geom Point2D getY.

Prototype

public abstract double getY();

Source Link

Document

Returns the Y coordinate of this Point2D in double precision.

Usage

From source file:inflor.core.gates.ui.RectangleGateAnnotation.java

@Override
public boolean containsPoint(Point2D p) {
    if (x0 <= p.getX() && p.getX() <= x1 && y0 <= p.getY() && p.getY() <= y1) {
        return true;
    } else {//from ww  w  .  j  a  v a 2  s .  c om
        return false;
    }
}

From source file:de.hstsoft.sdeep.NoteManager.java

public Note getNoteAt(Point2D mapPosition, int size) {
    int x = (int) mapPosition.getX() - size / 2;
    int y = (int) mapPosition.getY() - size / 2;
    Rectangle rectangle = new Rectangle(x, y, size, size);

    for (Note n : notes) {
        if (rectangle.contains(n.getPosition())) {
            return n;
        }//w w  w  . ja v a  2s.c om
    }
    return null;
}

From source file:ca.sqlpower.dao.session.Point2DConverter.java

public String convertToSimpleType(Point2D convertFrom, Object... additionalInfo) {
    StringBuilder result = new StringBuilder();

    result.append(convertFrom.getX());/*www .j av a  2 s  .  c  o  m*/
    result.append(DELIMITER);
    result.append(convertFrom.getY());

    return result.toString();
}

From source file:org.opennms.features.vaadin.topology.jung.BalloonLayoutAlgorithm.java

public void updateLayout(GraphContainer graph) {

    Graph g = new Graph(graph);

    int szl = g.getSemanticZoomLevel();

    Vertex rootItem = g.getDisplayVertex(g.getVertexByItemId(m_rootItemId), szl);

    Tree<Vertex, Edge> tree = new OrderedKAryTree<Vertex, Edge>(50);

    Queue<Vertex> q = new LinkedList<Vertex>();
    Set<Vertex> found = new HashSet<Vertex>();

    q.add(rootItem);/* w  ww.j  a v a2  s .com*/

    tree.addVertex(rootItem);

    Vertex v;
    while ((v = q.poll()) != null) {
        List<Edge> edges = g.getEdgesForVertex(v, szl);
        for (Edge e : edges) {
            Vertex neighbor = e.getSource() != v ? e.getSource() : e.getTarget();
            tree.addEdge(e, v, neighbor);
            if (!found.contains(neighbor)) {
                q.add(neighbor);
            }
        }
    }

    BalloonLayout<Vertex, Edge> layout = new BalloonLayout<Vertex, Edge>(tree);
    layout.setInitializer(new Transformer<Vertex, Point2D>() {
        public Point2D transform(Vertex v) {
            return new Point(v.getX(), v.getY());
        }
    });

    for (Vertex vertex : g.getVertices(szl)) {
        layout.lock(vertex, vertex.isLocked());
    }

    layout.setSize(new Dimension(750, 750));

    List<Vertex> vertices = g.getVertices(szl);
    for (Vertex vertex : vertices) {
        Point2D point = layout.transform(v);
        vertex.setX((int) point.getX());
        vertex.setY((int) point.getY());
    }

}

From source file:edu.uci.ics.jung.algorithms.layout.BalloonLayout.java

protected void setPolars(List<V> kids, Point2D parentLocation, double parentRadius) {

    int childCount = kids.size();
    if (childCount == 0)
        return;/*w ww  .  j a v  a  2  s. c  o  m*/
    // handle the 1-child case with 0 limit on angle.
    double angle = Math.max(0, Math.PI / 2 * (1 - 2.0 / childCount));
    double childRadius = parentRadius * Math.cos(angle) / (1 + Math.cos(angle));
    double radius = parentRadius - childRadius;

    double rand = Math.random();

    for (int i = 0; i < childCount; i++) {
        V child = kids.get(i);
        double theta = i * 2 * Math.PI / childCount + rand;
        radii.put(child, childRadius);

        PolarPoint pp = new PolarPoint(theta, radius);
        polarLocations.put(child, pp);

        Point2D p = PolarPoint.polarToCartesian(pp);
        p.setLocation(p.getX() + parentLocation.getX(), p.getY() + parentLocation.getY());
        locations.put(child, p);
        setPolars(new ArrayList<V>(graph.getChildren(child)), p, childRadius);
    }
}

From source file:edu.uci.ics.jung.algorithms.layout.BalloonLayout.java

@Override
public void setLocation(V v, Point2D location) {
    Point2D c = getCenter(v);/*  w w w . j ava 2 s.  c o  m*/
    Point2D pv = new Point2D.Double(location.getX() - c.getX(), location.getY() - c.getY());
    PolarPoint newLocation = PolarPoint.cartesianToPolar(pv);
    polarLocations.get(v).setLocation(newLocation);

    Point2D center = getCenter(v);
    pv.setLocation(pv.getX() + center.getX(), pv.getY() + center.getY());
    locations.put(v, pv);
}

From source file:org.apache.geode.geospatial.client.Roads.java

private Coordinate convert(Point2D point2D) {
    return new Coordinate(point2D.getX(), point2D.getY());
}

From source file:joshua.ui.tree_visualizer.DerivationTreeTransformer.java

public void setAnchorPoint(DerivationViewer.AnchorType type, Point2D viewerAnchor) {
    Point2D oldAnchor = getAnchorPosition(type);
    double x = viewerAnchor.getX() - oldAnchor.getX();
    double y = viewerAnchor.getY() - oldAnchor.getY();
    anchorPoint = new Point2D.Double(x, y);
}

From source file:inflor.core.gates.ui.PolygonGateAdapter.java

@Override
public void mouseMoved(MouseEvent e) {
    if (anchorSegment != null) {
        panel.removeTemporaryAnnotation(anchorSegment);
    }/*from   w  w w.ja  v  a  2s.c  o  m*/
    if (anchorPoint != null) {
        Point2D p = ChartUtils.getPlotCoordinates(e, panel);
        anchorSegment = new XYLineAnnotation(anchorPoint.getX(), anchorPoint.getY(), p.getX(), p.getY());
        panel.addTemporaryAnnotation(anchorSegment);
    }
}

From source file:org.bigwiv.blastgraph.gui.graphvisualization.EdgePainter.java

@Override
public Paint transform(ValueEdge ve) {
    Layout<HitVertex, ValueEdge> layout = vv.getGraphLayout();
    BlastGraph<HitVertex, ValueEdge> graph = (BlastGraph<HitVertex, ValueEdge>) layout.getGraph();
    Pair<HitVertex> p = graph.getEndpoints(ve);
    HitVertex b = p.getFirst();//from   www.  j a  v a  2 s.  co  m
    HitVertex f = p.getSecond();

    BasicStroke stroke = (BasicStroke) strokeTransformer.transform(ve);
    float lineWith = stroke.getLineWidth();

    Point2D pb = transformer.transform(layout.transform(b));
    Point2D pf = transformer.transform(layout.transform(f));

    float xB = (float) pb.getX();
    float yB = (float) pb.getY();
    float xF = (float) pf.getX();
    float yF = (float) pf.getY();

    return null;
}