Search in sources :

Example 36 with ValueAxis

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

the class ChartFactory method createHighLowChart.

/**
 * Creates and returns a default instance of a high-low-open-close chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A high-low-open-close chart.
 */
public static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) {
    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    HighLowRenderer renderer = new HighLowRenderer();
    renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) HighLowItemLabelGenerator(org.jfree.chart.labels.HighLowItemLabelGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) HighLowRenderer(org.jfree.chart.renderer.xy.HighLowRenderer)

Example 37 with ValueAxis

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

the class ChartFactory method createBoxAndWhiskerChart.

/**
 * Creates and returns a default instance of a box and whisker chart.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param timeAxisLabel  a label for the time axis (<code>null</code>
 *                       permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A box and whisker chart.
 */
public static JFreeChart createBoxAndWhiskerChart(String title, String timeAxisLabel, String valueAxisLabel, BoxAndWhiskerXYDataset dataset, boolean legend) {
    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);
    XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) XYBoxAndWhiskerRenderer(org.jfree.chart.renderer.xy.XYBoxAndWhiskerRenderer) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis)

Example 38 with ValueAxis

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

the class StandardChartTheme method applyToXYPlot.

/**
 * Applies the attributes of this theme to a {@link XYPlot}.
 *
 * @param plot  the plot (<code>null</code> not permitted).
 */
protected void applyToXYPlot(XYPlot plot) {
    plot.setAxisOffset(this.axisOffset);
    plot.setDomainZeroBaselinePaint(this.baselinePaint);
    plot.setRangeZeroBaselinePaint(this.baselinePaint);
    plot.setDomainGridlinePaint(this.domainGridlinePaint);
    plot.setRangeGridlinePaint(this.rangeGridlinePaint);
    plot.setDomainCrosshairPaint(this.crosshairPaint);
    plot.setRangeCrosshairPaint(this.crosshairPaint);
    plot.setShadowGenerator(this.shadowGenerator);
    // process all domain axes
    int domainAxisCount = plot.getDomainAxisCount();
    for (int i = 0; i < domainAxisCount; i++) {
        ValueAxis axis = plot.getDomainAxis(i);
        if (axis != null) {
            applyToValueAxis(axis);
        }
    }
    // process all range axes
    int rangeAxisCount = plot.getRangeAxisCount();
    for (int i = 0; i < rangeAxisCount; i++) {
        ValueAxis axis = plot.getRangeAxis(i);
        if (axis != null) {
            applyToValueAxis(axis);
        }
    }
    // process all renderers
    int rendererCount = plot.getRendererCount();
    for (int i = 0; i < rendererCount; i++) {
        XYItemRenderer r = plot.getRenderer(i);
        if (r != null) {
            applyToXYItemRenderer(r);
        }
    }
    // process all annotations
    Iterator iter = plot.getAnnotations().iterator();
    while (iter.hasNext()) {
        XYAnnotation a = (XYAnnotation) iter.next();
        applyToXYAnnotation(a);
    }
    if (plot instanceof CombinedDomainXYPlot) {
        CombinedDomainXYPlot cp = (CombinedDomainXYPlot) plot;
        Iterator iterator = cp.getSubplots().iterator();
        while (iterator.hasNext()) {
            XYPlot subplot = (XYPlot) iterator.next();
            if (subplot != null) {
                applyToPlot(subplot);
            }
        }
    }
    if (plot instanceof CombinedRangeXYPlot) {
        CombinedRangeXYPlot cp = (CombinedRangeXYPlot) plot;
        Iterator iterator = cp.getSubplots().iterator();
        while (iterator.hasNext()) {
            XYPlot subplot = (XYPlot) iterator.next();
            if (subplot != null) {
                applyToPlot(subplot);
            }
        }
    }
}
Also used : XYAnnotation(org.jfree.chart.annotations.XYAnnotation) XYPlot(org.jfree.chart.plot.XYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) Iterator(java.util.Iterator) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) CombinedRangeXYPlot(org.jfree.chart.plot.CombinedRangeXYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) Paint(java.awt.Paint)

Example 39 with ValueAxis

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

the class StandardChartTheme method applyToFastScatterPlot.

