Java Code Examples for org.jfree.chart.ChartFactory#createLineChart()

The following examples show how to use org.jfree.chart.ChartFactory#createLineChart() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CategoryPlotTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A test for bug 1654215 (where a renderer is added to the plot without
 * a corresponding dataset and it throws an exception at drawing time).
 */
public void test1654215() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRenderer(1, new LineAndShapeRenderer());
    boolean success = false;
    try {
        BufferedImage image = new BufferedImage(200 , 100, 
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
    }
    catch (Exception e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
Example 2
Source File: LogAxisTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * A simple test for the auto-range calculation looking at a
 * NumberAxis used as the range axis for a CategoryPlot.  In this
 * case, the original dataset is replaced with a new dataset.
 */
@Test
public void testAutoRange3() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(100.0, "Row 1", "Column 1");
    dataset.setValue(200.0, "Row 1", "Column 2");
    JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
            "Value", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    LogAxis axis = new LogAxis("Log(Y)");
    plot.setRangeAxis(axis);
    assertEquals(96.59363289248458, axis.getLowerBound(), EPSILON);
    assertEquals(207.0529847682752, axis.getUpperBound(), EPSILON);

    // now replacing the dataset should update the axis range...
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(900.0, "Row 1", "Column 1");
    dataset2.setValue(1000.0, "Row 1", "Column 2");
    plot.setDataset(dataset2);
    assertEquals(895.2712433374774, axis.getLowerBound(), EPSILON);
    assertEquals(1005.2819262292991, axis.getUpperBound(), EPSILON);
}
 
Example 3
Source File: ValueAxisTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * A test for bug 3555275 (where the fixed axis space is calculated 
 * incorrectly).
 */
@Test
public void test3555275() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setAxisOffset(RectangleInsets.ZERO_INSETS);
    ValueAxis yAxis = plot.getRangeAxis();
    yAxis.setFixedDimension(100.0);
    BufferedImage image = new BufferedImage(500, 300, 
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    ChartRenderingInfo info = new ChartRenderingInfo();
    chart.draw(g2, new Rectangle2D.Double(0, 0, 500, 300), info);
    g2.dispose();
    Rectangle2D rect = info.getPlotInfo().getDataArea();
    double x = rect.getMinX();
    assertEquals(100.0, x, 1.0);
}
 
Example 4
Source File: NumberAxisTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * A simple test for the auto-range calculation looking at a
 * NumberAxis used as the range axis for a CategoryPlot.  In this
 * case, the 'autoRangeIncludesZero' flag is set to false AND the
 * original dataset is replaced with a new dataset.
 */
@Test
public void testAutoRange3() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(100.0, "Row 1", "Column 1");
    dataset.setValue(200.0, "Row 1", "Column 2");
    JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
            "Value", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(axis.getLowerBound(), 95.0, EPSILON);
    assertEquals(axis.getUpperBound(), 205.0, EPSILON);

    // now replacing the dataset should update the axis range...
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(900.0, "Row 1", "Column 1");
    dataset2.setValue(1000.0, "Row 1", "Column 2");
    plot.setDataset(dataset2);
    assertEquals(axis.getLowerBound(), 895.0, EPSILON);
    assertEquals(axis.getUpperBound(), 1005.0, EPSILON);
}
 
Example 5
Source File: LineChartTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a line chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createLineChart() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-3), new Integer(-2)},
         {new Integer(-1), new Integer(1)},
         {new Integer(2), new Integer(3)}};

    CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", 
            "C", data);

    // create the chart...
    return ChartFactory.createLineChart(
        "Line Chart",
        "Domain", "Range",
        dataset,
        PlotOrientation.HORIZONTAL,
        true,     // include legend
        true,
        true
    );

}
 
Example 6
Source File: CategoryPlotTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * A test for bug 1654215 (where a renderer is added to the plot without
 * a corresponding dataset and it throws an exception at drawing time).
 */
