Package org.jfree.chart

Examples of org.jfree.chart.LegendItemCollection


     * Returns an item for each interval.
     *
     * @return A collection of legend items.
     */
    public LegendItemCollection getLegendItems() {
        LegendItemCollection result = new LegendItemCollection();
        Iterator iterator = this.intervals.iterator();
        while (iterator.hasNext()) {
            MeterInterval mi = (MeterInterval) iterator.next();
            Paint color = mi.getBackgroundPaint();
            if (color == null) {
                color = mi.getOutlinePaint();
            }
            LegendItem item = new LegendItem(mi.getLabel(), mi.getLabel(),
                    null, null, new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0),
                    color);
            item.setDataset(getDataset());
            result.add(item);
        }
        return result;
    }
View Full Code Here


   @Override
   public LegendItemCollection getLegendItems()
   {
      if (this.plot == null)
      {
         return new LegendItemCollection();
      }
      LegendItemCollection result = new LegendItemCollection();
      int index = this.plot.getIndexOf(this);
      XYDataset dataset = this.plot.getDataset(index);
      if (dataset != null)
      {
         int seriesCount = dataset.getSeriesCount();
         for (int i = 0; i < seriesCount; i++)
         {
            if (isSeriesVisibleInLegend(i))
            {
               LegendItem item = getLegendItem(index, i);
               if (item != null)
               {
                  result.add(item);
               }
            }
         }

      }
View Full Code Here

     * @return The legend item collection (never <code>null</code>).
     *
     * @see #getLegendItem(int, int)
     */
    public LegendItemCollection getLegendItems() {
        LegendItemCollection result = new LegendItemCollection();
        if (this.plot == null) {
            return result;
        }
        int index = this.plot.getIndexOf(this);
        CategoryDataset dataset = this.plot.getDataset(index);
        if (dataset == null) {
            return result;
        }
        int seriesCount = dataset.getRowCount();
        if (plot.getRowRenderingOrder().equals(SortOrder.ASCENDING)) {
            for (int i = 0; i < seriesCount; i++) {
                if (isSeriesVisibleInLegend(i)) {
                    LegendItem item = getLegendItem(index, i);
                    if (item != null) {
                        result.add(item);
                    }
                }
            }
        }
        else {
            for (int i = seriesCount - 1; i >= 0; i--) {
                if (isSeriesVisibleInLegend(i)) {
                    LegendItem item = getLegendItem(index, i);
                    if (item != null) {
                        result.add(item);
                    }
                }
            }
        }
        return result;
View Full Code Here

    *
    * @return The legend items.
    */
   public LegendItemCollection getLegendCollection()
   {
      LegendItemCollection result = new LegendItemCollection();
      if (this.paintIndex != null && this.paintIndex.size() > 0)
      {
         if (this.paintIndex.size() <= this.paintLimit)
         {
            for (Iterator i = this.paintIndex.entrySet().iterator();
                    i.hasNext();)
            {
               // in this case, every color has a unique value
               Map.Entry entry = (Map.Entry) i.next();
               String label = entry.getKey().toString();
               String description = label;
               Shape shape = new Rectangle2D.Double(1d, 1d, 1d, 1d);
               Paint paint = lookupSeriesPaint(
                       ((Integer) entry.getValue()).intValue());
               Paint outlinePaint = Color.black;
               Stroke outlineStroke = DEFAULT_STROKE;

               result.add(new LegendItem(label, description, null,
                       null, shape, paint, outlineStroke, outlinePaint));

            }
         }
         else
         {
            // in this case, every color has a range of values
            Set unique = new HashSet();
           
            for (Iterator i = this.paintIndex.entrySet().iterator();
                    i.hasNext();)
            {
               Map.Entry entry = (Map.Entry) i.next();
               if (unique.add(entry.getValue()))
               {
                  String label = getMinPaintValue(
                          (Integer) entry.getValue()).toString()
                          + " - " + getMaxPaintValue(
                          (Integer) entry.getValue()).toString();
                  String description = label;
                  Shape shape = new Rectangle2D.Double(1d, 1d, 1d, 1d);
                 
                  Paint paint = getSeriesPaint(
                          ((Integer) entry.getValue()).intValue());
                 
                  Paint outlinePaint = Color.black;
                  Stroke outlineStroke = DEFAULT_STROKE;

                  result.add(new LegendItem(label, description,
                          null, null, shape, paint, outlineStroke,
                          outlinePaint));
               }
            } // end foreach map entry
         } // end else
View Full Code Here

     * Returns a collection of legend items for the plot.
     *
     * @return The legend items.
     */
    public LegendItemCollection getLegendItems() {
        LegendItemCollection result = getFixedLegendItems();
        if (result == null) {
            result = new LegendItemCollection();
            if (this.subplots != null) {
                Iterator iterator = this.subplots.iterator();
                while (iterator.hasNext()) {
                    XYPlot plot = (XYPlot) iterator.next();
                    LegendItemCollection more = plot.getLegendItems();
                    result.addAll(more);
                }
            }
        }
        return result;
View Full Code Here

     *
     * @return The legend item collection (never <code>null</code>).
     */
    public LegendItemCollection getLegendItems() {
        if (this.plot == null) {
            return new LegendItemCollection();
        }
        LegendItemCollection result = new LegendItemCollection();
        int index = this.plot.getIndexOf(this);
        XYDataset dataset = this.plot.getDataset(index);
        if (dataset != null) {
            int seriesCount = dataset.getSeriesCount();
            for (int i = 0; i < seriesCount; i++) {
                if (isSeriesVisibleInLegend(i)) {
                    LegendItem item = getLegendItem(index, i);
                    if (item != null) {
                        result.add(item);
                    }
                }
            }

        }
View Full Code Here

     * Returns an item for each interval.
     *
     * @return A collection of legend items.
     */
    public LegendItemCollection getLegendItems() {
        LegendItemCollection result = new LegendItemCollection();
        Iterator iterator = this.intervals.iterator();
        while (iterator.hasNext()) {
            MeterInterval mi = (MeterInterval) iterator.next();
            Paint color = mi.getBackgroundPaint();
            if (color == null) {
                color = mi.getOutlinePaint();
            }
            LegendItem item = new LegendItem(mi.getLabel(), mi.getLabel(),
                    null, null, new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0),
                    color);
            item.setDataset(getDataset());
            result.add(item);
        }
        return result;
    }
View Full Code Here

     *
     * @return The legend item collection (never <code>null</code>).
     */
    public LegendItemCollection getLegendItems() {
        if (this.plot == null) {
            return new LegendItemCollection();
        }
        LegendItemCollection result = new LegendItemCollection();
        int index = this.plot.getIndexOf(this);
        XYDataset dataset = this.plot.getDataset(index);
        if (dataset != null) {
            int seriesCount = dataset.getSeriesCount();
            for (int i = 0; i < seriesCount; i++) {
                if (isSeriesVisibleInLegend(i)) {
                    LegendItem item = getLegendItem(index, i);
                    if (item != null) {
                        result.add(item);
                    }
                }
            }

        }
View Full Code Here

        }
        else {
            this.items.setArrangement(this.vLayout);
        }
        for (int s = 0; s < this.sources.length; s++) {
            LegendItemCollection legendItems = this.sources[s].getLegendItems();
            if (legendItems != null) {
                for (int i = 0; i < legendItems.getItemCount(); i++) {
                    LegendItem item = legendItems.get(i);
                    Block block = createLegendItemBlock(item);
                    this.items.add(block);
                }
            }
        }
View Full Code Here

     * @return The legend item collection (never <code>null</code>).
     *
     * @see #getLegendItem(int, int)
     */
    public LegendItemCollection getLegendItems() {
        LegendItemCollection result = new LegendItemCollection();
        if (this.plot == null) {
            return result;
        }
        int index = this.plot.getIndexOf(this);
        CategoryDataset dataset = this.plot.getDataset(index);
        if (dataset == null) {
            return result;
        }
        int seriesCount = dataset.getRowCount();
        if (plot.getRowRenderingOrder().equals(SortOrder.ASCENDING)) {
            for (int i = 0; i < seriesCount; i++) {
                if (isSeriesVisibleInLegend(i)) {
                    LegendItem item = getLegendItem(index, i);
                    if (item != null) {
                        result.add(item);
                    }
                }
            }
        }
        else {
            for (int i = seriesCount - 1; i >= 0; i--) {
                if (isSeriesVisibleInLegend(i)) {
                    LegendItem item = getLegendItem(index, i);
                    if (item != null) {
                        result.add(item);
                    }
                }
            }
        }
        return result;
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.