/**
 * Applies the attributes of this theme to a {@link FastScatterPlot}.
 *
 * @param plot  the plot ({@code null} not permitted).
 */
protected void applyToFastScatterPlot(FastScatterPlot plot) {
    plot.setDomainGridlinePaint(this.domainGridlinePaint);
    plot.setRangeGridlinePaint(this.rangeGridlinePaint);
    ValueAxis xAxis = plot.getDomainAxis();
    if (xAxis != null) {
        applyToValueAxis(xAxis);
    }
    ValueAxis yAxis = plot.getRangeAxis();
    if (yAxis != null) {
        applyToValueAxis(yAxis);
    }
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis)

Example 40 with ValueAxis

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

the class StandardChartTheme method applyToTitle.

/**
 * Applies the attributes of this theme to the specified title.
 *
 * @param title  the title.
 */
protected void applyToTitle(Title title) {
    if (title instanceof TextTitle) {
        TextTitle tt = (TextTitle) title;
        tt.setFont(this.largeFont);
        tt.setPaint(this.subtitlePaint);
    } else if (title instanceof LegendTitle) {
        LegendTitle lt = (LegendTitle) title;
        if (lt.getBackgroundPaint() != null) {
            lt.setBackgroundPaint(this.legendBackgroundPaint);
        }
        lt.setItemFont(this.regularFont);
        lt.setItemPaint(this.legendItemPaint);
        if (lt.getWrapper() != null) {
            applyToBlockContainer(lt.getWrapper());
        }
    } else if (title instanceof PaintScaleLegend) {
        PaintScaleLegend psl = (PaintScaleLegend) title;
        psl.setBackgroundPaint(this.legendBackgroundPaint);
        ValueAxis axis = psl.getAxis();
        if (axis != null) {
            applyToValueAxis(axis);
        }
    } else if (title instanceof CompositeTitle) {
        CompositeTitle ct = (CompositeTitle) title;
        BlockContainer bc = ct.getContainer();
        List blocks = bc.getBlocks();
        Iterator iterator = blocks.iterator();
        while (iterator.hasNext()) {
            Block b = (Block) iterator.next();
            if (b instanceof Title) {
                applyToTitle((Title) b);
            }
        }
    }
}
Also used : TextTitle(org.jfree.chart.title.TextTitle) PaintScaleLegend(org.jfree.chart.title.PaintScaleLegend) BlockContainer(org.jfree.chart.block.BlockContainer) ValueAxis(org.jfree.chart.axis.ValueAxis) Iterator(java.util.Iterator) LabelBlock(org.jfree.chart.block.LabelBlock) Block(org.jfree.chart.block.Block) Title(org.jfree.chart.title.Title) TextTitle(org.jfree.chart.title.TextTitle) LegendTitle(org.jfree.chart.title.LegendTitle) CompositeTitle(org.jfree.chart.title.CompositeTitle) LegendTitle(org.jfree.chart.title.LegendTitle) List(java.util.List) CompositeTitle(org.jfree.chart.title.CompositeTitle)

Aggregations

ValueAxis (org.jfree.chart.axis.ValueAxis)182 XYPlot (org.jfree.chart.plot.XYPlot)52 NumberAxis (org.jfree.chart.axis.NumberAxis)44 JFreeChart (org.jfree.chart.JFreeChart)37 CategoryPlot (org.jfree.chart.plot.CategoryPlot)35 Paint (java.awt.Paint)31 CategoryAxis (org.jfree.chart.axis.CategoryAxis)30 Test (org.junit.Test)24 Rectangle2D (java.awt.geom.Rectangle2D)20 Iterator (java.util.Iterator)20 XYDataset (org.jfree.data.xy.XYDataset)20 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)18 Range (org.jfree.data.Range)18 CategoryDataset (org.jfree.data.category.CategoryDataset)17 RectangleEdge (org.jfree.ui.RectangleEdge)16 XYSeries (org.jfree.data.xy.XYSeries)14 Font (java.awt.Font)13 StandardCategoryToolTipGenerator (org.jfree.chart.labels.StandardCategoryToolTipGenerator)13 StandardCategoryURLGenerator (org.jfree.chart.urls.StandardCategoryURLGenerator)13 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)13