Example usage for org.jfree.chart JFreeChart removeLegend

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

Introduction

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

Prototype

public void removeLegend() 

Source Link

Document

Removes the first legend in the chart and sends a ChartChangeEvent to all registered listeners.

Usage

From source file:com.itemanalysis.jmetrik.graph.irt.IrtPlotPanel.java

public void updateDataset(String name, XYSeriesCollection dataset, boolean showLegend) {
    JFreeChart chart = charts.get(name);
    if (!showLegend)
        chart.removeLegend();
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDataset(dataset);/*from w w  w. j av  a2 s  . c  o m*/
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    setXYPlotRenderer(plot);
}

From source file:com.itemanalysis.jmetrik.graph.irt.IrtPlotPanel.java

/**
 * Same as updateDataset() but includes additional series for observed points. The dataset is twice
 * the size as the number of lines because there is a line and set of points for each category.
 *
 * @param name name of chart/*from  w w w.  ja v  a  2  s. c o m*/
 * @param dataset data set where the first half of the entries define the lines and the second half
 *                of the series define the points. The series for lines and points are assumed to be
 *                in the same order.
 * @param showLegend show legend.
 */
public void updateDatasetLinesAndPoints(String name, XYSeriesCollection dataset, boolean showLegend) {
    JFreeChart chart = charts.get(name);
    if (!showLegend)
        chart.removeLegend();
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDataset(dataset);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    setXYPlotRendererWithPoints(plot);
}

From source file:org.n52.server.sos.generator.DiagramGenerator.java

/**
 * Creates a time series chart diagram and writes it to the OutputStream.
 * /*from w w w. j  av  a 2s .com*/
 * @param entireCollMap
 * @param options
 * @param out
 * @throws OXFException
 * @throws IOException
 */
public void producePresentation(Map<String, OXFFeatureCollection> entireCollMap, DesignOptions options,
        FileOutputStream out, boolean compress) throws OXFException, IOException {

    // render features:
    int width = options.getWidth();
    int height = options.getHeight();
    Calendar begin = Calendar.getInstance();
    begin.setTimeInMillis(options.getBegin());
    Calendar end = Calendar.getInstance();
    end.setTimeInMillis(options.getEnd());

    DiagramRenderer renderer = new DiagramRenderer(false);

    JFreeChart diagramChart = renderer.renderChart(entireCollMap, options, begin, end, compress);
    diagramChart.removeLegend();

    // draw chart into image:
    BufferedImage diagramImage = new BufferedImage(width, height, TYPE_INT_RGB);
    Graphics2D chartGraphics = diagramImage.createGraphics();
    chartGraphics.setColor(Color.white);
    chartGraphics.fillRect(0, 0, width, height);

    diagramChart.draw(chartGraphics, new Rectangle2D.Float(0, 0, width, height));

    JPEGEncodeParam p = new JPEGEncodeParam();
    p.setQuality(1f);
    ImageEncoder encoder = ImageCodec.createImageEncoder("jpeg", out, p);

    encoder.encode(diagramImage);
}

From source file:be.ac.ua.comp.scarletnebula.gui.DecoratedGraph.java

/**
 * @see Graph//from   ww  w  .  j av a2 s  .  c  o  m
 */
@Override
public ChartPanel getChartPanel() {
    final XYPlot plot = new XYPlot(dataset, domain, range, renderer);
    plot.setBackgroundPaint(Color.darkGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    // plot.setInsets(new RectangleInsets(0, 0, 0, 0));
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);

    if (stream.getMax() != null) {
        log.info("Getting chart panel for stream with maximum.");
        range.setAutoRange(false);

        range.setTickUnit(new NumberTickUnit(stream.getMax() / 10, new DecimalFormat(), 1));
        range.setRange(0, stream.getMax());
    } else if (stream.getType() == Type.RELATIVE) {
        range.setAutoRange(false);

        range.setTickUnit(new NumberTickUnit(0.1, new DecimalFormat(), 1));
        range.setRange(0, 1);
    } else {
        double sum = 0;
        final List<TimedDatapoint> datapoints = stream.getRecentlyProcessedDatapoints();

        range.setTickUnit(
                new NumberTickUnit((int) (Utils.max(datapoints).getValue() / 5) + 1, new DecimalFormat(), 1));
    }

    final JFreeChart chart = new JFreeChart(stream.getStreamname(), new Font("SansSerif", Font.PLAIN, 20), plot,
            true);
    chart.setBackgroundPaint(Color.white);
    chart.removeLegend();
    final ChartPanel chartPanel = new ChartPanel(chart);
    // chartPanel.setBorder(BorderFactory
    // .createBevelBorder(BevelBorder.LOWERED));

    return chartPanel;
}

