Example usage for java.awt.geom Rectangle2D getMaxY

List of usage examples for java.awt.geom Rectangle2D getMaxY

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D getMaxY.

Prototype

public double getMaxY() 

Source Link

Document

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

Usage

From source file:org.logisticPlanning.utils.graphics.chart.impl.jfree._JFCXYItemRenderer.java

/** {@inheritDoc} */
@Override//  w w w.ja v a  2  s  .com
public final XYItemRendererState initialise(final Graphics2D arg0, final Rectangle2D arg1, final XYPlot arg2,
        final XYDataset arg3, final PlotRenderingInfo arg4) {
    final double x1, y1, x2, y2;
    // AffineTransform t;

    if (arg1 != null) {

        x1 = arg1.getMinX();
        x2 = arg1.getMaxX();
        y1 = arg1.getMinY();
        y2 = arg1.getMaxY();

        this.m_minX = Math.min(this.m_minX, Math.min(x1, x2));
        this.m_maxX = Math.max(this.m_maxX, Math.max(x1, x2));

        this.m_minY = Math.min(this.m_minY, Math.min(y1, y2));
        this.m_maxY = Math.max(this.m_maxY, Math.max(y1, y2));

        //

        // this.m_src[0] = x1;
        // this.m_src[1] = y1;
        // this.m_src[2] = x2;
        // this.m_src[3] = y1;
        // this.m_src[4] = x2;
        // this.m_src[5] = y2;
        // this.m_src[6] = x1;
        // this.m_src[7] = y2;
        //
        // t = arg0.getTransform();
        // if ((t != null) && (!(t.isIdentity()))) {
        // t.transform(this.m_src, 0, this.m_dst, 0, 4);
        // } else {
        // System.arraycopy(this.m_src, 0, this.m_dst, 0, 8);
        // }
        //
        // this.m_maxX = Math.min(this.m_maxX, Math.max(//
        // Math.max(this.m_dst[0], this.m_dst[2]),//
        // Math.max(this.m_dst[4], this.m_dst[6])));
        //
        // this.m_maxY = Math.min(this.m_maxY, Math.max(//
        // Math.max(this.m_dst[1], this.m_dst[3]),//
        // Math.max(this.m_dst[5], this.m_dst[7])));
        //
        // this.m_minX = Math.max(this.m_minX, Math.min(//
        // Math.min(this.m_dst[0], this.m_dst[2]),//
        // Math.min(this.m_dst[4], this.m_dst[6])));
        //
        // this.m_minY = Math.max(this.m_minY, Math.min(//
        // Math.min(this.m_dst[1], this.m_dst[3]),//
        // Math.min(this.m_dst[5], this.m_dst[7])));
    }

    return this.m_out.initialise(arg0, arg1, arg2, arg3, arg4);
}

From source file:org.csa.rstb.dat.toolviews.HaAlphaPlotPanel.java

