Class JaxoTab
java.lang.Object
net.sf.jaxodraw.gui.JaxoTab
-
Constructor Summary
ConstructorsConstructorDescriptionJaxoTab(JaxoDrawingArea canvas) Constructor.JaxoTab(JaxoDrawingArea canvas, JaxoGraph g) Constructor.JaxoTab(JaxoDrawingArea canvas, JaxoGraph g, JaxoPaintableGrid grid) Constructor.JaxoTab(JaxoDrawingArea canvas, JaxoPaintableGrid g) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidChangeEvents will be fired when a graph change is performed, basically this means when the properties "canUndo", "canRedo", "isSaved" and "saveFileName" may have changed.static JaxoTabDetermine if a component is a JaxoTab.booleancanRedo()Determines if redo is possible.booleancanUndo()Determines if undo is possible.voidClear undo history.voidCommit changes to 'tabGraph' to the undo history.voidCommit changes to 'tabGraph' to the undo history, where the change is the addition of the last object that should be repeatable.voidcommitRepeatableGraphChanges(int count) Commit changes to 'tabGraph' to the undo history, where the change is the addition of 'count' last objects that should be repeatable.protected voidNotifies all listeners of state changes.getGrid()Returns the current grid.final ColorReturns the current color of the grid.final intReturns the current size of the grid.final intReturns the current style of the grid.final intReturns the current type of the grid.final JComponentgetRoot()Returns the root component of this tab.final StringReturns the current save file name.final JaxoGraphReturns this tab's graph.intReturns the tab mode.final StringReturns this tab's title.booleanIndicates whether this tab has been used.booleanCheck if the grid is switched on.booleanisSaved()Determines if the graph is saved.final booleanDetermines whether snapping to the grid is currently on.voidnewGraph()Starts a new graph for this tab.voidredoMove()Redo last operation.voidRemoves a change listener.final voidInitialize the canvas with this tab's graph and grid.final voidsetGridColor(Color color) Sets the color of the grid.voidsetGridPainted(boolean on) Switch on the grid.final voidsetGridSize(int gs) Sets the size of the grid to the given value.final voidsetGridStyle(int style) Sets the style of the grid.final voidsetGridType(int type) Sets the type of the grid.voidsetSaved(boolean value) Sets the tab saved / not saved.voidsetSaveFileName(String value) Sets the save file name.final voidsetSnappingToGrid(boolean value) Switches snapping to the grid on/off.voidsetTabMode(int mode) Sets the tab mode.final voidsetTabTitle(String theTitle) Sets this tab's title.voidundoMove()Undo last operation.
-
Constructor Details
-
JaxoTab
Constructor.- Parameters:
canvas- the drawing area on which to paint this tab.
-
JaxoTab
Constructor.- Parameters:
canvas- the drawing area on which to paint this tab.g- The graph for the tab.
-
JaxoTab
Constructor.- Parameters:
canvas- the drawing area on which to paint this tab.g- A grid for the tab.
-
JaxoTab
Constructor.- Parameters:
canvas- the drawing area on which to paint this tab.g- A graph.grid- A grid. May be null.
-
-
Method Details
-
asJaxoTab
-
getRoot
Returns the root component of this tab.- Returns:
- The root component.
-
getTabGraph
-
getTabTitle
-
setTabTitle
Sets this tab's title.- Parameters:
theTitle- The new title.
-
addChangeListener
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
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
-
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 inJaxoConstants.
-
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 inJaxoConstants.
-
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
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
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
Sets the save file name.- Parameters:
value- The name to set.
-
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.
-