@Test
public void test1654215() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRenderer(1, new LineAndShapeRenderer());
    try {
        BufferedImage image = new BufferedImage(200 , 100,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
    }
    catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
 
Example 7
Source File: CategoryPlotTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A test for bug 1654215 (where a renderer is added to the plot without
 * a corresponding dataset and it throws an exception at drawing time).
 */
@Test
public void test1654215() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRenderer(1, new LineAndShapeRenderer());
    try {
        BufferedImage image = new BufferedImage(200 , 100,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
    }
    catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
 
Example 8
Source File: NumberAxisTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A simple test for the auto-range calculation looking at a
 * NumberAxis used as the range axis for a CategoryPlot.  In this
 * case, the 'autoRangeIncludesZero' flag is set to false AND the
 * original dataset is replaced with a new dataset.
 */
public void testAutoRange3() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(100.0, "Row 1", "Column 1");
    dataset.setValue(200.0, "Row 1", "Column 2");
    JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
            "Value", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(axis.getLowerBound(), 95.0, EPSILON);    
    assertEquals(axis.getUpperBound(), 205.0, EPSILON);    
    
    // now replacing the dataset should update the axis range...
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(900.0, "Row 1", "Column 1");
    dataset2.setValue(1000.0, "Row 1", "Column 2");
    plot.setDataset(dataset2);
    assertEquals(axis.getLowerBound(), 895.0, EPSILON);    
    assertEquals(axis.getUpperBound(), 1005.0, EPSILON);    
}
 
Example 9
Source File: CategoryPlotTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A test for bug 1654215 (where a renderer is added to the plot without
 * a corresponding dataset and it throws an exception at drawing time).
 */
@Test
public void test1654215() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRenderer(1, new LineAndShapeRenderer());
    try {
        BufferedImage image = new BufferedImage(200 , 100,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
    }
    catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
 
Example 10
Source File: NumberAxisTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A simple test for the auto-range calculation looking at a
 * NumberAxis used as the range axis for a CategoryPlot.  In this
 * case, the 'autoRangeIncludesZero' flag is set to false AND the
 * original dataset is replaced with a new dataset.
 */
@Test
public void testAutoRange3() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(100.0, "Row 1", "Column 1");
    dataset.setValue(200.0, "Row 1", "Column 2");
    JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
            "Value", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(axis.getLowerBound(), 95.0, EPSILON);
    assertEquals(axis.getUpperBound(), 205.0, EPSILON);

    // now replacing the dataset should update the axis range...
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(900.0, "Row 1", "Column 1");
    dataset2.setValue(1000.0, "Row 1", "Column 2");
    plot.setDataset(dataset2);
    assertEquals(axis.getLowerBound(), 895.0, EPSILON);
    assertEquals(axis.getUpperBound(), 1005.0, EPSILON);
}
 
Example 11
Source File: NumberAxisTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A simple test for the auto-range calculation looking at a
 * NumberAxis used as the range axis for a CategoryPlot.  In this
 * case, the 'autoRangeIncludesZero' flag is set to false AND the
 * original dataset is replaced with a new dataset.
 */
public void testAutoRange3() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(100.0, "Row 1", "Column 1");
    dataset.setValue(200.0, "Row 1", "Column 2");
    JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
            "Value", dataset, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(axis.getLowerBound(), 95.0, EPSILON);
    assertEquals(axis.getUpperBound(), 205.0, EPSILON);

    // now replacing the dataset should update the axis range...
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(900.0, "Row 1", "Column 1");
    dataset2.setValue(1000.0, "Row 1", "Column 2");
    plot.setDataset(dataset2);
    assertEquals(axis.getLowerBound(), 895.0, EPSILON);
    assertEquals(axis.getUpperBound(), 1005.0, EPSILON);
}
 
Example 12
Source File: LogAxisTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A simple test for the auto-range calculation looking at a
 * NumberAxis used as the range axis for a CategoryPlot.  In this
 * case, the original dataset is replaced with a new dataset.
 */
@Test
public void testAutoRange3() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(100.0, "Row 1", "Column 1");
    dataset.setValue(200.0, "Row 1", "Column 2");
    JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
            "Value", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    LogAxis axis = new LogAxis("Log(Y)");
    plot.setRangeAxis(axis);
    assertEquals(96.59363289248458, axis.getLowerBound(), EPSILON);
    assertEquals(207.0529847682752, axis.getUpperBound(), EPSILON);

    // now replacing the dataset should update the axis range...
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(900.0, "Row 1", "Column 1");
    dataset2.setValue(1000.0, "Row 1", "Column 2");
    plot.setDataset(dataset2);
    assertEquals(895.2712433374774, axis.getLowerBound(), EPSILON);
    assertEquals(1005.2819262292991, axis.getUpperBound(), EPSILON);
}
 