@Override
protected String getDataAsText() {
    final BufferedImage image = plot.getImage();
    final Rectangle2D bounds = plot.getImageDataBounds();

    final byte[] data = getValidData(image);
    if (data == null) {
        return null;
    }/*from w  w  w  .  j  a va2  s .co m*/

    final StringBuilder sb = new StringBuilder(64000);
    final int w = image.getWidth();
    final int h = image.getHeight();

    final RasterDataNode rasterX = getRaster(X_VAR);
    final String nameX = rasterX.getName();
    final double sampleMinX = bounds.getMinX();
    final double sampleMaxX = bounds.getMaxX();

    final RasterDataNode rasterY = getRaster(Y_VAR);
    final String nameY = rasterY.getName();
    final double sampleMinY = bounds.getMinY();
    final double sampleMaxY = bounds.getMaxY();

    sb.append("Product name:\t").append(rasterX.getProduct().getName()).append("\n");
    sb.append("Dataset X name:\t").append(nameX).append("\n");
    sb.append("Dataset Y name:\t").append(nameY).append("\n");
    sb.append('\n');
    sb.append(nameX).append(" minimum:\t").append(sampleMinX).append("\t").append(rasterX.getUnit())
            .append("\n");
    sb.append(nameX).append(" maximum:\t").append(sampleMaxX).append("\t").append(rasterX.getUnit())
            .append("\n");
    sb.append(nameX).append(" bin size:\t").append((sampleMaxX - sampleMinX) / w).append("\t")
            .append(rasterX.getUnit()).append("\n");
    sb.append(nameX).append(" #bins:\t").append(w).append("\n");
    sb.append('\n');
    sb.append(nameY).append(" minimum:\t").append(sampleMinY).append("\t").append(rasterY.getUnit())
            .append("\n");
    sb.append(nameY).append(" maximum:\t").append(sampleMaxY).append("\t").append(rasterY.getUnit())
            .append("\n");
    sb.append(nameY).append(" bin size:\t").append((sampleMaxY - sampleMinY) / h).append("\t")
            .append(rasterY.getUnit()).append("\n");
    sb.append(nameY).append(" #bins:\t").append(h).append("\n");
    sb.append('\n');

    sb.append(nameX);
    sb.append('\t');
    sb.append(nameY);
    sb.append('\t');
    sb.append("Bin counts\t(cropped at 255)");
    sb.append('\n');

    int x, y, z;
    double v1, v2;
    for (int i = 0; i < data.length; i++) {
        z = data[i] & 0xff;
        if (z != 0) {

            x = i % w;
            y = h - i / w - 1;

            v1 = sampleMinX + ((x + 0.5) * (sampleMaxX - sampleMinX)) / w;
            v2 = sampleMinY + ((y + 0.5) * (sampleMaxY - sampleMinY)) / h;

            sb.append(v1);
            sb.append('\t');
            sb.append(v2);
            sb.append('\t');
            sb.append(z);
            sb.append('\n');
        }
    }

    return sb.toString();
}

From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java

@Override
public void mousePressed(MouseEvent e) {
    super.mousePressed(e);

    Rectangle2D origArea = this.getScreenDataArea();
    Plot plot = chart.getPlot();/*  w  w  w  .  j  a v  a 2  s  . c om*/

    if (!(plot instanceof XYPlot)) {
        return;
    }

    XYPlot xyPlot = chart.getXYPlot();
    String origDomainAxisLabel = xyPlot.getDomainAxis().getLabel();

    if (SwingUtilities.isRightMouseButton(e)) {
        return;
    }
    for (DBSeerSelectableChartPanel panel : DBSeerPlotPresetFrame.chartPanels) {
        if (panel != this) {
            Plot otherPlot = panel.getChart().getPlot();
            if (!(otherPlot instanceof XYPlot)) {
                continue;
            }
            Rectangle2D otherArea = panel.getScreenDataArea();
            XYPlot otherXYPlot = panel.getChart().getXYPlot();
            String otherDomainAxisLabel = otherXYPlot.getDomainAxis().getLabel();

            if (origDomainAxisLabel.equalsIgnoreCase(otherDomainAxisLabel)) {
                double origRangeX = origArea.getMaxX() - origArea.getMinX();
                double origRangeY = origArea.getMaxY() - origArea.getMinY();
                double otherRangeX = otherArea.getMaxX() - otherArea.getMinX();
                double otherRangeY = otherArea.getMaxY() - otherArea.getMinY();

                double syncX = otherArea.getMinX() + (e.getX() - origArea.getMinX()) / origRangeX * otherRangeX;
                double syncY = otherArea.getMinY() + (e.getY() - origArea.getMinY()) / origRangeY * otherRangeY;
                MouseEvent syncEvent = new MouseEvent(this, 0, 0, 0, (int) syncX, (int) syncY, 1, false);
                panel.syncMousePressed(syncEvent);
            }
        }
    }
}

From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java

