net.sf.jaxodraw.gui
Class JaxoTab

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

public class JaxoTab
extends java.lang.Object

One tab of the JaxoTabbedPane.

Since:
2.0

Constructor Summary
JaxoTab()
          Constructor.
JaxoTab(JaxoDefaultGrid g)
          Constructor.
JaxoTab(JaxoGraph g)
          Constructor.
JaxoTab(JaxoGraph g, JaxoDefaultGrid grid)
          Constructor.
 
Method Summary
 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.
static JaxoTab asJaxoTab(java.awt.Component c)
          Determine if a component is a JaxoTab.
 boolean canRedo()
          Determines if redo is possible.
 boolean canUndo()
          Determines if undo is possible.
 void clearBackupList()
          Clear undo history.
 void commitGraphChanges()
          Commit changes to 'tabGraph' to the undo history.
 void commitRepeatableGraphChanges()
          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 fireStateChanged()
          Notifies all listeners of state changes.
 JaxoDefaultGrid getGrid()
          Returns the current grid.
 java.awt.Color getGridColor()
          Returns the current color of the grid.
 int getGridSize()
          Returns the current size of the grid.
 int getGridStyle()
          Returns the current style of the grid.
 int getGridType()
          Returns the current type of the grid.
 javax.swing.JComponent getRoot()
          Returns the root component of this tab.
 java.lang.String getSaveFileName()
          Returns the current save file name.
 JaxoGraph getTabGraph()
          Returns this tab's graph.
 int getTabMode()
          Returns the tab mode.
 java.lang.String getTabTitle()
          Returns this tab's title.
 boolean hasBeenUsed()
          Indicates whether this tab has been used.
 boolean isSaved()
          Determines if the graph is saved.
 boolean isSnappingToGrid()
          Determines whether snapping to the grid is currently on.
 void newGraph()
          Starts a new graph for this tab.
 void redoMove()
          Redo last operation.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes a change listener.
 void setCanvas(JaxoCanvas value)
          Redraws the given canvas with this tab's graph.
 void setGridColor(java.awt.Color color)
          Sets the color of the grid.
 void setGridSize(int gs)
          Sets the size of the grid to the given value.
 void setGridStyle(int style)
          Sets the style of the grid.
 void setGridType(int type)
          Sets the type of the grid.
 void setSaved(boolean value)
          Sets the tab saved / not saved.
 void setSaveFileName(java.lang.String value)
          Sets the save file name.
 void setSnappingToGrid(boolean value)
          Switches snapping to the grid on/off.
 void setTabGraph(JaxoGraph theGraph)
          Sets this tab's graph.
 void setTabMode(int mode)
          Sets the tab mode.
 void setTabTitle(java.lang.String theTitle)
          Sets this tab's title.
 void undoMove()
          Undo last operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaxoTab

public JaxoTab()
Constructor.


JaxoTab

public JaxoTab(JaxoGraph g)
Constructor.

Parameters:
g - The graph for the tab.

JaxoTab

public JaxoTab(JaxoDefaultGrid g)
Constructor.

Parameters:
g - A grid for the tab.

JaxoTab

public JaxoTab(JaxoGraph g,
               JaxoDefaultGrid grid)
Constructor.

Parameters:
g - A graph.
grid - A grid.
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.

setTabGraph

public final void setTabGraph(JaxoGraph theGraph)
Sets this tab's graph.

Parameters:
theGraph - The new 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.


setCanvas

public void setCanvas(JaxoCanvas value)
Redraws the given canvas with this tab's graph.

Parameters:
value - The canvas to update.

getGrid

public JaxoDefaultGrid getGrid()
Returns the current grid.

Returns:
The grid.

setSnappingToGrid

public final void setSnappingToGrid(boolean value)
Switches snapping to the grid on/off.

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 the grid is on.

setGridSize

public final void setGridSize(int gs)
Sets the size of the grid to the given value.

Parameters:
gs - The grid size to be set.

getGridSize

public final int getGridSize()
Returns the current size of the grid.

Returns:
The grid size.

setGridType

public final void setGridType(int type)
Sets the type of the grid.

Parameters:
type - The type of the grid to be set.

getGridType

public final int getGridType()
Returns the current type of the grid.

Returns:
The type of the grid.

setGridStyle

public final void setGridStyle(int style)
Sets the style of the grid.

Parameters:
style - The style of the grid to be set.

getGridStyle

public final int getGridStyle()
Returns the current style of the grid.

Returns:
The style of the grid.

setGridColor

public final void setGridColor(java.awt.Color color)
Sets the color of the grid.

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.

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.

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.


Licensed under GPL. For more information, see http://jaxodraw.sourceforge.net/license.html or the LICENSE file in the jaxodraw distribution.