Example usage for org.jfree.chart JFreeChart getSubtitles

List of usage examples for org.jfree.chart JFreeChart getSubtitles

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart getSubtitles.

Prototype

public List getSubtitles() 

Source Link

Document

Returns the list of subtitles for the chart.

Usage

From source file:de.laures.cewolf.util.Renderer.java

public static void removeLegend(JFreeChart chart) {
    List subTitles = chart.getSubtitles();
    Iterator iter = subTitles.iterator();
    while (iter.hasNext()) {
        Object o = iter.next();//w  w  w  . j  a v a 2 s.  c o m
        if (o instanceof LegendTitle) {
            iter.remove();
            break;
        }
    }
}

From source file:de.laures.cewolf.util.Renderer.java

public static LegendTitle getLegend(JFreeChart chart) {
    //i need to find the legend now.
    LegendTitle legend = null;//from  w  w w . j av  a 2 s.co  m
    List subTitles = chart.getSubtitles();
    Iterator iter = subTitles.iterator();
    while (iter.hasNext()) {
        Object o = iter.next();
        if (o instanceof LegendTitle) {
            legend = (LegendTitle) o;
            break;
        }
    }
    return legend;
}

From source file:fr.amap.commons.javafx.chart.ChartViewer.java

public static JFreeChart createBasicChart(String title, XYSeriesCollection dataset, String xAxisLabel,
        String yAxisLabel) {/*w  w  w.  ja va  2 s  .co m*/

    JFreeChart chart = ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    String fontName = "Palatino";
    chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
    XYPlot plot = (XYPlot) chart.getPlot();

    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getDomainAxis().setLowerMargin(0.0);

    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));

    chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    chart.getLegend().setFrame(BlockBorder.NONE);

    LegendTitle subtitle = (LegendTitle) chart.getSubtitles().get(0);
    subtitle.setHorizontalAlignment(HorizontalAlignment.LEFT);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);

        Ellipse2D.Float shape = new Ellipse2D.Float(-2.5f, -2.5f, 5.0f, 5.0f);
        renderer.setSeriesShape(0, shape);
    }

    return chart;
}

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

@Override
public void updateChart(JFreeChart chart) {
    chart.setShowSubtitle(showColorScale.isSelected());
    for (Object object : chart.getSubtitles()) {
        if (object instanceof PaintScaleLegend) {
            PaintScale scale = ((PaintScaleLegend) object).getScale();
            if (scale instanceof ColorPaintScale) {
                ((ColorPaintScale) scale).setLogScale(logarithmScale.isSelected());
                ((ColorPaintScale) scale).setColorScale((ColorScale) colourScaleCombo.getSelectedItem());
                XYItemRenderer renderer = chart.getXYPlot().getRenderer();
                if (renderer instanceof XYBlockRenderer) {
                    ((XYBlockRenderer) renderer).setPaintScale(scale);
                }//from   w  w  w .  j a  va2s  .  co m
            }
        }
    }

    ValueAxis axis = chart.getXYPlot().getDomainAxis();
    if (flipX.isSelected() != initialFlipX) {
        axis.setInverted(flipX.isSelected());
    }

    axis = chart.getXYPlot().getRangeAxis();
    if (flipY.isSelected() != initialFlipY) {
        axis.setInverted(flipY.isSelected());
    }

    applyROIChange();
    super.updateChart(chart);
}

From source file:net.sf.mzmine.chartbasics.chartthemes.ChartThemeParameters.java

public void applyToChart(JFreeChart chart) {
    // apply chart settings
    boolean showTitle = this.getParameter(ChartThemeParameters.showTitle).getValue();
    boolean changeTitle = this.getParameter(ChartThemeParameters.changeTitle).getValue();
    String title = this.getParameter(ChartThemeParameters.changeTitle).getEmbeddedParameter().getValue();
    boolean showLegends = this.getParameter(ChartThemeParameters.showLegends).getValue();

    boolean usexlabel = this.getParameter(ChartThemeParameters.xlabel).getValue();
    boolean useylabel = this.getParameter(ChartThemeParameters.ylabel).getValue();
    String xlabel = this.getParameter(ChartThemeParameters.xlabel).getEmbeddedParameter().getValue();
    String ylabel = this.getParameter(ChartThemeParameters.ylabel).getEmbeddedParameter().getValue();

    Color gbColor = this.getParameter(ChartThemeParameters.color).getValue();
    chart.setBackgroundPaint(gbColor);/*from  www  .  ja  v a  2  s  .  c  o m*/
    chart.getPlot().setBackgroundPaint(gbColor);

    if (changeTitle)
        chart.setTitle(title);
    chart.getTitle().setVisible(showTitle);
    ((List<Title>) chart.getSubtitles()).stream().forEach(t -> t.setVisible(showLegends));

    if (chart.getXYPlot() != null) {
        XYPlot p = chart.getXYPlot();
        if (usexlabel)
            p.getDomainAxis().setLabel(xlabel);
        if (useylabel)
            p.getRangeAxis().setLabel(ylabel);

        boolean xgrid = this.getParameter(ChartThemeParameters.xGridPaint).getValue();
        boolean ygrid = this.getParameter(ChartThemeParameters.yGridPaint).getValue();
        Color cxgrid = this.getParameter(ChartThemeParameters.xGridPaint).getEmbeddedParameter().getValue();
        Color cygrid = this.getParameter(ChartThemeParameters.yGridPaint).getEmbeddedParameter().getValue();
        p.setDomainGridlinesVisible(xgrid);
        p.setDomainGridlinePaint(cxgrid);
        p.setRangeGridlinesVisible(ygrid);
        p.setRangeGridlinePaint(cygrid);

        p.getDomainAxis().setVisible(this.getParameter(ChartThemeParameters.showXAxis).getValue());
        p.getRangeAxis().setVisible(this.getParameter(ChartThemeParameters.showYAxis).getValue());
    }
}

From source file:fr.amap.lidar.amapvox.chart.VoxelsToChart.java

public JFreeChart createChart(String title, XYSeriesCollection dataset, String xAxisLabel, String yAxisLabel) {

    JFreeChart chart = ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    String fontName = "Palatino";
    chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
    XYPlot plot = (XYPlot) chart.getPlot();

    plot.setDomainPannable(true);//from  www .  j  a  va2 s .co  m
    plot.setRangePannable(true);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getDomainAxis().setLowerMargin(0.0);

    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));

    chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    chart.getLegend().setFrame(BlockBorder.NONE);

    LegendTitle subtitle = (LegendTitle) chart.getSubtitles().get(0);
    subtitle.setHorizontalAlignment(HorizontalAlignment.LEFT);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);

        Ellipse2D.Float shape = new Ellipse2D.Float(-2.5f, -2.5f, 5.0f, 5.0f);

        for (int i = 0; i < voxelFiles.length; i++) {
            renderer.setSeriesShape(i, shape);
            renderer.setSeriesPaint(i, voxelFiles[i].getSeriesParameters().getColor());
            renderer.setLegendTextPaint(i, voxelFiles[i].getSeriesParameters().getColor());
        }
    }

    return chart;
}