java.lang.Object
de.grogra.graph.impl.Edge
de.grogra.graph.impl.Node
de.grogra.rgg.RGG
- All Implemented Interfaces:
Manageable
,PersistenceCapable
,Shareable
,RegistryContext
,Selectable
,UserFields
,XObject
,Map
,Serializable
,Observer
- Direct Known Subclasses:
LSystem
This class is the base class of all instances of relational
growth grammars within GroIMP. The main class of an
rgg-file automatically extends this class.
This class declares some methods which may be overriden by subclasses in order to respond to specific events:
This class declares some methods which may be overriden by subclasses in order to respond to specific events:
-
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 ofrunLater(Object)
orrunLater(long, Object)
. The argument is the argument which has been passed torunLater
. The invocation ofrun
is queued in theJobManager
of the current workbench and executed in its thread.
reset()
.- Author:
- Ole Kniemeyer
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class de.grogra.graph.impl.Node
Node.AccessorBridge, Node.FieldAttributeAccessor, Node.NType
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Node.NType
static final Node.NType.Field
static final Node.NType.Field
static final Node.NType.Field
static final EnumerationType
static final I18NBundle
protected TurtleState
static final Node.NType.Field
static final UIProperty
Fields inherited from class de.grogra.graph.impl.Node
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, MAX_RESOLUTION, MIME_TYPE, MIN_RESOLUTION, MIN_UNUSED_SPECIAL_OF_SOURCE, MIN_UNUSED_SPECIAL_OF_TARGET, name$FIELD, RESOLUTION_BIT, RESOLUTION_MASK, resolution$FIELD, USED_BITS
Fields inherited from interface de.grogra.util.Map
DEFAULT_VALUE, EMPTY_MAP
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addTask
(ConcurrentTask task) protected void
This method can be invoked if interpretive rules shall be applied to the current graph by the methodinterpret()
.protected void
Sets the node classes which shall be considered by the methodsleft(Node)
andright(Node)
.static RGG
protected Node.NType
This method returns theNode.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 :'=.Returns theRegistry
which is linked with this instance.getRoot()
Returns the RGG root of the graph.getTasks()
Returns an instance ofConcurrentTasks
which is associated with thisRGG
.protected void
Sets the node classes which shall be ignored by the methodsleft(Node)
andright(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
protected void
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 ofduration
time units.protected void
void
This method is used to invoke the normally protected init-method when compiler is called from outside GroIMP.boolean
Get whether if all monitors should be removed automatically after integration.protected boolean
Determins whether this RGG should be used as the project's main RGG.static boolean
Computes the first neighbour to the left ofn
which is not an instance of one of the classes set byignore(Class[])
.protected void
Install a monitor function that generates an event when the returned value changes its sign.protected void
monitor
(VoidToDouble g, Runnable r) Install a monitor function that generates an event when the returned value changes its sign.protected void
monitorPeriodic
(double period, Runnable r) Trigger an event in regular intervals and call the event handler.protected Node
This method returns a new instance of the class of this node.void
observe
(ScaleClass s, int arg, String methodName) Register the method (by its name) to invoke given the notification from an observable and an argument object.void
observe
(ScaleClass s, Object arg, String methodName) Register the method (by its name) to invoke given the notification from an observable and an argument object.pullLock()
float
readChannelAt
(int channel, Parallelogram plane, float x, float y, float z) float
readChannelAt
(int channel, Parallelogram plane, Node node) float
readChannelAt
(int channel, String plane, Node node) protected void
reset()
This method can be invoked to reset the RGG to its initial state.Computes the first neighbour to the right ofn
which is not an instance of one of the classes set byignore(Class[])
.protected void
This callback method is invoked as a response to the invocation ofrunLater(Object)
orrunLater(long, Object)
.void
This method is used to induce an invocation ofrun(Object)
in the thread of theJobManager
of the current workbench after a delay of at leastdelay
milliseconds.void
This method is used to induce an invocation ofrun(Object)
in the thread of theJobManager
of the current workbench.void
setAutoClearMonitors
(boolean autoClearMonitors) Set whether if all monitors should be removed automatically after integration.void
void
setSolver
(org.apache.commons.math3.ode.FirstOrderIntegrator integrator) protected void
shutdown()
This method is invoked when an RGG instance is unloaded within GroIMP.static void
void
This method simply invokesConcurrentTasks.solve()
on the set of tasks of thisRGG
(seegetTasks()
).protected void
startup()
This method is invoked when an RGG instance is loaded within GroIMP.static void
void
stop()
This method can be invoked in order to stop the repeated invocation of a method.toSelection
(Context ctx) Converts this object into aSelection
.protected void
Remove all currently set monitor functions.void
update
(Observable o, Object arg) Method invoked when the observable object observed by this object invokes notifyMethods inherited from class de.grogra.graph.impl.Node
addEdgeBitsTo, addReference, appendBranchNode, appendBranchNode, appendReferencesTo, clone, clone, cloneGraph, dump, dumpTree, dup, dupFrom, dupnew, 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, getIgnored, getIndex, getInstantiator, getInt, getLayer, getLong, getManageableType, getName, getNeighbor, getNext, getNType, getObject, getOrCreateEdgeTo, getOrNull, getPersistenceManager, getPredecessor, getProvider, getResolution, 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, setIgnored, setLayer, setMark, setName, setResolution, setSuccessor, setSuccessor, specialEdgeAdded, specialEdgeRefModified, specialEdgeRemoved, toString, writeReplace
Methods inherited from class de.grogra.graph.impl.Edge
addEdgeBits, getBitMark, getEdgeBits, getEdgeKeys, getObjectMark, getSpecialEdgeDescriptor, parseEdgeKeys, remove, removeEdgeBits, setBitMark, setEdgeBits, setObjectMark, testEdgeBits
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface de.grogra.persistence.PersistenceCapable
getBitMark, getObjectMark, setBitMark, setObjectMark
-
Field Details
-
I18N
-
initialTurtleState
-
STEPRUN
-
GROUP_TYPE
-
$TYPE
-
initialTurtleState$FIELD
-
classesToIgnoreOrConsider$FIELD
-
consider$FIELD
-
doRun$FIELD
-
-
Constructor Details
-
RGG
public RGG()
-
-
Method Details
-
addLock
-
pullLock
-
toSelection
Description copied from interface:Selectable
Converts this object into aSelection
.- Specified by:
toSelection
in interfaceSelectable
- Parameters:
ctx
- the UI context- Returns:
- a selection, or
null
if this is not possible
-
startup
-
isMainRGG
protected boolean isMainRGG()Determins whether this RGG should be used as the project's main RGG. The main RGG creates menu entries in the RGG toolbar. A project must not contain more than one main RGG.This default implementation defines an RGG to be the main RGG iff its class declares a
public
void
method with no arguments, or aninit
method. This method should be overwritten by non-main RGGs for which this simple definition is not sufficient.- Returns:
true
iff this RGG is the main RGG of a project
-
getMainRGG
-
shutdown
-
getRGGForTypeMap
-
getRegistry
Description copied from interface:RegistryContext
Returns theRegistry
which is linked with this instance.- Specified by:
getRegistry
in interfaceRegistryContext
- Returns:
- the registry linked with this instance
-
getRoot
Returns the RGG root of the graph. This is not necessarily the real root of the graph: If there exists a branch edge from the real root to an instance ofRGGRoot
, then this instance is returned. Otherwise, the real root is returned.- Returns:
- RGG root of graph
-
initializeApplyMenu
-
initializeRunMenu
-
isTransformationMethod
-
startup
protected void startup()This method 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.
If this method is overridden,super.startup();
should be invoked at first. -
shutdown
protected void shutdown()This method 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.
If this method is overriden,super.shutdown();
should be invoked. -
reset
protected void reset()This method can be invoked to reset the RGG to its initial state. The following steps are performed:-
If there is an instance of
RGGRoot
which is connected with the real root of the graph by a branch edge, then this instance is removed. A new instance ofRGGRoot
is created and connected with the real root by a branch edge. -
A new instance of
Axiom
is created and inserted in the graph by a successor edge from theRGGRoot
instance. The result of this step is a graph containing anRGGRoot
which has a singleAxiom
as its successor. -
The method
init()
is invoked. This invocation is surrounded by transformation boundaries (seeLibrary.apply()
).
-
If there is an instance of
-
init
protected void init()This method is invoked to initialize an RGG This happens after the compilation of its source code and after a reset.
The default implementation does nothing. It may be overridden by subclasses in order to perform some initialization. This may include the creation of an initial graph structure, or the initialization of field values. -
invokeInit
public void invokeInit()This method is used to invoke the normally protected init-method when compiler is called from outside GroIMP. -
initializeTurtleState
-
stop
public void stop()This method can be invoked in order to stop the repeated invocation of a method. -
applyInterpretation
protected void applyInterpretation()This method can be invoked if interpretive rules shall be applied to the current graph by the methodinterpret()
. The effect ofapplyInterpretation
is the following:- Existing interpretive nodes are removed.
- A transformation boundary is passed in order to apply pending transformations.
- The current extent is set up such that following
==>
rules are treated as interpretive rules. This action is undone at the end of this method. - The method
interpret()
is invoked.
-
interpret
protected void interpret() -
getSolver
-
setSolver
-
setSolver
public void setSolver(org.apache.commons.math3.ode.FirstOrderIntegrator integrator) -
monitor
Install a monitor function that generates an event when the returned value changes its sign. The monitor must not modify the state of the graph.- Parameters:
g
- monitor function
-
monitor
Install a monitor function that generates an event when the returned value changes its sign. The monitor must not modify the state of the graph. When the event triggers, the event handler is called.- Parameters:
g
- monitor functionr
- event handler
-
monitorPeriodic
Trigger an event in regular intervals and call the event handler. Additionally, the write lock on the graph (automatically obtained when executing rules) is temporarily released so that modifications to the attributes made in the event handler will become visible.- Parameters:
g
- monitor functionr
- event handler
-
unmonitor
protected void unmonitor()Remove all currently set monitor functions. This will be called implicitly afterintegrate(double)
ifisAutoClearMonitors()
is true. -
isAutoClearMonitors
public boolean isAutoClearMonitors()Get whether if all monitors should be removed automatically after integration.- Returns:
- true if all monitors should be removed after integration automatically
-
setAutoClearMonitors
public void setAutoClearMonitors(boolean autoClearMonitors) Set whether if all monitors should be removed automatically after integration.- Parameters:
autoClearMonitors
- if true, all monitors should be removed after integration automatically
-
integrate
Integrate numerically using the ODE framework for an unlimited duration of time units. This is implemented by callingintegrate(double)
with a duration ofjava.lang.Double.MAX_VALUE
. To stop the integration a monitor must be set.- Throws:
NumericException
- See Also:
-
integrate
Integrate numerically using the ODE framework over a duration ofduration
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 functiongetRate()
. The user should not make any assumptions about how many times or with which parameters of time and state the functiongetRate()
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.- Parameters:
duration
- time duration over which to integrate- Throws:
NumericException
- See Also:
-
getRate
protected void getRate()Override this to provide the rate function using the rate assignment operator :'=. The state is passed implicitly as the current graph, and graph queries can be used to calculate the rates. -
ignore
Sets the node classes which shall be ignored by the methodsleft(Node)
andright(Node)
. This method may be invoked as a variable arity method, i.e., with a variable number of arguments of classClass
.- Parameters:
ignore
- an array of classes to be ignored
-
consider
Sets the node classes which shall be considered by the methodsleft(Node)
andright(Node)
. This method may be invoked as a variable arity method, i.e., with a variable number of arguments of classClass
.- Parameters:
consider
- an array of classes to be considered
-
left
Computes the first neighbour to the left ofn
which is not an instance of one of the classes set byignore(Class[])
. The neighbours to the left are those which are reachable by successor or branch edges in reverse direction.- Parameters:
n
- where to start the search- Returns:
- first neighbour to the left, excluding instances of ignored classes
-
right
Computes the first neighbour to the right ofn
which is not an instance of one of the classes set byignore(Class[])
. The neighbours to the right are those which are reachable by successor edges in forward direction.- Parameters:
n
- where to start the search- Returns:
- first neighbour to the right, excluding instances of ignored classes
-
readChannelAt
-
readChannelAt
-
readChannelAt
-
getTasks
Returns an instance ofConcurrentTasks
which is associated with thisRGG
.- Returns:
- instance of
ConcurrentTasks
for use within thisRGG
-
addTask
Adds a singletask
to the set of tasks of thisRGG
(seegetTasks()
). After all tasks have been added, the methodsolveTasks()
has to be invoked in order to solve the tasks concurrently using a number of threads or even distributed computers.- Parameters:
task
- task to add
-
solveTasks
public void solveTasks()This method simply invokesConcurrentTasks.solve()
on the set of tasks of thisRGG
(seegetTasks()
). This solves all added tasks (seeaddTask(ConcurrentTask)
) concurrently using the available resources (multiple processors, distributed computers). -
runLater
This method is used to induce an invocation ofrun(Object)
in the thread of theJobManager
of the current workbench. The invocation is queued in the job manager, i.e., it is performed after all pending jobs have been completed.- Parameters:
arg
- argument to pass torun(Object)
-
runLater
This method is used to induce an invocation ofrun(Object)
in the thread of theJobManager
of the current workbench after a delay of at leastdelay
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.- Parameters:
delay
- delay in millisecondsarg
- argument to pass torun(Object)
-
run
This callback method is invoked as a response to the invocation ofrunLater(Object)
orrunLater(long, Object)
.arg
is the argument which has been passed torunLater
. The invocation is executed in the thread of theJobManager
of the current workbench. In addition, a write-lock on the graph is being aquired during execution.
The default implementation does nothing.- Parameters:
arg
- the argument which has been passed torunLater
-
observe
Register the method (by its name) to invoke given the notification from an observable and an argument object.- Parameters:
s
-arg
-methodName
-
-
observe
Register the method (by its name) to invoke given the notification from an observable and an argument object.- Parameters:
o
-arg
-methodName
-
-
update
Method invoked when the observable object observed by this object invokes notify -
getNTypeImpl
Description copied from class:Node
This method returns theNode.NType
which describes the managed fields of the class of this node. This method has to be implemented in every concrete subclass.- Overrides:
getNTypeImpl
in classNode
- Returns:
- type describing the managed fields of the class of this node
-
newInstance
Description copied from class:Node
This method returns a new instance of the class of this node. This method has to be implemented in every concrete subclass.- Overrides:
newInstance
in classNode
- Returns:
- new instance of class of this node
-