Search in sources :

Example 76 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.

the class CombinedXYPlot method add.

/**
 * Adds a new subplot with the specified weight.
 *
 * @param subplot  the subplot.
 * @param weight  the weight for the subplot.
 */
public void add(XYPlot subplot, int weight) {
    super.add(subplot, weight);
    ValueAxis l_range = super.getRangeAxis();
    subplot.setRangeAxis(0, l_range, false);
    super.setRangeAxis(l_range);
    if (null == l_range) {
        return;
    }
    l_range.configure();
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis)

Example 77 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.

the class BarRenderer method initialise.

/**
 * Initialises the renderer and returns a state object that will be passed
 * to subsequent calls to the drawItem method.  This method gets called
 * once at the start of the process of drawing a chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 *
 * @return The renderer state.
 */
@Override
public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info) {
    CategoryItemRendererState state = super.initialise(g2, dataArea, plot, rendererIndex, info);
    // get the clipping values...
    ValueAxis rangeAxis = plot.getRangeAxisForDataset(rendererIndex);
    this.lowerClip = rangeAxis.getRange().getLowerBound();
    this.upperClip = rangeAxis.getRange().getUpperBound();
    // calculate the bar width
    calculateBarWidth(plot, dataArea, rendererIndex, state);
    return state;
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis)

Example 78 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.

the class PolarPlot method setAxis.

/**
 * Sets an axis for the plot and, if requested, sends a
 * {@link PlotChangeEvent} to all registered listeners.
 *
 * @param index  the axis index.
 * @param axis  the axis (<code>null</code> permitted).
 * @param notify  notify listeners?
 *
 * @see #getAxis(int)
 *
 * @since 1.0.14
 */
public void setAxis(int index, ValueAxis axis, boolean notify) {
    ValueAxis existing = getAxis(index);
    if (existing != null) {
        existing.removeChangeListener(this);
    }
    if (axis != null) {
        axis.setPlot(this);
    }
    this.axes.set(index, axis);
    if (axis != null) {
        axis.configure();
        axis.addChangeListener(this);
    }
    if (notify) {
        fireChangeEvent();
    }
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis)

Example 79 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.

the class PolarPlot method getAxisForDataset.

/**
 * Returns the axis for a dataset.
 *
 * @param index  the dataset index.
 *
 * @return The axis.
 *
 * @since 1.0.14
 */
public ValueAxis getAxisForDataset(int index) {
    ValueAxis valueAxis;
    List axisIndices = (List) this.datasetToAxesMap.get(new Integer(index));
    if (axisIndices != null) {
        // the first axis in the list is used for data <--> Java2D
        Integer axisIndex = (Integer) axisIndices.get(0);
        valueAxis = getAxis(axisIndex.intValue());
    } else {
        valueAxis = getAxis(0);
    }
    return valueAxis;
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis) List(java.util.List) ArrayList(java.util.ArrayList) ObjectList(org.jfree.util.ObjectList)

Example 80 with ValueAxis

use of org.jfree.chart.axis.ValueAxis in project SIMVA-SoS by SESoS.

the class PolarPlot method draw.

/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a
 * printer).
 * <P>
 * This plot relies on a {@link PolarItemRenderer} to draw each
 * item in the plot.  This allows the visual representation of the data to
 * be changed easily.
 * <P>
 * The optional info argument collects information about the rendering of
 * the plot (dimensions, tooltip information etc).  Just pass in
 * <code>null</code> if you do not need this information.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot (including axes and
 *              labels) should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  ignored.
 * @param info  collects chart drawing information (<code>null</code>
 *              permitted).
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) {
    // if the plot area is too small, just return...
    boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }
    // record the plot area...
    if (info != null) {
        info.setPlotArea(area);
    }
    // adjust the drawing area for the plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);
    Rectangle2D dataArea = area;
    if (info != null) {
        info.setDataArea(dataArea);
    }
    // draw the plot background and axes...
    drawBackground(g2, dataArea);
    int axisCount = this.axes.size();
    AxisState state = null;
    for (int i = 0; i < axisCount; i++) {
        ValueAxis axis = getAxis(i);
        if (axis != null) {
            PolarAxisLocation location = (PolarAxisLocation) this.axisLocations.get(i);
            AxisState s = this.drawAxis(axis, location, g2, dataArea);
            if (i == 0) {
                state = s;
            }
        }
    }
    // now for each dataset, get the renderer and the appropriate axis
    // and render the dataset...
    Shape originalClip = g2.getClip();
    Composite originalComposite = g2.getComposite();
    g2.clip(dataArea);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha()));
    this.angleTicks = refreshAngleTicks();
    drawGridlines(g2, dataArea, this.angleTicks, state.getTicks());
    render(g2, dataArea, info);
    g2.setClip(originalClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, dataArea);
    drawCornerTextItems(g2, dataArea);
}
Also used : AxisState(org.jfree.chart.axis.AxisState) Shape(java.awt.Shape) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) ValueAxis(org.jfree.chart.axis.ValueAxis) Rectangle2D(java.awt.geom.Rectangle2D) RectangleInsets(org.jfree.ui.RectangleInsets) Point(java.awt.Point) Paint(java.awt.Paint)

Aggregations

ValueAxis (org.jfree.chart.axis.ValueAxis)216 XYPlot (org.jfree.chart.plot.XYPlot)77 NumberAxis (org.jfree.chart.axis.NumberAxis)50 Range (org.jfree.data.Range)40 JFreeChart (org.jfree.chart.JFreeChart)39 CategoryPlot (org.jfree.chart.plot.CategoryPlot)35 Paint (java.awt.Paint)31 CategoryAxis (org.jfree.chart.axis.CategoryAxis)30 Rectangle2D (java.awt.geom.Rectangle2D)28 CombinedDomainXYPlot (org.jfree.chart.plot.CombinedDomainXYPlot)25 Test (org.junit.Test)24 CombinedRangeXYPlot (org.jfree.chart.plot.CombinedRangeXYPlot)22 XYDataset (org.jfree.data.xy.XYDataset)22 Iterator (java.util.Iterator)20 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)18 CategoryDataset (org.jfree.data.category.CategoryDataset)17 RectangleEdge (org.jfree.ui.RectangleEdge)16 Font (java.awt.Font)14 XYSeries (org.jfree.data.xy.XYSeries)14 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)14