Example usage for org.jfree.chart.plot CategoryPlot getDomainAxisLocation

List of usage examples for org.jfree.chart.plot CategoryPlot getDomainAxisLocation

Introduction

In this page you can find the example usage for org.jfree.chart.plot CategoryPlot getDomainAxisLocation.

Prototype

public AxisLocation getDomainAxisLocation() 

Source Link

Document

Returns the domain axis location for the primary domain axis.

Usage

From source file:edu.cuny.jfree.chart.annotations.CategoryIntervalAnnotation.java

public void draw(final Graphics2D g2, final CategoryPlot plot, final Rectangle2D dataArea,
        final CategoryAxis domainAxis, final ValueAxis rangeAxis) {

    final AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            plot.getForegroundAlpha());/*from   w ww . j  a  va  2 s. c o m*/
    final Composite oldComposite = g2.getComposite();
    g2.setComposite(alphaComposite);

    final CategoryDataset dataset = plot.getDataset();
    final int catIndex = dataset.getColumnIndex(category);
    final int catCount = dataset.getColumnCount();
    double lineX1 = 0.0D;
    double lineY = 0.0D;
    double lineX2 = 0.0D;
    final PlotOrientation orientation = plot.getOrientation();
    final RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation);
    final RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation);
    if (orientation == PlotOrientation.HORIZONTAL) {
        lineY = domainAxis.getCategoryJava2DCoordinate(CategoryAnchor.MIDDLE, catIndex, catCount, dataArea,
                domainEdge);
        lineX1 = rangeAxis.valueToJava2D(value1, dataArea, rangeEdge);
        lineX2 = rangeAxis.valueToJava2D(value2, dataArea, rangeEdge);
    } else if (orientation == PlotOrientation.VERTICAL) {
        lineY = rangeAxis.valueToJava2D(value1, dataArea, rangeEdge);
        lineX1 = domainAxis.getCategoryJava2DCoordinate(CategoryAnchor.MIDDLE, catIndex, catCount, dataArea,
                domainEdge);
        lineX2 = domainAxis.getCategoryJava2DCoordinate(CategoryAnchor.MIDDLE, catIndex, catCount, dataArea,
                domainEdge);
    }
    g2.setPaint(paint);
    g2.setStroke(stroke);
    g2.drawLine((int) lineX1, (int) lineY, (int) lineX2, (int) lineY);

    g2.setComposite(oldComposite);
}