jview
Class JAbstractAnalyser

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by jview.AbstractDisplayable
                  extended by jview.JAbstractAnalyser
All Implemented Interfaces:
ComponentListener, PropertyChangeListener, Cloneable, EventListener, DataAnalysing, DataObserver, Displayable, BeanSupport, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying
Direct Known Subclasses:
JAsynchronAnalyser, JStatisticAnalyser

public abstract class JAbstractAnalyser
extends AbstractDisplayable
implements DataAnalysing, ComponentListener, PropertyChangeListener

An abstract analyser is a data change listener on a specified set name. Additionally, it is notified when the data canvas it is listening to gets visible. If it is also a viewport change listener, it receives zooming events, too.

Each analyser has a representational component, which might be a button if analysing data takes too long to be instantly displayed and/or more windows are to be put up. For analyser that can analyse the data on the fly, a simple component like a Label may be sufficient. If the #getComponet method returns null, the #getAction method should deliver an action, which is then used for a button or menu item.

Each analyser should have a KEY_ANALYSER property set that is the class of the analyser used. Additionally, the KEY_ANALYSESETS property must point to the data set name this analyser is attached to.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  List<String> allow
          The list of allowed canvi or null, if all are allowed.
private  Analyser anal
          The analyser we pass the events to.
private static double DEFEXECFACTOR
          Multpliy with one.
private static double DEFEXECOFFSET
          No offset per default.
private  List<String> deny
          The list of denied canvi or null, if all are allowed.
private  PropertyChangeSupport ear
          The listners receiving analyser events.
private static long[] exectime
          The execution times, measured at startup.
private  VectorG[] input
          The analyser input data constructed from the data card set.
static String KEY_ALLOW
          If set, only these canvi are allowed.
static String KEY_ANALYSER
          The key for the analyser class.
static String KEY_ANALYSESETS
          The key to the analysed set name.
static String KEY_BASELOG
          The time base in ms for log operations.
static String KEY_BASEPLAIN
          The time base in ms for plain operations.
static String KEY_BASEPOWER
          The time base in ms for power operations.
static String KEY_BASERANDOM
          The time base in ms for random operations.
static String KEY_BASESINUS
          The time base in ms for sin/cos operations.
static String KEY_BASESQRT
          The time base in ms for sqrt operations.
static String KEY_BASETAN
          The time base in ms for tan operations.
static String KEY_DENY
          If set, only these canvi are not allowed.
static String KEY_EXECFACTOR
          The time multiplier for execution time estimation.
static String KEY_EXECOFFSET
          The time offset in ms for execution time estimation.
static String KEY_TRANSFERCLASSES
          The list of class names for transferrring points to input.
static String KEY_TRANSFERINIT
          The list of string initializers for the transfer classes.
static String KEY_VIEWPORTLISTEN
          If this is true, we listen to viewport changes.
private  Collection<DataCard> set
          The cumulated data we act on, used for add/delete.
private  Object[] tagging
          The tagging information to the input data.
private static String TIME
          Tooltip text on action.
private  List<Function> transfer
          If set, we use these functions to transfer set data to analyser input.
 
Fields inherited from class jview.AbstractDisplayable
KEY_COMPONENTNAME, KEY_ICON, KEY_INSETS
 
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 jview.DataAnalysing
ANALYSERINPUT, ANALYSERMETA, ANALYSERPROCESS, ANALYSERVISUAL, ATTACHED
 
Fields inherited from interface util.BeanSupport
CASTING
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
protected JAbstractAnalyser(Map<String,String> prop)
          On construct, we pass to the super constructor, the analyser is created in the init section.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener pcl)
          Adds, if new, this property change listeners.
 void addPropertyChangeListener(String p, PropertyChangeListener pcl)
          Adds, if new, this property change listeners.
private  void canvasHidden(JDataCanvas jdc)
          Called when an allowed component was hiddn, captured by a component event.
private  void canvasShown(JDataCanvas jdc)
          Called when an allowed component was shown, captured by a component event.
 void componentHidden(ComponentEvent e)
          Called to clear any cached data.
 void componentMoved(ComponentEvent e)
          Empty.
 void componentResized(ComponentEvent e)
          Empty.
 void componentShown(ComponentEvent e)
          The component that is shown is analysed if analysing of the underlying data canvas is allowed.
 void dataChanged(DataChangeEvent dce)
          Called when the observed data changed.
protected  long estimateExecutionTime(VectorG[] in)
          Estimates the execution time based on the input data.
 long estimateExecutionTime(VectorG[] in, Analyser anal)
          Estimates the execution time based on the input data.
