FileDocCategorySizeDatePackage
OccurrenceRenderer.javaAPI DocAndroid 1.5 API3401Wed May 06 22:41:08 BST 2009com.android.ddmuilib.log.event

OccurrenceRenderer

public class OccurrenceRenderer extends org.jfree.chart.renderer.xy.XYLineAndShapeRenderer
Custom renderer to render event occurrence. This rendered ignores the y value, and simply draws a line from min to max at the time of the item.

Fields Summary
private static final long
serialVersionUID
Constructors Summary
Methods Summary
public voiddrawItem(java.awt.Graphics2D g2, org.jfree.chart.renderer.xy.XYItemRendererState state, java.awt.geom.Rectangle2D dataArea, org.jfree.chart.plot.PlotRenderingInfo info, org.jfree.chart.plot.XYPlot plot, org.jfree.chart.axis.ValueAxis domainAxis, org.jfree.chart.axis.ValueAxis rangeAxis, org.jfree.data.xy.XYDataset dataset, int series, int item, org.jfree.chart.plot.CrosshairState crosshairState, int pass)


    
        
                          
                          
                          
                           
                           
                          
                           
                           
                          
                           
                           
        TimeSeriesCollection timeDataSet = (TimeSeriesCollection)dataset;
        
        // get the x value for the series/item.
        double x = timeDataSet.getX(series, item).doubleValue();

        // get the min/max of the range axis
        double yMin = rangeAxis.getLowerBound();
        double yMax = rangeAxis.getUpperBound();

        RectangleEdge domainEdge = plot.getDomainAxisEdge();
        RectangleEdge rangeEdge = plot.getRangeAxisEdge();

        // convert the coordinates to java2d.
        double x2D = domainAxis.valueToJava2D(x, dataArea, domainEdge);
        double yMin2D = rangeAxis.valueToJava2D(yMin, dataArea, rangeEdge);
        double yMax2D = rangeAxis.valueToJava2D(yMax, dataArea, rangeEdge);

        // get the paint information for the series/item
        Paint p = getItemPaint(series, item);
        Stroke s = getItemStroke(series, item);
        
        Line2D line = null;
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            line = new Line2D.Double(yMin2D, x2D, yMax2D, x2D);
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            line = new Line2D.Double(x2D, yMin2D, x2D, yMax2D);
        }
        g2.setPaint(p);
        g2.setStroke(s);
        g2.draw(line);