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.$CanvasRenderingContext2DctxRectThe rendering context of the rectprotected simulation.dom.$CanvasRenderingContext2DctxSquareThe rendering context of the squareprotected static intRECT_HEIGHTThe rect heightprotected static intRECT_WIDTHthe rect widthprotected static intSQUARE_SIZEThe square size
-
Constructor Summary
Constructors Modifier Constructor Description protectedJSAbstractColorFormatPanel()Creates the object
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddChangeListener(ChangeListener listener)Adds a change listenerprotected voidaddRadio(JSRadioButton radio, java.lang.String text, boolean selected, int gridx, int gridy)Adds a radio buttonprotected voidaddSlider(JSSlider slider, JSSpinner spinner, int value, int max, int gridx, int gridy)Adds a sliderprotected voidaddSpinner(JSSpinner spinner, JSSlider slider, int value, int max, int gridx, int gridy)Adds a spinnerprotected booleancanDoItRect(def.dom.MouseEvent event, java.lang.String type)Checks if a mouse event can be managed on the rectprotected booleancanDoItSquare(def.dom.MouseEvent event, java.lang.String type)Checks if a mouse event can be managed on the squareprotected voiddrawAll()Draws all objectsprotected voiddrawCircle(double x, double y)Draws the circle selectorprotected voiddrawLine(double y)Draws the lineprotected abstract voiddrawRect()Draws the rectprotected abstract voiddrawRectSelector()Draws the rect selectorprotected abstract voiddrawSquare()Draws the squareprotected abstract voiddrawSquareSelector()Draws the square selectorabstract ColorgetSelectedColor()Returns the selected colorbooleangetValueIsAdjusting()Returns if the selected color is "adjusting"protected voidonchange(boolean b)To call to invoke a change eventprotected abstract voidrectEvent(def.dom.MouseEvent event, java.lang.String type)Manages a mouse event on the rectabstract voidsetSelectedColor(Color color)Sets the selected colorprotected abstract voidsquareEvent(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
-
-