|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sub_arctic.style.style
This class provides the implementation for a style. Styles provide sets of resources such as images, colors, fonts, etc. that can be used in implementing the appearance (and in some cases behavior) of interactors. The resources of a style are normally designed to work together to create a uniform appearance for interactors that provides some particular "look" to the interface.
Style objects provide four categories of functionallity:
Style Creation and Manipulation
Styles support a series of named resources. Several different constructors
are provided for creating styles and initializing them with resources, and
routines are provided for adding and removing resources from a style. In
addition, styles are placed in an inheritance structure which allows them
to be constructed on the basis of other styles. Each style may designate
one or more super-styles from which it is constructed. If a resource is
not provided directly by a style, the system will automatically look for
it in the super-styles. This makes it easy to make small extensions or
modifications to existing styles, and provides a convenient mechanism for
support style independent system defaults for some resources.
Resource Lookup Once a style has been populated with a set of resources, interactor objects will access those resources in order to build thier appearances. Interactors access style resources by name. Names are style independent and represent a functional category of resource (such as the font for displaying labels, the set of images needed for the "up" button on a slider, or a method for constructing labelled button images).
All resource names are registered in advance with the style system manager (for efficiency, registered names are represented internally by "resource designators"; see style_resource_desig). Since a name represents a functional category of resource, names can also provide "fallbacks". A fallback represents a more general category of resource that may be substituted if a particular style doesn't have the particular resource needed. So for example, if an interactor needs a "lefthanded_knoby" image and a particular style doesn't provide those, it may provide a "knoby" image instead (assuming "knoby" has been designated as the fallback for "lefthanded_knoby"). In general, fallbacks form chains of less and less specific resources. The system provides a range of standard resource names that most or all styles provide resoruces for. A well designed interactor will either use standard resources, or when non-standard resources are required, will provide fallback chain that includes a standard resource. In this way interactors can be assured of working regardless of the style currently in effect.
During resource lookup, a style will first attempt to fill a request with a resource that exactly matches the name requested. If no such resource can be found (locally or within super-styles), then fallback resources are considered. In general the style will supply a resource with the most closely matching name to the one requested (where "closely" is defined by the declared fallbacks). Only if no resource along the fallback chain can be found will a resource lookup fail.
Image and Image Set Construction In addition to static resources such as images, fonts, colors, or spacing values, styles also support a mechanism for constructing an image or a set of images (and related sets of images) from a set of parameters. This is used for example to create button labels which need to be parameterized by a label string. This capability is provided by the build_image() and build_image_set() methods and is implemented using composer objects. These objects provide a fairly general mechanism for describing style independent layouts, and for using those descriptions to create images based on parameters and style provided resources (see the composer class for more details).
Restyling Support Finally, styles provide a mechanism for allowing interactor appearance to be "restyled" -- that is to allow resources created with one style to be (semi-)automatically exchanged with equivalent resources from a new style. This allows dynamic style "switching". For static resources such as simple fonts or colors, restyling can be done simply by looking up the same resource name in a new style. For images that are constructed dynamicly, a special styled_image class is provided. This class saves the information used to create the image under one style in a way that allows an equivalent image to be recreated under a new style.
style_manager
,
style_resource_desig
,
composer
,
styled_image
Field Summary | |
protected int |
_last_hunt_id
Identifier for last search through this style's table. |
protected java.lang.String |
_name
Name of this style. |
protected static int |
_next_uniq_id
Counter for generating unique positive integers |
protected static int |
_num_buckets
Number of hash buckets in lookup table. |
protected style[] |
_super_styles
Array of styles that we inherit from (our super-styles). |
protected style_resource_cell[] |
bucket
Hash buckets for our lookup table. |
Constructor Summary | |
style(java.lang.String name)
Constructor for empty style with no super-styles. |
|
style(java.lang.String nam,
java.lang.Object[] init_list)
Constructor for style initialized from name value pair list and no super-style. |
|
style(java.lang.String name,
style super_styl)
Constructor for empty style with exactly one super-style. |
|
style(java.lang.String name,
style[] super_list)
Constructor for empty style. |
|
style(java.lang.String nam,
style[] super_list,
java.lang.Object[] init_list)
Constructor for style initialized from name value pair list and array of super-styles. |
|
style(java.lang.String nam,
style[] super_list,
style_resource_desig[] desig_list,
java.lang.Object[] res_list)
Constructor for style initialized from parallel arrays of designators and resource values. |
|
style(java.lang.String nam,
style super_styl,
java.lang.Object[] init_list)
Constructor for style initialized from name value pair list and a single super-style. |
Method Summary | |
void |
add_resource(java.lang.String name,
java.lang.Object res)
Add a resource to the style. |
void |
add_resource(style_resource_desig desig,
java.lang.Object res)
Add a resource to the style. |
void |
add_resources(java.lang.Object[] init_list)
Add a list of resources to the style. |
void |
add_resources(style_resource_desig[] desig_list,
java.lang.Object[] res_list)
Add a list of resources to the style. |
styled_image[] |
build_image_set(java.lang.String target_name,
loaded_image parm1)
Shortcut method for building an image set that has an image parameter. |
styled_image[] |
build_image_set(java.lang.String target_name,
loaded_image parm1,
int parm2)
Shortcut method for building an image set that has an image and one integer as parameters. |
styled_image[] |
build_image_set(java.lang.String target_name,
loaded_image parm1,
int parm2,
int parm3)
Shortcut method for building an image set that has an image and two integers as parameters. |
styled_image[] |
build_image_set(java.lang.String target_name,
java.lang.Object[] composition_parms)
Search for the named composer set resource, apply the given parameters to each composer to build, and return an image set. |
styled_image[] |
build_image_set(java.lang.String target_name,
java.lang.String parm)
Shortcut method for building an image set that has a single String parameter. |
styled_image[] |
build_image_set(java.lang.String target_name,
java.lang.String parm1,
int parm2)
Shortcut method for building an image set that has a String and one integer as parameters. |
styled_image[] |
build_image_set(java.lang.String target_name,
java.lang.String parm1,
int parm2,
int parm3)
Shortcut method for building an image set that has a String and two integers as parameters. |
styled_image[] |
build_image_set(style_resource_desig target_desig,
java.lang.Object[] composition_parms)
Search for the designated composer set resource, apply the given parameters to each composer to build and return an image set. |
styled_image |
build_image(java.lang.String target_name,
loaded_image parm1)
Shortcut method for building an image that has one image parameter. |
styled_image |
build_image(java.lang.String target_name,
loaded_image parm1,
int parm2)
Shortcut method for building an image that has an image and one integer as parameters. |
styled_image |
build_image(java.lang.String target_name,
loaded_image parm1,
int parm2,
int parm3)
Shortcut method for building an image that has an image and two integers as parameters. |
styled_image |
build_image(java.lang.String target_name,
java.lang.Object[] composition_parms)
Search for the named composer resource, apply the given parameters to it to build an image, and return that image. |
styled_image |
build_image(java.lang.String target_name,
java.lang.String parm)
Shortcut method for building an image that has a single String parameter. |
styled_image |
build_image(java.lang.String target_name,
java.lang.String parm1,
int parm2)
Shortcut method for building an image that has a String and one integer as parameters. |
styled_image |
build_image(java.lang.String target_name,
java.lang.String parm1,
int parm2,
int parm3)
Shortcut method for building an image that has a String and two integers as parameters. |
styled_image |
build_image(style_resource_desig target_desig,
java.lang.Object[] composition_parms)
Search for the designated composer resource, apply the given parameters to it to build an image, and return that image. |
java.lang.Object |
get_resource_exact(java.lang.String target_name)
Search for the named resource within this style and its super-styles. |
java.lang.Object |
get_resource_exact(style_resource_desig target)
Search for the designated resource within this style and its super-styles. |
java.lang.Object |
get_resource(java.lang.String target_name)
Search for the designated resource within this style and its super-styles. |
java.lang.Object |
get_resource(style_resource_desig target)
Search for the designated resource within this style and its super-styles. |
static int |
hash(style_resource_desig desig)
Hash function over style resource designators |
java.lang.Object |
hunt_resource(style_resource_desig target,
int bucket_num,
int hunt_id)
Search a particular hash bucket for a designated resource. |
void |
init_resources(java.lang.Object[] init_list)
Add a list of resources to the style without checking for duplicates. |
void |
init_resources(style_resource_desig[] desig_list,
java.lang.Object[] res_list)
Add a list of resources to the style without checking for duplicates. |
java.lang.String |
name()
Name of this style. |
void |
quick_add_resource(java.lang.String name,
java.lang.Object res)
Add a named resource to the style without checking if it is already in the table. |
void |
quick_add_resource(style_resource_desig desig,
java.lang.Object res)
Add a resource to the style without checking if it is already in the table. |
void |
remove_resource(java.lang.String res)
Remove a resource from the style. |
void |
remove_resource(style_resource_desig res)
Remove a resource from the style. |
loaded_image[] |
restyle_image_set(loaded_image[] the_set)
Create a new image set which is a restyling of the given image set under this style. |
loaded_image |
restyle_image(loaded_image the_image)
Create a new image which is a restyling of the given image under this style. |
style[] |
super_styles()
Array of styles that we inherit from (our super-styles). |
protected void |
tag_image(styled_image img,
style stl,
style_resource_desig desig,
java.lang.Object[] parms,
int indx)
Place bookkeeping in a styled image to remember how it was created so it can be reconstructed under a new style. |
protected static int |
uniq_id()
Create a unique integer id. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected java.lang.String _name
protected static int _next_uniq_id
protected int _last_hunt_id
protected static final int _num_buckets
protected style_resource_cell[] bucket
protected style[] _super_styles
Constructor Detail |
public style(java.lang.String name, style[] super_list)
public style(java.lang.String name, style super_styl)
public style(java.lang.String name)
public style(java.lang.String nam, style[] super_list, java.lang.Object[] init_list)
The resources come as an array of objects which alternates between Strings for the name of the resource and an object for the resource itself. If the array has improperly typed elements (i.e., not in String, Object pairs), or a name which has not been registered with the style manager is encountered, an error will be thrown.
String
- nam name of stylestyle[]
- super_list list of super-styles we inherit from.Object[]
- init_list resource initialization listpublic style(java.lang.String nam, style super_styl, java.lang.Object[] init_list)
The resources come as an array of objects which alternates between Strings for the name of the resource and an object for the resource itself. If the array has improperly typed elements (i.e., not in String, Object pairs), or a name which has not been registered with the style manager is encountered, an error will be thrown.
String
- nam name of stylestyle
- super_styl super-style we inherit from.Object[]
- init_list resource initialization listpublic style(java.lang.String nam, java.lang.Object[] init_list)
The resources come as an array of objects which alternates between Strings for the name of the resource and an object for the resource itself. If the array has improperly typed elements (i.e., not in String, Object pairs), or a name which has not been registered with the style manager is encountered, an error will be thrown.
String
- nam name of styleObject[]
- init_list resource initialization listpublic style(java.lang.String nam, style[] super_list, style_resource_desig[] desig_list, java.lang.Object[] res_list)
.
String
- nam name of stylestyle[]
- super_list list of super-styles we inherit
fromstyle_resource_desig[]
- desig_list resource designators
initialization listObject[]
- init_list resources corresponding to the
designators.Method Detail |
public java.lang.String name()
protected static int uniq_id()
public style[] super_styles()
public static int hash(style_resource_desig desig)
style_resource_desig
- desig the designator being hashedpublic void add_resource(style_resource_desig desig, java.lang.Object res)
style_resource_desig
- desig the designator for the new resourceObject
- res the resource being addedquick_add_resource(sub_arctic.style.style_resource_desig, java.lang.Object)
public void add_resource(java.lang.String name, java.lang.Object res)
String
- name the designator for the new resourceObject
- res the resource being addedquick_add_resource(sub_arctic.style.style_resource_desig, java.lang.Object)
public void quick_add_resource(style_resource_desig desig, java.lang.Object res)
style_resource_desig
- desig the designator for the new resourceObject
- res the resource being addedadd_resource(sub_arctic.style.style_resource_desig, java.lang.Object)
public void quick_add_resource(java.lang.String name, java.lang.Object res)
String
- name the name of the new resourceObject
- res the resource being addedadd_resource(sub_arctic.style.style_resource_desig, java.lang.Object)
public void add_resources(java.lang.Object[] init_list)
Note: this routine silently replaces any duplicate entries. This requires a search for duplicates which produces O(N^2) worst case behavior (although on average this is scaled by the reciprocal of the size of the hash table squared). If you can be certain there are no duplicates with existing entries, for example at style initialization, use init_resources() instead to avoid this.
Object[]
- init_list array of String, Object pairs to initialize from.add_resource(sub_arctic.style.style_resource_desig, java.lang.Object)
,
init_resources(java.lang.Object[])
public void add_resources(style_resource_desig[] desig_list, java.lang.Object[] res_list)
Note: this routine silently replaces any duplicate entries. This requires a search for duplicates which produces O(N^2) worst case behavior (although on average this is scaled by the reciprocal of the size of the hash table squared). If you can be certain there are no duplicates with existing entries, for example at style initialization, use init_resources() instead to avoid this.
style_resource_desig[]
- desig_list array of resource designatorsObject[]
- res_list array or resource valuesadd_resource(sub_arctic.style.style_resource_desig, java.lang.Object)
,
init_resources(java.lang.Object[])
public void init_resources(java.lang.Object[] init_list)
Note: If the named resource already exists in the style, it is shadowed by this entry. That means that the previous entry will not be accessible, but will stay in the table (and not be garbage collected). As a result, this should normally only be used when the style is being initialized (or at some other time when the contents of the style is fully understood).
Object[]
- init_list array of String, Object pairs to initialize from.quick_add_resource(sub_arctic.style.style_resource_desig, java.lang.Object)
,
add_resources(java.lang.Object[])
public void init_resources(style_resource_desig[] desig_list, java.lang.Object[] res_list)
Note: If the named resource already exists in the style, it is shadowed by this entry. That means that the previous entry will not be accessible, but will stay in the table (and not be garbage collected). As a result, this should normally only be used when the style is being initialized (or at some other time when the contents of the style is fully understood).
style_resource_desig[]
- desig_list array of resource designatorsObject[]
- res_list array or resource valuesquick_add_resource(sub_arctic.style.style_resource_desig, java.lang.Object)
,
add_resources(java.lang.Object[])
public void remove_resource(style_resource_desig res)
style_resource_desig
- res the resource to removepublic void remove_resource(java.lang.String res)
String
- res name of the resource to removepublic java.lang.Object hunt_resource(style_resource_desig target, int bucket_num, int hunt_id)
style_resource_desig
- target the designator of the resource we
are looking for.int
- bucket_num the hash bucket we are looking in.int
- hunt_id unique id for this search.public java.lang.Object get_resource_exact(style_resource_desig target)
If the object returned is a loaded_image, we put a styled_image wrapper around it and tag it with the information needed to find the corresponding image in another style.
style_resource_desig
- target the designator for the resource we are
are looking for.public java.lang.Object get_resource_exact(java.lang.String target_name)
String
- target_name the name of the resource we are are looking for.
If this name has not been registered with the
style manager, an error is thrown.public java.lang.Object get_resource(style_resource_desig target)
style_resource_desig
- target the designator for the resource we are
are looking for.public java.lang.Object get_resource(java.lang.String target_name)
String
- target_name the name of the resource we are are looking for.
If this name has not been registered with the
style manager, an error is thrown.protected void tag_image(styled_image img, style stl, style_resource_desig desig, java.lang.Object[] parms, int indx)
styled_image
- img the image being taggedstyle
- stl the style that created the imagestyle_resource_desig
- desig the designator for the composer that
created it or the image itselfObject[]
- parms the parameters to the composer (or null
if there was no composer)public styled_image build_image(style_resource_desig target_desig, java.lang.Object[] composition_parms)
style_resource_desig
- target_desig the designator for the resource
we are looking for.Object[]
- composition_parms parameters to the composition
object. If these parameters are
not of the type and number
expected by the composer, an
error is thrown.public styled_image build_image(java.lang.String target_name, java.lang.Object[] composition_parms)
String
- target_name the name of the resource we are
looking for. If this name has
not been registered with the
style manager, an error is thrown.Object[]
- composition_parms parameters to the composition
object. If these parameters are
not of the type and number
expected by the composer, an
error is thrown.public styled_image build_image(java.lang.String target_name, java.lang.String parm)
String
- target_name the name of the composer resource we are
looking for. If this name has not been
registered with the style manager, an error is
thrown.String
- parm single string parameters to the composition
object. If this parameter is not what is
expected by the composer, an error is thrown.public styled_image build_image(java.lang.String target_name, java.lang.String parm1, int parm2)
String
- target_name the name of the composer resource we are
looking for. If this name has not been
registered with the style manager, an error is
thrown.String
- parm1 string parameter to the composition
object. If this parameter is not what is
expected by the composer, an error is thrown.int
- parm2 first integer parameter to the composition
object. If this parameter is now what is
expected by the composer, an error is thrown.public styled_image build_image(java.lang.String target_name, java.lang.String parm1, int parm2, int parm3)
String
- target_name the name of the composer resource we are
looking for. If this name has not been
registered with the style manager, an error is
thrown.String
- parm1 string parameter to the composition
object. If this parameter is not what is
expected by the composer, an error is thrown.int
- parm2 first integer parameter to the composition
object. If this parameter is now what is
expected by the composer, an error is thrown.int
- parm3 second integer parameter to the composition
object. If this parameter is now what is
expected by the composer, an error is thrown.public styled_image build_image(java.lang.String target_name, loaded_image parm1)
String
- target_name the name of the composer resource we are
looking for. If this name has not been
registered with the style manager, an error is
thrown.String
- parm1 image parameter to the composition
object. If this parameter is not what is
expected by the composer, an error is thrown.public styled_image build_image(java.lang.String target_name, loaded_image parm1, int parm2)
String
- target_name the name of the composer resource we are
looking for. If this name has not been
registered with the style manager, an error is
thrown.loaded_image
- parm1 image parameter to the composition
object. If this parameter is not what is
expected by the composer, an error is thrown.int
- parm2 first integer parameter to the composition
object. If this parameter is now what is
expected by the composer, an error is thrown.public styled_image build_image(java.lang.String target_name, loaded_image parm1, int parm2, int parm3)
String
- target_name the name of the composer resource we are
looking for. If this name has not been
registered with the style manager, an error is
thrown.loaded_image
- parm1 image parameter to the composition
object. If this parameter is not what is
expected by the composer, an error is thrown.int
- parm2 first integer parameter to the composition
object. If this parameter is now what is
expected by the composer, an error is thrown.int
- parm3 second integer parameter to the composition
object. If this parameter is now what is
expected by the composer, an error is thrown.public styled_image[] build_image_set(style_resource_desig target_desig, java.lang.Object[] composition_parms)
style_resource_desig
- target_desig the designator for the resource
we are looking for.Object[]
- composition_parms parameters to the composition
objects. If these parameters are
not of the type and number
expected by the composers, an
error is thrown.public styled_image[] build_image_set(java.lang.String target_name, java.lang.Object[] composition_parms)
String
- target_name the name of for the resource we are
looking for.Object[]
- composition_parms parameters to the composition objects.
If these parameters are not of the type
and number expected by the composers, an
error is thrown.public styled_image[] build_image_set(java.lang.String target_name, java.lang.String parm)
String
- target_name the name of the composer resource we are
looking for. If this name has not been
registered with the style manager, an error is
thrown.String
- parm single string parameters to the composition
objects. If this parameter is not what is
expected by the composers, an error is thrown.public styled_image[] build_image_set(java.lang.String target_name, java.lang.String parm1, int parm2)
String
- target_name the name of the composer resource we are
looking for. If this name has not been
registered with the style manager, an error is
thrown.String
- parm1 string parameter to the composition
object. If this parameter is not what is
expected by the composer, an error is thrown.int
- parm2 first integer parameter to the composition
object. If this parameter is now what is
expected by the composer, an error is thrown.public styled_image[] build_image_set(java.lang.String target_name, java.lang.String parm1, int parm2, int parm3)
String
- target_name the name of the composer resource we are
looking for. If this name has not been
registered with the style manager, an error is
thrown.String
- parm1 string parameter to the composition
object. If this parameter is not what is
expected by the composer, an error is thrown.int
- parm2 first integer parameter to the composition
object. If this parameter is now what is
expected by the composer, an error is thrown.int
- parm3 second integer parameter to the composition
object. If this parameter is now what is
expected by the composer, an error is thrown.public styled_image[] build_image_set(java.lang.String target_name, loaded_image parm1)
String
- target_name the name of the composer resource we are
looking for. If this name has not been
registered with the style manager, an error is
thrown.loaded_image
- parm1 image parameter to the composition
object. If this parameter is not what is
expected by the composer, an error is thrown.public styled_image[] build_image_set(java.lang.String target_name, loaded_image parm1, int parm2)
String
- target_name the name of the composer resource we are
looking for. If this name has not been
registered with the style manager, an error is
thrown.loaded_image
- parm1 image parameter to the composition
object. If this parameter is not what is
expected by the composer, an error is thrown.int
- parm2 first integer parameter to the composition
object. If this parameter is now what is
expected by the composer, an error is thrown.public styled_image[] build_image_set(java.lang.String target_name, loaded_image parm1, int parm2, int parm3)
String
- target_name the name of the composer resource we are
looking for. If this name has not been
registered with the style manager, an error is
thrown.loaded_image
- parm1 image parameter to the composition
object. If this parameter is not what is
expected by the composer, an error is thrown.int
- parm2 first integer parameter to the composition
object. If this parameter is now what is
expected by the composer, an error is thrown.int
- parm3 second integer parameter to the composition
object. If this parameter is now what is
expected by the composer, an error is thrown.public loaded_image restyle_image(loaded_image the_image)
loaded_image
- the_image the image to restylestyled_image.restyle(sub_arctic.style.style)
public loaded_image[] restyle_image_set(loaded_image[] the_set)
loaded_image[]
- the_set the image set to restylestyled_image.restyle(sub_arctic.style.style)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |