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:net.sf.maltcms.chromaui.charts.events.XYPeakAnnotationOverlay.java

/**
 *
 * @param p//from w w  w. j  a  v a 2s  .  c  o m
 */
public void addAnnotation(final Point2D p) {
    addXYPeakAnnotation(p.getX(), p.getY(), null, true);
}

From source file:com.mycompany.complexity.tool.mvn.TreeLayout.java

public void moveNodes(int x, int y) {
    Point2D p;
    for (V value : locations.keySet()) {
        p = locations.get(value);//from w w  w  .  j av  a  2 s  .  co m
        p.setLocation(p.getX() + x, p.getY() + y);
        locations.get(value).setLocation(p);
    }
}

From source file:com.mycompany.complexity.tool.mvn.TreeLayout.java

public int lastDimensionY() {
    Point2D p;
    int maxY = 0;
    for (V value : locations.keySet()) {
        p = locations.get(value);/*ww  w. java  2 s. co m*/
        if (p.getY() > maxY) {
            maxY = (int) p.getY() + 1;
        }
    }
    return maxY;
}

From source file:ru.jcorp.smartstreets.gui.map.MapEditor.java

public void saveMap() {
    Dimension size = graphLayout.getSize();
    mapContext.getMap().setHeight(size.height);
    mapContext.getMap().setWidth(size.width);

    // preprocess positions
    for (GraphNode node : graphModel.getVertices()) {
        Point2D point = graphLayout.transform(node);
        node.getMapNode().setX(point.getX());
        node.getMapNode().setY(point.getY());
    }//from w w  w.  j  a  va2 s  .c  o  m

    mapContext.commit();
}

From source file:net.sf.mzmine.modules.visualization.scatterplot.scatterplotchart.ScatterPlotRenderer.java

/**
 * Draws an item label.//ww  w. j av a 2s .  c o m
 * 
 * @param g2
 *            the graphics device.
 * @param orientation
 *            the orientation.
 * @param dataset
 *            the dataset.
 * @param series
 *            the series index (zero-based).
 * @param item
 *            the item index (zero-based).
 * @param x
 *            the x coordinate (in Java2D space).
 * @param y
 *            the y coordinate (in Java2D space).
 * @param negative
 *            indicates a negative value (which affects the item label
 *            position).
 */
protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation, XYDataset dataset, int series,
        int item, double x, double y, boolean negative) {

    XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
    Font labelFont = getItemLabelFont(series, item);
    g2.setFont(labelFont);
    String label = generator.generateLabel(dataset, series, item);

    if ((label == null) || (label.length() == 0))
        return;

    // get the label position..
    ItemLabelPosition position = null;
    if (!negative) {
        position = getPositiveItemLabelPosition(series, item);
    } else {
        position = getNegativeItemLabelPosition(series, item);
    }

    // work out the label anchor point...
    Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), x, y, orientation);

    FontMetrics metrics = g2.getFontMetrics(labelFont);
    int width = SwingUtilities.computeStringWidth(metrics, label) + 2;
    int height = metrics.getHeight();

    int X = (int) (anchorPoint.getX() - (width / 2));
    int Y = (int) (anchorPoint.getY() - (height));

    g2.setPaint(searchColor);
    g2.fillRect(X, Y, width, height);

    super.drawItemLabel(g2, orientation, dataset, series, item, x, y, negative);

}

From source file:org.apache.fop.render.java2d.Java2DPainter.java

/** {@inheritDoc} */
public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, String text)
        throws IFException {
    g2dState.updateColor(state.getTextColor());
    FontTriplet triplet = new FontTriplet(state.getFontFamily(), state.getFontStyle(), state.getFontWeight());
    //TODO Ignored: state.getFontVariant()
    //TODO Opportunity for font caching if font state is more heavily used
    Font font = getFontInfo().getFontInstance(triplet, state.getFontSize());
    //String fontName = font.getFontName();
    //float fontSize = state.getFontSize() / 1000f;
    g2dState.updateFont(font.getFontName(), state.getFontSize() * 1000);

    Graphics2D g2d = this.g2dState.getGraph();
    GlyphVector gv = g2d.getFont().createGlyphVector(g2d.getFontRenderContext(), text);
    Point2D cursor = new Point2D.Float(0, 0);

    int l = text.length();
    int dxl = (dx != null ? dx.length : 0);

    if (dx != null && dxl > 0 && dx[0] != 0) {
        cursor.setLocation(cursor.getX() - (dx[0] / 10f), cursor.getY());
        gv.setGlyphPosition(0, cursor);/*from  w  w w  . j a v a  2 s.  c  o  m*/
    }
    for (int i = 0; i < l; i++) {
        char orgChar = text.charAt(i);
        float glyphAdjust = 0;
        int cw = font.getCharWidth(orgChar);

        if ((wordSpacing != 0) && CharUtilities.isAdjustableSpace(orgChar)) {
            glyphAdjust += wordSpacing;
        }
        glyphAdjust += letterSpacing;
        if (dx != null && i < dxl - 1) {
            glyphAdjust += dx[i + 1];
        }

        cursor.setLocation(cursor.getX() + cw + glyphAdjust, cursor.getY());
        gv.setGlyphPosition(i + 1, cursor);
    }
    g2d.drawGlyphVector(gv, x, y);
}

From source file:gov.nih.nci.caintegrator.application.geneexpression.BoxAndWhiskerCoinPlotRenderer.java

private void drawEllipse(Point2D point, double oRadius, Graphics2D g2) {
    Ellipse2D dot = new Ellipse2D.Double(point.getX() + oRadius / 2, point.getY(), oRadius, oRadius);
    g2.draw(dot);/*from   w w  w. j av  a2  s  .com*/
}

From source file:net.panthema.BispanningGame.MyEditingGraphMousePlugin.java

/**
 * If startVertex is non-null, and the mouse is released over an existing
 * vertex, create an undirected edge from startVertex to the vertex under
 * the mouse pointer. If shift was also pressed, create a directed edge
 * instead./*from   w  ww.j a va 2  s .c o m*/
 */
@SuppressWarnings("unchecked")
public void mouseReleased(MouseEvent e) {
    if (checkModifiers(e)) {
        final VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) e.getSource();
        final Point2D p = e.getPoint();
        Layout<V, E> layout = vv.getModel().getGraphLayout();
        GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
        if (pickSupport != null) {
            final V vertex = pickSupport.getVertex(layout, p.getX(), p.getY());
            if (vertex != null && startVertex != null && startVertex != vertex) {
                Graph<V, E> graph = vv.getGraphLayout().getGraph();
                graph.addEdge(edgeFactory.create(), startVertex, vertex, EdgeType.UNDIRECTED);
                vv.getRenderContext().getParallelEdgeIndexFunction().reset();

                if (graph instanceof MyGraph)
                    ((MyGraph) graph).graphChanged();

                vv.repaint();
            }
        }
        startVertex = null;
        down = null;
        vv.removePostRenderPaintable(edgePaintable);
    }
}

From source file:org.uva.itast.blended.omr.pages.PageImage.java

/**
 * @param pointMM
 * @return
 */
public Point toPixels(Point2D pointMM) {
    return toPixels(pointMM.getX(), pointMM.getY());
}

From source file:org.jfree.experimental.chart.plot.dial.DialTextAnnotation.java

/**
 * Draws the background to the specified graphics device.  If the dial
 * frame specifies a window, the clipping region will already have been 
 * set to this window before this method is called.
 *
 * @param g2  the graphics device (<code>null</code> not permitted).
 * @param plot  the plot (ignored here).
 * @param frame  the dial frame (ignored here).
 * @param view  the view rectangle (<code>null</code> not permitted). 
 */// ww w . j  a  va  2s.co m
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) {

    // work out the anchor point
    Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, this.radius);
    Arc2D arc = new Arc2D.Double(f, this.angle, 0.0, Arc2D.OPEN);
    Point2D pt = arc.getStartPoint();
    g2.setPaint(this.paint);
    g2.setFont(this.font);
    TextUtilities.drawAlignedString(this.label, g2, (float) pt.getX(), (float) pt.getY(), this.anchor);

}