Package org.jfree.chart

Examples of org.jfree.chart.LegendItemCollection


        PolarPlot plot = new PolarPlot();
        plot.setDataset(d1);
        plot.setDataset(1, d2);
        plot.setRenderer(r);
        plot.setRenderer(1, new DefaultPolarItemRenderer());
        LegendItemCollection items = plot.getLegendItems();
        assertEquals(4, items.getItemCount());
        LegendItem item1 = items.get(0);
        assertEquals("A", item1.getLabel());
        LegendItem item2 = items.get(1);
        assertEquals("B", item2.getLabel());
        LegendItem item3 = items.get(2);
        assertEquals("C", item3.getLabel());
        LegendItem item4 = items.get(3);
        assertEquals("D", item4.getLabel());
    }
View Full Code Here


        plot1.setMargin(6);
        assertFalse(plot1.equals(plot2));
        plot2.setMargin(6);
        assertTrue(plot1.equals(plot2));

        LegendItemCollection lic1 = new LegendItemCollection();
        lic1.add(new LegendItem("XYZ", Color.red));
        plot1.setFixedLegendItems(lic1);
        assertFalse(plot1.equals(plot2));
        LegendItemCollection lic2 = new LegendItemCollection();
        lic2.add(new LegendItem("XYZ", Color.red));
        plot2.setFixedLegendItems(lic2);
        assertTrue(plot1.equals(plot2));
    }
View Full Code Here

        assertFalse(plot1.equals(plot2));
        plot2.setFixedRangeAxisSpace(new AxisSpace());
        assertTrue(plot1.equals(plot2));

        // fixed legend items
        plot1.setFixedLegendItems(new LegendItemCollection());
        assertFalse(plot1.equals(plot2));
        plot2.setFixedLegendItems(new LegendItemCollection());
        assertTrue(plot1.equals(plot2));

        // crosshairDatasetIndex
        plot1.setCrosshairDatasetIndex(99);
        assertFalse(plot1.equals(plot2));
View Full Code Here

    /**
     * Some more cloning checks.
     */
    public void testCloning3() {
        LegendItemCollection c1 = new LegendItemCollection();
        CategoryPlot p1 = new CategoryPlot();
        p1.setFixedLegendItems(c1);
        CategoryPlot p2 = null;
        try {
            p2 = (CategoryPlot) p1.clone();
        }
        catch (CloneNotSupportedException e) {
            fail("Cloning failed.");
            return;
        }
        assertTrue(p1 != p2);
        assertTrue(p1.getClass() == p2.getClass());
        assertTrue(p1.equals(p2));

        c1.add(new LegendItem("X", "XX", "tt", "url", true,
                new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red,
                true, Color.yellow, new BasicStroke(1.0f), true,
                new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.0f),
                Color.green));
        assertFalse(p1.equals(p2));
View Full Code Here

        plot.setDataset(dataset);
        plot.setRenderer(r);
        assertEquals(0, r.getLegendItems().getItemCount());

        dataset.addValue(1.0, "S1", "C1");
        LegendItemCollection lic = r.getLegendItems();
        assertEquals(1, lic.getItemCount());
        assertEquals("S1", lic.get(0).getLabel());
    }
View Full Code Here

    private void _setDefaultLegendItems() {
        TargetDesc[] targets = _model.getTargets();
        int colorIndex = 0;
        Paint[] colors = new Paint[targets.length];
        Map<String, Paint> paintMap = new TreeMap<String, Paint>();
        LegendItemCollection lic = new LegendItemCollection();

        Shape shape = new Rectangle(-3, -3, 7, 7);
        for (int i = 0; i < targets.length; i++) {
            String name = targets[i].getName();
            if ((colors[i] = paintMap.get(name)) == null) {
                Paint color = _COLORS[colorIndex++ % _COLORS.length];
                paintMap.put(name, color);
                colors[i] = color;
                lic.add(new LegendItem(name, name, null, null, shape, color)); // TODO test change
            }
        }
        _itemColors = colors;
        _legendItems = lic;
    }
View Full Code Here

//        _renderer.setToolTipGenerator(_tooltipGenerator);

        // initialize the default priority colors
        _priorityPaintMap = new Hashtable<String, Paint>();
        _priorityLegendItemCollection = new LegendItemCollection();
        Shape shape = new Rectangle(-3, -3, 7, 7);
        for (int i = 0; i < _availablePriorities.length; i++) {
            _priorityPaintMap.put(_availablePriorities[i], _availablePriorityColors[i]);
            String s = _availablePriorities[i] + " Priority";
            _priorityLegendItemCollection.add(
View Full Code Here

      plot.setBackground(new DialBackground());

      logger.debug("Set values color");
      Vector arValuesName =  getValuesNames();
      legendItems = new LegendItemCollection();
      for (int j = 0; j < arValuesName.size(); j++) {
        DialPointer.Pin p = new DialPointer.Pin(j);
        if(colorMap!=null){
          String valueName=(String)arValuesName.get(j);
          Color color=(Color)colorMap.get(valueName);
View Full Code Here

  /**
   * Defines the legend for multivalue Speedometer
   * @return LegendItemCollection
   */
  private LegendItemCollection createLegend(){
    LegendItemCollection legendItems = new LegendItemCollection();
   
    return legendItems;
  }
View Full Code Here

      chart.addSubtitle(subTitle);
    }
    chart.setBackgroundPaint(Color.white);

//    I want to re order the legend
    LegendItemCollection legends=plot.getLegendItems();
    // legend Temp
    HashMap<String, LegendItem> legendTemp=new HashMap<String, LegendItem>();
    Vector<String> alreadyInserted=new Vector<String>();
    for (int i = 0; i<legends.getItemCount(); i++) {
      LegendItem item=legends.get(i);
      String label=item.getLabel();
      legendTemp.put(label, item);
    }
    LegendItemCollection newLegend=new LegendItemCollection();
    // force the order of the ones specified
    for (Iterator iterator = seriesOrder.iterator(); iterator.hasNext();) {
      String serie = (String) iterator.next();
      if(legendTemp.keySet().contains(serie)){
        newLegend.add(legendTemp.get(serie));
        alreadyInserted.add(serie);
      }
    }
    // check that there are no serie not specified, otherwise add them
    for (Iterator iterator = legendTemp.keySet().iterator(); iterator.hasNext();) {
      String serie = (String) iterator.next();
      if(!alreadyInserted.contains(serie)){
        newLegend.add(legendTemp.get(serie));
      }
    }

    plot.setFixedLegendItems(newLegend);
View Full Code Here

TOP

Related Classes of org.jfree.chart.LegendItemCollection

Copyright © 2018 www.massapicom. 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.