com.jgoodies.chart
Class FilteredChartModel<T>

java.lang.Object
  extended by com.jgoodies.chart.AbstractChartModel<T>
      extended by com.jgoodies.chart.FilteredChartModel<T>
All Implemented Interfaces:
ChartModel<T>

public final class FilteredChartModel<T>
extends AbstractChartModel<T>

A wrapper for ChartModels that limits the number of elements.

Version:
$Revision: 1.7 $
Author:
Karsten Lentzsch
See Also:
ChartModel

Constructor Summary
FilteredChartModel(ChartModel<T> chartModel, int itemLimit, float minimumFraction, String collapsedText, Color collapsedColor)
          Constructs a wrapper ChartModel on the given model.
 
Method Summary
 Color getCollapsedColor()
           
 String getCollapsedText()
           
 Color getColor(int index)
          Returns the color of the item at the given index.
 T getData(int index)
          Returns the user data at the given index.
 Icon getIcon(int index)
          Returns the icon at the given index.
 int getItemCount()
          Returns the number of items in this model.
 int getItemLimit()
           
 float getMinimumFraction()
           
 long getSize(int index)
          Returns the mandatory size at the given index.
 String getText(int index)
          Returns the text at the given index.
 void setCollapsedColor(Color newCollapsedColor)
           
 void setCollapsedText(String newCollapsedText)
           
 void setItemLimit(int newItemLimit)
           
 void setMinimumFraction(float newMinimumFraction)
           
 
Methods inherited from class com.jgoodies.chart.AbstractChartModel
addChangeListener, fireStateChanged, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilteredChartModel

public FilteredChartModel(ChartModel<T> chartModel,
                          int itemLimit,
                          float minimumFraction,
                          String collapsedText,
                          Color collapsedColor)
Constructs a wrapper ChartModel on the given model. The wrapper has a limited number of items, and all items have a size larger than the specified minimum sizes. Cropped elements are collapsed to a new item with the given collapsedText and collapsedColor.

Parameters:
chartModel - the chart model to colorize
itemLimit - the maximum number of items in the wrapper
minimumFraction - the minimum size of items in the wrapper
collapsedText - the text of the collapsed items
collapsedColor - the color of the collapsed items
Throws:
NullPointerException - if the chartModel is null
Method Detail

getItemLimit

public int getItemLimit()

setItemLimit

public void setItemLimit(int newItemLimit)

getMinimumFraction

public float getMinimumFraction()

setMinimumFraction

public void setMinimumFraction(float newMinimumFraction)

getCollapsedText

public String getCollapsedText()

setCollapsedText

public void setCollapsedText(String newCollapsedText)

getCollapsedColor

public Color getCollapsedColor()

setCollapsedColor

public void setCollapsedColor(Color newCollapsedColor)

getItemCount

public int getItemCount()
Returns the number of items in this model.

Returns:
the number of items in this model

getData

public T getData(int index)
Returns the user data at the given index.

Parameters:
index - the index to look at
Returns:
the user data object at the given index

getIcon

public Icon getIcon(int index)
Returns the icon at the given index. Charts may display the icon or not.

Parameters:
index - the index to look at
Returns:
the icon at the given index

getText

public String getText(int index)
Returns the text at the given index. Charts may display the text or not.

Parameters:
index - the index to look at
Returns:
the text at the given index

getSize

public long getSize(int index)
Returns the mandatory size at the given index.

Parameters:
index - the index to look at
Returns:
the icon at the given index

getColor

public Color getColor(int index)
Returns the color of the item at the given index. Some chart models may return null and leave it to a wrapper chart model to colorize the data.

Parameters:
index - the index to look at
Returns:
the color at the given index


Copyright © 2000-2008 JGoodies Karsten Lentzsch. All Rights Reserved.