Class DrawingArea

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byDrawingArea
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable

public class DrawingArea
extends javax.swing.JPanel
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.ActionListener

This class represents the drawingarea where all objects in a sequence diagram is drawn.

Author:
Matilda Östling
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  java.util.Vector actorsAndObjects
          The list with all classEntitys(actors and objects) in the drawingarea.
protected  bluej.extensions.BlueJ bluej
          The BlueJ object used when the editor is connected to a BlueJ-project
private  javax.swing.JButton classCancel
           
private  javax.swing.JDialog classDialog
           
private  bluej.extensions.BClass[] classes
           
private  javax.swing.JComboBox classList
           
private  javax.swing.JButton classOk
           
private  Entity currentEntity
          The active entity in the drawingarea.
private  java.io.File currentFile
          The file for the current sequence diagram
private  CurrentState currentState
          The current state for the drawingarea.
static float[] dash1
           
static java.awt.BasicStroke dashed
           
private  java.util.Vector drawingObjects
          The list with all objects to draw in the drawingarea.
private  java.util.Vector lifelines
          The list with all lifelines in the drawingarea.
private  javax.swing.JDialog messageDialog
           
private  javax.swing.JComboBox messageList
           
private  javax.swing.JButton messageOk
           
private  bluej.extensions.BMethod[] methods
           
private  long newtime
           
private  java.lang.String notes
           
protected  int nrOfObjects
          The number of classEntitys(actor and objects) in the drawingarea.
private  long oldtime
           
private  SeqDiagramEditor seqDiagramEditor
          The Sequence Diagram Editor this drawingArea belongs to
 
Fields inherited from class javax.swing.JPanel
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
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
DrawingArea(bluej.extensions.BlueJ b, SeqDiagramEditor s)
          The constructor for the class, used when the editor is started from BlueJ.
DrawingArea(SeqDiagramEditor s)
          The constructor for the class.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          This method is called when an event takes place.
 void addClassEntity(Entity e)
          This method adds an object or an actor to the drawingarea.
 void addEntity(Entity e)
          This method adds an entity to the drawingarea.
 void arrangeReturnMessages()
          This method is used to arrange all return messages.
protected  void chooseMethod(Entity e)
          This methos is used when the editor is in "BlueJ"-mode.
private  void chooseNewObject(Entity e)
          This method is used when the editor is in "BlueJ"-mode.
 void clear()
          This method is called when the user wants to open a new sequence diagram.
 java.util.Vector getActorsAndObject()
           
 Entity getCurrentEntity()
           
 java.io.File getCurrentFile()
           
 CurrentState getCurrState()
           
 java.util.Vector getDrawingObjects()
           
 java.util.Vector getLifelines()
           
private  Message getMessage(org.w3c.dom.Element e)
          This method is used by the method readInMessage.
 java.lang.String getNoteFile()
           
 SeqDiagramEditor getSeqDiagramEditor()
           
 void hideReturnMessages()
          This method is used to remove all return messages from the drawingobjects.
 void mouseClicked(java.awt.event.MouseEvent e)
          This method is called when the mouse is clicked in the drawingarea.
 void mouseDragged(java.awt.event.MouseEvent e)
          This method is called when the mouse is dragged.
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
          This method is called when the mouse is moved in the drawingarea.
 void mousePressed(java.awt.event.MouseEvent e)
          This method is called when the mouse is pressed in the drawingarea.
 void mouseReleased(java.awt.event.MouseEvent e)
          This method is called when the mouse is released on the drawingarea.
 void openFromFile(java.io.File file)
          This method is called when the user wants to open a saved sequence diagram.
 void paintComponent(java.awt.Graphics g)
          This method draws all objects on the drawingarea by calling the draw-method for all objects.
private  void readInDestroySymbol(ClassEntity c, org.w3c.dom.Element d)
          This method is used by the readInObject method.
private  void readInLifeLine(ClassEntity c, org.w3c.dom.Element m)
          This method is used by the readInObject method to read in a lifeline for an object/actor.
private  void readInMessage(ClassEntity c, org.w3c.dom.Element m)
          This method is used by the readInObject method.
private  void readInObject(org.w3c.dom.Element object)
          This method is called to read in an actor or a sequenceobject from a file.
 org.w3c.dom.Document saveToFile(java.io.File file)
          This method is called when the editor tells the drawingarea that it should save itself to a file.
 void setCurrentFile(java.io.File f)
           
 void setNoteFile(java.lang.String n)
           
 void showReturnMessages()
          This method is used to add all return messages to the drawingobjects.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getWidth, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

currentState

private CurrentState currentState
The current state for the drawingarea.


drawingObjects

private java.util.Vector drawingObjects
The list with all objects to draw in the drawingarea.


lifelines

private java.util.Vector lifelines
The list with all lifelines in the drawingarea.


actorsAndObjects

private java.util.Vector actorsAndObjects
The list with all classEntitys(actors and objects) in the drawingarea.


currentEntity

private Entity currentEntity
The active entity in the drawingarea.


nrOfObjects

protected int nrOfObjects
The number of classEntitys(actor and objects) in the drawingarea.


bluej

protected bluej.extensions.BlueJ bluej
The BlueJ object used when the editor is connected to a BlueJ-project


seqDiagramEditor

private SeqDiagramEditor seqDiagramEditor
The Sequence Diagram Editor this drawingArea belongs to


currentFile

private java.io.File currentFile
The file for the current sequence diagram


dash1

public static final float[] dash1

dashed

public static final java.awt.BasicStroke dashed

messageDialog

private javax.swing.JDialog messageDialog

messageList

private javax.swing.JComboBox messageList

messageOk

