de.grogra.rgg
public class RGG extends Node implements Selectable, RegistryContext, java.util.Observer
init() is invoked to initialize an RGG
instance. This happens after the compilation
of its source code and after a reset.
startup() is invoked when an RGG instance
is loaded within GroIMP. This happens after the compilation
of its source code and after loading a project containing an RGG.
shutdown() is invoked when an RGG instance
is unloaded within GroIMP. This happens to an old RGG instance
after compilation when this old instance is to be replaced
by the newly compiled RGG instance.
run(Object) is invoked as a response to the invocation
of runLater(Object) or runLater(long, Object).
The argument is the
argument which has been passed to runLater. The
invocation of run is queued in the
JobManager of the current
workbench and executed in its thread.
reset().| Modifier and Type | Class and Description |
|---|---|
class |
RGG.Apply |
Node.AccessorBridge, Node.FieldAttributeAccessor, Node.NType| Modifier and Type | Field and Description |
|---|---|
static Node.NType |
$TYPE |
static Node.NType.Field |
classesToIgnoreOrConsider$FIELD |
static Node.NType.Field |
consider$FIELD |
static Node.NType.Field |
doRun$FIELD |
static EnumerationType |
GROUP_TYPE |
static I18NBundle |
I18N |
protected TurtleState |
initialTurtleState |
static Node.NType.Field |
initialTurtleState$FIELD |
static UIProperty |
STEPRUN |
ADDITIONAL_FIELDS, bits, DELETED, EXTENT_BIT, EXTENT_MASK, extentIndex$FIELD, extentTail$FIELD, HAS_OBSERVERS, IS_INTERPRETIVE, isInterpretive$FIELD, LAST_EXTENT_INDEX, layer$FIELD, MARK, mark$FIELD, MIME_TYPE, MIN_UNUSED_SPECIAL_OF_SOURCE, MIN_UNUSED_SPECIAL_OF_TARGET, name$FIELD, USED_BITSDEFAULT_VALUE, EMPTY_MAP| Constructor and Description |
|---|
RGG() |
| Modifier and Type | Method and Description |
|---|---|
void |
addTask(ConcurrentTask task)
|
protected void |
applyInterpretation()
This method can be invoked if interpretive rules shall be applied
to the current graph by the method
interpret(). |
protected void |
consider(java.lang.Class... consider)
Sets the node classes which shall be considered by the methods
left(Node) and right(Node). |
static RGG |
getMainRGG(RegistryContext r) |
protected Node.NType |
getNTypeImpl()
This method returns the
Node.NType which describes the managed
fields of the class of this node. |
protected void |
getRate()
Override this to provide the rate function using the rate
assignment operator :'=.
|
Registry |
getRegistry()
Returns the
Registry which is linked with this instance. |
static java.util.Map<java.lang.String,RGG> |
getRGGForTypeMap(RegistryContext r) |
Node |
getRoot()
Returns the RGG root of the graph.
|
Solver |
getSolver() |
ConcurrentTasks |
getTasks()
Returns an instance of
ConcurrentTasks which is associated
with this RGG. |
protected void |
ignore(java.lang.Class... ignore)
Sets the node classes which shall be ignored by the methods
left(Node) and right(Node). |
protected void |
init()
This method is invoked to initialize an RGG
This happens after the compilation
of its source code and after a reset.
|
protected void |
initializeApplyMenu(Item d,
boolean flat,
boolean useRunCheckBox) |
protected void |
initializeRunMenu(Item d,
boolean flat,
boolean useRunCheckBox) |
void |
initializeTurtleState(TurtleState s) |
protected void |
integrate()
Integrate numerically using the ODE framework for an unlimited duration of time units.
|
protected void |
integrate(double duration)
Integrate numerically using the ODE framework over a duration of
duration
time units. |
protected void |
interpret() |
void |
invokeInit()
This method is used to invoke the normally
protected init-method when compiler is called
from outside GroIMP.
|
boolean |
isAutoClearMonitors()
Get whether if all monitors should be removed automatically after integration.
|
protected boolean |
isMainRGG()
Determins whether this RGG should be used as the project's main RGG.
|
Node |
left(Node n)
Computes the first neighbour to the left of
n which
is not an instance of one of the classes set by
ignore(Class[]). |
protected void |
monitor(VoidToDouble g)
Install a monitor function that generates an event when the
returned value changes its sign.
|
protected void |
monitor(VoidToDouble g,
java.lang.Runnable r)
Install a monitor function that generates an event when the
returned value changes its sign.
|
protected void |
monitorPeriodic(double period,
java.lang.Runnable r)
Trigger an event in regular intervals and call the event handler.
|
protected Node |
newInstance()
This method returns a new instance of the class of this
node.
|
void |
observe(ScaleClass s,
int arg,
java.lang.String methodName)
Register the method (by its name) to invoke given the notification from an
observable and an argument object.
|
void |
observe(ScaleClass s,
java.lang.Object arg,
java.lang.String methodName)
Register the method (by its name) to invoke given the notification from an
observable and an argument object.
|
float |
readChannelAt(int channel,
Parallelogram plane,
float x,
float y,
float z) |
float |
readChannelAt(int channel,
Parallelogram plane,
Node node) |
float |
readChannelAt(int channel,
java.lang.String plane,
Node node) |
protected void |
reset()
This method can be invoked to reset the RGG
to its initial state.
|
Node |
right(Node n)
Computes the first neighbour to the right of
n which
is not an instance of one of the classes set by
ignore(Class[]). |
protected void |
run(java.lang.Object arg)
This callback method is invoked as a response to the invocation
of
runLater(Object) or runLater(long, Object). |
void |
runLater(long delay,
java.lang.Object arg)
This method is used to induce an invocation
of
run(Object) in the thread
of the JobManager of the current workbench
after a delay of at least delay
milliseconds. |
void |
runLater(java.lang.Object arg)
This method is used to induce an invocation
of
run(Object) in the thread
of the JobManager of the current workbench. |
void |
setAutoClearMonitors(boolean autoClearMonitors)
Set whether if all monitors should be removed automatically after integration.
|
void |
setSolver(org.apache.commons.math.ode.FirstOrderIntegrator integrator) |
void |
setSolver(Solver solver) |
protected void |
shutdown()
This method is invoked when an RGG instance
is unloaded within GroIMP.
|
static void |
shutdown(Registry r,
Type t) |
void |
solveTasks()
This method simply invokes
ConcurrentTasks.solve() on
the set of tasks of this RGG (see getTasks()). |
protected void |
startup()
This method is invoked when an RGG instance
is loaded within GroIMP.
|
static void |
startup(Registry r,
Type type) |
void |
stop()
This method can be invoked in order to stop the repeated invocation
of a method.
|
Selection |
toSelection(Context ctx)
Converts this object into a
Selection. |
protected void |
unmonitor()
Remove all currently set monitor functions.
|
void |
update(java.util.Observable o,
java.lang.Object arg)
Method invoked when the observable object observed by this object invokes notify
|
addEdgeBitsTo, addReference, appendBranchNode, appendBranchNode, appendReferencesTo, clone, clone, cloneGraph, dump, dumpTree, dup, dupUnmanagedFields, edgeChanged, fieldModified, findAdjacent, findRefinementType, get, getAccessor, getAccessor, getAttributes, getAxisParent, getBoolean, getBranch, getBranchLength, getBranchNode, getBranchTail, getByte, getChar, getCommonAncestor, getCurrentGraphState, getDirectChildCount, getDouble, getEdgeAttributeAccessor, getEdgeAttributes, getEdgeBitsTo, getEdgeTo, getExtentIndex, getFirst, getFirstEdge, getFloat, getGraph, getId, getIndex, getInstantiator, getInt, getLayer, getLong, getManageableType, getName, getNeighbor, getNext, getNType, getObject, getOrCreateEdgeTo, getOrNull, getPersistenceManager, getPredecessor, getProvider, getShort, getSource, getStamp, getSuccessor, getSymbol, getSymbolColor, getTarget, getTransaction, getUserField, getUserFieldCount, getXClass, getXData, hasName, initProvider, initXClass, insertBranchNode, insertBranchNode, instantiateGraph, isAncestorOf, isDirection, isEncoarseOf, isManagingInstance, isMarked, isRoot, isSource, isTarget, manageableReadResolve, manageableWriteReplace, paramString, removeAll, removeEdgeBitsTo, removeFromChain, removeFromChain, removeReference, setBranch, setBranch, setExtentIndex, setGraphForDeserialization, setLayer, setMark, setName, setSuccessor, setSuccessor, specialEdgeAdded, specialEdgeRefModified, specialEdgeRemoved, toString, writeReplaceaddEdgeBits, getBitMark, getEdgeBits, getObjectMark, getSpecialEdgeDescriptor, parseEdgeKeys, remove, removeEdgeBits, setBitMark, setEdgeBits, setObjectMark, testEdgeBitsequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetBitMark, getObjectMark, setBitMark, setObjectMarkpublic static final Node.NType $TYPE
public static final Node.NType.Field classesToIgnoreOrConsider$FIELD
public static final Node.NType.Field consider$FIELD
public static final Node.NType.Field doRun$FIELD
public static final EnumerationType GROUP_TYPE
public static final I18NBundle I18N
protected TurtleState initialTurtleState
public static final Node.NType.Field initialTurtleState$FIELD
public static final UIProperty STEPRUN
public void addTask(ConcurrentTask task)
task to the set of tasks of this
RGG (see getTasks()). After all tasks
have been added, the method solveTasks() has to be
invoked in order to solve the tasks concurrently using a number
of threads or even distributed computers.task - task to addprotected void applyInterpretation()
interpret(). The effect
of applyInterpretation is the following:
==> rules are treated as interpretive rules. This
action is undone at the end of this method.
interpret() is invoked.
protected void consider(java.lang.Class... consider)
left(Node) and right(Node). This method
may be invoked as a variable arity method, i.e., with
a variable number of arguments of class Class.consider - an array of classes to be consideredpublic static RGG getMainRGG(RegistryContext r)
protected Node.NType getNTypeImpl()
NodeNode.NType which describes the managed
fields of the class of this node. This method has to be implemented
in every concrete subclass.getNTypeImpl in class Nodeprotected void getRate()
public Registry getRegistry()
RegistryContextRegistry which is linked with this instance.getRegistry in interface RegistryContextpublic static java.util.Map<java.lang.String,RGG> getRGGForTypeMap(RegistryContext r)
public Node getRoot()
RGGRoot, then this instance is returned. Otherwise,
the real root is returned.public Solver getSolver()
public ConcurrentTasks getTasks()
ConcurrentTasks which is associated
with this RGG.ConcurrentTasks for use within this
RGGprotected void ignore(java.lang.Class... ignore)
left(Node) and right(Node). This method
may be invoked as a variable arity method, i.e., with
a variable number of arguments of class Class.ignore - an array of classes to be ignoredprotected void init()
protected void initializeApplyMenu(Item d, boolean flat, boolean useRunCheckBox)
protected void initializeRunMenu(Item d, boolean flat, boolean useRunCheckBox)
public void initializeTurtleState(TurtleState s)
protected void integrate()
throws NumericException
integrate(double) with a duration of java.lang.Double.MAX_VALUE.
To stop the integration a monitor must be set.NumericExceptionintegrate(double),
monitor(VoidToDouble)protected void integrate(double duration)
throws NumericException
duration
time units. The user has to provide a rate function dy/dt=f(t,y) to calculate the first
derivative of the state vector with respect to time for a given time and state pair.
The rate function f(t,y) is implemented by overriding the function getRate().
The user should not make any assumptions about how many times or with which parameters of
time and state the function getRate() will be called. Since laws of physics do not
depend on the current time the parameter t of f(t,y) is hidden from the user. The state y
is provided implicitly as the attributes of the nodes in the current graph.duration - time duration over which to integrateNumericExceptiongetRate()protected void interpret()
public void invokeInit()
public boolean isAutoClearMonitors()
protected boolean isMainRGG()
This default implementation defines an RGG to be the main RGG iff
its class declares a public void method
with no arguments, or an init method. This method should
be overwritten by non-main RGGs for which this simple definition
is not sufficient.
true iff this RGG is the main RGG of a projectpublic Node left(Node n)
n which
is not an instance of one of the classes set by
ignore(Class[]). The neighbours to the left
are those which are reachable by successor or branch edges
in reverse direction.n - where to start the searchprotected void monitor(VoidToDouble g)
g - monitor functionprotected void monitor(VoidToDouble g, java.lang.Runnable r)
g - monitor functionr - event handlerprotected void monitorPeriodic(double period,
java.lang.Runnable r)
g - monitor functionr - event handlerprotected Node newInstance()
NodenewInstance in class Nodepublic void observe(ScaleClass s, int arg, java.lang.String methodName)
o - arg - methodName - public void observe(ScaleClass s, java.lang.Object arg, java.lang.String methodName)
s - arg - methodName - public float readChannelAt(int channel,
Parallelogram plane,
float x,
float y,
float z)
public float readChannelAt(int channel,
Parallelogram plane,
Node node)
public float readChannelAt(int channel,
java.lang.String plane,
Node node)
protected void reset()
RGGRoot
which is connected with the real root of the
graph by a branch edge, then this instance is removed.
A new instance of RGGRoot
is created and connected with the real root
by a branch edge.
Axiom is created
and inserted in the graph by a successor edge
from the RGGRoot instance.
The result of this step
is a graph containing an RGGRoot
which has a single Axiom as its
successor.
init() is invoked. This invocation
is surrounded by transformation boundaries
(see Library.apply()).
public Node right(Node n)
n which
is not an instance of one of the classes set by
ignore(Class[]). The neighbours to the right
are those which are reachable by successor edges
in forward direction.n - where to start the searchprotected void run(java.lang.Object arg)
runLater(Object) or runLater(long, Object).
arg is the
argument which has been passed to runLater.
The invocation is executed in the thread of
the JobManager of the current workbench. In addition,
a write-lock on the graph is being aquired during execution.
arg - the argument which has been passed to runLaterpublic void runLater(long delay,
java.lang.Object arg)
run(Object) in the thread
of the JobManager of the current workbench
after a delay of at least delay
milliseconds.
The invocation is queued in the job manager, i.e.,
it is performed after all pending jobs have been
completed and after the delay is elapsed.delay - delay in millisecondsarg - argument to pass to run(Object)public void runLater(java.lang.Object arg)
run(Object) in the thread
of the JobManager of the current workbench.
The invocation is queued in the job manager, i.e.,
it is performed after all pending jobs have been
completed.arg - argument to pass to run(Object)public void setAutoClearMonitors(boolean autoClearMonitors)
autoClearMonitors - if true, all monitors should be removed after integration automaticallypublic void setSolver(org.apache.commons.math.ode.FirstOrderIntegrator integrator)
public void setSolver(Solver solver)
protected void shutdown()
super.shutdown(); should
be invoked.public void solveTasks()
ConcurrentTasks.solve() on
the set of tasks of this RGG (see getTasks()).
This solves all added tasks (see addTask(ConcurrentTask))
concurrently using the available resources (multiple processors,
distributed computers).protected void startup()
super.startup(); should
be invoked at first.public void stop()
public Selection toSelection(Context ctx)
SelectableSelection.toSelection in interface Selectablectx - the UI contextnull if this is not possibleprotected void unmonitor()
integrate(double) if isAutoClearMonitors()
is true.public void update(java.util.Observable o,
java.lang.Object arg)
update in interface java.util.Observer