protected  void firePropertyChange(String propname, Object old, Object now)
          Notifies all registered property change listeners.
 List<String> getAnalysedSets()
          Gets the set name we register to.
 Analyser getAnalyser()
          Returns my analyser.
 VectorG[] getAnalyserInput()
          As a source for the analysers, we use the original data, as it comes with error bars.
 Object[] getDataTagging()
          Whoever wants to track the taggings that came along with the original data.
 void init()
          We scan the properties for the KEY_ANALYSER property and try to create that from my properties.
 void propertyChange(PropertyChangeEvent e)
          If the visible area changes, we grep all data in the component, as well as when we lost some data.
 void removePropertyChangeListener(PropertyChangeListener pcl)
          Removes this property change listeners.
 void removePropertyChangeListener(String p, PropertyChangeListener pcl)
          Removes this property change listeners.
protected  void setAnalyserInput(VectorG[] in)
          This is the method that is called whenever the analyser input data is modified.
protected  void setDataTagging(Object[] keys)
          This method is called when the data tagging is set.
private  JDataCanvas traceSource(ComponentEvent e)
          Tries to get the data canvas from the component event.
private  void transferAnalyserInput(Map<String,Object> ai)
          We set the analyser input and fire a property change.
private  Map<String,Object> vectorData(Collection<DataCard> dc)
          Analyser work on an array of VectorGs, but the data is normally provided as data cards.
 
Methods inherited from class jview.AbstractDisplayable
getComponentName, getIcon, getIcon
 
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, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jview.DataAnalysing
getAnalyserAction
 
Methods inherited from interface jview.Displayable
getIcon, getRepresentation
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
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
 

Field Detail

KEY_ANALYSER

public static final String KEY_ANALYSER
The key for the analyser class.

See Also:
Constant Field Values

KEY_VIEWPORTLISTEN

public static final String KEY_VIEWPORTLISTEN
If this is true, we listen to viewport changes.

See Also:
Constant Field Values

KEY_ANALYSESETS

public static final String KEY_ANALYSESETS
The key to the analysed set name.

See Also:
Constant Field Values

KEY_ALLOW

public static final String KEY_ALLOW
If set, only these canvi are allowed.

See Also:
Constant Field Values

KEY_DENY

public static final String KEY_DENY
If set, only these canvi are not allowed.

See Also:
Constant Field Values

KEY_BASEPLAIN

public static final String KEY_BASEPLAIN
The time base in ms for plain operations.

See Also:
Constant Field Values

KEY_BASESINUS

public static final String KEY_BASESINUS
The time base in ms for sin/cos operations.

See Also:
Constant Field Values

KEY_BASETAN

public static final String KEY_BASETAN
The time base in ms for tan operations.

See Also:
Constant Field Values

KEY_BASESQRT

public static final String KEY_BASESQRT
The time base in ms for sqrt operations.

See Also:
Constant Field Values

KEY_BASELOG

public static final String KEY_BASELOG
The time base in ms for log operations.

See Also:
Constant Field Values

KEY_BASEPOWER

public static final String KEY_BASEPOWER
The time base in ms for power operations.

See Also:
Constant Field Values

KEY_BASERANDOM

public static final String KEY_BASERANDOM
The time base in ms for random operations.

See Also:
Constant Field Values

KEY_EXECOFFSET

public static final String KEY_EXECOFFSET
The time offset in ms for execution time estimation.

See Also:
Constant Field Values

KEY_EXECFACTOR

public static final String KEY_EXECFACTOR
The time multiplier for execution time estimation.

See Also:
Constant Field Values

KEY_TRANSFERCLASSES

public static final String KEY_TRANSFERCLASSES
The list of class names for transferrring points to input.

See Also:
Constant Field Values

KEY_TRANSFERINIT

public static final String KEY_TRANSFERINIT
The list of string initializers for the transfer classes.

See Also:
Constant Field Values

TIME

private static final String TIME
Tooltip text on action.

See Also:
Constant Field Values

DEFEXECOFFSET

private static final double DEFEXECOFFSET
No offset per default.

See Also:
Constant Field Values

DEFEXECFACTOR

private static final double DEFEXECFACTOR
Multpliy with one.

See Also:
Constant Field Values

set

private Collection<DataCard> set
The cumulated data we act on, used for add/delete.


transfer

private List<Function> transfer
If set, we use these functions to transfer set data to analyser input.


input

private VectorG[] input
The analyser input data constructed from the data card set.


tagging

private Object[] tagging
The tagging information to the input data.


ear

private PropertyChangeSupport ear
The listners receiving analyser events.


anal

private Analyser anal
The analyser we pass the events to.


allow

private List<String> allow
The list of allowed canvi or null, if all are allowed.


deny

private List<String> deny
The list of denied canvi or null, if all are allowed.


exectime

private static final long[] exectime
The execution times, measured at startup.

Constructor Detail

JAbstractAnalyser

