Package javascript.swing.colorchooser
Class JSAbstractColorFormatPanel
- java.lang.Object
-
- javascript.swing.JSComponent
-
- javascript.swing.JSPanel
-
- javascript.swing.colorchooser.JSAbstractColorFormatPanel
-
- Direct Known Subclasses:
JSColorCMYKPanel
,JSColorHSLPanel
,JSColorHSVPanel
,JSColorRGBPanel
,JSColorYUVPanel
public abstract class JSAbstractColorFormatPanel extends JSPanel
The abstract panel to show colors in a color format- Author:
- gianpiero.diblasi
-
-
Field Summary
Fields Modifier and Type Field Description protected simulation.dom.$CanvasRenderingContext2D
ctxRect
The rendering context of the rectprotected simulation.dom.$CanvasRenderingContext2D
ctxSquare
The rendering context of the squareprotected static int
RECT_HEIGHT
The rect heightprotected static int
RECT_WIDTH
the rect widthprotected static int
SQUARE_SIZE
The square size
-
Constructor Summary
Constructors Modifier Constructor Description protected
JSAbstractColorFormatPanel()
Creates the object
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addChangeListener(ChangeListener listener)
Adds a change listenerprotected void
addRadio(JSRadioButton radio, java.lang.String text, boolean selected, int gridx, int gridy)
Adds a radio buttonprotected void
addSlider(JSSlider slider, JSSpinner spinner, int value, int max, int gridx, int gridy)
Adds a sliderprotected void
addSpinner(JSSpinner spinner, JSSlider slider, int value, int max, int gridx, int gridy)
Adds a spinnerprotected boolean
canDoItRect(def.dom.MouseEvent event, java.lang.String type)
Checks if a mouse event can be managed on the rectprotected boolean
canDoItSquare(def.dom.MouseEvent event, java.lang.String type)
Checks if a mouse event can be managed on the squareprotected void
drawAll()
Draws all objectsprotected void
drawCircle(double x, double y)
Draws the circle selectorprotected void
drawLine(double y)
Draws the lineprotected abstract void
drawRect()
Draws the rectprotected abstract void
drawRectSelector()
Draws the rect selectorprotected abstract void
drawSquare()
Draws the squareprotected abstract void
drawSquareSelector()
Draws the square selectorabstract Color
getSelectedColor()
Returns the selected colorboolean
getValueIsAdjusting()
Returns if the selected color is "adjusting"protected void
onchange(boolean b)
To call to invoke a change eventprotected abstract void
rectEvent(def.dom.MouseEvent event, java.lang.String type)
Manages a mouse event on the rectabstract void
setSelectedColor(Color color)
Sets the selected colorprotected abstract void
squareEvent(def.dom.MouseEvent event, java.lang.String type)
Manages a mouse event on the square-
Methods inherited from class javascript.swing.JSComponent
addChildEventListenerByQuery, addEventListener, appendChild, appendChildInTree, appendInBody, appendNodeChild, appendNodeChildInTree, clearChildContentByQuery, clearContent, cssAddClass, cssClassList, cssRemoveClass, cssToggleClass, getAttribute, getChildAttributeByIndex, getChildAttributeByQuery, getChildCount, getChildPropertyByQuery, getChilStyleByIndex, getChilStyleByQuery, getID, getProperty, getStyle, insertBefore, insertBeforeInTree, insertNodeBefore, insertNodeBeforeInTree, invoke, invokeInTree, prependChild, prependChildInTree, prependNodeChild, prependNodeChildInTree, removeAttribute, removeChildAttributeByQuery, removeFromBody, setAttribute, setBackground, setChildAttributeByIndex, setChildAttributeByQuery, setChildPropertyByQuery, setContent, setEnabled, setID, setProperty
-
-
-
-
Field Detail
-
ctxSquare
protected final simulation.dom.$CanvasRenderingContext2D ctxSquare
The rendering context of the square
-
ctxRect
protected final simulation.dom.$CanvasRenderingContext2D ctxRect
The rendering context of the rect
-
SQUARE_SIZE
protected static final int SQUARE_SIZE
The square size- See Also:
- Constant Field Values
-
RECT_WIDTH
protected static final int RECT_WIDTH
the rect width- See Also:
- Constant Field Values
-
RECT_HEIGHT
protected static final int RECT_HEIGHT
The rect height- See Also:
- Constant Field Values
-
-
Method Detail
-
addRadio
protected void addRadio(JSRadioButton radio, java.lang.String text, boolean selected, int gridx, int gridy)
Adds a radio button- Parameters:
radio
- The radio buttontext
- The textselected
- true to select the radio button, false otherwisegridx
- The grid xgridy
- The grid y
-
addSlider
protected void addSlider(JSSlider slider, JSSpinner spinner, int value, int max, int gridx, int gridy)
Adds a slider- Parameters:
slider
- The sliderspinner
- The connected spinnervalue
- The valuemax
- The max valuegridx
- The grid xgridy
- The grid y
-
addSpinner
protected void addSpinner(JSSpinner spinner, JSSlider slider, int value, int max, int gridx, int gridy)
Adds a spinner- Parameters:
spinner
- The spinnerslider
- The connected slidervalue
- The valuemax
- The max valuegridx
- The grid xgridy
- The grid y
-
drawAll
protected void drawAll()
Draws all objects
-
drawSquare
protected abstract void drawSquare()
Draws the square
-
drawSquareSelector
protected abstract void drawSquareSelector()
Draws the square selector
-
drawCircle
protected void drawCircle(double x, double y)
Draws the circle selector- Parameters:
x
- The x-axis coordinatey
- The y-axis coordinate
-
drawRect
protected abstract void drawRect()
Draws the rect
-
drawRectSelector
protected abstract void drawRectSelector()
Draws the rect selector
-
drawLine
protected void drawLine(double y)
Draws the line- Parameters:
y
- The y-axis coordinate
-
squareEvent
protected abstract void squareEvent(def.dom.MouseEvent event, java.lang.String type)
Manages a mouse event on the square- Parameters:
event
- The mouse eventtype
- The event type
-
canDoItSquare
protected boolean canDoItSquare(def.dom.MouseEvent event, java.lang.String type)
Checks if a mouse event can be managed on the square- Parameters:
event
- The mouse eventtype
- The event type- Returns:
- true if the mouse event can be managed on the square, false otherwise
-
rectEvent
protected abstract void rectEvent(def.dom.MouseEvent event, java.lang.String type)
Manages a mouse event on the rect- Parameters:
event
- The mouse eventtype
- The event type
-
canDoItRect
protected boolean canDoItRect(def.dom.MouseEvent event, java.lang.String type)
Checks if a mouse event can be managed on the rect- Parameters:
event
- The mouse eventtype
- The event type- Returns:
- true if the mouse event can be managed on the square, false otherwise
-
getValueIsAdjusting
public boolean getValueIsAdjusting()
Returns if the selected color is "adjusting"- Returns:
- true if the selected color is adjusting, false otherwise
-
addChangeListener
public void addChangeListener(ChangeListener listener)
Adds a change listener- Parameters:
listener
- The listener
-
onchange
protected void onchange(boolean b)
To call to invoke a change event- Parameters:
b
- true if the value is adjusting, false otherwise
-
getSelectedColor
public abstract Color getSelectedColor()
Returns the selected color- Returns:
- The selected color
-
setSelectedColor
public abstract void setSelectedColor(Color color)
Sets the selected color- Parameters:
color
- The selected color
-
-