Last modified 12 months ago
Last modified on 05/29/11 16:42:36
Color Dialog
(Part of GSoC 2011)
Goal
Developing a component for GeoGebra which allows the user to easily select colors in an intuitive way, combining both normal and advanced colors (although just in the GUI).
Required Functionality
- The user can select colors with a color picker
- The user can enter color values in different formats (RGB, HSV, HSL) and input range (0 to 1 or 0 to 255)
- Current color values are displayed in the selected format and in the selected range
- Range is fixed to 0 to 1 for dynamic colors
- Color values are converted automatically if range is changed
- The user can enter an equation instead of a color value, this is interpreted as advanced color (just in certain cases)
- Update color picker for dynamic color selection as well
- A list of recently used colors is displayed for quick-picking
- Colors for multiple objects should be handled gracefully, ie the color of the objects is just changed if necessary
- The component can be embedded directly in a panel or opened as a popup after clicking a button
Use Cases
- Properties Dialog - to change various colors of single or multiple object (foreground, background, hatching).
- EV Style Bar - to change the object colors easily. Probably a simplified version is needed.
- Spreadsheet Style Bar - TODO: check how this coloring is handled internally
- Axes / Grid Color
- ... ?
Decisions
- The color picker does not know anything about the context in which the colors are used. Saving and applying the color is task of the context-specific GUI.
- Rationale: There are a number of different use cases where colors are picked. Differentiating between those cases in the color picker itself would make the class interface more complex and move the logic away from their original location.
- Colors which may contain advanced information (like color space, range, functions) are stored as part of a special color class and not in the GeoElement directly. This class is called ExtendedColor and offers a simple interface to convert those objects into a normal Color object.
- Rationale: The color picker needs a simple container to exchange color information with the GUI as well.
Decoupling the color information from the GeoElement is allowing the color picker to use the same color conversion methods as the the GeoElement itself in another context (ie if the grid color is changed, to which no GeoElement is related).
This change also supports the goal of making the color picker independent of the context as it can simply store its own color object.
- Rationale: The color picker needs a simple container to exchange color information with the GUI as well.
- The color picker is a simple JPanel without any information about how to embed it into the application.
- Rationale: This simplifies the task of embedding this panel into a popup or into a dialog directly.
Technical Notes
- Change listener to inform other components about changed color.
- Passes ExtendedColor object which carries the following information: Color values (static color), color functions (dynamic color), input range, color format.
- ExtendedColor should also provide functionality to convert values into the format necessary for the target object (ie convert to RGB, 0 to 255).
