|
|||||||||
| Home >> All >> org >> modama >> framework >> [ operations overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.modama.framework.operations
Class AbstractOperation

java.lang.Objectorg.modama.ModelStates
org.modama.Model
org.modama.framework.AbstractFrameworkModel
org.modama.framework.operations.AbstractOperation
- All Implemented Interfaces:
- java.util.EventListener, java.beans.PropertyChangeListener
- Direct Known Subclasses:
- Abstracton1ImageOperation, Abstracton2InputOperation, OpSlice
- public abstract class AbstractOperation
- extends org.modama.framework.AbstractFrameworkModel
- implements java.beans.PropertyChangeListener
- extends org.modama.framework.AbstractFrameworkModel
The abstract base class for an operation. An op consists of several inputentities, after setting needed inputs, an op can be executed to create an output entity. if you want to create a new operation extend this class, if your operation depends on the input, you can use the strategy pattern -> create innerclasses that implement Calculator, they are automaticly choosen by searching a calculator that accepts the current input in addition, if you change an input entity, the op will recalculate and set the new data to the resulting entity, what will also affect an event, etc.. TODO add thread TODO test threadsafety changes: 05/10/03 - synopia - added getInputCount(), need this to start calculation, when op is ready
| Nested Class Summary | |
(package private) static interface |
AbstractOperation.Calculator
interface for the strategypattern |
| Field Summary | |
protected boolean |
active
when created an operator is inactive, by executing its acitvated and will automaticly recalc if input changes |
protected AbstractOperation.Calculator[] |
availabeCalculators
an array with instances of all the inner classes that implement the Calculator interface, this is automaticly filled in the constructor |
protected AbstractOperation.Calculator |
calculator
this is a strategypattern, the concret calculation depends on the inputs and should be choosen when the inputlist changes |
static java.lang.String |
EVENT_CONNECT
|
static java.lang.String |
EVENT_DISCONNECT
|
static java.lang.String |
EVENT_EXECUTION_FINISHED
is fired when the execution thread finished |
static java.lang.String |
EVENT_EXECUTION_STARTED
|
protected java.util.List |
input
the input entities of the operation |
protected static org.apache.log4j.Logger |
logger
|
protected org.modama.framework.entities.AbstractEntity |
output
the result of the operation or null if not yet executed |
protected java.lang.Class |
resultingClass
class of the entity that results by this operation |
| Fields inherited from class org.modama.framework.AbstractFrameworkModel |
name, PROP_NAME |
| Fields inherited from class org.modama.Model |
changeAgent, EVENT_FIRED, state |
| Fields inherited from class org.modama.ModelStates |
CREATED, DELETED, MODIFIED, SAVED |
| Constructor Summary | |
AbstractOperation()
create an empty operation |
|
AbstractOperation(java.lang.String name)
create operation with given name |
|
| Method Summary | |
abstract boolean |
accept(org.modama.framework.entities.AbstractEntity entity)
returns true if the entity will be accepted if put to the operation |
protected org.modama.framework.entities.AbstractEntity |
calculate()
here YOU can place your code for the calculation if you dont want to use the strategypattern, but in this case you also have to change the search method (because it wont find anything and so sets some values to null), so you sould use the pattern :) |
abstract boolean |
canExecute()
|
protected void |
create()
put the entity to the world |
protected void |
createOutputEntity()
creates an instance of the resulting class |
void |
delete()
delete the entity from the world |
org.modama.framework.entities.AbstractEntity |
execute()
execute the operation, if the last created output entity is of the same type as the one we will create this time, it is reused, otherwise a new one is created |
protected abstract void |
fillAvailabeCalculatorsArray()
this has to be implemented, all the available calculators have to be inserted here |
int |
getInputCount()
returns the number of inputs |
java.util.List |
getInputs()
|
org.modama.framework.entities.AbstractEntity |
getOutput()
|
boolean |
isActive()
returns true if the operation is active, what means it listens for changes in the input and recalculates automaticly |
boolean |
load(java.net.URL url)
uses the XMLDecoder to load the object from an inputstream |
org.modama.framework.entities.AbstractEntity |
Output()
get the result of the operation |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
an inputproperty has changed, normaly this means we have to recalculate TODO do handling for partly changes of lists, so only changed parts have to be recalculated |
void |
put(org.modama.framework.entities.AbstractEntity entity)
add this entity to the input IllegalArgumentException is thrown if the entity is not accepted (this should be tested bevor by using the method accept) |
void |
remove(org.modama.framework.entities.AbstractEntity entity)
removes the entity from the inputlist, or removes the output if entity is the outputentity |
void |
removeAll()
removes all input and the output |
void |
removeAllInput()
removes all input |
void |
save(java.net.URL url)
uses the XMLEncoder to save the object |
protected void |
searchCalculator()
uses reflection to search for a fitting calculator if one is found, that the outputClass |
void |
setActive(boolean active)
if set to false, the operation will not recalc automaticly if inputdata changes |
void |
setOutput(org.modama.framework.entities.AbstractEntity output)
|
java.lang.String |
toString()
get a string for the classname from the resources |
| Methods inherited from class org.modama.framework.AbstractFrameworkModel |
getName, setName |
| Methods inherited from class org.modama.Model |
addPropertyChangeListener, addPropertyChangeListener, fire, fire, fire, getState, removePropertyChangeListener, removePropertyChangeListener, setState |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
EVENT_EXECUTION_FINISHED
public static final java.lang.String EVENT_EXECUTION_FINISHED
- is fired when the execution thread finished
- See Also:
- Constant Field Values
EVENT_EXECUTION_STARTED
public static final java.lang.String EVENT_EXECUTION_STARTED
- See Also:
- Constant Field Values
EVENT_CONNECT
public static final java.lang.String EVENT_CONNECT
- See Also:
- Constant Field Values
EVENT_DISCONNECT
public static final java.lang.String EVENT_DISCONNECT
- See Also:
- Constant Field Values
logger
protected static org.apache.log4j.Logger logger
resultingClass
protected java.lang.Class resultingClass
- class of the entity that results by this operation
output
protected org.modama.framework.entities.AbstractEntity output
- the result of the operation or null if not yet executed
input
protected java.util.List input
- the input entities of the operation
active
protected boolean active
- when created an operator is inactive, by executing its acitvated and will automaticly recalc if input changes
calculator
protected AbstractOperation.Calculator calculator
- this is a strategypattern, the concret calculation depends on the inputs and should be choosen when the inputlist changes
availabeCalculators
protected AbstractOperation.Calculator[] availabeCalculators
- an array with instances of all the inner classes that implement the Calculator interface,
this is automaticly filled in the constructor
| Constructor Detail |
AbstractOperation
public AbstractOperation()
- create an empty operation
AbstractOperation
public AbstractOperation(java.lang.String name)
- create operation with given name
| Method Detail |
fillAvailabeCalculatorsArray
protected abstract void fillAvailabeCalculatorsArray()
- this has to be implemented, all the available calculators have to be inserted here
create
protected void create()
- put the entity to the world
delete
public void delete()
throws org.modama.framework.exceptions.DeleteCancelledException
- delete the entity from the world
load
public boolean load(java.net.URL url) throws java.io.IOException
- uses the XMLDecoder to load the object from an inputstream
save
public void save(java.net.URL url) throws java.io.IOException
- uses the XMLEncoder to save the object
execute
public org.modama.framework.entities.AbstractEntity execute()
- execute the operation, if the last created output entity is of the same type as the one we will create this time,
it is reused, otherwise a new one is created
Output
public org.modama.framework.entities.AbstractEntity Output()
- get the result of the operation
isActive
public boolean isActive()
- returns true if the operation is active, what means it listens for changes in the input and recalculates automaticly
setActive
public void setActive(boolean active)
- if set to false, the operation will not recalc automaticly if inputdata changes
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- an inputproperty has changed, normaly this means we have to recalculate
TODO do handling for partly changes of lists, so only changed parts have to be recalculated
- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener
put
public void put(org.modama.framework.entities.AbstractEntity entity)
- add this entity to the input
IllegalArgumentException is thrown if the entity is not accepted (this should be tested bevor by using the methodaccept)
removeAll
public void removeAll()
- removes all input and the output
removeAllInput
public void removeAllInput()
- removes all input
remove
public void remove(org.modama.framework.entities.AbstractEntity entity)
- removes the entity from the inputlist, or removes the output if entity is the outputentity
accept
public abstract boolean accept(org.modama.framework.entities.AbstractEntity entity)
- returns true if the entity will be accepted if put to the operation
calculate
protected org.modama.framework.entities.AbstractEntity calculate()
- here YOU can place your code for the calculation if you dont want to use the strategypattern, but in this case
you also have to change the search method (because it wont find anything and so sets some values to null),
so you sould use the pattern :)
searchCalculator
protected void searchCalculator()
- uses reflection to search for a fitting calculator
if one is found, that the outputClass
createOutputEntity
protected void createOutputEntity()
- creates an instance of the resulting class
getInputCount
public int getInputCount()
- returns the number of inputs
canExecute
public abstract boolean canExecute()
getInputs
public java.util.List getInputs()
getOutput
public org.modama.framework.entities.AbstractEntity getOutput()
setOutput
public void setOutput(org.modama.framework.entities.AbstractEntity output)
toString
public java.lang.String toString()
- get a string for the classname from the resources
|
|||||||||
| Home >> All >> org >> modama >> framework >> [ operations overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC