Example usage for org.jfree.chart.plot PolarPlot translateToJava2D

List of usage examples for org.jfree.chart.plot PolarPlot translateToJava2D

Introduction

In this page you can find the example usage for org.jfree.chart.plot PolarPlot translateToJava2D.

Prototype

public Point translateToJava2D(double angleDegrees, double radius, ValueAxis axis, Rectangle2D dataArea) 

Source Link

Document

Translates a (theta, radius) pair into Java2D coordinates.

Usage

From source file:com.bdb.weather.display.day.ItemRenderer.java

/**
 * Plots the data for a given series.//w w  w .j  a v  a 2s.c  om
 * 
 * @param g2  the drawing surface.
 * @param dataArea  the data area.
 * @param info  collects plot rendering info.
 * @param plot  the plot.
 * @param dataset  the dataset.
 * @param seriesIndex  the series index.
 */
@Override
public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot,
        XYDataset dataset, int seriesIndex) {
    Shape point = new Rectangle2D.Double(-2, -2, 4, 4);

    int numPoints = dataset.getItemCount(seriesIndex);

    g2.setPaint(lookupSeriesPaint(seriesIndex));
    g2.setStroke(lookupSeriesStroke(seriesIndex));

    for (int i = 0; i < numPoints; i++) {
        double theta = dataset.getXValue(seriesIndex, i);
        double radius = dataset.getYValue(seriesIndex, i);

        Point p = plot.translateToJava2D(theta, radius, plot.getAxis(), dataArea);

        Shape shape = ShapeUtilities.createTranslatedShape(point, p.getX(), p.getY());

        g2.fill(shape);
    }
}

From source file:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.AngularHistogramRenderer.java

@Override
public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot,
        XYDataset dataset, int seriesIndex) {

    // compute the right color for the paint
    int length = GuiUtils.getAvailableColors().length;
    Color color = GuiUtils.getAvailableColors()[index % length];
    // get all the data points
    int numPoints = dataset.getItemCount(seriesIndex);

    for (int i = 0; i < numPoints; i++) {
        double theta = dataset.getXValue(seriesIndex, i); // the angle at the center         
        double radius = dataset.getYValue(seriesIndex, i); // the frequency

        Point p0 = plot.translateToJava2D(0, 0, plot.getAxis(), dataArea);
        Point p1 = plot.translateToJava2D(theta - binSize, radius, plot.getAxis(), dataArea);
        Point p2 = plot.translateToJava2D(theta + binSize, radius, plot.getAxis(), dataArea);

        Polygon poly = new Polygon(new int[] { p0.x, p1.x, p2.x }, new int[] { p0.y, p1.y, p2.y }, 3);

        g2.setPaint(new Color(color.getRed(), color.getGreen(), color.getBlue(), 175));
        g2.fill(poly);/*www. ja  va2s. c  om*/
    }
}

From source file:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.CompassRenderer.java

@Override
public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot,
        XYDataset dataset, int seriesIndex) {

    // compute the right color for the paint
    int length = GuiUtils.getAvailableColors().length;
    Color color = GuiUtils.getAvailableColors()[index % length];
    // get all the data points
    int numPoints = dataset.getItemCount(seriesIndex);
    // set STroke and Paint of the graphics
    g2.setStroke(new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
    g2.setPaint(new Color(color.getRed(), color.getGreen(), color.getBlue(), 175));

    // iterate through the points of the dataset
    for (int i = 0; i < numPoints; i++) {
        double theta = dataset.getXValue(seriesIndex, i); // the angle at the center         
        double radius = dataset.getYValue(seriesIndex, i); // the frequency

        Point p0 = plot.translateToJava2D(0, 0, plot.getAxis(), dataArea);
        Point p1 = plot.translateToJava2D(theta, radius, plot.getAxis(), dataArea);

        Line2D line = new Line2D.Double(p0, p1);
        g2.draw(line);//ww w  . j a va  2 s .c  om
    }
}