Examples of LegendTitle


Examples of org.jfree.chart.title.LegendTitle

     * Serialize an instance, restore it, and check for equality.
     */
    public void testSerialization() {

        XYPlot plot = new XYPlot();
        LegendTitle t1 = new LegendTitle(plot);
        LegendTitle t2 = null;

        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(t1);
            out.close();

            ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray())
            );
            t2 = (LegendTitle) in.readObject();
            in.close();
        }
        catch (Exception e) {
            fail(e.toString());
        }
        assertTrue(t1.equals(t2));
        assertTrue(t2.getSources()[0].equals(plot));
    }
View Full Code Here

Examples of org.jfree.chart.title.LegendTitle

        plot.setRangeAxis(1, _valueAxis2);
        plot.mapDatasetToRangeAxis(1, 1);

        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
        if (_showLegend) {
            chart.addLegend(new LegendTitle(plot)); // TODO test change
        }

        return chart;
    }
View Full Code Here

Examples of org.jfree.chart.title.LegendTitle

     */
    public void setShowLegend(boolean show) {
        _showLegend = show;
        if (_chart != null) {
            if (show) {
                _chart.addLegend(new LegendTitle(_chart.getPlot()));
            } else {
//                _chart.setLegend(null); // TODO test change
                _chart.removeLegend();
            }
        }
View Full Code Here

Examples of org.jfree.chart.title.LegendTitle

        plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
        plot.setOrientation(PlotOrientation.HORIZONTAL);
        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
        if (_showLegend) {
            chart.addLegend(new LegendTitle(plot)); // TODO test change
        }

        return chart;
    }
View Full Code Here

Examples of org.jfree.chart.title.LegendTitle

    public void setShowLegend(boolean show) {
        _showLegend = show;
        if (_chart != null) {
            if (show) {
                for (JFreeChart chart : _chart) {
                    chart.addLegend(new LegendTitle(chart.getPlot())); // TODO test change
                }
            } else {
                for (JFreeChart chart : _chart) {
                    chart.removeLegend();
                }
View Full Code Here

Examples of org.jfree.chart.title.LegendTitle

    JFreeChart jfreechart = ChartFactory.createLineChart(chartTitle,
        rowName, colName, categoryDataset, PlotOrientation.VERTICAL,
        true, false, // tooltips
        false); // URLs

    LegendTitle legend = jfreechart.getLegend();

    legend.setItemFont(new Font("Dotum", Font.BOLD, 16));

    CategoryPlot plot = (CategoryPlot) jfreechart.getPlot();

    LineAndShapeRenderer render = (LineAndShapeRenderer) plot.getRenderer();
    render.setSeriesPaint(0, Color.RED);
View Full Code Here

Examples of org.jfree.chart.title.LegendTitle

  //gets first legend in the list
  public static LegendTitle getLegend(JFreeChart chart)
  {
    //i need to find the legend now.
    LegendTitle legend = null;
    List subTitles = chart.getSubtitles();
    Iterator iter = subTitles.iterator();
    while (iter.hasNext())
    {
      Object o = iter.next();
View Full Code Here

Examples of org.jfree.chart.title.LegendTitle

  private static RenderedImage renderLegend(ChartImage cd, Object c) throws CewolfException {
    try {
        JFreeChart chart = (JFreeChart) c;
      final int width = cd.getWidth();
      final int height = cd.getHeight();
      LegendTitle legend = getLegend(chart);
      boolean haslegend = true;
     
      // with JFreeChart v0.9.20, the only way to get a valid legend,
      // is either to retrieve it from the chart or to assign a new
      // one to the chart. In the case where the chart has no legend,
      // a new one must be assigned, but just for rendering. After, we
      // have to reset the legend to null in the chart.
      if (null == legend) {
        haslegend = false;
        legend = new LegendTitle(chart.getPlot());  
      }
      legend.setPosition(RectangleEdge.BOTTOM);
      BufferedImage bimage = ImageHelper.createImage(width, height);
      Graphics2D g = bimage.createGraphics();
      g.setColor(Color.white);
      g.fillRect(0, 0, width, height);
      legend.arrange(g,new RectangleConstraint(width,height));
       legend.draw(g, new Rectangle(width, height));
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
      JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bimage);
      param.setQuality(1.0f, true);
      encoder.encode(bimage, param);
View Full Code Here

Examples of org.jfree.chart.title.LegendTitle

 
    //gets first legend in the list
    public LegendTitle getLegend()
    {
      //i need to find the legend now.
      LegendTitle legend = null;
      List subTitles = chart.getSubtitles();
      Iterator iter = subTitles.iterator();
      while (iter.hasNext())
      {
        Object o = iter.next();
View Full Code Here

Examples of org.jfree.chart.title.LegendTitle

                chart.setBackgroundPaint(paint);
            }
            if (showLegend)
            {

                LegendTitle legend = this.getLegend();
                switch (legendAnchor)
                {
                    case ANCHOR_NORTH :
                        legend.setPosition(RectangleEdge.TOP);
                        break;
                    case ANCHOR_WEST :
                      legend.setPosition(RectangleEdge.RIGHT);
                        break;
                    case ANCHOR_EAST :
                      legend.setPosition(RectangleEdge.LEFT);
                        break;
                    default :
                      legend.setPosition(RectangleEdge.BOTTOM);
                }
            }
            else
            {
              this.removeLegend();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.