Package net.sf.jaxodraw.gui
Class JaxoTab
java.lang.Object
net.sf.jaxodraw.gui.JaxoTab
One tab of the JaxoTabbedPane.
- Since:
- 2.0
-
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 TypeMethodDescriptionvoid
ChangeEvents will be fired when a graph change is performed, basically this means when the properties "canUndo", "canRedo", "isSaved" and "saveFileName" may have changed.static JaxoTab
Determine if a component is a JaxoTab.boolean
canRedo()
Determines if redo is possible.boolean
canUndo()
Determines if undo is possible.void
Clear undo history.void
Commit changes to 'tabGraph' to the undo history.void
Commit changes to 'tabGraph' to the undo history, where the change is the addition of the last object that should be repeatable.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.protected void
Notifies all listeners of state changes.getGrid()
Returns the current grid.final Color
Returns the current color of the grid.final int
Returns the current size of the grid.final int
Returns the current style of the grid.final int
Returns the current type of the grid.final JComponent
getRoot()
Returns the root component of this tab.final String
Returns the current save file name.final JaxoGraph
Returns this tab's graph.int
Returns the tab mode.final String
Returns this tab's title.boolean
Indicates whether this tab has been used.boolean
Check if the grid is switched on.boolean
isSaved()
Determines if the graph is saved.final boolean
Determines whether snapping to the grid is currently on.void
newGraph()
Starts a new graph for this tab.void
redoMove()
Redo last operation.void
Removes a change listener.final void
Initialize the canvas with this tab's graph and grid.final void
setGridColor
(Color color) Sets the color of the grid.void
setGridPainted
(boolean on) Switch on the grid.final void
setGridSize
(int gs) Sets the size of the grid to the given value.final void
setGridStyle
(int style) Sets the style of the grid.final void
setGridType
(int type) Sets the type of the grid.void
setSaved
(boolean value) Sets the tab saved / not saved.void
setSaveFileName
(String value) Sets the save file name.final void
setSnappingToGrid
(boolean value) Switches snapping to the grid on/off.void
setTabMode
(int mode) Sets the tab mode.final void
setTabTitle
(String theTitle) Sets this tab's title.void
undoMove()
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
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
Returns the root component of this tab.- Returns:
- The root component.
-
getTabGraph
Returns this tab's graph.- Returns:
- This tab's graph.
-
getTabTitle
Returns this tab's title.- Returns:
- This tab's title.
-
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
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 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.
-