Example usage for java.awt.geom Ellipse2D.Double getCenterY

List of usage examples for java.awt.geom Ellipse2D.Double getCenterY

Introduction

In this page you can find the example usage for java.awt.geom Ellipse2D.Double getCenterY.

Prototype

public double getCenterY() 

Source Link

Document

Returns the Y coordinate of the center of the framing rectangle of the Shape in double precision.

Usage

From source file:edu.ucla.stat.SOCR.motionchart.MotionBubbleRenderer.java

/**
 * Draws the visual representation of a single data item.
 *
 * @param g2             the graphics device.
 * @param state          the renderer state.
 * @param dataArea       the area within which the data is being drawn.
 * @param info           collects information about the drawing.
 * @param plot           the plot (can be used to obtain standard color
 *                       information etc).
 * @param domainAxis     the domain (horizontal) axis.
 * @param rangeAxis      the range (vertical) axis.
 * @param dataset        the dataset (a {@link edu.ucla.stat.SOCR.motionchart.MotionDataSet} is expected).
 * @param series         the series index (zero-based).
 * @param item           the item index (zero-based).
 * @param crosshairState crosshair information for the plot
 *                       (<code>null</code> permitted).
 * @param pass           the pass index.
 *//* ww  w  .ja  v a 2  s  . c o m*/
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info,
        XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item,
        CrosshairState crosshairState, int pass) {
    if (!(dataset instanceof MotionDataSet)) {
        throw new IllegalArgumentException("The dataset must be of type MotionDataSet.");
    }

    // return straight away if the item is not visible
    if (!getItemVisible(series, item)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();

    Ellipse2D.Double shape = (Ellipse2D.Double) getItemShape(series, item);

    if (shape.getWidth() != 0 && shape.getHeight() != 0) {
        Ellipse2D.Double circle = translateShape(shape, plot, dataArea);
        g2.setPaint(getItemPaint(series, item));
        g2.fill(circle);
        g2.setStroke(getItemOutlineStroke(series, item));
        g2.setPaint(getItemOutlinePaint(series, item));
        g2.draw(circle);

        if (isItemLabelVisible(series, item)) {
            currCircle = circle;
            if (orientation == PlotOrientation.VERTICAL) {
                drawItemLabel(g2, orientation, dataset, series, item, circle.getCenterX(), circle.getCenterY(),
                        false);
            } else if (orientation == PlotOrientation.HORIZONTAL) {
                drawItemLabel(g2, orientation, dataset, series, item, circle.getCenterY(), circle.getCenterX(),
                        false);
            }
        }

        // add an entity if this info is being collected
        EntityCollection entities;
        if (info != null) {
            entities = info.getOwner().getEntityCollection();
            if (entities != null && circle.intersects(dataArea)) {
                addEntity(entities, circle, dataset, series, item, circle.getCenterX(), circle.getCenterY());
            }
        }

        int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
        int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
        updateCrosshairValues(crosshairState, shape.getCenterX(), shape.getCenterY(), domainAxisIndex,
                rangeAxisIndex, circle.getCenterX(), circle.getCenterY(), orientation);
    }
}