com.jgoodies.chart
Class ColoredChartModel<T>

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

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

A wrapper for ChartModels that colorizes the uncolored wrapped items. More precisely, if m is the wrapped ChartModel, and w is this wrapper, then w.getItemCount() == m.getItemCount(), and for all indices i, w and m return the same data, icon, text, and size. And w.getColor(i) == m.getColor(i), iff m.getColor(i) == null.

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

Constructor Summary
ColoredChartModel(ChartModel<T> chartModel, int colorCount, float saturation, float brightness)
          Constructs a wrapper ChartModel on the given model.
 
Method Summary
 float getBrightness()
           
 Color getColor(int index)
          Returns the color of the item at the given index.
 int getColorCount()
           
 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.
 float getSaturation()
           
 long getSize(int index)
          Returns the mandatory size at the given index.
 String getText(int index)
          Returns the text at the given index.
 void setBrightness(float newBrightness)
           
 void setColorCount(int newColorCount)
           
 void setSaturation(float newSaturation)
           
 
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

ColoredChartModel

public ColoredChartModel(ChartModel<T> chartModel,
                         int colorCount,
                         float saturation,
                         float brightness)
Constructs a wrapper ChartModel on the given model. The wrapper has a color set for all indexes where the wrapped model has a null color.

Parameters:
chartModel - the chart model to colorize
colorCount - the number of colors to compute
saturation - the saturation of the computed colors
brightness - the brightness of the computed colors
Throws:
NullPointerException - if the chartModel is null
Method Detail

getColorCount

public int getColorCount()

setColorCount

public void setColorCount(int newColorCount)

getSaturation

public float getSaturation()

setSaturation

public void setSaturation(float newSaturation)

getBrightness

public float getBrightness()

setBrightness

public void setBrightness(float newBrightness)

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. Returns the delegate's color if non-null, the computed otherwise.

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


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