protected JAbstractAnalyser(Map<String,String> prop)
On construct, we pass to the super constructor, the analyser is created in the init section. The setname defaults to the generic name.

Method Detail

init

public void init()
We scan the properties for the KEY_ANALYSER property and try to create that from my properties.

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

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener pcl)
Adds, if new, this property change listeners.

Specified by:
addPropertyChangeListener in interface BeanSupport

addPropertyChangeListener

public void addPropertyChangeListener(String p,
                                      PropertyChangeListener pcl)
Adds, if new, this property change listeners.

Specified by:
addPropertyChangeListener in interface BeanSupport

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener pcl)
Removes this property change listeners.

Specified by:
removePropertyChangeListener in interface BeanSupport

removePropertyChangeListener

public void removePropertyChangeListener(String p,
                                         PropertyChangeListener pcl)
Removes this property change listeners.

Specified by:
removePropertyChangeListener in interface BeanSupport

getAnalyserInput

public VectorG[] getAnalyserInput()
As a source for the analysers, we use the original data, as it comes with error bars.

Specified by:
getAnalyserInput in interface DataAnalysing

getDataTagging

public Object[] getDataTagging()
Whoever wants to track the taggings that came along with the original data.

Specified by:
getDataTagging in interface DataAnalysing

getAnalysedSets

public List<String> getAnalysedSets()
Gets the set name we register to.

Specified by:
getAnalysedSets in interface DataAnalysing

getAnalyser

public Analyser getAnalyser()
Returns my analyser.

Specified by:
getAnalyser in interface DataAnalysing

componentHidden

public void componentHidden(ComponentEvent e)
Called to clear any cached data.

Specified by:
componentHidden in interface ComponentListener

componentMoved

public void componentMoved(ComponentEvent e)
Empty.

Specified by:
componentMoved in interface ComponentListener

componentResized

public void componentResized(ComponentEvent e)
Empty.

Specified by:
componentResized in interface ComponentListener

componentShown

public void componentShown(ComponentEvent e)
The component that is shown is analysed if analysing of the underlying data canvas is allowed. This is done in the following ways If the canvas is not allowed, the analysers action (if any) is disabled, otherwise, it is enabled and the data canvas is forwarded to the canvasShown(jview.JDataCanvas) method.

Specified by:
componentShown in interface ComponentListener

dataChanged

public void dataChanged(DataChangeEvent dce)
Called when the observed data changed.

Specified by:
dataChanged in interface DataObserver

traceSource

private JDataCanvas traceSource(ComponentEvent e)
Tries to get the data canvas from the component event.


estimateExecutionTime

protected long estimateExecutionTime(VectorG[] in)
Estimates the execution time based on the input data. Used for the progress monitor displayed on action.


propertyChange

public void propertyChange(PropertyChangeEvent e)
If the visible area changes, we grep all data in the component, as well as when we lost some data.

Specified by:
propertyChange in interface PropertyChangeListener

estimateExecutionTime

public long estimateExecutionTime(VectorG[] in,
                                  Analyser anal)
Estimates the execution time based on the input data. Used for the progress monitor displayed on action.

Specified by:
estimateExecutionTime in interface DataAnalysing

vectorData

private Map<String,Object> vectorData(Collection<DataCard> dc)
Analyser work on an array of VectorGs, but the data is normally provided as data cards. This method can be used to convert a collection into an array of nvectors. Each component of the data point vector can be transferred with a single function, if properly constructed with the KEY_TRANSFERCLASSES and KEY_TRANSFERINIT keys. Any transfer not defined, e.g. if the data point has more components then there are entries in the transfer function list, means that the identical transfer is used fot that component. If further transformations than simple copying is required, subclasses may override this method. The output of this method is cached, propagated as a property change event, and retrievable with getAnalyserInput().

Returns:
A mapping of property names to new values.

firePropertyChange

protected void firePropertyChange(String propname,
                                  Object old,
                                  Object now)
Notifies all registered property change listeners.


canvasShown

private void canvasShown(JDataCanvas jdc)
Called when an allowed component was shown, captured by a component event.


transferAnalyserInput

private void transferAnalyserInput(Map<String,Object> ai)
We set the analyser input and fire a property change.


setAnalyserInput

protected void setAnalyserInput(VectorG[] in)
This is the method that is called whenever the analyser input data is modified. Subclasses can interfere here, if the layout of the analyser changes with data. This is not the place where non-subclasses of analyser should interfere, they must register as property change listeners.


setDataTagging

protected void setDataTagging(Object[] keys)
This method is called when the data tagging is set. Same restrictions as on the data.

See Also:
setAnalyserInput(vec_math.VectorG[])

canvasHidden

private void canvasHidden(JDataCanvas jdc)
Called when an allowed component was hiddn, captured by a component event.