Package net.sf.jaxodraw.gui
Class JaxoTab
- java.lang.Object
-
- net.sf.jaxodraw.gui.JaxoTab
-
public class JaxoTab extends java.lang.ObjectOne tab of the JaxoTabbedPane.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description JaxoTab(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChangeListener(javax.swing.event.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.static JaxoTabasJaxoTab(java.awt.Component c)Determine if a component is a JaxoTab.booleancanRedo()Determines if redo is possible.booleancanUndo()Determines if undo is possible.voidclearBackupList()Clear undo history.voidcommitGraphChanges()Commit changes to 'tabGraph' to the undo history.voidcommitRepeatableGraphChanges()Commit 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 voidfireStateChanged()Notifies all listeners of state changes.JaxoPaintableGridgetGrid()Returns the current grid.java.awt.ColorgetGridColor()Returns the current color of the grid.intgetGridSize()Returns the current size of the grid.intgetGridStyle()Returns the current style of the grid.intgetGridType()Returns the current type of the grid.javax.swing.JComponentgetRoot()Returns the root component of this tab.java.lang.StringgetSaveFileName()Returns the current save file name.JaxoGraphgetTabGraph()Returns this tab's graph.intgetTabMode()Returns the tab mode.java.lang.StringgetTabTitle()Returns this tab's title.booleanhasBeenUsed()Indicates whether this tab has been used.booleanisGridPainted()Check if the grid is switched on.booleanisSaved()Determines if the graph is saved.booleanisSnappingToGrid()Determines whether snapping to the grid is currently on.voidnewGraph()Starts a new graph for this tab.voidredoMove()Redo last operation.voidremoveChangeListener(javax.swing.event.ChangeListener l)Removes a change listener.voidrevalidate()Initialize the canvas with this tab's graph and grid.voidsetGridColor(java.awt.Color color)Sets the color of the grid.voidsetGridPainted(boolean on)Switch on the grid.voidsetGridSize(int gs)Sets the size of the grid to the given value.voidsetGridStyle(int style)Sets the style of the grid.voidsetGridType(int type)Sets the type of the grid.voidsetSaved(boolean value)Sets the tab saved / not saved.voidsetSaveFileName(java.lang.String value)Sets the save file name.voidsetSnappingToGrid(boolean value)Switches snapping to the grid on/off.voidsetTabMode(int mode)Sets the tab mode.voidsetTabTitle(java.lang.String theTitle)Sets this tab's title.voidundoMove()Undo last operation.
-
-
-
Constructor Detail
-
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 Detail
-
asJaxoTab
public static JaxoTab asJaxoTab(java.awt.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 javax.swing.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 java.lang.String getTabTitle()
Returns this tab's title.- Returns:
- This tab's title.
-
setTabTitle
public final void setTabTitle(java.lang.String theTitle)
Sets this tab's title.- Parameters:
theTitle- The new title.
-
addChangeListener
public void addChangeListener(javax.swing.event.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(javax.swing.event.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 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
public final void setGridColor(java.awt.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 java.awt.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(java.lang.String value)
Sets the save file name.- Parameters:
value- The name to set.
-
getSaveFileName
public final java.lang.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.
-
-