org.graffiti.plugins.modes.advanced
Class Function

java.lang.Object
  extended by org.graffiti.plugins.modes.advanced.Function

public class Function
extends Object

One function a FunctionComponent offers. Usually managed by the FunctionManager of the FunctionComponent. This class stores the name of a function, the associated FunctionAction, parameters for the function and (possibly existing) bindings for that function (for example "ctrl-alt-Q causes CivQuest to quit").


Field Summary
static String SEPARATOR
          The String which separates components and function-names from each other in a String referencing a function (like "civquest.quadmap.whateverFunction").
 
Constructor Summary
Function(String name)
          Constructs a new Function-object for the function with the given name.
 
Method Summary
 void addBinding(String event)
          Adds the given event to the set of bindings.
 void addBindings(Set<String> events)
          Adds all given events to the set of bindings
 void addSuperComponentPrefix(String superComponent)
          Adds the given String as a super-component-prefix to the name of this function.
 FunctionAction getAction()
          Returns the FunctionAction associated to this function.
 Iterator<String> getBindingIterator()
          Returns an Iterator over all bindings of this function.
 String getName()
          Returns the name of this function.
 Iterator<String> getParameterIterator()
          Returns an iterator over all names (Strings) of parameters currently set in this Function.
 Object getParameterValue(String name)
          Returns the value of the given parameter, if it exists, null otherwise.
 Set<String> putParametersIntoAction()
          Adds all parameter-mappings to the FunctionAction of this function.
 void setAction(FunctionAction action)
          Sets the FunctionAction associated to this function.
 void setParameter(String name, Object value)
          Sets the parameter with the given name to the given value.
 void setParameters(Map<String,Object> newParameters)
          Sets all (parameter -> value) - mappings the given Map contains.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR

public static final String SEPARATOR
The String which separates components and function-names from each other in a String referencing a function (like "civquest.quadmap.whateverFunction").

See Also:
Constant Field Values
Constructor Detail

Function

public Function(String name)
Constructs a new Function-object for the function with the given name.

Parameters:
name - name of the function
Method Detail

setAction

public void setAction(FunctionAction action)
Sets the FunctionAction associated to this function.

Parameters:
action - the FunctionAction to be associated to this function

getAction

public FunctionAction getAction()
Returns the FunctionAction associated to this function.

Returns:
the FunctionAction associated to this function.

getBindingIterator

public Iterator<String> getBindingIterator()
Returns an Iterator over all bindings of this function.

Returns:
an Iterator over all bindings of this function.

getName

public String getName()
Returns the name of this function.

Returns:
the name of this function

setParameter

public void setParameter(String name,
                         Object value)
Sets the parameter with the given name to the given value.

Parameters:
name - name of a parameter
value - new value of the parameter

getParameterIterator

public Iterator<String> getParameterIterator()
Returns an iterator over all names (Strings) of parameters currently set in this Function.

Returns:
an iterator over all parameter-names

getParameterValue

public Object getParameterValue(String name)
Returns the value of the given parameter, if it exists, null otherwise.

Parameters:
name - name of a parameter
Returns:
value of the parameter, if it exists, null otherwise

setParameters

public void setParameters(Map<String,Object> newParameters)
Sets all (parameter -> value) - mappings the given Map contains.

Parameters:
newParameters - a Map containing (parameter (String) -> value (Object)) - mappings

addBinding

public void addBinding(String event)
Adds the given event to the set of bindings.

Parameters:
event - String defining an event - see the texinfo-docs for the syntax

addBindings

public void addBindings(Set<String> events)
Adds all given events to the set of bindings

Parameters:
events - a Set of event-Strings (see the texinfo-docs for the syntax)

addSuperComponentPrefix

public void addSuperComponentPrefix(String superComponent)
Adds the given String as a super-component-prefix to the name of this function. In other words, transforms foo to prefix.foo

Parameters:
superComponent - name of the super-component

putParametersIntoAction

public Set<String> putParametersIntoAction()
Adds all parameter-mappings to the FunctionAction of this function. So the action-reference must already be set!!! Returns a Set with all keys which interfere with the predefined keys in javax.swing.Action. (this is done this way because setting these predefined keys/values this way may be wanted, but may also be done accidentally with strange results).

Returns:
Set with all keys interfering with the predefined keys in javax.swing.Action


Generated at 2012-05-30 11:01:25 PM CEST