From source file:playground.dgrether.analysis.charts.DgModalSplitQuantilesChart.java

public JFreeChart createChart() {
    CategoryAxis categoryAxis = this.axisBuilder.createCategoryAxis(xLabel);
    categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    ValueAxis valueAxis = this.axisBuilder.createValueAxis(yLabel);
    valueAxis.setRange(0.0, 102.0);/*from ww  w.j av  a2  s .  c  o  m*/

    DgColorScheme colorScheme = new DgColorScheme();

    CategoryPlot plot = new CategoryPlot();
    plot.setDomainAxis(categoryAxis);
    plot.setRangeAxis(valueAxis);
    plot.setDataset(0, this.dataset);
    BarRenderer carRenderer = new BarRenderer();
    carRenderer.setSeriesPaint(0, colorScheme.COLOR1A);
    carRenderer.setSeriesPaint(1, colorScheme.COLOR3A);

    carRenderer.setItemMargin(0.10);
    plot.setRenderer(0, carRenderer);

    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.removeLegend();
    return chart;
}

From source file:com.ivli.roim.controls.VOILUTPanel.java

public VOILUTPanel(LUTControl aP) {

    iCurveName = java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("VOILUTPANEL.VOI_LUT");

    iLUT = LUTControl.create(aP);/*from   w ww.  j a  va 2 s . c om*/

    aP.addWindowChangeListener(this);

    initComponents();

    XYPlot plot = new XYPlot();

    plot.setDataset(0, makeLUTCurve());
    plot.setRenderer(0, new XYSplineRenderer());

    ((XYSplineRenderer) plot.getRenderer()).setShapesVisible(false);
    plot.setRangeAxis(0, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
            .getString("VOILUTPANEL.AXIS_LABEL_VOI_CURVE")));

    XYSeriesCollection col2 = new XYSeriesCollection();
    col2.addSeries(makeHistogram());

    plot.setDataset(1, col2);
    plot.setRenderer(1, new XYBarRenderer());
    plot.setRangeAxis(1, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
            .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_SPACE")));
    plot.mapDatasetToRangeAxis(1, 1);

    plot.setDomainAxis(new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
            .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_HISTOGRAM")));
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);
    // change the rendering order so the primary dataset appears "behind" the 
    // other datasets...
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);

    JFreeChart jfc = new JFreeChart(plot);

    jfc.setBorderVisible(true);
    jfc.removeLegend();
    iPanel = new ChartPanel(jfc);
    iPanel.setSize(jPanel1.getPreferredSize());
    jPanel1.add(iPanel);//, java.awt.BorderLayout.CENTER);              
    iLUT.setSize(jPanel2.getPreferredSize());
    jPanel2.add(iLUT);
    iLabelMin.setText(String.format("%.0f", iLUT.getView().getMin()));
    iLabelMax.setText(String.format("%.0f", iLUT.getView().getMax()));

    validate();
}

From source file:Visuals.AreaChart.java