private javax.swing.JButton messageOk

methods

private bluej.extensions.BMethod[] methods

classDialog

private javax.swing.JDialog classDialog

classList

private javax.swing.JComboBox classList

classOk

private javax.swing.JButton classOk

classCancel

private javax.swing.JButton classCancel

classes

private bluej.extensions.BClass[] classes

notes

private java.lang.String notes

oldtime

private long oldtime

newtime

private long newtime
Constructor Detail

DrawingArea

public DrawingArea(SeqDiagramEditor s)
The constructor for the class.

Parameters:
s - The editor window that creates the drawingArea

DrawingArea

public DrawingArea(bluej.extensions.BlueJ b,
                   SeqDiagramEditor s)
The constructor for the class, used when the editor is started from BlueJ.

Parameters:
b - The BlueJ-object
s - The editor window that creates the drawingArea
Method Detail

addEntity

public void addEntity(Entity e)
This method adds an entity to the drawingarea.

Parameters:
e - The Entity to add

addClassEntity

public void addClassEntity(Entity e)
This method adds an object or an actor to the drawingarea.

Parameters:
e - The entity to add

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
This method is called when the mouse is clicked in the drawingarea. Depending on the currents state of the drawingarea the event is handled.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
e - The mouseEvent.

paintComponent

public void paintComponent(java.awt.Graphics g)
This method draws all objects on the drawingarea by calling the draw-method for all objects.

Parameters:
g - The graphics used for the drawing.

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
This method is called when the mouse is dragged. Depending on the current state of the drawingarea the event is handled.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e - The mouseEvent.

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
This method is called when the mouse is moved in the drawingarea. Depending on the current state for the drawingarea the event is handled.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
e - The mouseEvent.

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
This method is called when the mouse is pressed in the drawingarea. Depending on the current state of the drawingarea the event is handled.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - The mouseevent.

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
This method is called when the mouse is released on the drawingarea. Depending on the current state of the drawingarea the event is handled.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - The mouseEvent.

saveToFile

public org.w3c.dom.Document saveToFile(java.io.File file)
                                throws java.io.FileNotFoundException
This method is called when the editor tells the drawingarea that it should save itself to a file.

Parameters:
file - The file where the sequence diagram should be saved.
Returns:
A reference to the document where the drawingarea is saved.
Throws:
java.io.FileNotFoundException

openFromFile

public void openFromFile(java.io.File file)
                  throws javax.xml.parsers.ParserConfigurationException
This method is called when the user wants to open a saved sequence diagram.

Parameters:
file - The file for the saved sequence diagram.
Throws:
javax.xml.parsers.ParserConfigurationException

readInObject

private void readInObject(org.w3c.dom.Element object)
This method is called to read in an actor or a sequenceobject from a file.

Parameters:
object - The actor/sequence-object to read in.

readInLifeLine

private void readInLifeLine(ClassEntity c,
                            org.w3c.dom.Element m)
This method is used by the readInObject method to read in a lifeline for an object/actor.

Parameters:
c - The ClassEntity for this lifeline
m - The lifeline

readInMessage

private void readInMessage(ClassEntity c,
                           org.w3c.dom.Element m)
This method is used by the readInObject method. It is called to read in a message belonging to the calling classEntity.

Parameters:
c - The startEntity or endEntity of this message.
m - The message.

getMessage

private Message getMessage(org.w3c.dom.Element e)
This method is used by the method readInMessage. It checks wether the message already excist or not.

Parameters:
e - The Message
Returns:
Returns the message if it already excists, otherwise it returns null

readInDestroySymbol

private void readInDestroySymbol(ClassEntity c,
                                 org.w3c.dom.Element d)
This method is used by the readInObject method. It is called to read in a destroysymbol belonging to the calling classEntity.

Parameters:
c - The ownerentity of this destroysymbol.
d - The destroysymbol.

clear

public void clear()
This method is called when the user wants to open a new sequence diagram. It clears all variables for the drawingarea and repaints it.


chooseMethod

protected void chooseMethod(Entity e)
This methos is used when the editor is in "BlueJ"-mode. It is used to let the user choose one of the possible methods for the choosen object. This method creates and shows a dialog where the user can choose a method.

Parameters:
e - The current entity of the drawingArea

chooseNewObject

private void chooseNewObject(Entity e)
This method is used when the editor is in "BlueJ"-mode. This method is used to let the user choose which object to create, from which class. This method creates and shows a dialog where the user can make his choice.

Parameters:
e - The current entity of the drawingArea.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
This method is called when an event takes place.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - The ActionEvent

showReturnMessages

public void showReturnMessages()
This method is used to add all return messages to the drawingobjects. It is called If the user wants to add return messages to the sequence diagram.


hideReturnMessages

public void hideReturnMessages()
This method is used to remove all return messages from the drawingobjects. It is called if the user choose to hide all return messages in the sequence diagram.


arrangeReturnMessages

public void arrangeReturnMessages()
This method is used to arrange all return messages. If the user choose to show return messages in the sequence diagram all messages have to be arranged in a correct way.


getDrawingObjects

public java.util.Vector getDrawingObjects()

getLifelines

public java.util.Vector getLifelines()

getActorsAndObject

public java.util.Vector getActorsAndObject()

getCurrState

public CurrentState getCurrState()

getCurrentFile

public java.io.File getCurrentFile()

setCurrentFile

public void setCurrentFile(java.io.File f)

getSeqDiagramEditor

public SeqDiagramEditor getSeqDiagramEditor()

getCurrentEntity

public Entity getCurrentEntity()

getNoteFile

public java.lang.String getNoteFile()

setNoteFile

public void setNoteFile(java.lang.String n)

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener