borland Packages Class Hierarchy jbcl.view Package Index
java.lang.Object +----borland.jbcl.view.StateItemPainter
Constructors Properties Methods
Implements ItemPainter, Serializable
A StateItemPainter paints items differently, depending upon the data item's state. Specify the item painter to use with the painter parameter of the constructor.
The class maintains two arrays, values and states. To use StateItemPainter, first call the register() method to register a state/value pair with the item painter. register() inserts a state into the states array at the same time that it inserts a value in the same position in the values array. That position is always at the first location within the arrays (has an index value of 0). Call register() to register each pair. The last pair must be registered with a state of 0. When the last state/value pair is registered, the StateItemPainter is ready to paint.
The paint() method calls the getValue() method, which takes a state parameter. When getValue() finds a match for the specified state in the states array, it retrieves the value at the same position in the values array and passes it back to the paint() method for painting. If no match is found, it uses the value that coincides with the state of 0 in the states array as the default value. getValue() performs its search beginning at position 0 in the states array. Because all new state/value pairs are inserted at the beginning of the array, the search is in LIFO order.
public StateItemPainter()
public StateItemPainter(borland.jbcl.model.ItemPainter painter)Constructs a StateItemPainter using the specified item painter to do the painting.
Parameters:
public Integer getValue(int state)Returns the value associated with the specified state. If no match is found, the last value registered is returned, which is the default value. getValue() is called by the paint() method. When getValue() finds a match for the specified state in the states array, it retrieves the value at the same position in the values array and passes it back to the paint() method for painting. If no match is found, it uses the value that coincides with the state of 0 in the states array as the default value. getValue() performs its search beginning at position 0 in the states array. Because all new state/value pairs are inserted at the beginning of the array, the search is in LIFO order.
public void register(int state, int value)Inserts the specified state/value pair into two arrays: the state is stored in the states array, and the value is stored in the values array. Each item is inserted at the index position of 0.
After registering all state/pair values, call register() once more and specify state as 0 and the value you want used as the default value as the value.