| |
|
| java.lang.Object ejp.presenter.api.filters.parameters.AbstractParameter ejp.presenter.api.filters.parameters.ColorDistributionParameter
ColorDistributionParameter | public class ColorDistributionParameter extends AbstractParameter implements ActionListener,ChangeListener(Code) | | A color distribution parameter, which associates a color to every value in
the [0, 1] interval.
The interval is actually split into by a user-provided divider and a color
can be associated to every sub-range. A convenience system allows to
automatically build up a gradient of colors between the first and the last
ones.
Known issue : due to Swing's error #4497301, the combo box might not
be selectable the second time the dialog is showed. There is currently no
acceptable workaround to this. The solution used here consists on limiting
the count of rows to a maximum.
author: Sebastien Vauclair version: 1.0 |
Inner Class :protected class ColorsDisplay extends JPanel | |
Inner Class :protected class ComboItem | |
COLORS_SEPARATOR | final public static String COLORS_SEPARATOR(Code) | | Separator character between colors in text descriptions.
|
DECIMAL_FORMAT | final public static DecimalFormat DECIMAL_FORMAT(Code) | | Decimal numbers formatter used to render percents.
|
cdSamples | final protected ColorsDisplay cdSamples(Code) | | Panel that displays current color distribution.
|
colors | final protected ArrayList colors(Code) | | Current list of colors.
Additional colors (after index divisions are kept in memory
for possible later usage.
|
divisions | protected int divisions(Code) | | Number of divisions.
number of divisions = number of colors - 1 .
|
divisionsUpdatedIsWorking | protected boolean divisionsUpdatedIsWorking(Code) | | Avoids reentrancy into divisionsUpdated() .
|
jcbIntervals | final protected JComboBox jcbIntervals(Code) | | Intervals combo box.
|
jsDivisions | final protected JSpinner jsDivisions(Code) | | Divisions spinner.
|
readOnly | protected boolean readOnly(Code) | | Current read-only state of the parameter.
|
ColorDistributionParameter | public ColorDistributionParameter(String aName, String aTitle, String aToolTipText)(Code) | | Creates a new color distribution parameter instance.
Parameters: aName - the parameter's name. Parameters: aTitle - parameter's caption. Parameters: aToolTipText - a tool-tip text. |
actionPerformed | public void actionPerformed(ActionEvent aEvent)(Code) | | Called when an interval is selected in combo box.
|
buildGradient | protected void buildGradient()(Code) | | Builds up a gradient between the first and last colors.
|
colorForRatio | public Color colorForRatio(double aRatio)(Code) | | Gets the color currently associated to a real number.
Parameters: aRatio - a double value in the [0, 1] interval. the associated Color value. |
divisionsUpdated | protected void divisionsUpdated()(Code) | | Updates graphical representation of color intervals.
Uses divisions and colors .
|
getColorsValue | public Color[] getColorsValue()(Code) | | Get current value of the parameter.
a Color[] value. |
getValue | public Object getValue()(Code) | | Gets value as an object.
|
getValueAsText | public String getValueAsText()(Code) | | Gets value as text.
Colors are exported as integers using Color.getRGB() . They
are separated by COLORS_SEPARATOR character.
|
setReadOnly | public void setReadOnly()(Code) | | Sets the paramter as read-only.
Locks divisions spinner and no longer popups a color selection dialog when
an interval is selected.
|
setValue | public void setValue(Color[] aColors)(Code) | | Sets value from a color array.
Updates divisions and intervals values.
Parameters: aColors - a non-empty Color[] value. |
stateChanged | public void stateChanged(ChangeEvent aEvent)(Code) | | Called when the spinner's value is considered as changed.
Updates intervals.
|
updateDivisions | protected void updateDivisions(int aNewDivisions)(Code) | | Updates all fields to match a new divisions number.
When the number of divisions grows, previously selected colors are used or
if there are none, last color is repeated.
This method updates fields and calls divisionsUpdated() to
update the graphical representation.
Parameters: aNewDivisions - new int value. |
updateSelectedColor | protected void updateSelectedColor()(Code) | | Updates combo box to render currently selected colors.
This must be done because of an error in Swing's Metal UI, which does call
the renderer for the selected item but then overrides the foreground color.
|
|
|
|