Class JaxoTab

java.lang.Object
net.sf.jaxodraw.gui.JaxoTab

public class JaxoTab extends Object
One tab of the JaxoTabbedPane.
Since:
2.0
  • Constructor Details

    • JaxoTab

      public JaxoTab(JaxoDrawingArea canvas)
      Constructor.
      Parameters:
      canvas - the drawing area on which to paint this tab.
    • JaxoTab

      public JaxoTab(JaxoDrawingArea canvas, JaxoGraph g)
      Constructor.
      Parameters:
      canvas - the drawing area on which to paint this tab.
      g - The graph for the tab.
    • JaxoTab

      public JaxoTab(JaxoDrawingArea canvas, JaxoPaintableGrid g)
      Constructor.
      Parameters:
      canvas - the drawing area on which to paint this tab.
      g - A grid for the tab.
    • JaxoTab

      public JaxoTab(JaxoDrawingArea canvas, JaxoGraph g, JaxoPaintableGrid grid)
      Constructor.
      Parameters:
      canvas - the drawing area on which to paint this tab.
      g - A graph.
      grid - A grid. May be null.
  • Method Details

    • asJaxoTab

      public static JaxoTab asJaxoTab(Component c)
      Determine if a component is a JaxoTab.
      Parameters:
      c - The component to test.
      Returns:
      The component as a JaxoTab, or null if it was not a JaxoTab.
    • getRoot

      public final JComponent getRoot()
      Returns the root component of this tab.
      Returns:
      The root component.
    • getTabGraph

      public final JaxoGraph getTabGraph()
      Returns this tab's graph.
      Returns:
      This tab's graph.
    • getTabTitle

      public final String getTabTitle()
      Returns this tab's title.
      Returns:
      This tab's title.
    • setTabTitle

      public final void setTabTitle(String theTitle)
      Sets this tab's title.
      Parameters:
      theTitle - The new title.
    • addChangeListener

      public void addChangeListener(ChangeListener l)
      ChangeEvents will be fired when a graph change is performed, basically this means when the properties "canUndo", "canRedo", "isSaved" and "saveFileName" may have changed.
      Parameters:
      l - The listener to add.
    • removeChangeListener

      public void removeChangeListener(ChangeListener l)
      Removes a change listener.
      Parameters:
      l - The listener to remove.
    • fireStateChanged

      protected void fireStateChanged()
      Notifies all listeners of state changes.
    • revalidate

      public final void revalidate()
      Initialize the canvas with this tab's graph and grid.
    • getGrid

      public JaxoPaintableGrid getGrid()
      Returns the current grid.
      Returns:
      The grid. May be null.
    • setSnappingToGrid

      public final void setSnappingToGrid(boolean value)
      Switches snapping to the grid on/off. If the current grid is null, this method returns silently.
      Parameters:
      value - Boolean that sets the grid on/off.
    • isSnappingToGrid

      public final boolean isSnappingToGrid()
      Determines whether snapping to the grid is currently on.
      Returns:
      True if snapping is enabled, false otherwise or if the grid is null.
    • setGridPainted

      public void setGridPainted(boolean on)
      Switch on the grid.
      Parameters:
      on - true if the grid should be painted, false otherwise.
      Since:
      2.1
    • isGridPainted

      public boolean isGridPainted()
      Check if the grid is switched on.
      Returns:
      true if the grid is painted, false otherwise.
      Since:
      2.1
    • setGridSize

      public final void setGridSize(int gs)
      Sets the size of the grid to the given value. If the current grid is null, this method returns silently.
      Parameters:
      gs - The grid size to be set.
    • getGridSize

      public final int getGridSize()
      Returns the current size of the grid.
      Returns:
      The current grid size, or 0 if the current grid is null.
    • setGridType

      public final void setGridType(int type)
      Sets the type of the grid. If the current grid is null, this method returns silently.
      Parameters:
      type - The type of the grid to be set. One of the types defined in JaxoConstants.
    • getGridType

      public final int getGridType()
      Returns the current type of the grid.
      Returns:
      The type of the grid or 0 if thecurrent grid is null.
    • setGridStyle

      public final void setGridStyle(int style)
      Sets the style of the grid. If the current grid is null, this method returns silently.
      Parameters:
      style - The style of the grid to be set. One of the styles defined in JaxoConstants.
    • getGridStyle

      public final int getGridStyle()
      Returns the current style of the grid.
      Returns:
      The style of the current grid or 0 if the grid is null.
    • setGridColor

      public final void setGridColor(Color color)
      Sets the color of the grid. If the current grid is null, this method returns silently.
      Parameters:
      color - The color of the grid to be set.
    • getGridColor

      public final Color getGridColor()
      Returns the current color of the grid.
      Returns:
      The color of the grid or null if the grid is null.
    • commitGraphChanges

      public void commitGraphChanges()
      Commit changes to 'tabGraph' to the undo history.
    • commitRepeatableGraphChanges

      public void commitRepeatableGraphChanges()
      Commit changes to 'tabGraph' to the undo history, where the change is the addition of the last object that should be repeatable.
    • commitRepeatableGraphChanges

      public void commitRepeatableGraphChanges(int count)
      Commit changes to 'tabGraph' to the undo history, where the change is the addition of 'count' last objects that should be repeatable.
      Parameters:
      count - The number of changes to commit.
    • setSaveFileName

      public void setSaveFileName(String value)
      Sets the save file name.
      Parameters:
      value - The name to set.
    • getSaveFileName

      public final String getSaveFileName()
      Returns the current save file name. This never returns null, at most an empty string.
      Returns:
      The save file name of the current tab.
    • clearBackupList

      public void clearBackupList()
      Clear undo history. Start with a new history, as if newly constructed.
    • newGraph

      public void newGraph()
      Starts a new graph for this tab. This should be equivalent with re-starting, eg it is not un-doable and the new status is saved.
    • undoMove

      public void undoMove()
      Undo last operation.
    • redoMove

      public void redoMove()
      Redo last operation.
    • setTabMode

      public void setTabMode(int mode)
      Sets the tab mode.
      Parameters:
      mode - The tab mode.
    • getTabMode

      public int getTabMode()
      Returns the tab mode.
      Returns:
      The tab mode.
    • hasBeenUsed

      public boolean hasBeenUsed()
      Indicates whether this tab has been used.
      Returns:
      True, if the canvas has been modified, false otherwise.
    • setSaved

      public void setSaved(boolean value)
      Sets the tab saved / not saved.
      Parameters:
      value - True for saved.
    • isSaved

      public boolean isSaved()
      Determines if the graph is saved. This is internally cleared at each change (also undo/redo).
      Returns:
      True if the tab is saved.
    • canUndo

      public boolean canUndo()
      Determines if undo is possible.
      Returns:
      True if undo is possible.
    • canRedo

      public boolean canRedo()
      Determines if redo is possible.
      Returns:
      True if redo is possible.