Package it.univr.wordautomata.model
Class Model
java.lang.Object
it.univr.wordautomata.model.Model
The Model class represents the model component of the Word Automata
application. It stores the
State
of the application, including the
theme, graph, initial state, placement strategies, playback speed and state,
and various boolean properties. The Model class follows the Singleton
design pattern to ensure that only one instance of the class exists
throughout the application.-
Property Summary
TypePropertyDescriptionjavafx.beans.property.SimpleBooleanProperty
Returns a property telling if there is at least one edge in the current graphjavafx.beans.property.SimpleBooleanProperty
Returns a property telling if there is at least one vertex in the current graphjavafx.beans.property.SimpleBooleanProperty
Returns the auto position property.javafx.beans.property.SimpleIntegerProperty
Returns a property telling if there is at least one final state in the current graph.javafx.beans.property.SimpleObjectProperty
<State> Returns the initial state as a property.javafx.beans.property.SimpleObjectProperty
<File> Returns the opened file property.javafx.beans.property.SimpleBooleanProperty
Returns a property telling if a path has been found.javafx.beans.property.SimpleObjectProperty
<Constants.PlayBackSpeed> Returns the current playback speed as a property.javafx.beans.property.SimpleObjectProperty
<Constants.PlayBackState> Returns the playback state as a property.javafx.beans.property.SimpleBooleanProperty
Returns the saved property.javafx.beans.property.SimpleObjectProperty
<Constants.Theme> Returns the current theme property of the application. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.property.SimpleBooleanProperty
Returns the buttons enabled property.javafx.beans.property.SimpleBooleanProperty
Returns a property telling if there is at least one edge in the current graphjavafx.beans.property.SimpleBooleanProperty
Returns a property telling if there is at least one vertex in the current graphjavafx.beans.property.SimpleBooleanProperty
Returns the auto position property.void
clear()
Clears the graph.Cycles the playback state and returns the next one.Cycles playback speed and returns the next one.Cycles the theme of the application.javafx.beans.property.SimpleIntegerProperty
Returns a property telling if there is at least one final state in the current graph.com.brunomnsilva.smartgraph.graphview.ForceDirectedLayoutStrategy
<State> Returns the automatic placement strategy.ListIterator
<com.brunomnsilva.smartgraph.graph.Edge<Transition, State>> Returns an iterator to a list of edges to color.com.brunomnsilva.smartgraph.graph.DigraphEdgeList
<State, Transition> getGraph()
Returns the current shown graph as a DigraphEdgeList.com.brunomnsilva.smartgraph.graphview.SmartPlacementStrategy
Returns the initial placement strategy.Returns the initial state of the automata.com.brunomnsilva.smartgraph.graph.Vertex
<State> Returns the initial vertex of the automata (linked to the initial state).static Model
Returns the single instance of the Model class.Returns the opened file.Returns the current playback state of the application.getSpeed()
Returns the current playback speed.getTheme()
Returns the theme of the application as Enumboolean
Check if the application has at least one edge.boolean
Check if the application has at least one vertex.boolean
Check if the application has found a path.javafx.beans.property.SimpleObjectProperty
<State> Returns the initial state as a property.com.brunomnsilva.smartgraph.graph.DigraphEdgeList
<State, Transition> Initializes a sample graph (given in the assignment).boolean
Check if the auto position property is enabled.javafx.beans.property.SimpleBooleanProperty
Tells if the play next button has been pressed.javafx.beans.property.SimpleBooleanProperty
Returns the play previous pressed property.boolean
isSaved()
Check if the graph has been saved.javafx.beans.property.SimpleObjectProperty
<File> Returns the opened file property.javafx.beans.property.SimpleBooleanProperty
Returns a property telling if a path has been found.javafx.beans.property.SimpleObjectProperty
<Constants.PlayBackSpeed> Returns the current playback speed as a property.javafx.beans.property.SimpleObjectProperty
<Constants.PlayBackState> Returns the playback state as a property.javafx.beans.property.SimpleBooleanProperty
Returns the saved property.void
setAutoPosition
(boolean value) Sets the auto position property.void
setEdgeToColor
(ListIterator<com.brunomnsilva.smartgraph.graph.Edge<Transition, State>> edgeToColor) Sets the iterator.void
Sets the initial state of the automata.void
setOpenedFile
(File file) Sets the opened file.void
setPathFound
(boolean value) Sets the path found property.void
setSaved
(boolean value) Sets the saved property.void
setTheme
(Constants.Theme theme) Sets the theme of the application.javafx.beans.property.SimpleObjectProperty
<Constants.Theme> Returns the current theme property of the application.void
Toggles the auto position property.void
updateGraph
(com.brunomnsilva.smartgraph.graph.DigraphEdgeList<State, Transition> graph) Updates the graph by copying the given graph.void
Updates the graph property reflecting the current state of the graph.
-
Property Details
-
theme
Returns the current theme property of the application.- See Also:
-
initialState
Returns the initial state as a property.- See Also:
-
playBackSpeed
Returns the current playback speed as a property.- See Also:
-
playBackState
Returns the playback state as a property.- See Also:
-
autoPosition
public javafx.beans.property.SimpleBooleanProperty autoPositionPropertyReturns the auto position property.- See Also:
-
atLeastOneVertex
public javafx.beans.property.SimpleBooleanProperty atLeastOneVertexPropertyReturns a property telling if there is at least one vertex in the current graph- See Also:
-
atLeastOneEdge
public javafx.beans.property.SimpleBooleanProperty atLeastOneEdgePropertyReturns a property telling if there is at least one edge in the current graph- See Also:
-
finalStatesCount
public javafx.beans.property.SimpleIntegerProperty finalStatesCountPropertyReturns a property telling if there is at least one final state in the current graph.- See Also:
-
pathFound
public javafx.beans.property.SimpleBooleanProperty pathFoundPropertyReturns a property telling if a path has been found.- See Also:
-
openedFile
Returns the opened file property.- See Also:
-
saved
public javafx.beans.property.SimpleBooleanProperty savedPropertyReturns the saved property.- See Also:
-
-
Method Details
-
getInstance
Returns the single instance of the Model class.- Returns:
- the single instance of the Model class
-
themeProperty
Returns the current theme property of the application.- Returns:
- the current theme property of the application
- See Also:
-
getTheme
Returns the theme of the application as Enum- Returns:
- the theme of the application as Enum
-
setTheme
Sets the theme of the application.- Parameters:
theme
- the theme to set
-
cycleTheme
Cycles the theme of the application.- Returns:
- the next theme
-
getGraph
Returns the current shown graph as a DigraphEdgeList.- Returns:
- the current graph
-
initSampleGraph
Initializes a sample graph (given in the assignment).- Returns:
- the sample graph
-
setInitialState
Sets the initial state of the automata.- Parameters:
s
- the initial state to set
-
getInitialState
Returns the initial state of the automata.- Returns:
- the initial state of the automata
-
getInitialVertex
Returns the initial vertex of the automata (linked to the initial state).- Returns:
- the initial vertex of the application
-
initialStateProperty
Returns the initial state as a property.- Returns:
- the initial state as a property
- See Also:
-
getInitialPlacement
public com.brunomnsilva.smartgraph.graphview.SmartPlacementStrategy getInitialPlacement()Returns the initial placement strategy.- Returns:
- the initial placement strategy
-
getAutomaticPlacementStrategy
public com.brunomnsilva.smartgraph.graphview.ForceDirectedLayoutStrategy<State> getAutomaticPlacementStrategy()Returns the automatic placement strategy.- Returns:
- the automatic placement strategy
-
getSpeed
Returns the current playback speed.- Returns:
- the current playback speed
-
cycleSpeed
Cycles playback speed and returns the next one.- Returns:
- the next playback speed
-
cyclePlayBackState
Cycles the playback state and returns the next one.- Returns:
- the next playback state
-
getPlayBackState
Returns the current playback state of the application.- Returns:
- the current playback state of the application
-
playBackSpeedProperty
Returns the current playback speed as a property.- Returns:
- the playback speed property of the application
-
playBackStateProperty
Returns the playback state as a property.- Returns:
- the playback state property
- See Also:
-
isPlayNextPressed
public javafx.beans.property.SimpleBooleanProperty isPlayNextPressed()Tells if the play next button has been pressed.- Returns:
- the play next pressed property
-
isPlayPrevPressed
public javafx.beans.property.SimpleBooleanProperty isPlayPrevPressed()Returns the play previous pressed property.- Returns:
- the play previous pressed property
-
areButtonsEnabled
public javafx.beans.property.SimpleBooleanProperty areButtonsEnabled()Returns the buttons enabled property.- Returns:
- the buttons enabled property
-
setAutoPosition
public void setAutoPosition(boolean value) Sets the auto position property.- Parameters:
value
- the value to set
-
autoPositionProperty
public javafx.beans.property.SimpleBooleanProperty autoPositionProperty()Returns the auto position property.- Returns:
- the auto position property
- See Also:
-
isAutoPositioningEnabled
public boolean isAutoPositioningEnabled()Check if the auto position property is enabled.- Returns:
- true if the auto position property is enabled, false otherwise
-
toggleAutoPositioning
public void toggleAutoPositioning()Toggles the auto position property. -
atLeastOneVertexProperty
public javafx.beans.property.SimpleBooleanProperty atLeastOneVertexProperty()Returns a property telling if there is at least one vertex in the current graph- Returns:
- the at least one vertex property
-
atLeastOneEdgeProperty
public javafx.beans.property.SimpleBooleanProperty atLeastOneEdgeProperty()Returns a property telling if there is at least one edge in the current graph- Returns:
- the at least one edge property
-
finalStatesCountProperty
public javafx.beans.property.SimpleIntegerProperty finalStatesCountProperty()Returns a property telling if there is at least one final state in the current graph.- Returns:
- the at least one final state property
-
hasAtLeastOneVertex
public boolean hasAtLeastOneVertex()Check if the application has at least one vertex.- Returns:
- true if the application has at least one vertex, false otherwise
-
hasAtLeastOneEdge
public boolean hasAtLeastOneEdge()Check if the application has at least one edge.- Returns:
- true if the application has at least one edge, false otherwise
-
updateGraphProperties
public void updateGraphProperties()Updates the graph property reflecting the current state of the graph. -
pathFoundProperty
public javafx.beans.property.SimpleBooleanProperty pathFoundProperty()Returns a property telling if a path has been found.- Returns:
- the path found property
- See Also:
-
hasPathFound
public boolean hasPathFound()Check if the application has found a path.- Returns:
- true if the application has found a path, false otherwise
-
setPathFound
public void setPathFound(boolean value) Sets the path found property.- Parameters:
value
- the value to set
-
updateGraph
Updates the graph by copying the given graph.- Parameters:
graph
- the graph to set
-
setOpenedFile
Sets the opened file.- Parameters:
file
- the file to set
-
getOpenedFile
Returns the opened file.- Returns:
- the opened file
-
openedFileProperty
Returns the opened file property.- Returns:
- the opened file property
- See Also:
-
setSaved
public void setSaved(boolean value) Sets the saved property.- Parameters:
value
- the value to set
-
savedProperty
public javafx.beans.property.SimpleBooleanProperty savedProperty()Returns the saved property.- Returns:
- the saved property
- See Also:
-
isSaved
public boolean isSaved()Check if the graph has been saved.- Returns:
- true if the graph has been saved, false otherwise
-
clear
public void clear()Clears the graph. -
getEdgesToColor
Returns an iterator to a list of edges to color.- Returns:
- the iterator to a list of edges to color
-
setEdgeToColor
public void setEdgeToColor(ListIterator<com.brunomnsilva.smartgraph.graph.Edge<Transition, State>> edgeToColor) Sets the iterator.- Parameters:
edgeToColor
- the iterator to set
-