|
Java 6 SE Platform 6.0 Home |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.woven_media.colorsafe.Controller
public class Controller
Controller class handles UI and event-handling.
Field Summary | |
---|---|
static java.lang.String |
DEF_RES_PATH
Constants |
static java.awt.Color |
DEFAULT_SWATCH
|
static int |
TXT_MAXLENGTH
|
Fields inherited from interface com.woven_media.colorsafe.IPalette |
---|
BG_VAL, GRAYSCALE_NUM_COLORS, GRAYSCALE_PALETTE, GRAYSCALE_TITLE, HEX_VAL, NAMED_COLORS_PALETTE, NAMED_COLORS_TITLE, NAMED_NUM_COLORS, NETSCAPE_NUM_COLORS, NETSCAPE_PALETTE, NETSCAPE_TITLE, RGB_VAL, WIN_GRAYS_NUM_COLORS, WIN_NUM_COLORS, WINDOWS_GRAYS_PALETTE, WINDOWS_GRAYS_TITLE, WINDOWS_PALETTE, WINDOWS_TITLE, X11_NUM_COLORS, X11_PALETTE, X11_TITLE |
Constructor Summary | |
---|---|
Controller(javax.swing.JFrame f)
Class constructor sets up the javax.swing.JFrame and calls
Controller.start . |
Method Summary | |
---|---|
void |
applyAction()
Applies all changes made within the RGB and Hex text fields. |
void |
colorPicker(java.lang.String title,
int selection)
Opens a javax.swing.JColorChooser dialog. |
protected void |
finalValidation(java.awt.event.FocusEvent fe,
javax.swing.JTextField txt)
Completes validation for the RGB text fields. |
static java.awt.Color |
getBgColor()
Returns this app's background color. |
javax.swing.JTextField |
getBlueField()
|
java.awt.Color |
getChooserColor(int selection)
Returns the current color selection from the javax.swing.JColorChooser . |
java.awt.Color |
getCurrentSafeColor()
Returns the swatch panel's current selected safe color. |
java.awt.Color |
getCurrentSelectedColor()
Returns the swatch panel's current selected color. |
javax.swing.JTextField |
getGreenField()
|
static javax.swing.ImageIcon |
getImageIcon()
Returns this instance's icon image. |
java.awt.Insets |
getInsets()
Returns the insets for GridBag padding of components in this window. |
static java.util.Locale |
getLocale()
Returns the Controller.locale member. |
javax.swing.JTextField |
getRedField()
|
static java.util.ResourceBundle |
getResources()
Reads in the java.util.ResourceBundle strings_xx.properties file
used by this GUI instance. |
java.awt.Color |
getRGBColor()
Reads the values from the RGB text fields and converts and returns java.awt.Color object
via the ColorUtil class. |
java.awt.Color |
getSafeColor(int[] rgbArray)
Returns the nearest safe color based on the selected color. |
java.net.URL |
getURL()
Returns the Controller.url member. |
static void |
getURLResource(java.lang.String res)
Sets the Controller.url member. |
boolean |
isArithmeticConversion()
Determines selection of the Arithmetic conversion checkbox. |
boolean |
isSafeColor()
|
static void |
loadIcon(javax.swing.JFrame f)
Loads image icon from default resources. |
void |
msgDialog(java.awt.Component parent,
java.lang.Object msg,
java.lang.String title,
int msgType)
Handles error, warning and information messages by opening a dialog. |
void |
openColorPalette(java.lang.String title,
int palette)
Opens the palette windows. |
int[] |
parseRGBfields()
Parses the RGB string textfield values for floating point or integer values. |
void |
resetAction()
Resets this application back to its default values. |
void |
restart()
Calls Controller.start . |
static void |
setBgColor(java.awt.Color c)
Sets this app's background color. |
void |
setCurrentColor(java.awt.Color c)
Sets the current color selection. |
void |
setHexText(java.lang.String str)
Sets the text value of the Hex text field. |
static void |
setLocale(java.util.Locale loc)
Sets Controller.locale . |
void |
setRGBcontrols()
Sets RGB textfields and sliders to the correct values based on the value of the Hex textfield. |
void |
setSelection(java.awt.event.FocusEvent fe)
Sets selection for text entered into javax.swing.JTextFields . |
void |
showAboutBox()
Displays the About object in a bordless window - called from Help menu. |
void |
showColor(java.awt.Color c)
Displays selected color for this instance. |
void |
showHexString()
Sets the hexadecimal value in the javax.swing.JTextField . |
void |
showSafeColor()
Displays the current color information. |
void |
stateChanged(javax.swing.event.ChangeEvent e)
Receives stateChanged events from this instance's javax.swing.JSlider components. |
void |
textFieldGainedFocus(java.awt.event.FocusEvent fe,
javax.swing.JTextField txt)
Handle actions when a javax.swing.JtextField gains focus. |
void |
textFieldLostFocus(java.awt.event.FocusEvent fe,
javax.swing.JTextField txt)
Handles actions when a javax.swing.JtextField loses focus. |
protected void |
validateTextField(java.awt.event.KeyEvent e)
Sets the maximum number of characters that are allowed to be entered into the textfields. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEF_RES_PATH
public static final java.awt.Color DEFAULT_SWATCH
public static final int TXT_MAXLENGTH
Constructor Detail |
---|
public Controller(javax.swing.JFrame f)
javax.swing.JFrame
and calls
Controller.start
. The constructor sets an init
flag
to true
indicating that this class is being initialized, then sets
background color and loads the image icon.
f
- javax.swing.JFrame
reference to the parent window.Method Detail |
---|
public void restart()
Controller.start
.
The restart
method reloads this app instance without destroying
the enclosing parent frame. Convenience method only. Used by the ColorSafeMenubar
class to handle the language toggle event at runtime.
public static void setBgColor(java.awt.Color c)
c
- java.awt.Color
objectpublic static java.awt.Color getBgColor()
java.awt.Color
object of the background color
for this instance.public static javax.swing.ImageIcon getImageIcon()
javax.swing.IconImage
public java.awt.Color getCurrentSelectedColor()
java.awt.Color
object of this swatch panel's background color
if colorSwatch
panel is not null
, otherwise
returns null
.public java.awt.Color getCurrentSafeColor()
java.awt.Color
object of this safe swatch panel's background
color if colorSafeSwatch
panel is not null
, otherwise
returns null
.public static void setLocale(java.util.Locale loc)
Controller.locale
. The locale
setting is primarily used for
multiple language support.
loc
- a java.util.Locale
object primarily used for setting language options.Locale
public static java.util.Locale getLocale()
Controller.locale
member.
java.util.Locale
objectLocale
public static java.util.ResourceBundle getResources()
java.util.ResourceBundle strings_xx.properties
file
used by this GUI instance.
java.util.ResourceBundle
used for localization support.ResourceBundle
public static void getURLResource(java.lang.String res)
Controller.url
member. Locates relative path resources.
res
- java.lang.String
resource.URLClassLoader
public java.net.URL getURL()
Controller.url
member.
java.net.URL
object.URL
public static void loadIcon(javax.swing.JFrame f)
f
- parent javax.swing.JFrame
reference.JFrame
public boolean isSafeColor()
public void setSelection(java.awt.event.FocusEvent fe)
javax.swing.JTextFields
.
fe
- java.awt.event.FocusEvent
JTextField
,
FocusEvent
public void applyAction()
public void resetAction()
public void textFieldGainedFocus(java.awt.event.FocusEvent fe, javax.swing.JTextField txt)
javax.swing.JtextField
gains focus.
fe
- java.awt.event.FocusEvent
txt
- javax.swing.JtextField
reference of the field requesting focus.public void textFieldLostFocus(java.awt.event.FocusEvent fe, javax.swing.JTextField txt)
javax.swing.JtextField
loses focus.
fe
- java.awt.event.FocusEvent
txt
- javax.swing.JTextField
public javax.swing.JTextField getRedField()
public javax.swing.JTextField getGreenField()
public javax.swing.JTextField getBlueField()
public boolean isArithmeticConversion()
public void showColor(java.awt.Color c)
c
- java.awt.Color
object.Color
public java.awt.Color getRGBColor()
java.awt.Color
object
via the ColorUtil
class.
java.awt.Color
objectpublic void showSafeColor()
ColorUtil
public void showHexString()
javax.swing.JTextField
.
public int[] parseRGBfields()
public void stateChanged(javax.swing.event.ChangeEvent e)
stateChanged
events from this instance's javax.swing.JSlider
components.
Values of the text fields are adjusted according to current color selection.
stateChanged
in interface javax.swing.event.ChangeListener
e
- java.awt.event.ChangeEvent
ChangeListener
,
ChangeEvent
public void setRGBcontrols()
Hex
textfield.
JSlider
public void setCurrentColor(java.awt.Color c)
c
- java.awt.Color
object of the current selected color.public java.awt.Color getSafeColor(int[] rgbArray)
rgbArray
- int
array of RGB values
java.awt.Color
objectpublic java.awt.Color getChooserColor(int selection)
javax.swing.JColorChooser
.
selection
- int
value representing the
current chooser color value.JColorChooser
public void colorPicker(java.lang.String title, int selection)
javax.swing.JColorChooser
dialog.
title
- string for the title bar.selection
- int
value for selected color.JColorChooser
,
JDialog
,
JRootPane
public void openColorPalette(java.lang.String title, int palette)
dispose
method of javax.swing.JFrame
instead of System.exit
during window close events so that the parent window is not destroyed.
title
- string for the title bar.palette
- int
value representing the palette type.WindowAdapter
,
WindowEvent
,
ColorModelView
public void setHexText(java.lang.String str)
Hex
text field.
JTextField
public java.awt.Insets getInsets()
java.awt.Insets
objectInsets
public void msgDialog(java.awt.Component parent, java.lang.Object msg, java.lang.String title, int msgType)
The msgType
parameter of the msgDialog
can
accept the following parameters,
parent
- parent component for the dialog.msg
- message to disply in the content pane.title
- title bar text.msgType
- defines the style of the message.public void showAboutBox() throws java.io.IOException
About
object in a bordless window - called from Help
menu.
The About
class is called statically since it is a stand-alone application
containing a main
method.
java.io.IOException
protected void validateTextField(java.awt.event.KeyEvent e)
e
- java.awt.event.KeyEvent
for text field validation.KeyEvent
,
Character
protected void finalValidation(java.awt.event.FocusEvent fe, javax.swing.JTextField txt)
fe
- java.awt.event.FocusEvent
for text field validation.txt
- javax.swing.JTextField
reference for validation.FocusEvent
|
Java 6 SE Platform 6.0 Home |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |