|
CIDER Toolkit Version 0.3.0 |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Object | +--Interpreter
The Interpreter is the main control class in the CIDER toolkit that maintains
a parse forest representation of a diagram, is responsible for applying productions,
and also controls the application of transformations. It as an abstract base class
that is extended by a grammar-specific class that is responsible for implementing
functionality that is grammar dependent. This grammar-specific class is produced
by the CIDER compiler. Note that when an instance of this class is created,
auto forest checking and auto constraint solving are initially turned on.
Important change from version 0.2.0: The load() and save()
methods have been removed. Loading and saving functionality must now be implemented by
the application developer. For example, to save, all terminal symbols (and their attribute values)
can be written to a file (in a format that the application developer is free to choose). Then, to
load again, each terminal symbol (and their attribute values) can be read in and added to an instance
of the Interpreter class, and the associated parse forest will be automatically generated.
| Field Summary | |
static java.lang.String |
VERSION
|
| Method Summary | |
void |
addGrammarSymbolListener(GrammarSymbolListener gsl)
Adds an listener to listen for grammar symbol events. |
boolean |
addTerminalSymbol(GrammarSymbol symbol)
Adds a terminal symbol to the parse forest. |
void |
applyForceDirectedLayout(int timeStep)
Invokes the force directed layout algorithm to be performed on the diagram. |
abstract boolean |
applyTransformation(int transformation)
Applies a specified transformation to the parse forest at the first valid location it finds. |
abstract boolean |
applyTransformationInParallel(int transformation)
Applies a specified transformation to the parse forest in parallel. |
abstract boolean |
applyTransformationWithMapping(int transformation,
boolean parallel,
java.util.Map candidatesMap)
Applies a specified transformation to the parse forest with a specified symbol mapping. |
void |
checkForest()
Checks all productions and updates all attributes in the parse forest that require it. |
void |
disableUndo()
Turns off the ability to undo actions. |
void |
enableUndo()
Turns on the ability to undo actions. |
abstract void |
evaluateProductionRules()
Explicitly calls the grammar-specific interpreter to evaluate the production rules. |
java.util.Set |
getAllSymbols()
Returns a set containing all symbols in the parse forest. |
javax.swing.JComponent |
getJComponent()
Returns the JComponent associated with the visual representation of the diagram
being stored by this Interpreter instance (or null if there is none). |
int |
getUndoIndex()
Returns the index to the most recent action recorded on the undo action list. |
boolean |
isAutoConstraintSolvingOn()
Returns true if auto constraint solving is on, false otherwise. |
boolean |
isAutoForestCheckingOn()
Returns true if auto forest checking is on, false otherwise. |
boolean |
isUndoEnabled()
Returns true if the undo feature is currently enabled, false otherwise. |
boolean |
isUpToDate()
Returns true if the parse forest is up to date, false otherwise. |
void |
printForest(java.io.PrintStream stream)
Prints the parse forest. |
void |
reevaluateForest()
Reevaluates all productions in the parse forest. |
void |
removeGrammarSymbolListener(GrammarSymbolListener gsl)
Removes a listener that listens for grammar symbol events. |
boolean |
removeSubTree(GrammarSymbol symbol)
Removes from the parse forest the sub tree of this symbol. |
boolean |
removeTerminalSymbol(GrammarSymbol symbol)
Removes a terminal symbol from the parse forest. |
void |
resolve()
Calls the constraint solver resolve method. |
void |
setAutoConstraintSolving(boolean on)
Allows auto constraint solving to be turned on or off. |
void |
setAutoForestChecking(boolean on)
Allows auto forest checking to be turned on or off. |
void |
setForceDirectedLayoutParameters(double springEquilibriumDistance,
double particleRepulsionConstant,
double springConstant)
This methods sets the parameters for force directed layout. |
void |
setJComponent(javax.swing.JComponent jc)
This method is invoked by the constructor of an InterpretedTokenCanvas. |
static void |
setLoggingLevel(java.util.logging.Level level)
Allows the logging level for the CIDER logger to be set. |
void |
solve()
Calls the solver to solve all constraints. |
boolean |
undoActions(int index)
Will undo actions that occurred after a specific time, as indicated by the index value. |
void |
variableModified(ConstraintVariableEvent event)
Implemented for an internally used interface. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String VERSION
| Method Detail |
public void applyForceDirectedLayout(int timeStep)
timeStep - The time (in milliseconds) between animation steps. Note that this is the minimum time -
calculation of the next layout iteration may take longer than the value specified.public void setJComponent(javax.swing.JComponent jc)
InterpretedTokenCanvas. It should not
be invoked at any other time.
public javax.swing.JComponent getJComponent()
JComponent associated with the visual representation of the diagram
being stored by this Interpreter instance (or null if there is none). Typically, this should
be an instance of an InterpretedTokenCanvas.
public void setForceDirectedLayoutParameters(double springEquilibriumDistance,
double particleRepulsionConstant,
double springConstant)
springEquilibriumDistance - The equilibrium distance that the spring force tries to achieve between graph nodes
that are connected by a graph edge. Default value is 25.0particleRepulsionConstant - Used to calculate the repulsive force between each pair of graph nodes (both connected and
unconnected), which drops of quadratically as the distance between nodes increases. Default value is 400.0
Force = ParticleRepulsionConstant / (Distance * Distance)springConstant - Used to calculate spring force between connected graph nodes. Default value is 0.5
Force = SpringConstant * | Distance - SpringEquilibriumDistance | public static void setLoggingLevel(java.util.logging.Level level)
Level.INFO. Logging can be turned off by using Level.OFF, and all messages
will be logged if Level.ALL is used.
level - The logging level to be set.public abstract void evaluateProductionRules()
public abstract boolean applyTransformation(int transformation)
throws java.lang.IllegalArgumentException
transformation - The transformation to be applied.
true if the transformation was successful, false otherwise.
java.lang.IllegalArgumentException - If an unknown transformation is specified.
public abstract boolean applyTransformationInParallel(int transformation)
throws java.lang.IllegalArgumentException
transformation - The transformation to be applied.
true if the transformation was successful, false otherwise.
java.lang.IllegalArgumentException - If an unknown transformation is specified, or a
a transformation is specified that cannot be applied in parallel (such as a compound transformation).
public abstract boolean applyTransformationWithMapping(int transformation,
boolean parallel,
java.util.Map candidatesMap)
throws java.lang.IllegalArgumentException
transformation - The transformation to be applied. Must be a basic transformation (not a disjunction or compound transformation).parallel - true applies the transformation in parallel, false does not.candidatesMap - Contains a mapping of String objects to Set objects.
Each String object should be the name of an input or referable existential symbol in the transformation specified (as it
appears in the input specification). The corresponding Set object should contain a collection of candidate symbols,
each of which must be of the correct type. That is, if the name corresponds to a symbol of type Circle, the Set
should only contain Circle objects.
true if the transformation was successful, false otherwise.
java.lang.IllegalArgumentException - If an unknown transformation is specified, or the candidates mapping contains
objects of the wrong type.public java.util.Set getAllSymbols()
public boolean addTerminalSymbol(GrammarSymbol symbol)
symbol - The symbol to be added.
true if successful, false if the symbol
is not a terminal symbol, or is already present in the parse forest of this or another Interpreter.public boolean removeTerminalSymbol(GrammarSymbol symbol)
symbol - The symbol to be removed.
true if successful, false if the symbol
is not a terminal symbol, or is not present in the parse forest of this Interpreter.public boolean removeSubTree(GrammarSymbol symbol)
symbol - The symbol to be removed.
true if successful, false if the symbol
is not present in the parse forest of this Interpreter.public void resolve()
public void solve()
public void printForest(java.io.PrintStream stream)
stream - The output stream where the text is sent to.public boolean isUpToDate()
true if the parse forest is up to date, false otherwise.
public void addGrammarSymbolListener(GrammarSymbolListener gsl)
gsl - The listener to be added.public void removeGrammarSymbolListener(GrammarSymbolListener gsl)
gsl - The listener to be removed.public boolean isAutoForestCheckingOn()
true if auto forest checking is on, false otherwise.
Auto forest checking means that each change that is made to the forest (via a symbol
being added, removed or modified), will result in checks to ensure that the forest
is in a valid state and up to date.
public void setAutoForestChecking(boolean on)
on - true to turn on, false to turn off.public boolean isAutoConstraintSolvingOn()
true if auto constraint solving is on, false otherwise.
Auto constraint solving means that the multi-way constraint solver will automatically
enforce any constraints that it is responsible for, ensuring that the parse forest remains in a valid state.
public void setAutoConstraintSolving(boolean on)
on - true to turn on, false to turn off.public void checkForest()
public void reevaluateForest()
public void variableModified(ConstraintVariableEvent event)
variableModified in interface ConstraintVariableListenerpublic boolean isUndoEnabled()
true if the undo feature is currently enabled, false otherwise.
public void enableUndo()
public void disableUndo()
public int getUndoIndex()
undoActions(int) method).
public boolean undoActions(int index)
index - The index in the undo action list (obtained from getUndoIndex()).
true if successful, false if undo is not enabled,
or an invalid index value is given.
|
CIDER Toolkit Version 0.3.0 |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||