Example usage for org.jfree.chart.title PaintScaleLegend setSubdivisionCount

List of usage examples for org.jfree.chart.title PaintScaleLegend setSubdivisionCount

Introduction

In this page you can find the example usage for org.jfree.chart.title PaintScaleLegend setSubdivisionCount.

Prototype

public void setSubdivisionCount(int count) 

Source Link

Document

Sets the subdivision count and sends a TitleChangeEvent to all registered listeners.

Usage

From source file:com.javafxpert.neuralnetviz.scenario.PlotUtil.java

private static JFreeChart createChart(XYZDataset dataset, double[] mins, double[] maxs, int nPoints,
        XYDataset xyData) {/*from  w ww  .  ja  va 2s .  c  o m*/
    NumberAxis xAxis = new NumberAxis("X");
    xAxis.setRange(mins[0], maxs[0]);

    NumberAxis yAxis = new NumberAxis("Y");
    yAxis.setRange(mins[1], maxs[1]);

    XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setBlockWidth((maxs[0] - mins[0]) / (nPoints - 1));
    renderer.setBlockHeight((maxs[1] - mins[1]) / (nPoints - 1));
    PaintScale scale = new GrayPaintScale(0, 1.0);
    renderer.setPaintScale(scale);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    JFreeChart chart = new JFreeChart("", plot);
    chart.getXYPlot().getRenderer().setSeriesVisibleInLegend(0, false);

    NumberAxis scaleAxis = new NumberAxis("Probability (class 0)");
    scaleAxis.setAxisLinePaint(Color.white);
    scaleAxis.setTickMarkPaint(Color.white);
    scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7));
    PaintScaleLegend legend = new PaintScaleLegend(new GrayPaintScale(), scaleAxis);
    legend.setStripOutlineVisible(false);
    legend.setSubdivisionCount(20);
    legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    legend.setAxisOffset(5.0);
    legend.setMargin(new RectangleInsets(5, 5, 5, 5));
    legend.setFrame(new BlockBorder(Color.red));
    legend.setPadding(new RectangleInsets(10, 10, 10, 10));
    legend.setStripWidth(10);
    legend.setPosition(RectangleEdge.LEFT);
    chart.addSubtitle(legend);

    ChartUtilities.applyCurrentTheme(chart);

    plot.setDataset(1, xyData);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setBaseLinesVisible(false);
    plot.setRenderer(1, renderer2);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    return chart;
}

From source file:org.gumtree.vis.awt.PlotFactory.java

private static PaintScaleLegend createScaleLegend(PaintScale scale, NumberAxis scaleAxis) {

    PaintScaleLegend legend = new PaintScaleLegend2D(scale, scaleAxis);
    legend.setSubdivisionCount(20);
    legend.setStripOutlineVisible(false);
    legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    legend.setAxisOffset(5);// w  w w .j  a v a  2 s.co  m
    RectangleInsets rec = new RectangleInsets(5, 0, 10, 5);
    legend.setMargin(rec);
    RectangleInsets rec2 = new RectangleInsets(4, 0, 22, 2);
    legend.setPadding(rec2);
    legend.setStripWidth(10);
    legend.setPosition(RectangleEdge.RIGHT);
    return legend;
}

From source file:org.gumtree.vis.awt.PlotFactory.java

public static JFreeChart createXYBlockChart(IXYZDataset dataset) {
    NumberAxis xAxis = createXAxis(dataset);
    NumberAxis yAxis = createYAxis(dataset);
    NumberAxis scaleAxis = createScaleAxis(dataset);

    float min = (float) dataset.getZMin();
    float max = (float) dataset.getZMax();
    PaintScale scale = generateRainbowScale(min, max, StaticValues.DEFAULT_COLOR_SCALE);
    XYBlockRenderer renderer = createRender(dataset, scale);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainPannable(true);//from ww  w.  jav  a 2  s.c o  m
    plot.setRangePannable(true);

    JFreeChart chart = new JFreeChart(dataset.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    //      chart = new JFreeChart(dataset.getTitle(), plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);

    PaintScale scaleBar = generateRainbowScale(min, max, StaticValues.DEFAULT_COLOR_SCALE);
    PaintScaleLegend legend = createScaleLegend(scale, scaleAxis);
    legend.setSubdivisionCount(ColorScale.DIVISION_COUNT);
    //      legend.setStripOutlineVisible(true);
    chart.addSubtitle(legend);
    chart.setBorderVisible(true);
    //      ChartUtilities.applyCurrentTheme(chart);
    chartTheme.apply(chart);
    chart.fireChartChanged();
    return chart;
}

From source file:org.gumtree.vis.hist2d.Hist2D.java

private PaintScaleLegend createScaleLegend(PaintScale scale) {

    PaintScaleLegend legend = new PaintScaleLegend(scale, scaleAxis);
    legend.setSubdivisionCount(20);
    legend.setStripOutlineVisible(false);
    legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    legend.setAxisOffset(5);/*from ww  w  . ja v  a 2 s .c om*/
    RectangleInsets rec = new RectangleInsets(5, 0, 10, 5);
    legend.setMargin(rec);
    RectangleInsets rec2 = new RectangleInsets(4, 0, 22, 2);
    legend.setPadding(rec2);
    legend.setStripWidth(10);
    legend.setPosition(RectangleEdge.RIGHT);
    return legend;
}

From source file:org.gumtree.vis.hist2d.Hist2D.java

private void createChart() {
    createXAxis();//from  w ww  .jav a  2  s  .  c  o m
    createYAxis();
    createScaleAxis();

    float min = (float) dataset.getZMin();
    float max = (float) dataset.getZMax();
    PaintScale scale = generateRainbowScale(min, max, ColorScale.Rainbow);
    createRender(scale);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainPannable(true);
    plot.setRangePannable(true);

    chart = new JFreeChart(dataset.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    //      chart = new JFreeChart(dataset.getTitle(), plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);

    PaintScale scaleBar = generateRainbowScale(min, max, ColorScale.Rainbow);
    PaintScaleLegend legend = createScaleLegend(scaleBar);
    legend.setSubdivisionCount(ColorScale.DIVISION_COUNT);
    chart.addSubtitle(legend);
    chart.setBorderVisible(true);
    //      ChartUtilities.applyCurrentTheme(chart);
    defaultChartTheme.apply(chart);
    chart.fireChartChanged();
}