/** * 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.setToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates and returns a default instance of a high-low-open-close chart with * a special timeline. This timeline can be a {@link org.jfree.chart.axis.SegmentedTimeline} * such as the Monday trough Friday timeline that will remove Saturdays and Sundays from * the axis. * * @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 timeline the timeline. * @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, Timeline timeline, boolean legend) { DateAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setTimeline(timeline); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * 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); return chart; }
/** * Creates and returns a default instance of a high-low-open-close chart * with a special timeline. This timeline can be a * {@link org.jfree.chart.axis.SegmentedTimeline} such as the Monday * through Friday timeline that will remove Saturdays and Sundays from * the axis. * * @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 timeline the timeline. * @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, Timeline timeline, boolean legend) { DateAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setTimeline(timeline); 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); return chart; }
/** * 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; }
/** * Creates and returns a default instance of a high-low-open-close chart. * * @param title the chart title ({@code null} permitted). * @param timeAxisLabel a label for the time axis ({@code null} * permitted). * @param valueAxisLabel a label for the value axis ({@code null} * permitted). * @param dataset the dataset for the chart ({@code null} 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.setDefaultToolTipGenerator(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; }
/** * Creates and returns a default instance of a high-low-open-close chart * with a special timeline. This timeline can be a * {@link org.jfree.chart.axis.SegmentedTimeline} such as the Monday * through Friday timeline that will remove Saturdays and Sundays from * the axis. * * @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 timeline the timeline. * @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, Timeline timeline, boolean legend) { DateAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setTimeline(timeline); 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; }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { HighLowRenderer r1 = new HighLowRenderer(); HighLowRenderer r2 = new HighLowRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { HighLowRenderer r1 = new HighLowRenderer(); HighLowRenderer r2 = new HighLowRenderer(); assertEquals(r1, r2); // drawOpenTicks r1.setDrawOpenTicks(false); assertFalse(r1.equals(r2)); r2.setDrawOpenTicks(false); assertTrue(r1.equals(r2)); // drawCloseTicks r1.setDrawCloseTicks(false); assertFalse(r1.equals(r2)); r2.setDrawCloseTicks(false); assertTrue(r1.equals(r2)); // openTickPaint r1.setOpenTickPaint(Color.red); assertFalse(r1.equals(r2)); r2.setOpenTickPaint(Color.red); assertTrue(r1.equals(r2)); // closeTickPaint r1.setCloseTickPaint(Color.blue); assertFalse(r1.equals(r2)); r2.setCloseTickPaint(Color.blue); assertTrue(r1.equals(r2)); }
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { HighLowRenderer r1 = new HighLowRenderer(); HighLowRenderer r2 = new HighLowRenderer(); assertEquals(r1, r2); // drawOpenTicks r1.setDrawOpenTicks(false); assertFalse(r1.equals(r2)); r2.setDrawOpenTicks(false); assertTrue(r1.equals(r2)); // drawCloseTicks r1.setDrawCloseTicks(false); assertFalse(r1.equals(r2)); r2.setDrawCloseTicks(false); assertTrue(r1.equals(r2)); // openTickPaint r1.setOpenTickPaint(Color.red); assertFalse(r1.equals(r2)); r2.setOpenTickPaint(Color.red); assertTrue(r1.equals(r2)); // closeTickPaint r1.setCloseTickPaint(Color.blue); assertFalse(r1.equals(r2)); r2.setCloseTickPaint(Color.blue); assertTrue(r1.equals(r2)); // tickLength r1.setTickLength(99.9); assertFalse(r1.equals(r2)); r2.setTickLength(99.9); assertTrue(r1.equals(r2)); }
@Override public void test() { super.test(); numberOfPagesTest(1); JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", HighLowRenderer.class, renderer.getClass()); Assert.assertEquals("show open ticks", true, ((HighLowRenderer) renderer).getDrawOpenTicks()); Assert.assertEquals("show close ticks", true, ((HighLowRenderer) renderer).getDrawCloseTicks()); highLowChartDataTest(chart, 0, new Object[][] { {"serie", date1, 50d, 35d, 40d, 47d, 70d}, {"serie", date2, 55d, 40d, 50d, 45d, 120d}, {"serie", date3, 48d, 41d, 42d, 47d, 90d}}); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().getDomainAxis(); Assert.assertEquals("category label", "time", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels()); chart = getChart("summary.chart3", 0); axis = chart.getXYPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); //Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); Assert.assertTrue("vertical tick labels", ((ValueAxis) axis).isVerticalTickLabels()); }
/** * Problem that the equals(...) method distinguishes all fields. */ public void testEquals() { HighLowRenderer r1 = new HighLowRenderer(); HighLowRenderer r2 = new HighLowRenderer(); assertEquals(r1, r2); }
/** * * @param evaluation * @throws JRException */ protected JFreeChart createHighLowChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createHighLowChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset)getDataset(), isShowLegend() ); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRHighLowPlot highLowPlot = (JRHighLowPlot)getPlot(); HighLowRenderer hlRenderer = (HighLowRenderer) xyPlot.getRenderer(); boolean isShowOpenTicks = highLowPlot.getShowOpenTicks() == null ? false : highLowPlot.getShowOpenTicks().booleanValue(); boolean isShowCloseTicks = highLowPlot.getShowCloseTicks() == null ? false : highLowPlot.getShowCloseTicks().booleanValue(); hlRenderer.setDrawOpenTicks(isShowOpenTicks); hlRenderer.setDrawCloseTicks(isShowCloseTicks); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), highLowPlot.getTimeAxisLabelFont(), highLowPlot.getTimeAxisLabelColor(), highLowPlot.getTimeAxisTickLabelFont(), highLowPlot.getTimeAxisTickLabelColor(), highLowPlot.getTimeAxisTickLabelMask(), highLowPlot.getTimeAxisVerticalTickLabels(), highLowPlot.getOwnTimeAxisLineColor(), false, (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), highLowPlot.getValueAxisLabelFont(), highLowPlot.getValueAxisLabelColor(), highLowPlot.getValueAxisTickLabelFont(), highLowPlot.getValueAxisTickLabelColor(), highLowPlot.getValueAxisTickLabelMask(), highLowPlot.getValueAxisVerticalTickLabels(), highLowPlot.getOwnValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
/** * * @param evaluation * @throws JRException */ protected JFreeChart createHighLowChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createHighLowChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset)getDataset(), isShowLegend() ); configureChart(jfreeChart, getPlot()); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRHighLowPlot highLowPlot = (JRHighLowPlot)getPlot(); HighLowRenderer hlRenderer = (HighLowRenderer) xyPlot.getRenderer(); boolean isShowOpenTicks = highLowPlot.getShowOpenTicks() == null ? false : highLowPlot.getShowOpenTicks().booleanValue(); boolean isShowCloseTicks = highLowPlot.getShowCloseTicks() == null ? false : highLowPlot.getShowCloseTicks().booleanValue(); hlRenderer.setDrawOpenTicks(isShowOpenTicks); hlRenderer.setDrawCloseTicks(isShowCloseTicks); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), highLowPlot.getTimeAxisLabelFont(), highLowPlot.getTimeAxisLabelColor(), highLowPlot.getTimeAxisTickLabelFont(), highLowPlot.getTimeAxisTickLabelColor(), highLowPlot.getTimeAxisTickLabelMask(), highLowPlot.getTimeAxisVerticalTickLabels(), highLowPlot.getOwnTimeAxisLineColor(), getDomainAxisSettings(), (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMaxValueExpression()) ); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), highLowPlot.getValueAxisLabelFont(), highLowPlot.getValueAxisLabelColor(), highLowPlot.getValueAxisTickLabelFont(), highLowPlot.getValueAxisTickLabelColor(), highLowPlot.getValueAxisTickLabelMask(), highLowPlot.getValueAxisVerticalTickLabels(), highLowPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMaxValueExpression()) ); return jfreeChart; }
/** * */ protected JFreeChart createHighLowChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createHighLowChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getTimeAxisLabelExpression()), evaluateTextExpression(((JRHighLowPlot)getPlot()).getValueAxisLabelExpression()), (DefaultHighLowDataset)getDataset(), isShowLegend() ); configureChart(jfreeChart); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); JRHighLowPlot highLowPlot = (JRHighLowPlot)getPlot(); HighLowRenderer hlRenderer = (HighLowRenderer) xyPlot.getRenderer(); boolean isShowOpenTicks = highLowPlot.getShowOpenTicks() == null ? false : highLowPlot.getShowOpenTicks().booleanValue(); boolean isShowCloseTicks = highLowPlot.getShowCloseTicks() == null ? false : highLowPlot.getShowCloseTicks().booleanValue(); hlRenderer.setDrawOpenTicks(isShowOpenTicks); hlRenderer.setDrawCloseTicks(isShowCloseTicks); // Handle the axis formating for the category axis configureAxis(xyPlot.getDomainAxis(), highLowPlot.getTimeAxisLabelFont(), highLowPlot.getTimeAxisLabelColor(), highLowPlot.getTimeAxisTickLabelFont(), highLowPlot.getTimeAxisTickLabelColor(), highLowPlot.getTimeAxisTickLabelMask(), highLowPlot.getTimeAxisVerticalTickLabels(), highLowPlot.getTimeAxisLineColor(), false, (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(xyPlot.getRangeAxis(), highLowPlot.getValueAxisLabelFont(), highLowPlot.getValueAxisLabelColor(), highLowPlot.getValueAxisTickLabelFont(), highLowPlot.getValueAxisTickLabelColor(), highLowPlot.getValueAxisTickLabelMask(), highLowPlot.getValueAxisVerticalTickLabels(), highLowPlot.getValueAxisLineColor(), true, (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMinValueExpression()), (Comparable<?>)evaluateExpression(highLowPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }