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;
}
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;
}
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);
}
}
}
}
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);
}
}
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);
}
}
}
}
Aggregations