Example 13
Source File: ValueAxisTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A test for bug 3555275 (where the fixed axis space is calculated 
 * incorrectly).
 */
@Test
public void test3555275() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setAxisOffset(RectangleInsets.ZERO_INSETS);
    ValueAxis yAxis = plot.getRangeAxis();
    yAxis.setFixedDimension(100.0);
    BufferedImage image = new BufferedImage(500, 300, 
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    ChartRenderingInfo info = new ChartRenderingInfo();
    chart.draw(g2, new Rectangle2D.Double(0, 0, 500, 300), info);
    g2.dispose();
    Rectangle2D rect = info.getPlotInfo().getDataArea();
    double x = rect.getMinX();
    assertEquals(100.0, x, 1.0);
}
 
Example 14
Source File: ValueAxisTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A test for bug 3555275 (where the fixed axis space is calculated 
 * incorrectly).
 */
@Test
public void test3555275() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setAxisOffset(RectangleInsets.ZERO_INSETS);
    ValueAxis yAxis = plot.getRangeAxis();
    yAxis.setFixedDimension(100.0);
    BufferedImage image = new BufferedImage(500, 300, 
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    ChartRenderingInfo info = new ChartRenderingInfo();
    chart.draw(g2, new Rectangle2D.Double(0, 0, 500, 300), info);
    g2.dispose();
    Rectangle2D rect = info.getPlotInfo().getDataArea();
    double x = rect.getMinX();
    assertEquals(100.0, x, 1.0);
}
 
Example 15
Source File: CategoryPlotTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A test for bug 1654215 (where a renderer is added to the plot without
 * a corresponding dataset and it throws an exception at drawing time).
 */
@Test
public void test1654215() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRenderer(1, new LineAndShapeRenderer());
    try {
        BufferedImage image = new BufferedImage(200 , 100,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
    }
    catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
 
Example 16
Source File: NumberAxisTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A simple test for the auto-range calculation looking at a
 * NumberAxis used as the range axis for a CategoryPlot.  In this
 * case, the 'autoRangeIncludesZero' flag is set to false.
 */
public void testAutoRange2() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(100.0, "Row 1", "Column 1");
    dataset.setValue(200.0, "Row 1", "Column 2");
    JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
            "Value", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(axis.getLowerBound(), 95.0, EPSILON);    
    assertEquals(axis.getUpperBound(), 205.0, EPSILON);    
}
 
Example 17
Source File: NumberAxisTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A simple test for the auto-range calculation looking at a
 * NumberAxis used as the range axis for a CategoryPlot.  In this
 * case, the 'autoRangeIncludesZero' flag is set to false.
 */
public void testAutoRange2() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(100.0, "Row 1", "Column 1");
    dataset.setValue(200.0, "Row 1", "Column 2");
    JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
            "Value", dataset, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(axis.getLowerBound(), 95.0, EPSILON);
    assertEquals(axis.getUpperBound(), 205.0, EPSILON);
}
 
Example 18
Source File: NewJFrame.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates new form NewJFrame
 */
public NewJFrame() {
    setTitle("[SIMVA-SoS] Main Window");
    initComponents();
    this.setLocationRelativeTo(null);
    graph_panel.setLayout(new java.awt.BorderLayout());
    graph_panel1.setLayout(new java.awt.BorderLayout());
    
    scheduler = Executors.newScheduledThreadPool(2);
    dataReadingScheduler = Executors.newScheduledThreadPool(1);
    dataAddingScheduler = Executors.newScheduledThreadPool(1);
    dataTool1 = new DatasetUtility(new DefaultCategoryDataset());
    dataTool2 = new DatasetUtility(new DefaultCategoryDataset());
    
    lineChart = ChartFactory.createLineChart("Single Simulation", "Tick", "Patients", dataTool1.getDataset(), PlotOrientation.VERTICAL, true, true, false);
    barChart = ChartFactory.createBarChart("Statistical Verification", "Theta", "NumSamples", dataTool2.getDataset(), PlotOrientation.VERTICAL, true, true, false); // horizontal
    
    // Single
    drawGraph(null);
    // Verification
    drawBarGraph(null);
    
    jTextArea1.setEditable(false); // log for the simulation-based Analysis
    jTextArea2.setEditable(false); // log for the single simulation
    
    printStreamSimulation = new PrintStream(new CustomOutputStream(jTextArea1));
    printStreamSingle = new PrintStream(new CustomOutputStream(jTextArea2));
    
    fileBufferVerification = new ArrayList<>();
    fileBufferSingle = new ArrayList<>();
}
 
