|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--y.option.OptionHandler
A class that manages a set of parameters. It provides an editor component for the set of parameters that allows to modify the values interactively. The parameters are arranged in sections, each section is displayed by a proper card in a tabbed pane layout. Each section contains a set of parameters. They are arranged in top down fashion, each parameter in a line, on the left side a name for the parameter, on the right side an input mask for the parameter.
Field Summary | |
protected GuiFactory |
guiFactory
the guifactory used for constructing the panel |
static byte |
OK_APPLY_CANCEL_BUTTONS
Button mask for the editor dialog. |
static byte |
OK_CANCEL_BUTTONS
Button mask for the editor dialog. |
static byte |
OK_RESET_APPLY_CANCEL_BUTTONS
Button mask for the editor dialog. |
static byte |
OK_RESET_CANCEL_BUTTONS
Button mask for the editor dialog. |
protected OptionsIOHandler |
optionsIOHandler
the iohandler used for serializing the values |
Constructor Summary | |
OptionHandler(GuiFactory factory,
InputStream is)
Deprecated. use the OptionsIOhandler way |
|
OptionHandler(GuiFactory factory,
OptionsIOHandler optionsIOHandler,
String name)
Create a new OptionHandler instance with a given name using the given IOHandler and GUIFactory. |
|
OptionHandler(InputStream is)
Deprecated. use the OptionsIOhandler way |
|
OptionHandler(String name)
Create a new OptionHandler instance with a given name, no (default) GuiFactory and no (default) OptionsIOHandler. |
Method Summary | |
OptionItem |
addBool(String name,
boolean value)
Adds a boolean option item |
OptionItem |
addColor(String name,
Object value)
Adds a color option item. |
OptionItem |
addColor(String name,
Object value,
boolean showPopup)
Adds a color option item. |
OptionItem |
addColor(String name,
Object value,
boolean showNoColor,
boolean showSomeColors,
boolean showMostRecentlyUsedColors,
boolean showMoreColors)
Adds a color option item. |
void |
addComment(String text)
Adds a commentary text to the option editor. |
void |
addComment(String text,
int fontSize)
Adds a commentary text to the option editor. |
OptionItem |
addDouble(String name,
double value)
Adds a double option item |
OptionItem |
addDouble(String name,
double value,
double minValue,
double maxValue)
Adds a double option item that has a lower and upper value bound |
OptionItem |
addDouble(String name,
double value,
double minValue,
double maxValue,
int precision)
Like OptionHandler.addDouble(String,double,double,double) . |
EnumOptionItem |
addEnum(String name)
Adds an empty enumeration option item. |
EnumOptionItem |
addEnum(String name,
Object[] enum,
int valueIndex)
Adds an enumeration option item. |
EnumOptionItem |
addEnum(String name,
Object[] enum,
Object defaultValue,
ListCellRenderer renderer)
Adds an enumeration option item. |
FileOptionItem |
addFile(String name,
String value)
Adds a file name option item |
OptionItem |
addInt(String name,
int value)
Adds an integer option item |
OptionItem |
addInt(String name,
int value,
int minValue,
int maxValue)
Adds an integer option item that has a lower and upper value bound |
OptionItem |
addItem(OptionItem it)
Adds a generic option item. |
void |
addOptionHandler(OptionHandler childHandler,
String defaultName)
Adds all the sections of another optionhandler to this one. |
OptionItem |
addString(String name,
String value)
Adds a string option item. |
OptionItem |
addString(String name,
String value,
int rowCount)
Adds a string option item whose text editor has a specific number of rows. |
boolean |
checkValues()
Checks if the values in the option editor are valid. |
void |
clear()
Removes all sections and option items from this option handler |
void |
commitValues()
Commits all values that where modified with the option editor to the corresponding option items. |
Object |
get(String name)
Returns the value of the option item that has the given identifying name. |
Object |
get(String section,
String name)
Returns the value of an option item |
boolean |
getBool(String name)
Returns the boolean value of an option item. |
boolean |
getBool(String section,
String name)
Returns the boolean value of an option item. |
static GuiFactory |
getDefaultGuiFactory()
getter for the default GUIFactory |
static OptionsIOHandler |
getDefaultOptionsIOHandler()
getter for the default OptionsIOhandler |
double |
getDouble(String name)
Returns the double value of an option item. |
double |
getDouble(String section,
String name)
Returns the double value of an option item. |
JComponent |
getEditor()
Returns the editor component of thjis option handler. |
int |
getEnum(String name)
Returns the index value of an enumeration item. |
int |
getEnum(String section,
String name)
Returns the index value of an enumeration item. |
GuiFactory |
getGuiFactory()
Getter for property guiFactory. |
static byte |
getIndex(Object[] enum,
Object value)
Returns the index for the given array at which the given value is found. |
int |
getInt(String name)
Returns the integer value of an option item. |
int |
getInt(String section,
String name)
Returns the integer value of an option item. |
OptionItem |
getItem(String name)
Returns the option item tha thas the given identifying name. |
OptionItem |
getItem(String section,
String name)
Returns the option item found in the given section under the given name. |
String |
getName()
Returns the name of the option handler |
OptionsIOHandler |
getOptionsIOHandler()
Getter for property OptionsIOHandler. |
static List |
getRegisteredOptionHandlers()
This method returns a list of all non-garbagecollected instances of OptionHandlers, which have been instanciated during this session. |
String |
getString(String name)
Returns the String value of an option item. |
String |
getString(String section,
String name)
Returns the String value of an option item. |
Object |
getStringValue(String section,
String name)
Returns the stringified value of an option item |
static void |
installDefaultGuiFactory(GuiFactory guiFactory)
Static method to install a default GUIFactory for all optionhandlers, which will be used if no specific GUIFactory is provided for each instance. |
static void |
installDefaultOptionsIOHandler(OptionsIOHandler OptionsIOHandler)
Static method to install a default IOHandler for all optionhandlers, which will be used if no specific instance is provided for each instance. |
static void |
main(String[] args)
Test method. |
boolean |
read()
reads in the values for the items from the installd IOHandler |
boolean |
read(OptionsIOHandler ioh)
reads in the values for the items from the given IOHandler |
void |
resetValues()
Resets all option values to their original settings. |
OptionSection |
section(int index)
Returns the option section at position index
the first section has the index 0 |
OptionSection |
section(String name)
Returns the option section that has the given name. |
int |
sectionCount()
Returns the number of sections of this option handler |
void |
set(String name,
Object value)
Sets the value for the option that has the given name. |
void |
set(String section,
String name,
Object value)
Sets the value for the option that has the given name in the given section |
void |
setGuiFactory(GuiFactory guiFactory)
Setter for property guiFactory. |
void |
setName(String name)
Sets the name of the option handler |
void |
setOptionsIOHandler(OptionsIOHandler optionsIOHandler)
Setter for property OptionsIOHandler. |
void |
setPreferredEditorWidth(int width)
Sets the preferred width of the option editor |
void |
setStringValue(String section,
String name,
String value)
Sets the value for the option that has the given name in the given section |
boolean |
showEditor()
Displays the editor for this option handler as a modal dialog window It uses OptionHandler.OK_RESET_CANCEL_BUTTONS as button mask. |
boolean |
showEditor(Frame frame)
Displays the editor for this option handler as a modal dialog window It uses OptionHandler.OK_RESET_CANCEL_BUTTONS as button mask. |
boolean |
showEditor(Frame frame,
byte buttonMask)
Displays the editor for this option handler as a modal dialog window |
String |
toString()
Returns a String that contains what would be written out by OptionHandler.write(OutputStream) . |
OptionSection |
useSection(String name)
Switch to specific section. |
void |
write(OptionsIOHandler ioh)
writes out the values from the items to the given IOHandler |
void |
write(OutputStream os)
Deprecated. use the OptionsIOhandler way |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected GuiFactory guiFactory
protected OptionsIOHandler optionsIOHandler
public static final byte OK_RESET_CANCEL_BUTTONS
public static final byte OK_APPLY_CANCEL_BUTTONS
public static final byte OK_CANCEL_BUTTONS
public static final byte OK_RESET_APPLY_CANCEL_BUTTONS
Constructor Detail |
public OptionHandler(String name)
public OptionHandler(GuiFactory factory, OptionsIOHandler optionsIOHandler, String name)
factory
- optionsIOHandler
- name
- public OptionHandler(InputStream is)
OptionHandler.write(OutputStream)
.
public OptionHandler(GuiFactory factory, InputStream is)
OptionHandler.write(OutputStream)
.
factory
- the default factoryis
- Method Detail |
public static void installDefaultGuiFactory(GuiFactory guiFactory)
guiFactory
- the default factorypublic static void installDefaultOptionsIOHandler(OptionsIOHandler OptionsIOHandler)
OptionsIOHandler
- the default handlerpublic static OptionsIOHandler getDefaultOptionsIOHandler()
public static GuiFactory getDefaultGuiFactory()
public static List getRegisteredOptionHandlers()
public void setName(String name)
public String getName()
public FileOptionItem addFile(String name, String value)
name
- the identifier of this optionvalue
- the initial path to the filepublic OptionItem addInt(String name, int value)
name
- the identifier of this optionvalue
- the initial value of the optionpublic OptionItem addInt(String name, int value, int minValue, int maxValue)
name
- the identifier of this optionvalue
- the initial value of the optionminValue
- the minimal value of the optionmaxValue
- the maximal value of the optionpublic OptionItem addDouble(String name, double value)
name
- the identifier of this optionvalue
- the initial value of the optionpublic OptionItem addDouble(String name, double value, double minValue, double maxValue)
name
- the identifier of this optionvalue
- the initial value of the optionminValue
- the minimal value of the optionmaxValue
- the maximal value of the optionpublic OptionItem addDouble(String name, double value, double minValue, double maxValue, int precision)
OptionHandler.addDouble(String,double,double,double)
. Additionally
the precicion of the double can be specified as the number of decimal
places.
public EnumOptionItem addEnum(String name, Object[] enum, int valueIndex)
name
- the identifier of this optionenum
- an array that holds all possible values for this item.valueIndex
- the array index of the initial value.public EnumOptionItem addEnum(String name)
name
- the identifier of this optionpublic EnumOptionItem addEnum(String name, Object[] enum, Object defaultValue, ListCellRenderer renderer)
name
- the identifier of this optionenum
- an array that holds all possible values for this item.defaultValue
- the initial value chosen (must be found in enum!)renderer
- The renderer being used in the editor component to display
the values of the enumeration.public OptionItem addBool(String name, boolean value)
name
- the identifier of this optionvalue
- the initial value of the optionpublic OptionItem addItem(OptionItem it)
it
- an option item.public OptionItem addString(String name, String value)
name
- the identifier of this optionvalue
- the initial value of the optionpublic OptionItem addString(String name, String value, int rowCount)
name
- the identifier of this optionvalue
- the initial value of the optionrowCount
- the number of rows of the text editorpublic OptionItem addColor(String name, Object value)
name
- the identifier of this optionvalue
- the initial value of the optionpublic OptionItem addColor(String name, Object value, boolean showPopup)
name
- the identifier of this optionvalue
- the initial value of the optionpublic OptionItem addColor(String name, Object value, boolean showNoColor, boolean showSomeColors, boolean showMostRecentlyUsedColors, boolean showMoreColors)
name
- the identifier of this optionvalue
- the initial value of the optionpublic void addComment(String text, int fontSize)
text
- the text of the commentfontSize
- the size of the text font usedpublic void addComment(String text)
text
- the text of the commentpublic void addOptionHandler(OptionHandler childHandler, String defaultName)
public void set(String name, Object value)
public void set(String section, String name, Object value)
public void setStringValue(String section, String name, String value)
public int getInt(String section, String name)
section
- the name of the section where the item residesname
- the identifying name of the itempublic int getInt(String name)
name
- the identifying name of the itempublic double getDouble(String section, String name)
section
- the name of the section where the item residesname
- the identifying name of the itempublic double getDouble(String name)
name
- the identifying name of the itempublic boolean getBool(String name)
name
- the identifying name of the itempublic boolean getBool(String section, String name)
section
- the name of the section where the item residesname
- the identifying name of the itempublic String getString(String name)
name
- the identifying name of the itempublic String getString(String section, String name)
section
- the name of the section where the item residesname
- the identifying name of the itempublic int getEnum(String name)
name
- the identifying name of the itempublic int getEnum(String section, String name)
section
- the name of the section where the item residesname
- the identifying name of the itempublic Object get(String section, String name)
section
- the name of the section where the item residesname
- the identifying name of the itempublic Object getStringValue(String section, String name)
section
- the name of the section where the item residesname
- the identifying name of the itempublic static byte getIndex(Object[] enum, Object value)
-1
is returned.
Conveniance method for enumeration option items.
public OptionItem getItem(String section, String name)
public Object get(String name)
public OptionItem getItem(String name)
public void setPreferredEditorWidth(int width)
public void clear()
public OptionSection useSection(String name)
public OptionSection section(int index)
index
the first section has the index 0
public int sectionCount()
public OptionSection section(String name)
public boolean showEditor()
OptionHandler.OK_RESET_CANCEL_BUTTONS
as button mask.
public boolean showEditor(Frame frame)
OptionHandler.OK_RESET_CANCEL_BUTTONS
as button mask.
frame
- centers the dialog relative to this framepublic boolean showEditor(Frame frame, byte buttonMask)
frame
- centers the dialog relative to this framebuttonMask
- the button layout and functionality for the dialog.public JComponent getEditor()
public void commitValues()
public boolean checkValues()
public void resetValues()
public void write(OutputStream os)
public String toString()
OptionHandler.write(OutputStream)
.
toString
in class Object
public boolean read(OptionsIOHandler ioh)
ioh
- the ioHandler to write to
public boolean read()
public void write(OptionsIOHandler ioh)
ioh
- the iohandler to usepublic GuiFactory getGuiFactory()
public void setGuiFactory(GuiFactory guiFactory)
guiFactory
- New value of property guiFactory.public OptionsIOHandler getOptionsIOHandler()
public void setOptionsIOHandler(OptionsIOHandler optionsIOHandler)
optionsIOHandler
- New value of property OptionsIOHandler.public static void main(String[] args) throws IOException
IOException
|
© Copyright 2000-2003, yWorks GmbH. All rights reserved. 2003 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |