Package org.svvrl.goal.core.draw
Class DrawerUtils
java.lang.Object
org.svvrl.goal.core.draw.DrawerUtils
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
public class DrawerUtils
extends java.lang.Object
implements java.beans.PropertyChangeListener
This class provides some utility methods for drawing an automaton.
- Author:
- Ming-Hsien Tsai
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean
use_double_circle
Indicates if an additional shape should be used for accepting states. -
Constructor Summary
Constructors Constructor Description DrawerUtils()
-
Method Summary
Modifier and Type Method Description void
clearAboveTransitionPropertyNames(Automaton aut)
Clear the custom property names to be displayed above a transition.void
clearBelowStatePropertyNames(Automaton aut)
Clear the custom property names to be displayed below a state.Node
drawState(Automaton aut, State s)
Returns a node that visually represents an automaton state.Node
drawState(Automaton aut, State s, java.awt.Color color, java.awt.Color text_color, int opacity, int onState, java.util.List<java.lang.String> belowState)
Returns a node that visually represents an automaton state.Curve
drawTransition(Transition tran, Node fromNode, Node toNode, int index, boolean visible, int ascent)
Draws a curve corresponding to a transition.Curve
drawTransition(Transition tran, Node fromNode, Node toNode, int index, boolean visible, int ascent, java.awt.Color color, java.awt.Color text_color, int opacity, java.util.List<java.lang.String> aboveTransition)
Draws a curve corresponding to a transition.java.util.List<java.lang.String>
getAboveTransitionPropertyNames(Automaton aut)
Returns the property names to be displayed above a transition.java.util.List<java.lang.String>
getBelowStatePropertyNames(Automaton aut)
Returns the property names to be displayed below a state.java.awt.Color
getComponentColor(GraphicComponent comp, java.awt.Color def)
Returns the drawing color of a specified graphic component.java.awt.Color
getComponentTextColor(GraphicComponent comp, java.awt.Color def)
Returns the text color of a specified graphic component.java.lang.String
getDisplayedLabel(State s)
Returns the label to be displayed below a state.java.lang.String
getDisplayedLabel(Transition t)
Returns the label to be displayed above a specified transition.java.awt.Point[]
getInitialIndicator(java.awt.geom.Point2D center, int radius, Orientation orient)
Returns a path that forms an initial indicator for a state at a specified location and with a specified radius.Orientation
getInitialTrianglePosition(State state)
Computes the orientation of the initial triangle of a state.static DrawerUtils
getInstance()
Returns an instance ofDrawerUtils
.Orientation
getLoopPosition(State state)
Decides the orientation of a self-loop.java.lang.String
getOnStateText(State s)
Returns the text to be displayed on a state.java.awt.Image
getStateImage(State state, boolean init)
Returns an image where a state is drawn.boolean
isAcceptingColorStyled()
Returnstrue
if accepting states are displayed with the accepting color.boolean
isAcceptingDoubleCircleStyled()
Returnstrue
if accepting states are displayed with double circles.void
propertyChange(java.beans.PropertyChangeEvent e)
void
setAboveTransitionPropertyNames(Automaton aut, java.lang.String[] names)
Sets the names of the properties to be displayed above a transition.void
setAboveTransitionPropertyNames(Automaton aut, java.util.Collection<java.lang.String> names)
Sets the names of the properties to be displayed above a transition.void
setBelowStatePropertyNames(Automaton aut, java.lang.String[] names)
Sets the names of the properties to be displayed below a state.void
setBelowStatePropertyNames(Automaton aut, java.util.Collection<java.lang.String> names)
Sets the names of the properties to be displayed below a state.
-
Field Details
-
use_double_circle
boolean use_double_circleIndicates if an additional shape should be used for accepting states.
-
-
Constructor Details
-
DrawerUtils
public DrawerUtils()
-
-
Method Details
-
getInstance
Returns an instance ofDrawerUtils
.- Returns:
- an instance of
DrawerUtils
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
isAcceptingColorStyled
public boolean isAcceptingColorStyled()Returnstrue
if accepting states are displayed with the accepting color.- Returns:
true
if accepting states are displayed with the accepting color
-
isAcceptingDoubleCircleStyled
public boolean isAcceptingDoubleCircleStyled()Returnstrue
if accepting states are displayed with double circles.- Returns:
true
if accepting states are displayed with double circles
-
getInitialIndicator
public java.awt.Point[] getInitialIndicator(java.awt.geom.Point2D center, int radius, Orientation orient)Returns a path that forms an initial indicator for a state at a specified location and with a specified radius.- Parameters:
center
- the central location of the initial stateradius
- the radius of the initial stateorient
- the orient of the initial indicator- Returns:
- a path that forms an initial indicator for the initial state at a specified location and with a specified radius
-
getInitialTrianglePosition
Computes the orientation of the initial triangle of a state.- Parameters:
state
- a state- Returns:
- the orientation of the initial triangle of
state
- Created by:
- Conion Wu, modified by Jinn-Shu Chang
-
getLoopPosition
Decides the orientation of a self-loop.- Parameters:
state
- a state that has a self-loop- Returns:
- the orientation of the self-loop of
state
- Created by:
- Conion Wu
-
getComponentColor
Returns the drawing color of a specified graphic component. The priority of the returned color is (1) the custom color of the component, (2) the accepting color if the component is in the NBW-like acceptance condition, and (3) the default colordef
.- Parameters:
comp
- a graphic componentdef
- the default color- Returns:
- the drawing color of
comp
-
getComponentTextColor
Returns the text color of a specified graphic component. For transitions, the priority of the returned color is (1) the custom text color of the component, (2) the accepting color if the component is in the NTBW-like acceptance condition, and (3) the default colordef
.- Parameters:
comp
- a graphic componentdef
- the default color- Returns:
- the text color of
comp
-
drawState
Returns a node that visually represents an automaton state. The accepting style of the returned node will be decided by the user's preference. The opacity, information displayed on the state, and properties displayed below the state are determined by the properties set on the state and the user's preference.- Parameters:
aut
- an automaton containing the state to be drawns
- a state to be drawn- Returns:
- a node that visually represents the state
- See Also:
drawState(Automaton, State, Color, Color, int, int, List)
-
drawState
public Node drawState(Automaton aut, State s, java.awt.Color color, java.awt.Color text_color, int opacity, int onState, java.util.List<java.lang.String> belowState)Returns a node that visually represents an automaton state. The automaton can be an FSA, an alternating automaton, or a game graph. The accepting style of the returned node will be decided by the user's preference.- Parameters:
aut
- an automaton containing the state to be drawns
- a state to be drawncolor
- the color of the statetext_color
- the color of the text on the stateopacity
- the opacity of the stateonState
- a flag indicating the information to be displayed on the statebelowState
- a list of property names indicating what properties should be displayed below the state- Returns:
- a node that visually represents the state
-
drawTransition
public Curve drawTransition(Transition tran, Node fromNode, Node toNode, int index, boolean visible, int ascent)Draws a curve corresponding to a transition. The color, opacity, and properties displayed above the transition are decided by properties set on the transition and the user's preference.- Parameters:
tran
- a transition to be displayedfromNode
- the node that represents the source state of the transitiontoNode
- the node that represents the destination state of the transitionindex
- an index oftran
among all transitions from the source state oftran
to the destination state oftran
visible
-true
if the curve corresponding totran
is visibleascent
- the font ascent of the current graphic context- Returns:
- a curve corresponding to a transition to be drawn on the screen
- See Also:
drawTransition(Transition, Node, Node, int, boolean, int, Color, Color, int, List)
-
drawTransition
public Curve drawTransition(Transition tran, Node fromNode, Node toNode, int index, boolean visible, int ascent, java.awt.Color color, java.awt.Color text_color, int opacity, java.util.List<java.lang.String> aboveTransition)Draws a curve corresponding to a transition. The curve may benull
because the source node of the curve or the destination node of the curve has been deleted.- Parameters:
tran
- a transition to be displayedfromNode
- the node that represents the source state of the transitiontoNode
- the node that represents the destination state of the transitionindex
- an index oftran
among all transitions from the source state oftran
to the destination state oftran
visible
-true
if the curve corresponding totran
is visibleascent
- the font ascent of the current graphic contextcolor
- the line color of the transitiontext_color
- the color of the text on the transitionopacity
- the opacity of the transitionaboveTransition
- a list of property names indicating what properties should be displayed above the transition- Returns:
- a curve corresponding to a transition to be drawn on the screen
-
getOnStateText
Returns the text to be displayed on a state.- Parameters:
s
- a state- Returns:
- the text to be displayed on a state
- See Also:
Preference.OnStatePropertyKey
-
setBelowStatePropertyNames
public void setBelowStatePropertyNames(Automaton aut, java.util.Collection<java.lang.String> names)Sets the names of the properties to be displayed below a state. If the input names is empty, then no property will be displayed.- Parameters:
aut
- an automatonnames
- the names of the properties to be displayed below a state.
-
setBelowStatePropertyNames
Sets the names of the properties to be displayed below a state. If the input names is empty, then no property will be displayed.- Parameters:
aut
- an automatonnames
- the names of the properties to be displayed below a state.
-
clearBelowStatePropertyNames
Clear the custom property names to be displayed below a state. The system default property names below a state will be displayed.- Parameters:
aut
- an automaton
-
getBelowStatePropertyNames
Returns the property names to be displayed below a state. If there are custom properties names set for the specified automaton, the custom properties names will be returned. Otherwise, the system default property names will be returned.- Parameters:
aut
- an automaton- Returns:
- the property names to be displayed below a state
-
setAboveTransitionPropertyNames
public void setAboveTransitionPropertyNames(Automaton aut, java.util.Collection<java.lang.String> names)Sets the names of the properties to be displayed above a transition. If the input names is empty, then no property will be displayed.- Parameters:
aut
- an automatonnames
- the names of the properties to be displayed above a transition.
-
setAboveTransitionPropertyNames
Sets the names of the properties to be displayed above a transition. If the input names is empty, then no property will be displayed.- Parameters:
aut
- an automatonnames
- the names of the properties to be displayed above a transition.
-
clearAboveTransitionPropertyNames
Clear the custom property names to be displayed above a transition. The system default property names below a state will be displayed.- Parameters:
aut
- an automaton
-
getAboveTransitionPropertyNames
Returns the property names to be displayed above a transition. If there are custom properties names set for the specified automaton, the custom properties names will be returned. Otherwise, the system default property names will be returned.- Parameters:
aut
- an automaton- Returns:
- the property names to be displayed below a state
-
getDisplayedLabel
Returns the label to be displayed below a state. The displayed label may contain several properties of a state.- Parameters:
s
- a state- Returns:
- the label to be displayed below a state
-
getDisplayedLabel
Returns the label to be displayed above a specified transition. The displayed label may contain several properties of the transition.- Parameters:
t
- a transition- Returns:
- the label to be displayed above the transition
-
getStateImage
Returns an image where a state is drawn.- Parameters:
state
- a stateinit
-true
to draw also the initial indicator- Returns:
- an image where the state is drawn
-