fr.umlv.unitex
Class GenericGraphicalZone

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by fr.umlv.unitex.GenericGraphicalZone
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
FstGraphicalZone, GraphicalZone

public abstract class GenericGraphicalZone
extends javax.swing.JComponent

This class describes a component on which a graph can be drawn.

Author:
Sébastien Paumier
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
 int EDITING_MODE
          Indicates mouse's editing mode
 java.util.ArrayList graphBoxes
          ArrayList containing all the graph's boxes
 int Height
          Height of the drawing area.
 boolean isGrid
          Indicates if a grid be drawn in backend
 boolean modified
          Indicates if the graph contains unsaved modifications.
 int nPixels
          Indicates the size of the grid's cells
 javax.swing.JInternalFrame parentFrame
          JInternalFrame that contains this component
 double scaleFactor
          Zoom factor
 java.util.ArrayList selectedBoxes
          ArrayList containing the current selected boxes
 javax.swing.JTextField texte
          Text field in which the content of boxes can be edited.
 int Width
          Width of the drawing area.
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GenericGraphicalZone(int w, int h, javax.swing.JTextField t, javax.swing.JInternalFrame p)
          Constructs a new GenericGraphicalZone.
GenericGraphicalZone(int w, int h, javax.swing.JTextField t, TextAutomatonFrame p)
          Constructs a new GenericGraphicalZone.
 
Method Summary
 void addBox(GenericGraphBox g)
          Adds a graph box to the graph
 void addReverseTransitionsFromSelectedBoxes(GenericGraphBox src)
          Adds transitions from a specified graph box to all selected boxes
 void addTransitionsFromSelectedBoxes(GenericGraphBox dest, boolean save)
          Adds transitions from all selected boxes to a specified graph box
 void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
           
 void drawAllBoxes(java.awt.Graphics2D gr)
          Draws all boxes of the graph
 void drawAllTransitions(java.awt.Graphics2D gr)
          Draws all graph's transitions
 void drawGrid(java.awt.Graphics2D f)
          Draws the grid of the graph if the isGrid field is set to true
 void drawTransitionsFromMousePointerToSelectedBoxes(java.awt.Graphics2D gr)
          Adds transitions from the last mouse click position to all selected boxes
 void drawTransitionsFromSelectedBoxesToMousePointer(java.awt.Graphics2D gr)
          Adds transitions from all selected boxes to the last mouse click position
 java.awt.Rectangle getClipZone()
           
 int getSelectedBox(int x, int y)
          Finds the box that is selected by a click
 java.util.ArrayList getSelectedBoxes()
           
 java.util.ArrayList getTransitionTo(GenericGraphBox dest)
          Removes all transitions that go to a specified graph box
 void HBottomAlign()
          Aligns horizontally all selected boxes on the lower box
 void HCenterAlign()
          Aligns horizontally all selected boxes on the average Y coordinate of these boxes
 void HTopAlign()
          Aligns horizontally all selected boxes on the upper box
 void initText(java.lang.String s)
          Sets the text field content
 void pasteSelection(MultipleSelection m)
          Paste a graph box selection in the graph.
 void postEdit(javax.swing.undo.UndoableEdit e)
           
 void removeSelected()
          Remove all selected graph boxes
 void removeTransitionsToSelected()
          Removes all transitions that go selected graph boxes
 void removeTransitionTo(GenericGraphBox dest)
          Removes all transitions that go to a specified graph box
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
           
 void selectAllBoxes()
          Select all graph boxes
 void selectByRectangle(int x, int y, int w, int h)
          Selects all graph boxes that have a non empty intersection with a selection rectangle
 void setClipZone(java.awt.Rectangle r)
           
 void setGrid(boolean b)
          Sets the isGrid field
 void setGrid(boolean b, int n)
          Sets the isGrid field
 void setModified(boolean b)
          Indicates if the graph must be marked as modified are not
 void setRightToLeft(boolean b)
          Indicates if the graph must be drawn from right to left or not.
 void setTextForSelected(java.lang.String s)
          Sets the content for all selected graph boxes
 void translateAllSelectedBoxes(int dx, int dy)
          Translates all selected graph boxes
 void unSelectAllBoxes()
          Unselect all selected graph boxes
 void updateAllBoxes()
          Updates all graph's boxes
 void validateTextField()
          Validates the text field content
 void VCenterAlign()
          Aligns vertically all selected boxes on the average X coordinate of these boxes
 void VLeftAlign()
          Aligns vertically all selected boxes on the leftmost box
 void VRightAlign()
          Aligns vertically all selected boxes on the rightmost box
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

modified

public boolean modified
Indicates if the graph contains unsaved modifications.


Width

public int Width
Width of the drawing area.


Height

public int Height
Height of the drawing area.


texte

public javax.swing.JTextField texte
Text field in which the content of boxes can be edited.


selectedBoxes

public java.util.ArrayList selectedBoxes
ArrayList containing the current selected boxes


graphBoxes

public java.util.ArrayList graphBoxes
ArrayList containing all the graph's boxes


isGrid

public boolean isGrid
Indicates if a grid be drawn in backend


nPixels

public int nPixels
Indicates the size of the grid's cells


parentFrame

public javax.swing.JInternalFrame parentFrame
JInternalFrame that contains this component


scaleFactor

public double scaleFactor
Zoom factor


EDITING_MODE

public int EDITING_MODE
Indicates mouse's editing mode

Constructor Detail

GenericGraphicalZone

public GenericGraphicalZone(int w,
                            int h,
                            javax.swing.JTextField t,
                            javax.swing.JInternalFrame p)
Constructs a new GenericGraphicalZone.

Parameters:
w - width of the drawing area
h - heig ht of the drawing area
t - text field to edit box contents
p - frame that contains the component