@Override
public void mouseDragged(MouseEvent e) {
    super.mouseDragged(e);

    Rectangle2D origArea = this.getScreenDataArea();
    Plot plot = chart.getPlot();//from w ww  . ja va  2 s .c o m

    if (!(plot instanceof XYPlot)) {
        return;
    }

    XYPlot xyPlot = chart.getXYPlot();
    String origDomainAxisLabel = xyPlot.getDomainAxis().getLabel();

    if (SwingUtilities.isRightMouseButton(e)) {
        return;
    }
    for (DBSeerSelectableChartPanel panel : DBSeerPlotPresetFrame.chartPanels) {
        if (panel != this) {
            Plot otherPlot = panel.getChart().getPlot();
            if (!(otherPlot instanceof XYPlot)) {
                continue;
            }
            Rectangle2D otherArea = panel.getScreenDataArea();
            XYPlot otherXYPlot = panel.getChart().getXYPlot();
            String otherDomainAxisLabel = otherXYPlot.getDomainAxis().getLabel();

            if (origDomainAxisLabel.equalsIgnoreCase(otherDomainAxisLabel)) {
                double origRangeX = origArea.getMaxX() - origArea.getMinX();
                double origRangeY = origArea.getMaxY() - origArea.getMinY();
                double otherRangeX = otherArea.getMaxX() - otherArea.getMinX();
                double otherRangeY = otherArea.getMaxY() - otherArea.getMinY();

                double syncX = otherArea.getMinX() + (e.getX() - origArea.getMinX()) / origRangeX * otherRangeX;
                double syncY = otherArea.getMinY() + (e.getY() - origArea.getMinY()) / origRangeY * otherRangeY;
                MouseEvent syncEvent = new MouseEvent(this, 0, 0, 0, (int) syncX, (int) syncY, 1, false);
                panel.syncMouseDragged(syncEvent);
            }
        }
    }
}

From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java

@Override
public void mouseReleased(MouseEvent e) {
    super.mouseReleased(e);

    Rectangle2D origArea = this.getScreenDataArea();
    Plot plot = chart.getPlot();/*from  w ww  .ja  v  a  2  s  .c om*/

    if (!(plot instanceof XYPlot)) {
        return;
    }

    XYPlot xyPlot = chart.getXYPlot();
    String origDomainAxisLabel = xyPlot.getDomainAxis().getLabel();

    if (SwingUtilities.isRightMouseButton(e)) {
        return;
    }
    for (DBSeerSelectableChartPanel panel : DBSeerPlotPresetFrame.chartPanels) {
        if (panel != this) {
            Plot otherPlot = panel.getChart().getPlot();
            if (!(otherPlot instanceof XYPlot)) {
                continue;
            }
            Rectangle2D otherArea = panel.getScreenDataArea();
            XYPlot otherXYPlot = panel.getChart().getXYPlot();
            String otherDomainAxisLabel = otherXYPlot.getDomainAxis().getLabel();

            if (origDomainAxisLabel.equalsIgnoreCase(otherDomainAxisLabel)) {
                double origRangeX = origArea.getMaxX() - origArea.getMinX();
                double origRangeY = origArea.getMaxY() - origArea.getMinY();
                double otherRangeX = otherArea.getMaxX() - otherArea.getMinX();
                double otherRangeY = otherArea.getMaxY() - otherArea.getMinY();

                double syncX = otherArea.getMinX() + (e.getX() - origArea.getMinX()) / origRangeX * otherRangeX;
                double syncY = otherArea.getMinY() + (e.getY() - origArea.getMinY()) / origRangeY * otherRangeY;
                MouseEvent syncEvent = new MouseEvent(this, 0, 0, 0, (int) syncX, (int) syncY, 1, false);
                panel.syncMouseReleased(syncEvent);
            }
        }
    }
}

From source file:org.tsho.dmc2.core.chart.AbstractDmcPlot.java

