Class Model

java.lang.Object
it.univr.wordautomata.model.Model

public class Model extends Object
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 Details

  • Method Details

    • getInstance

      public static Model getInstance()
      Returns the single instance of the Model class.
      Returns:
      the single instance of the Model class
    • themeProperty

      public javafx.beans.property.SimpleObjectProperty<Constants.Theme> themeProperty()
      Returns the current theme property of the application.
      Returns:
      the current theme property of the application
      See Also:
    • getTheme

      public Constants.Theme getTheme()
      Returns the theme of the application as Enum
      Returns:
      the theme of the application as Enum
    • setTheme

      public void setTheme(Constants.Theme theme)
      Sets the theme of the application.
      Parameters:
      theme - the theme to set
    • cycleTheme

      public Constants.Theme cycleTheme()
      Cycles the theme of the application.
      Returns:
      the next theme
    • getGraph

      public com.brunomnsilva.smartgraph.graph.DigraphEdgeList<State,Transition> getGraph()
      Returns the current shown graph as a DigraphEdgeList.
      Returns:
      the current graph
    • initSampleGraph

      public com.brunomnsilva.smartgraph.graph.DigraphEdgeList<State,Transition> initSampleGraph()
      Initializes a sample graph (given in the assignment).
      Returns:
      the sample graph
    • setInitialState

      public void setInitialState(State s)
      Sets the initial state of the automata.
      Parameters:
      s - the initial state to set
    • getInitialState

      public State getInitialState()
      Returns the initial state of the automata.
      Returns:
      the initial state of the automata
    • getInitialVertex

      public com.brunomnsilva.smartgraph.graph.Vertex<State> getInitialVertex()
      Returns the initial vertex of the automata (linked to the initial state).
      Returns:
      the initial vertex of the application
    • initialStateProperty

      public javafx.beans.property.SimpleObjectProperty<State> 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

      public Constants.PlayBackSpeed getSpeed()
      Returns the current playback speed.
      Returns:
      the current playback speed
    • cycleSpeed

      public Constants.PlayBackSpeed cycleSpeed()
      Cycles playback speed and returns the next one.
      Returns:
      the next playback speed
    • cyclePlayBackState

      public Constants.PlayBackState cyclePlayBackState()
      Cycles the playback state and returns the next one.
      Returns:
      the next playback state
    • getPlayBackState

      public Constants.PlayBackState getPlayBackState()
      Returns the current playback state of the application.
      Returns:
      the current playback state of the application
    • playBackSpeedProperty

      public javafx.beans.property.SimpleObjectProperty<Constants.PlayBackSpeed> playBackSpeedProperty()
      Returns the current playback speed as a property.
      Returns:
      the playback speed property of the application
    • playBackStateProperty

      public javafx.beans.property.SimpleObjectProperty<Constants.PlayBackState> 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

      public void updateGraph(com.brunomnsilva.smartgraph.graph.DigraphEdgeList<State,Transition> graph)
      Updates the graph by copying the given graph.
      Parameters:
      graph - the graph to set
    • setOpenedFile

      public void setOpenedFile(File file)
      Sets the opened file.
      Parameters:
      file - the file to set
    • getOpenedFile

      public File getOpenedFile()
      Returns the opened file.
      Returns:
      the opened file
    • openedFileProperty

      public javafx.beans.property.SimpleObjectProperty<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

      public ListIterator<com.brunomnsilva.smartgraph.graph.Edge<Transition,State>> 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