public ChartPanel drawAreaChart() {
    DefaultCategoryDataset areadataset = new DefaultCategoryDataset();
    areadataset.addValue(new Double(successCount), "Success", "Success (" + successCount + ")");
    areadataset.addValue(new Double(failCount), "Fail", "Fail (" + failCount + ")");

    JFreeChart areachart = ChartFactory.createBarChart("", // Title  
            "Result", "Attempts", areadataset // Dataset   
    );/*from  w w w.j  av a 2 s . co  m*/

    final CategoryPlot plot = areachart.getCategoryPlot();
    CategoryItemRenderer renderer = new CustomRendererAudit();

    areachart.removeLegend();
    plot.setRenderer(renderer);
    areachart.getCategoryPlot().setRenderer(renderer);
    //        plot.set("Success", new Color(230, 27, 27)); 
    //        plot.setSectionPaint("Fail", new Color(230, 90, 27)); 
    final CategoryPlot plotx = areachart.getCategoryPlot();
    ((BarRenderer) plotx.getRenderer()).setBarPainter(new StandardBarPainter());

    plotx.setBackgroundPaint(new Color(210, 234, 243));
    ChartPanel chartPanel = new ChartPanel(areachart);
    return chartPanel;
}

From source file:org.gephi.statistics.plugin.dynamic.DynamicNbEdges.java

public String getReport() {
    //Transform to Map
    Map<Double, Integer> map = new HashMap<Double, Integer>();
    for (Interval<Integer> interval : counts.getIntervals()) {
        map.put(interval.getLow(), interval.getValue());
    }/*from  w w  w  .j  av  a2  s  .  co m*/

    //Time series
    XYSeries dSeries = ChartUtils.createXYSeries(map, "Nb Edges Time Series");

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("# Edges Time Series", "Time", "# Edges", dataset,
            PlotOrientation.VERTICAL, true, false, false);

    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, false);
    String imageFile = ChartUtils.renderChart(chart, "nb-edges-ts.png");

    NumberFormat f = new DecimalFormat("#0.000");

    String report = "<HTML> <BODY> <h1>Dynamic Number of Edges Report </h1> " + "<hr>" + "<br> Bounds: from "
            + f.format(bounds.getLow()) + " to " + f.format(bounds.getHigh()) + "<br> Window: " + window
            + "<br> Tick: " + tick + "<br><br><h2> Number of edges over time: </h2>" + "<br /><br />"
            + imageFile;

    /*for (Interval<Integer> count : counts) {
    report += count.toString(dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DOUBLE)) + "<br />";
    }*/
    report += "<br /><br /></BODY></HTML>";
    return report;
}

From source file:org.gephi.statistics.plugin.dynamic.DynamicNbNodes.java

public String getReport() {
    //Transform to Map
    Map<Double, Integer> map = new HashMap<Double, Integer>();
    for (Interval<Integer> interval : counts.getIntervals()) {
        map.put(interval.getLow(), interval.getValue());
    }//from  ww  w.j  a  va2 s.c o  m

    //Time series
    XYSeries dSeries = ChartUtils.createXYSeries(map, "Nb Nodes Time Series");

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("# Nodes Time Series", "Time", "# Nodes", dataset,
            PlotOrientation.VERTICAL, true, false, false);

    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dSeries, false);
    String imageFile = ChartUtils.renderChart(chart, "nb-nodes-ts.png");

    NumberFormat f = new DecimalFormat("#0.000");

    String report = "<HTML> <BODY> <h1>Dynamic Number of Nodes Report </h1> " + "<hr>" + "<br> Bounds: from "
            + f.format(bounds.getLow()) + " to " + f.format(bounds.getHigh()) + "<br> Window: " + window
            + "<br> Tick: " + tick + "<br><br><h2> Number of nodes over time: </h2>" + "<br /><br />"
            + imageFile;

    /*for (Interval<Integer> count : counts) {
    report += count.toString(dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DOUBLE)) + "<br />";
    }*/
    report += "<br /><br /></BODY></HTML>";
    return report;
}

From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsQuantilesChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("% of Population Sorted by Income");
    xAxis.setRange(0.0, 102.0);//from ww w.j  a  va 2 s.  c o m
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    yAxis.setRange(-0.05, 0.3);
    //      xAxis.setVisible(false);
    //      xAxis.setFixedAutoRange(1.0);
    plot.setDomainAxis(xAxis);
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    renderer2.setSeriesItemLabelsVisible(0, true);
    //      renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator);
    plot.setDataset(0, this.dataset);
    renderer2.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer2.setSeriesOutlineStroke(0, new BasicStroke(3.0f));
    renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a"));
    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    chart.removeLegend();
    return chart;
}