/**
 * Draws the fast scatter plot on a Java 2D graphics device (such as the screen or
 * a printer).//  ww  w.j  a  v  a  2s  .  c o  m
 *
 * @param g2  the graphics device.
 * @param plotArea   the area within which the plot (including axis labels) should be drawn.
 * @param info  collects chart drawing information (<code>null</code> permitted).
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, PlotState parentState, PlotRenderingInfo info) {
    //        if (data == null)
    //            return;

    // set up info collection...
    if (info != null) {
        info.setPlotArea(plotArea);
    }

    // adjust the drawing area for plot insets (if any)...
    Insets insets = getInsets();
    if (insets != null) {
        plotArea.setRect(plotArea.getX() + insets.left, plotArea.getY() + insets.top,
                plotArea.getWidth() - insets.left - insets.right,
                plotArea.getHeight() - insets.top - insets.bottom);
    }

    AxisSpace space = new AxisSpace();
    space = this.domainAxis.reserveSpace(g2, this, plotArea, RectangleEdge.BOTTOM, space);
    space = this.rangeAxis.reserveSpace(g2, this, plotArea, RectangleEdge.LEFT, space);
    Rectangle2D dataArea = space.shrink(plotArea, null);

    if (info != null) {
        info.setDataArea(dataArea);
    }

    // draw the plot background and axes...
    drawBackground(g2, dataArea);

    /* if automatic bounds... */
    if (!isNoData()) {
        if (this instanceof DmcRenderablePlot) {
            DmcPlotRenderer renderer;
            renderer = ((DmcRenderablePlot) this).getPlotRenderer();
            if (renderer != null) {
                renderer.initialize();
                if (renderer.getState() == DmcPlotRenderer.STATE_STOPPED) {
                    return;
                }
            }
        }
    }

    AxisState domainAxisState = null, rangeAxisState = null;
    if (this.domainAxis != null) {
        double cursor;
        cursor = dataArea.getMaxY();
        domainAxisState = this.domainAxis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.BOTTOM, info);
        // cursor = info.getCursor();
    }
    if (this.rangeAxis != null) {
        double cursor;
        cursor = dataArea.getMinX();
        rangeAxisState = this.rangeAxis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.LEFT, info);
    }

    if (drawGridlines == true && domainAxisState != null && rangeAxisState != null) {
        drawGridlines(g2, dataArea, domainAxisState.getTicks(), rangeAxisState.getTicks());
    }

    Shape originalClip = g2.getClip();
    g2.clip(dataArea);

    //        Composite originalComposite = g2.getComposite();
    //        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
    //                                                   getForegroundAlpha()));
    //        g2.setStroke(new BasicStroke(12.0F));

    if (isNoData()) {
        drawNoDataMessage(g2, plotArea);
    } else {
        drawPlot(g2, dataArea, info);
    }

    g2.setClip(originalClip);
    drawOutline(g2, dataArea);
}

From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java

/**<!====== drawItem ======================================================>
   Draws a 3D bar to represent one data item.
   <!      Name       Description>
   @param  g2         the graphics device.
   @param  state      the renderer state.
   @param  dataArea   the area for plotting the data.
   @param  plot       the plot.//  w ww  .ja v a2s . c om
   @param  domainAxis the domain axis.
   @param  rangeAxis  the range axis.
   @param  dataset    the dataset.
   @param  row        the row index (zero-based).
   @param  column     the column index (zero-based).
   @param  pass       the pass index.
<!=======================================================================>*/
@Override
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot,
        CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) {

    // check the value we are plotting...
    Number dataValue = dataset.getValue(row, column);
    if (dataValue == null) {
        return;
    }

    g2.setStroke(new BasicStroke(1));
    double value = dataValue.doubleValue();

    Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(),
            dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset());

    PlotOrientation orientation = plot.getOrientation();

    double barW0 = calculateBarW0(plot, orientation, adjusted, domainAxis, state, row, column);
    double[] barL0L1 = calculateBarL0L1(value);
    if (barL0L1 == null) {
        return; // the bar is not visible
    }

    RectangleEdge edge = plot.getRangeAxisEdge();
    double transL0 = rangeAxis.valueToJava2D(barL0L1[0], adjusted, edge);
    double transL1 = rangeAxis.valueToJava2D(barL0L1[1], adjusted, edge);
    double barL0 = Math.min(transL0, transL1);
    double barLength = Math.abs(transL1 - transL0);

    // draw the bar...
    Rectangle2D bar = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        bar = new Rectangle2D.Double(barL0, barW0, barLength, state.getBarWidth());
    } else {
        bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), barLength);
    }
    Paint itemPaint = getItemPaint(row, column);
    if (itemPaint instanceof Color) {
        Color endColor = getFrontDark((Color) itemPaint);
        Color startColor = (Color) itemPaint;
        Paint paint = new GradientPaint((float) bar.getX(), (float) bar.getY(), startColor,
                (float) (bar.getX()), (float) (bar.getY() + bar.getHeight()), endColor);
        g2.setPaint(paint);
    }
    g2.fill(bar);

    double x0 = bar.getMinX(); // left
    double x1 = x0 + getXOffset(); // offset left
    double x2 = bar.getMaxX(); // right
    double x3 = x2 + getXOffset(); // offset right

    double y0 = bar.getMinY() - getYOffset(); // offset top
    double y1 = bar.getMinY(); // bar top
    double y2 = bar.getMaxY() - getYOffset(); // offset bottom
    double y3 = bar.getMaxY(); // bottom

    //Rectangle2D.Double line = new Rectangle2D.Double(x2, y1, 2, bar.getHeight());

    Line2D.Double line = new Line2D.Double(x2, y1, x2, y3);
    g2.draw(line);

    GeneralPath bar3dRight = null;
    GeneralPath bar3dTop = null;
    g2.setPaint(itemPaint);

    // Draw the right side
    if (barLength > 0.0) {
        bar3dRight = new GeneralPath();
        bar3dRight.moveTo((float) x2, (float) y3);
        bar3dRight.lineTo((float) x2, (float) y1);
        bar3dRight.lineTo((float) x3, (float) y0);
        bar3dRight.lineTo((float) x3, (float) y2);
        bar3dRight.closePath();

        if (itemPaint instanceof Color) {
            Color startColor = getSideLight((Color) itemPaint);
            Color endColor = getSideDark((Color) itemPaint);
            Paint paint = new GradientPaint((float) x3, (float) y0, startColor, (float) x2, (float) y3,
                    endColor);
            g2.setPaint(paint);
        }
        g2.fill(bar3dRight);
    }

    // Draw the top
    bar3dTop = new GeneralPath();
    bar3dTop.moveTo((float) x0, (float) y1); // bottom left
    bar3dTop.lineTo((float) x1, (float) y0); // top left
    bar3dTop.lineTo((float) x3, (float) y0); // top right
    bar3dTop.lineTo((float) x2, (float) y1); // bottom right
    bar3dTop.closePath();
    if (itemPaint instanceof Color) {
        Color endColor = getTopDark((Color) itemPaint);
        Color startColor = getTopLight((Color) itemPaint);
        //Paint paint = new GradientPaint((float)x2, (float)y0, startColor, (float)x0, (float)(y1), endColor);
        Point2D.Double topRight = new Point2D.Double(x3, y0);
        Point2D.Double bottomLeft = new Point2D.Double(x0, y1);
        //Point2D.Double darkEnd = getTargetPoint(bottomLeft, topRight, ((y0-y1)/(x3-x2)));
        Point2D.Double darkEnd = new Point2D.Double(x1, y0 - (x3 - x1) * ((y0 - y1) / (x3 - x2)));
        Paint paint = new GradientPaint((float) topRight.getX(), (float) topRight.getY(), startColor,
                (float) darkEnd.getX(), (float) darkEnd.getY(), endColor);
        g2.setPaint(paint);
        //drawMarker(topRight, g2, startColor);
    }
    g2.fill(bar3dTop);
    g2.setPaint(itemPaint);

    if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
        g2.setStroke(getItemOutlineStroke(row, column));
        g2.setPaint(getItemOutlinePaint(row, column));
        g2.draw(bar);
        if (bar3dRight != null) {
            g2.draw(bar3dRight);
        }
        if (bar3dTop != null) {
            g2.draw(bar3dTop);
        }
    }

    CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column);
    if (generator != null && isItemLabelVisible(row, column)) {
        drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0));
    }

    // add an item entity, if this information is being collected
    EntityCollection entities = state.getEntityCollection();
    if (entities != null) {
        GeneralPath barOutline = new GeneralPath();
        barOutline.moveTo((float) x0, (float) y3);
        barOutline.lineTo((float) x0, (float) y1);
        barOutline.lineTo((float) x1, (float) y0);
        barOutline.lineTo((float) x3, (float) y0);
        barOutline.lineTo((float) x3, (float) y2);
        barOutline.lineTo((float) x2, (float) y3);
        barOutline.closePath();
        addItemEntity(entities, dataset, row, column, barOutline);
    }

}

From source file:org.esa.snap.rcp.statistics.DensityPlotPanel.java

