Class JtvColorSelector
public class JtvColorSelector
extends JtvView
An interactive colour-swatch grid used within JtvColorDialog.
TColorSelector displays a grid of coloured blocks from which the user selects either a foreground or background colour. The type is determined by the ColorSel enum passed at construction:
- ColorSel.csForeground — shows all 16 foreground colours.
- ColorSel.csBackground — shows the first 8 background colours.
The currently selected colour is marked with an x inside its block.
Mouse clicks and arrow key navigation change the selection. When the colour
changes, this view broadcasts cmColorForegroundChanged or
cmColorBackgroundChanged with the new colour value.
Responds to cmColorSet broadcasts to update its selection from the
current palette entry.
org.viktor44.jtvision.dialogs.JtvColorSelector
Summary
Constructors
| Visibility | Signature |
|---|---|
| public | JtvColorSelector(JtvRect bounds, ColorSel aSelType) |
Fields
| Modifiers | Field name | Type |
|---|---|---|
| private | color | int |
| private | selType | org.viktor44.jtvision.dialogs.JtvColorSelector.ColorSel |
| private static final | icon | char |
Methods
| Modifiers | Method signature | Return type |
|---|---|---|
| public | draw() | void |
| private | colorChanged() | void |
| public | handleEvent(JtvEvent event) | void |
Constructors
JtvColorSelector(JtvRect bounds, ColorSel aSelType)
Creates a colour selector of the given type.
Parameters
bounds- the bounding rectangle (should accommodate a 4-column × 2- or 4-row grid)aSelType-ColorSel#csForegroundorColorSel#csBackground
Fields
int color
The currently selected colour index.
org.viktor44.jtvision.dialogs.JtvColorSelector.ColorSel selType
Whether this selector controls the foreground or background colour.
char icon
Unicode full-block character used to render each colour swatch.
Methods
draw()
Overrides:
draw() in org.viktor44.jtvision.views.JtvView
Draws the colour swatch grid. Each colour swatch is rendered as three
full-block characters. The currently selected swatch is marked with x.
colorChanged()
Broadcasts the colour change command (cmColorForegroundChanged or
cmColorBackgroundChanged) with the current colour value.
handleEvent(JtvEvent event)
Overrides:
handleEvent(JtvEvent event) in org.viktor44.jtvision.views.JtvView
Handles mouse, keyboard, and broadcast events.
- Mouse click/drag — selects the colour under the pointer.
- Arrow keys — move the colour selection in the grid.
cmColorSetbroadcast — updates the selection from the packed colour byte.
Parameters
event- the incoming event