|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjezuch.utils.starmapper3.config.Config
public class Config
The Config is similar to Parameters, but with slightly
limited and "condensed" interface, more suited to Unified Configuration
Model. This is a wrapper around Parameters, so it will use its
default Converters.
A "config" consists of values, under Paths (a path is basically a
list of Strings). Specific values - defined as NormalSettings -
have a Path, type, a default value and
Validator. All these things are aggregated in NormalSettings,
which are used to access config values. Values can be set using
NormalSettings (via set(NormalSetting, Object)) or with other
parameters (via set(Class, Path, Object)), after which the value
will be converted to proper type (if possible, and if the Path is a
known NormalSetting).
NormalSettings contain a concrete Path to a value; but there are
also IndexedSettings, which aggregate Path,
type, a default value and Validator just like
NormalSettings, but the Path is a "pattern", and the
IndexedSetting can't be used to retrieve a config value. The pattern
is a Path with embedded tags, in a format defined by
MessageFormat. You can create a concrete NormalSetting
by calling IndexedSetting.get(Object[]) with proper index values (IndexedSetting
can also parse a Path to see if it matches its pattern and if so,
retrieve the index values from it).
The NormalSettingBase and IndexedSettingBase are a typeless objects
that can be used to "derive" other NormalSettings (or
IndexedSettings) from them under their subpaths. The derivation
process should be done via
NormalSettingBase.derive(Class, Object, Validator, String[]),
NormalSettingBase.deriveIndexed(Class, Object, Validator, String[]) and
IndexedSettingBase.derive(Class, Object, Validator, String[])
methods, as they remember the new NormalSettings and
IndexedSettings in a static List, which is later used to
reserve them for validation.
The Config class can be subclassed by applications to define their
own config values. The NormalSettings and IndexedSettings defined
by subclasses by calling
NormalSettingBase.derive(Class, Object, Validator, String...),
NormalSettingBase.deriveIndexed(Class, Object, Validator, String...) or
IndexedSettingBase.derive(Class, Object, Validator, String...), will
be registered for validation with the base class.
| Nested Class Summary | |
|---|---|
static class |
Config.ClassWrapperConverter<T,U extends Config.GenericsWrapper<Class<? extends T>>>
A generic Converter for Config.GenericsWrapper for Classes. |
static class |
Config.GenericsWrapper<T>
A wrapper class that aims to convert generified form of any class to a concrete class (overcoming limications of .class operator and
allowing for NormalSettings to be of type Class, among
others). |
static class |
Config.SortedIntSet
This class is a very thin wrapper around SortedSet<Integer>
necessary to be able to specify SortedSet<Integer>.class. |
| Field Summary | |
|---|---|
static int |
PARAM_CLIP_EAST
A magic value for 0th index of SET_IMAGE_CLIP translating to "east". |
static int |
PARAM_CLIP_NORTH
A magic value for 0th index of SET_IMAGE_CLIP translating to "north". |
static int |
PARAM_CLIP_SOUTH
A magic value for 0th index of SET_IMAGE_CLIP translating to "south". |
static int |
PARAM_CLIP_WEST
A magic value for 0th index of SET_IMAGE_CLIP translating to "west". |
static int |
PARAM_COLOR_BLUE
A magic value for 1st index of SET_REGION_COLOR translating to "blue". |
static int |
PARAM_COLOR_GREEN
A magic value for 1st index of SET_REGION_COLOR translating to "green". |
static int |
PARAM_COLOR_RED
A magic value for 1st index of SET_REGION_COLOR translating to "red". |
static int |
PARAM_IMAGE_SIZE_MAPSIZE
A magic value for SET_IMAGE_WIDTH and SET_IMAGE_HEIGHT
that equals the image size with the map size for the dimension it is
assigned to. |
static int |
PARAM_IMAGE_SIZE_PROPORTIONAL
A magic value for SET_IMAGE_WIDTH and SET_IMAGE_HEIGHT
that causes the image to retain the proportions of The Map; this is most
useful when one of the dimensions is
PARAM_IMAGE_SIZE_PROPORTIONAL and the other is a concrete
number. |
static Pattern |
PATTERN_LIST_SEPARATOR
A Pattern used to separate elements of lists of values for config
values whose types are arrays; the exact pattern is: "[,; \t\+] *+",
which means: a comma, semicolon, space, tab or plus sign followed by any
number of spaces. |
static NormalSettingBase |
SET_CONCURRENCY_BASE
A NormalSettingBase for paths under which concurrency options are
defined. |
static NormalSetting<Integer> |
SET_CONCURRENCY_QUEUE_DEPTH
Sets maximum queue depth for incoming results in a batch. |
static NormalSetting<Integer> |
SET_CONCURRENCY_THREADS
Sets a ratio of parallelism in batch mode, or, in other words, number of concurrently drawn images. |
static NormalSetting<Integer> |
SET_CONCURRENCY_THREADS_PERIMAGE
Sets a ratio of image-level parallelism, or, in other words, a number of threads drawing each image. |
static NormalSettingBase |
SET_GLOBAL_BASE
A NormalSettingBase for paths under which some global parameters are
defined. |
static NormalSetting<Boolean> |
SET_GLOBAL_LINKFRAMES
Causes data from previous time points to carry to later time points; that is each time a new image os prepared the data is not erased and accumulated from scratch. |
static NormalSetting<Config.SortedIntSet> |
SET_GLOBAL_TIMES
A sorted set of time points to draw images from. |
static NormalSettingBase |
SET_IMAGE_BASE
A NormalSettingBase for paths under which image parameters are defined. |
static IndexedSetting<Long> |
SET_IMAGE_CLIP
A value indexed by a string ("west", "south", "east", "north") defining (up to) four edges of a clip regions. |
static NormalSetting<Boolean> |
SET_IMAGE_DRAWNAMES
A flag defining whether Starmapper will
draw names for Nodes. |
static NormalSetting<Boolean> |
SET_IMAGE_DRAWNAMES_NOTOWNED
A flag defining whether Starmapper will
draw names for Nodes which don't
have owners. |
static NormalSetting<Boolean> |
SET_IMAGE_DRAWNODES
A flag defining whether Starmapper will
draw Icons for
Nodes. |
static NormalSetting<Boolean> |
SET_IMAGE_DRAWNODES_NOTOWNED
A flag defining whether Starmapper will draw Icons
for Nodes which don't have owners. |
static NormalSetting<Integer> |
SET_IMAGE_HEIGHT
Defines the image height. |
static NormalSetting<Integer> |
SET_IMAGE_WIDTH
Defines the image width, not including the legend's width. |
static NormalSettingBase |
SET_MODEL_BASE
A NormalSettingBase for paths under which model-specific values are
set. |
static NormalSettingBase |
SET_PLOTTER_BASE
A NormalSettingBase for paths under which plotter-specific values are
set. |
static IndexedSettingBase |
SET_REGION_BASE
An IndexedSettingBase for paths under which
Regions are defined. |
static IndexedSetting<Integer> |
SET_REGION_COLOR
A value indexed by Region's
number and colour component ("red", "green", "blue") which declares
Region's Color. |
static IndexedSetting<String> |
SET_REGION_NAME
A value indexed by Region's
number which declares Region's
name. |
| Constructor Summary | |
|---|---|
Config()
Creates a new Config with all base settings registered with their
Validators and with no custom settings or converters. |
|
Config(List<Setting> settings,
List<Converter<?>> converters)
Creates a new Config with all base and specified settings
registered with their Validators and with specified
Converters also registered. |
|
| Method Summary | ||
|---|---|---|
|
get(NormalSetting<T> setting)
Returns a value under the given NormalSetting's Path. |
|
Iterator<Pair<Path,Object>> |
iterator()
Returns a view of this Config as a mapping of plain
Objects under Paths. |
|
|
set(Class<T> type,
Path path,
T value)
Sets a value under the given Path. |
|
|
set(NormalSetting<T> setting,
T value)
Sets the value under the path described by the given NormalSetting. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Pattern PATTERN_LIST_SEPARATOR
Pattern used to separate elements of lists of values for config
values whose types are arrays; the exact pattern is: "[,; \t\+] *+",
which means: a comma, semicolon, space, tab or plus sign followed by any
number of spaces.
public static final int PARAM_IMAGE_SIZE_MAPSIZE
SET_IMAGE_WIDTH and SET_IMAGE_HEIGHT
that equals the image size with the map size for the dimension it is
assigned to.
public static final int PARAM_IMAGE_SIZE_PROPORTIONAL
SET_IMAGE_WIDTH and SET_IMAGE_HEIGHT
that causes the image to retain the proportions of The Map; this is most
useful when one of the dimensions is
PARAM_IMAGE_SIZE_PROPORTIONAL and the other is a concrete
number. If both dimensions are any of the magic values, it has the same
effect as PARAM_IMAGE_SIZE_MAPSIZE assigned to both dimensions.
public static final int PARAM_CLIP_WEST
SET_IMAGE_CLIP translating to "west".
public static final int PARAM_CLIP_SOUTH
SET_IMAGE_CLIP translating to "south".
public static final int PARAM_CLIP_EAST
SET_IMAGE_CLIP translating to "east".
public static final int PARAM_CLIP_NORTH
SET_IMAGE_CLIP translating to "north".
public static final int PARAM_COLOR_RED
SET_REGION_COLOR translating to "red".
public static final int PARAM_COLOR_GREEN
SET_REGION_COLOR translating to "green".
public static final int PARAM_COLOR_BLUE
SET_REGION_COLOR translating to "blue".
public static final NormalSettingBase SET_MODEL_BASE
NormalSettingBase for paths under which model-specific values are
set. Each model should define its own namespace for its values.
public static final NormalSettingBase SET_PLOTTER_BASE
NormalSettingBase for paths under which plotter-specific values are
set. Each Plotter should define its own
namespace for its values.
public static final NormalSettingBase SET_GLOBAL_BASE
NormalSettingBase for paths under which some global parameters are
defined.
public static final NormalSetting<Config.SortedIntSet> SET_GLOBAL_TIMES
Starmapper.startBatch(jezuch.utils.Predicate, Config, jezuch.utils.starmapper3.Plotter, java.net.URI, String).
Repeated values will be ignored. The times can be specified as single
values or ranges in the form <from>..<to> (both ends inclusive),
separated by separators matching the regular expression in
PATTERN_LIST_SEPARATOR.
List of zero elements is treated specially: all time points encountered are plotted.
Path: /global/times
Type: Config.SortedIntSet (SortedSet<Integer>)
(convertible from Strings of items separated by separators
matching the regular expression in PATTERN_LIST_SEPARATOR)
Default: new int[0]
Validated: no
public static final NormalSetting<Boolean> SET_GLOBAL_LINKFRAMES
SET_GLOBAL_TIMES is set or not.
Path: /global/link-frames
Type: Boolean
Default: Boolean.TRUE
Validated: no
public static final NormalSettingBase SET_IMAGE_BASE
NormalSettingBase for paths under which image parameters are defined.
public static final NormalSetting<Integer> SET_IMAGE_WIDTH
legend's width.
Can be a concrete positive numer or one of magic values:
-1 or
-2.
Path: /image/width
Type: Integer
Default: 640
Validated: yes (value ≥ 1 or value in (-1, -2))
public static final NormalSetting<Integer> SET_IMAGE_HEIGHT
-1 or
-2.
Path: /image/height
Type: Integer
Default: 480
Validated: yes (value ≥ 1 or value in (-1, -2))
public static final IndexedSetting<Long> SET_IMAGE_CLIP
Path: /image/clip/{0}
Type: Integer
Default: null
Validated: no
public static final NormalSetting<Boolean> SET_IMAGE_DRAWNODES
Starmapper will
draw Icons for
Nodes.
Path: /image/draw-nodes
Type: Boolean
Default: Boolean.TRUE
Validated: no
public static final NormalSetting<Boolean> SET_IMAGE_DRAWNODES_NOTOWNED
Starmapper will draw Icons
for Nodes which don't have owners.
Path: /image/draw-nodes-notowned
Type: Boolean
Default: Boolean.TRUE
Validated: no
public static final NormalSetting<Boolean> SET_IMAGE_DRAWNAMES
Starmapper will
draw names for Nodes.
Path: /image/draw-names
Type: Boolean
Default: Boolean.TRUE
Validated: no
public static final NormalSetting<Boolean> SET_IMAGE_DRAWNAMES_NOTOWNED
Starmapper will
draw names for Nodes which don't
have owners.
Path: /image/draw-names-notowned
Type: Boolean
Default: Boolean.FALSE
Validated: no
public static final IndexedSettingBase SET_REGION_BASE
IndexedSettingBase for paths under which
Regions are defined.
public static final IndexedSetting<String> SET_REGION_NAME
Region's
number which declares Region's
name.
Path: /regions/reg{0}/name
Type: String
Default: null
Validated: no
public static final IndexedSetting<Integer> SET_REGION_COLOR
Region's
number and colour component ("red", "green", "blue") which declares
Region's Color.
Path: /regions/reg{0}/color/{1}
Type: Integer
Default: 0
Validated: yes (value ≥ 0 and value ≤ 255)
public static final NormalSettingBase SET_CONCURRENCY_BASE
NormalSettingBase for paths under which concurrency options are
defined.
public static final NormalSetting<Integer> SET_CONCURRENCY_THREADS
Path: /concurrency/threads
Type: Integer
Default: 0
Validated: yes (value ≥ 0)
public static final NormalSetting<Integer> SET_CONCURRENCY_QUEUE_DEPTH
BlockingQueue returned from
Starmapper.startBatch(jezuch.utils.Predicate, Config, jezuch.utils.starmapper3.Plotter, java.net.URI, String)
will be bounded by this number; if the client application can't keep up
with consuming the images, producer threads will wait until there's
enough free space in the output queue. The value can be null,
meaning an unbounded queue.
This config value is useful to limit mamory usage of
Starmapper. The image buffers are
rather large and for each image a new buffer is allocated (TODO:
implement buffer reuse?) so if the producer threads are allowed to run
without limits and the client application doesn't consume the results
fast enough, they can quickly exhaust all available memory.
Path: /concurrency/queue-depth
Type: Integer
Default: null (unbounded)
Validated: yes (value ≥ 1 or == null)
public static final NormalSetting<Integer> SET_CONCURRENCY_THREADS_PERIMAGE
SET_CONCURRENCY_THREADS.
Path: /concurrency/threads/per-image
Type: Integer
Default: number of processors availale to this VM
Validated: yes (value ≥ 1)
| Constructor Detail |
|---|
public Config()
Config with all base settings registered with their
Validators and with no custom settings or converters.
public Config(List<Setting> settings,
List<Converter<?>> converters)
Config with all base and specified settings
registered with their Validators and with specified
Converters also registered. The settings passed to this
constructor override any base settings under the same path. Similarily,
converters override any existing (default) converters for the same class.
Be sure to specify all converters necessary to handle all the settings.
| Method Detail |
|---|
public <T> T get(NormalSetting<T> setting)
throws ConversionException
NormalSetting's Path.
T - the NormalSetting's typesetting - the NormalSetting
NormalSetting's Path
ConversionException - if the value somehow can't be converted (quite impossible)
public <T> void set(Class<T> type,
Path path,
T value)
throws ConversionException,
ValidationException
Path. The value will be converted
to proper type if this Path belongs to a known NormalSetting.
T - the value's typetype - the value's type's Classpath - the value's Pathvalue - the value
ConversionException - if the value can't be converted to proper type
ValidationException - if the value is invalid for the NormalSetting owning this
Path
public <T> void set(NormalSetting<T> setting,
T value)
throws ConversionException,
ValidationException
NormalSetting.
T - the NormalSetting's typesetting - the NormalSetting to setvalue - the NormalSetting's new value
ConversionException - if the value somehow can't be converted to proper type
ValidationException - if the value is invalid for the NormalSetting owning this
Pathpublic Iterator<Pair<Path,Object>> iterator()
Config as a mapping of plain
Objects under Paths. The Paths are a concrete
values, not patterns.
iterator in interface Iterable<Pair<Path,Object>>Iterator of all values in this Config
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||