@Override
protected String getDataAsText() {
    final BufferedImage image = plot.getImage();
    final Rectangle2D bounds = plot.getImageDataBounds();

    final byte[] data = getValidData(image);
    if (data == null) {
        return null;
    }// ww  w .jav a 2 s .c o  m

    final StringBuilder sb = new StringBuilder(64000);
    final int w = image.getWidth();
    final int h = image.getHeight();

    final RasterDataNode rasterX = getRaster(X_VAR);
    assert rasterX != null;
    final String nameX = rasterX.getName();
    final double sampleMinX = bounds.getMinX();
    final double sampleMaxX = bounds.getMaxX();

    final RasterDataNode rasterY = getRaster(Y_VAR);
    assert rasterY != null;
    final String nameY = rasterY.getName();
    final double sampleMinY = bounds.getMinY();
    final double sampleMaxY = bounds.getMaxY();

    sb.append("Product name:\t").append(rasterX.getProduct().getName()).append("\n");
    sb.append("Dataset X name:\t").append(nameX).append("\n");
    sb.append("Dataset Y name:\t").append(nameY).append("\n");
    sb.append('\n');
    sb.append(nameX).append(" minimum:\t").append(sampleMinX).append("\t").append(rasterX.getUnit())
            .append("\n");
    sb.append(nameX).append(" maximum:\t").append(sampleMaxX).append("\t").append(rasterX.getUnit())
            .append("\n");
    sb.append(nameX).append(" bin size:\t").append((sampleMaxX - sampleMinX) / w).append("\t")
            .append(rasterX.getUnit()).append("\n");
    sb.append(nameX).append(" #bins:\t").append(w).append("\n");
    sb.append('\n');
    sb.append(nameY).append(" minimum:\t").append(sampleMinY).append("\t").append(rasterY.getUnit())
            .append("\n");
    sb.append(nameY).append(" maximum:\t").append(sampleMaxY).append("\t").append(rasterY.getUnit())
            .append("\n");
    sb.append(nameY).append(" bin size:\t").append((sampleMaxY - sampleMinY) / h).append("\t")
            .append(rasterY.getUnit()).append("\n");
    sb.append(nameY).append(" #bins:\t").append(h).append("\n");
    sb.append('\n');

    sb.append(nameX);
    sb.append('\t');
    sb.append(nameY);
    sb.append('\t');
    sb.append("Bin counts\t(cropped at 255)");
    sb.append('\n');

    int x, y, z;
    double v1, v2;
    for (int i = 0; i < data.length; i++) {
        z = data[i] & 0xff;
        if (z != 0) {

            x = i % w;
            y = h - i / w - 1;

            v1 = sampleMinX + ((x + 0.5) * (sampleMaxX - sampleMinX)) / w;
            v2 = sampleMinY + ((y + 0.5) * (sampleMaxY - sampleMinY)) / h;

            sb.append(v1);
            sb.append('\t');
            sb.append(v2);
            sb.append('\t');
            sb.append(z);
            sb.append('\n');
        }
    }

    return sb.toString();
}

From source file:org.proteosuite.FastScatterPlot.java

/**
 * Draws the gridlines for the plot, if they are visible.
 *
 * @param g2  the graphics device./*from w  w w  . j  a  v  a 2  s .  co m*/
 * @param dataArea  the data area.
 * @param ticks  the ticks.
 */
protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List<ValueTick> ticks) {

    // draw the domain grid lines, if any...
    if (isDomainGridlinesVisible()) {
        Stroke gridStroke = getDomainGridlineStroke();
        Paint gridPaint = getDomainGridlinePaint();
        if ((gridStroke != null) && (gridPaint != null)) {
            Iterator<ValueTick> iterator = ticks.iterator();
            while (iterator.hasNext()) {
                ValueTick tick = (ValueTick) iterator.next();
                double v = this.domainAxis.valueToJava2D(tick.getValue(), dataArea, RectangleEdge.BOTTOM);
                Line2D line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
                g2.setPaint(gridPaint);
                g2.setStroke(gridStroke);
                g2.draw(line);
            }
        }
    }
}

From source file:umontreal.iro.lecuyer.charts.EmpiricalRenderer.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 axis.//from w w w  . ja  v a  2 s . c om
 * @param rangeAxis    the range axis.
 * @param dataset      the dataset.
 * @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.
 */
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 (!getItemVisible(series, item))
        return;
    PlotOrientation orientation = plot.getOrientation();
    java.awt.Paint seriesPaint = getItemPaint(series, item);
    java.awt.Stroke seriesStroke = getItemStroke(series, item);
    g2.setPaint(seriesPaint);
    g2.setStroke(seriesStroke);
    double x0 = dataset.getXValue(series, item);
    double y0 = dataset.getYValue(series, item);
    if (java.lang.Double.isNaN(y0))
        return;
    org.jfree.ui.RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    org.jfree.ui.RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation);
    double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation);

    double x1 = 0, y1 = 0;
    if (item < dataset.getItemCount(series) - 1) {
        x1 = dataset.getXValue(series, item + 1);
        y1 = dataset.getYValue(series, item + 1);
    } else {
        x1 = dataArea.getMaxX();
        y1 = dataArea.getMaxY();
    }

    boolean useFillPaint = getUseFillPaint();
    ;
    boolean drawOutlines = getDrawOutlines();
    if (!java.lang.Double.isNaN(y0)) {
        double transX1;
        double transY1;
        if (item < dataset.getItemCount(series) - 1) {
            transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
            transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);
        } else {
            transX1 = x1;
            transY1 = y1;
        }
        Line2D line = state.workingLine;
        if (orientation == PlotOrientation.HORIZONTAL) {
            line.setLine(transY0, transX0, transY0, transX1);
            g2.draw(line);
        } else if (orientation == PlotOrientation.VERTICAL) {
            line.setLine(transX0, transY0, transX1, transY0);
            g2.draw(line);
        }
    }
    if (getItemShapeVisible(series, item)) {
        Shape shape = getItemShape(series, item);
        if (orientation == PlotOrientation.HORIZONTAL)
            shape = ShapeUtilities.createTranslatedShape(shape, transY0, transX0);
        else if (orientation == PlotOrientation.VERTICAL)
            shape = ShapeUtilities.createTranslatedShape(shape, transX0, transY0);
        if (shape.intersects(dataArea)) {
            if (getItemShapeFilled(series, item)) {
                if (useFillPaint)
                    g2.setPaint(getItemFillPaint(series, item));
                else
                    g2.setPaint(getItemPaint(series, item));
                g2.fill(shape);
            }
            if (drawOutlines) {
                if (getUseOutlinePaint())
                    g2.setPaint(getItemOutlinePaint(series, item));
                else
                    g2.setPaint(getItemPaint(series, item));
                g2.setStroke(getItemOutlineStroke(series, item));
                g2.draw(shape);
            }
        }
    }
    if (isItemLabelVisible(series, item)) {
        double xx = transX0;
        double yy = transY0;
        if (orientation == PlotOrientation.HORIZONTAL) {
            xx = transY0;
            yy = transX0;
        }
        drawItemLabel(g2, orientation, dataset, series, item, xx, yy, y0 < 0.0D);
    }
    int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
    int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
    updateCrosshairValues(crosshairState, x0, y0, domainAxisIndex, rangeAxisIndex, transX0, transY0,
            orientation);
    if (state.getInfo() != null) {
        EntityCollection entities = state.getEntityCollection();
        if (entities != null) {
            int r = getDefaultEntityRadius();
            java.awt.Shape shape = orientation != PlotOrientation.VERTICAL
                    ? ((java.awt.Shape) (new java.awt.geom.Rectangle2D.Double(transY0 - (double) r,
                            transX0 - (double) r, 2 * r, 2 * r)))
                    : ((java.awt.Shape) (new java.awt.geom.Rectangle2D.Double(transX0 - (double) r,
                            transY0 - (double) r, 2 * r, 2 * r)));
            if (shape != null) {
                String tip = null;
                XYToolTipGenerator generator = getToolTipGenerator(series, item);
                if (generator != null)
                    tip = generator.generateToolTip(dataset, series, item);
                String url = null;
                if (getURLGenerator() != null)
                    url = getURLGenerator().generateURL(dataset, series, item);
                XYItemEntity entity = new XYItemEntity(shape, dataset, series, item, tip, url);
                entities.add(entity);
            }
        }
    }
}