Example 19
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected JFreeChart createLineChart() throws JRException 
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart jfreeChart = ChartFactory.createLineChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression( ((JRLinePlot)getPlot()).getCategoryAxisLabelExpression()),
			evaluateTextExpression(((JRLinePlot)getPlot()).getValueAxisLabelExpression()),
			(CategoryDataset)getDataset(),
			getPlot().getOrientationValue().getOrientation(),
			isShowLegend(),
			true,
			false);

	configureChart(jfreeChart);

	CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
	JRLinePlot linePlot = (JRLinePlot)getPlot();

	LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer)categoryPlot.getRenderer();
	boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes();
	boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines();
	
	lineRenderer.setBaseShapesVisible( isShowShapes );//FIXMECHART check this
	lineRenderer.setBaseLinesVisible( isShowLines );
	
	//FIXME labels?

	// Handle the axis formating for the category axis
	configureAxis(categoryPlot.getDomainAxis(), linePlot.getCategoryAxisLabelFont(),
			linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(),
			linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(), linePlot.getCategoryAxisVerticalTickLabels(),
			linePlot.getCategoryAxisLineColor(),  false,
			(Comparable<?>)evaluateExpression(linePlot.getDomainAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(linePlot.getDomainAxisMaxValueExpression()));

	// Handle the axis formating for the value axis
	configureAxis(categoryPlot.getRangeAxis(), linePlot.getValueAxisLabelFont(),
			linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(),
			linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(), linePlot.getValueAxisVerticalTickLabels(),
			linePlot.getValueAxisLineColor(), true,
			(Comparable<?>)evaluateExpression(linePlot.getRangeAxisMinValueExpression()),
			(Comparable<?>)evaluateExpression(linePlot.getRangeAxisMaxValueExpression()));

	return jfreeChart;
}
 
Example 20
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected JFreeChart createLineChart() throws JRException 
{
	ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
	JFreeChart freeChart = 
		ChartFactory.createLineChart(
			evaluateTextExpression(getChart().getTitleExpression()),
			evaluateTextExpression( ((JRLinePlot)getPlot()).getCategoryAxisLabelExpression()),
			evaluateTextExpression(((JRLinePlot)getPlot()).getValueAxisLabelExpression()),
			(CategoryDataset)getDataset(),
			getPlot().getOrientationValue().getOrientation(),
			isShowLegend(),
			true,
			false);

	configureChart(freeChart, getPlot());

	CategoryPlot categoryPlot = (CategoryPlot)freeChart.getPlot();
	JRLinePlot linePlot = (JRLinePlot)getPlot();

	LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer)categoryPlot.getRenderer();
	boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes();
	boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines();
	
	lineRenderer.setBaseShapesVisible( isShowShapes );//FIXMECHART check this
	lineRenderer.setBaseLinesVisible( isShowLines );
	
	//FIXME labels?

	// Handle the axis formating for the category axis
	configureAxis(categoryPlot.getDomainAxis(), linePlot.getCategoryAxisLabelFont(),
			linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(),
			linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(), linePlot.getCategoryAxisVerticalTickLabels(),
			linePlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(),
			(Comparable<?>)evaluateExpression(linePlot.getDomainAxisMinValueExpression()), 
			(Comparable<?>)evaluateExpression(linePlot.getDomainAxisMaxValueExpression())
			);


	// Handle the axis formating for the value axis
	configureAxis(categoryPlot.getRangeAxis(), linePlot.getValueAxisLabelFont(),
			linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(),
			linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(), linePlot.getValueAxisVerticalTickLabels(),
			linePlot.getOwnValueAxisLineColor(), getRangeAxisSettings(),
			(Comparable<?>)evaluateExpression(linePlot.getRangeAxisMinValueExpression()), 
			(Comparable<?>)evaluateExpression(linePlot.getRangeAxisMaxValueExpression())
			);

	return freeChart;
}