GenericGraphicalZone

public GenericGraphicalZone(int w,
                            int h,
                            javax.swing.JTextField t,
                            TextAutomatonFrame p)
Constructs a new GenericGraphicalZone.

Parameters:
w - width of the drawing area
h - height of the drawing area
t - text field to edit box contents
p - frame that contains the component
Method Detail

addBox

public void addBox(GenericGraphBox g)
Adds a graph box to the graph

Parameters:
g - the graph box

pasteSelection

public void pasteSelection(MultipleSelection m)
Paste a graph box selection in the graph. The created boxes will be the new box selection.

Parameters:
m - the graph box selection

initText

public void initText(java.lang.String s)
Sets the text field content

Parameters:
s - the new content

validateTextField

public void validateTextField()
Validates the text field content


setModified

public void setModified(boolean b)
Indicates if the graph must be marked as modified are not

Parameters:
b - true if the graph must be marked as modified, false otherwise

removeTransitionTo

public void removeTransitionTo(GenericGraphBox dest)
Removes all transitions that go to a specified graph box

Parameters:
dest - the target graph box

getTransitionTo

public java.util.ArrayList getTransitionTo(GenericGraphBox dest)
Removes all transitions that go to a specified graph box

Parameters:
dest - the target graph box
Returns:
the boxes which had transition to dest

removeTransitionsToSelected

public void removeTransitionsToSelected()
Removes all transitions that go selected graph boxes


removeSelected

public void removeSelected()
Remove all selected graph boxes


setTextForSelected

public void setTextForSelected(java.lang.String s)
Sets the content for all selected graph boxes

Parameters:
s - the new content

getSelectedBox

public int getSelectedBox(int x,
                          int y)
Finds the box that is selected by a click

Parameters:
x - X coordinate of the click
y - Y coordinate of the click
Returns:
the position of the box in the graphBoxes vector, or -1 if no box was selected by the click

unSelectAllBoxes

public void unSelectAllBoxes()
Unselect all selected graph boxes


selectAllBoxes

public void selectAllBoxes()
Select all graph boxes


selectByRectangle

public void selectByRectangle(int x,
                              int y,
                              int w,
                              int h)
Selects all graph boxes that have a non empty intersection with a selection rectangle

Parameters:
x - X coordinate of the selection rectangle
y - Y coordinate of the selection rectangle
w - width of the selection rectangle
h - height of the selection rectangle

translateAllSelectedBoxes

public void translateAllSelectedBoxes(int dx,
                                      int dy)
Translates all selected graph boxes

Parameters:
dx - value to be added to X coordinates
dy - value to be added to Y coordinates

addTransitionsFromSelectedBoxes

public void addTransitionsFromSelectedBoxes(GenericGraphBox dest,
                                            boolean save)
Adds transitions from all selected boxes to a specified graph box

Parameters:
dest - the target graph box
save - True if we went to save the state for do undo action

addReverseTransitionsFromSelectedBoxes

public void addReverseTransitionsFromSelectedBoxes(GenericGraphBox src)
Adds transitions from a specified graph box to all selected boxes

Parameters:
src - the source graph box

drawAllTransitions

public void drawAllTransitions(java.awt.Graphics2D gr)
Draws all graph's transitions

Parameters:
gr - the graphical context

drawTransitionsFromMousePointerToSelectedBoxes

public void drawTransitionsFromMousePointerToSelectedBoxes(java.awt.Graphics2D gr)
Adds transitions from the last mouse click position to all selected boxes

Parameters:
gr - the graphical context

drawTransitionsFromSelectedBoxesToMousePointer

public void drawTransitionsFromSelectedBoxesToMousePointer(java.awt.Graphics2D gr)
Adds transitions from all selected boxes to the last mouse click position

Parameters:
gr - the graphical context

drawAllBoxes

public void drawAllBoxes(java.awt.Graphics2D gr)
Draws all boxes of the graph

Parameters:
gr - the graphical context

drawGrid

public void drawGrid(java.awt.Graphics2D f)
Draws the grid of the graph if the isGrid field is set to true

Parameters:
f - the graphical context

HTopAlign

public void HTopAlign()
Aligns horizontally all selected boxes on the upper box


HCenterAlign

public void HCenterAlign()
Aligns horizontally all selected boxes on the average Y coordinate of these boxes


HBottomAlign

public void HBottomAlign()
Aligns horizontally all selected boxes on the lower box


VLeftAlign

public void VLeftAlign()
Aligns vertically all selected boxes on the leftmost box


VCenterAlign

public void VCenterAlign()
Aligns vertically all selected boxes on the average X coordinate of these boxes


VRightAlign

public void VRightAlign()
Aligns vertically all selected boxes on the rightmost box


setGrid

public void setGrid(boolean b)
Sets the isGrid field

Parameters:
b - true if the graph must be marked as modified, false otherwise

setGrid

public void setGrid(boolean b,
                    int n)
Sets the isGrid field

Parameters:
b - true if the graph must be marked as modified, false otherwise
n - size of grid's cells

updateAllBoxes

public void updateAllBoxes()
Updates all graph's boxes


setRightToLeft

public void setRightToLeft(boolean b)
Indicates if the graph must be drawn from right to left or not.

Parameters:
b - true if the graph must be drawn from right to left, false otherwise

addUndoableEditListener

public void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)

removeUndoableEditListener

public void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)

postEdit

public void postEdit(javax.swing.undo.UndoableEdit e)

getSelectedBoxes

public java.util.ArrayList getSelectedBoxes()
Returns:
selected boxes of the graph

getClipZone

public java.awt.Rectangle getClipZone()

setClipZone

public void setClipZone(java.awt.Rectangle r)