stella.parameter
Class FrameProvider

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.AbstractTargetParameter
                      extended by stella.parameter.FrameProvider
All Implemented Interfaces:
Cloneable, ErrorDependingParameter, Parameter, TargetDepending, TargetDependingParameter, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying

public class FrameProvider
extends AbstractTargetParameter
implements ErrorDependingParameter

A frame provider is a parameter that defines a certain rectangluar areas, normally depending on target picked and/or error received. This frame could be a read-out frasme on a CCD, but also a frame defining a useful area or a frame defining a moments-area.


Nested Class Summary
static class FrameProvider.Test
           
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  Rectangle defbox
          This is the default frame size or null if undefined.
static String DEFNAME
          Default name of this parameter.
private  Map<Object,Map<Class<? extends ErrorEvent>,Rectangle>> errors
          This lookup-table links target types to lookups of error to frames .
static String KEY_DEFAULTFRAME
          This is the default frame, prior to target registering.
static String KEY_LISTENFOR
          We ignore all errors not in this list.
static String KEY_MESSAGETABLE
          This keys links the combined target type plus error to frames .
static String KEY_TARGETTABLE
          This key links target types to frame entries.
private  Class<? extends ErrorEvent> lasterror
          Last error event recorded after target registering.
private  Object lasttype
          Last target type registered.
private  List<Class<? extends ErrorEvent>> listen
          We only listen to these errors.
private  Map<Object,Rectangle> targets
          This lookup-table links target types to frames.
static char TYPEERRORSEPARATOR
          This char separates the target type from the error class name in prop.
 
Fields inherited from class stella.parameter.AbstractTargetParameter
KEY_INDEX
 
Fields inherited from class stella.parameter.AbstractParameter
KEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWN
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface stella.ErrorDependingParameter
NAMING_EXTENSION
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
FrameProvider(Map<String,String> prop)
          We start by constructing all the lookup-tables in the init section.
 
Method Summary
 Object get()
          After registering of targets and possible erros, we can produce a frame.
 Object getForError(ErrorEvent ee)
          Returns the sub-frame of the currently registered target that would be active on the specified error.
 Object getForTarget(TargetDefinition td)
          Returns the frame that would be used with the stated target, no error class can be specified.
private  Rectangle getFrame(Object type, Class<? extends ErrorEvent> ee)
          Returns the subframe for a given target type and a specified errror.
 void init()
          On init, we parse the default rectangle and try to construct all the lookup tables.
private  Map<String,Rectangle> parseToRectangles(String s)
          We parse a properties mapping to a string-to-rectangle mapping.
 void registerError(ErrorEvent ee)
          Registers the error.
 void registerTarget(TargetDefinition td)
          Registers the target, clears the error received.
 Object set(Object o)
          Not allowed.
 
Methods inherited from class stella.parameter.AbstractTargetParameter
getAsStar, getConstant, getFormattedFor, getSetup
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, exit, getFormatted, getFormatted, getName, getPreserveFile, getString, getString, register, rescanned, setName, toString
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, setObject, setProperties, setProperty, stringProperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface stella.Parameter
getFormatted, getName, getString
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

TYPEERRORSEPARATOR

public static final char TYPEERRORSEPARATOR
This char separates the target type from the error class name in prop.

See Also:
Constant Field Values

KEY_DEFAULTFRAME

public static final String KEY_DEFAULTFRAME
This is the default frame, prior to target registering.

See Also:
Constant Field Values

KEY_TARGETTABLE

public static final String KEY_TARGETTABLE
This key links target types to frame entries.

See Also:
Constant Field Values

KEY_MESSAGETABLE

public static final String KEY_MESSAGETABLE
This keys links the combined target type plus error to frames .

See Also:
Constant Field Values

KEY_LISTENFOR

public static final String KEY_LISTENFOR
We ignore all errors not in this list.

See Also:
Constant Field Values

DEFNAME

public static final String DEFNAME
Default name of this parameter.

See Also:
Constant Field Values

defbox

private Rectangle defbox
This is the default frame size or null if undefined.


targets

private Map<Object,Rectangle> targets
This lookup-table links target types to frames.


errors

private Map<Object,Map<Class<? extends ErrorEvent>,Rectangle>> errors
This lookup-table links target types to lookups of error to frames .


lasttype

private Object lasttype
Last target type registered.


listen

private List<Class<? extends ErrorEvent>> listen
We only listen to these errors.


lasterror

private Class<? extends ErrorEvent> lasterror
Last error event recorded after target registering.

Constructor Detail

FrameProvider

public FrameProvider(Map<String,String> prop)
We start by constructing all the lookup-tables in the init section.

Method Detail

init

public void init()
On init, we parse the default rectangle and try to construct all the lookup tables.

Specified by:
init in interface Initializable
Overrides:
init in class AbstractParameter

registerTarget

public void registerTarget(TargetDefinition td)
Registers the target, clears the error received.

Specified by:
registerTarget in interface TargetDepending

registerError

public void registerError(ErrorEvent ee)
Registers the error.

Specified by:
registerError in interface ErrorDependingParameter

getForTarget

public Object getForTarget(TargetDefinition td)
Returns the frame that would be used with the stated target, no error class can be specified.

Specified by:
getForTarget in interface TargetDependingParameter

getForError

public Object getForError(ErrorEvent ee)
Returns the sub-frame of the currently registered target that would be active on the specified error.

Specified by:
getForError in interface ErrorDependingParameter

get

public Object get()
After registering of targets and possible erros, we can produce a frame.

Specified by:
get in interface Parameter

set

public Object set(Object o)
Not allowed.

Specified by:
set in interface Parameter
Returns:
The previous value of this parameter.

parseToRectangles

private Map<String,Rectangle> parseToRectangles(String s)
We parse a properties mapping to a string-to-rectangle mapping.


getFrame

private Rectangle getFrame(Object type,
                           Class<? extends ErrorEvent> ee)
Returns the subframe for a given target type and a specified errror. First, the specific look-up table errors is scanned, if that does not produce a hit, the targets table is scanned. If again without hit, the default frame is returned, which still might be null.