org.objectweb.jac.ide.diagrams
Class DiagramView

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--org.objectweb.jac.aspects.gui.swing.AbstractView
                                |
                                +--org.objectweb.jac.ide.diagrams.DiagramView
All Implemented Interfaces:
Accessible, CollectionUpdate, CH.ifa.draw.framework.DrawingEditor, DropTargetListener, EventListener, CH.ifa.draw.framework.FigureSelectionListener, ImageObserver, MenuContainer, CH.ifa.draw.util.PaletteListener, Serializable, CH.ifa.draw.util.VersionRequester, View, ViewIdentity

public class DiagramView
extends AbstractView
implements CH.ifa.draw.framework.DrawingEditor, CH.ifa.draw.util.PaletteListener, CH.ifa.draw.util.VersionRequester, CollectionUpdate, DropTargetListener

See Also:
Serialized Form

Field Summary
protected  Diagram diagram
           
static boolean init
           
 
Fields inherited from class org.objectweb.jac.aspects.gui.swing.AbstractView
closed, height, width
 
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.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
DiagramView(ViewFactory factory, DisplayContext context, Object diagram)
           
 
Method Summary
 void addClass(Class cl, Point location)
          Add a figure for a class at a given location
 void addViewChangeListener(CH.ifa.draw.framework.ViewChangeListener vsl)
           
 void close(boolean validate)
          Close this view.
protected  JPanel createButtonPanel()
          Creates the buttons panel.
protected  void createButtons(JPanel panel)
          Creates the buttons shown in the buttons panel.
protected  JComboBox createColorChoice(String attribute)
          Creates the color choice for the given attribute.
protected  CH.ifa.draw.framework.Drawing createDrawing()
          Creates the drawing used in this application.
protected  CH.ifa.draw.framework.DrawingView createDrawingView()
          Creates the drawing view used in this application.
 void createRelation(Class source, Class target, RelationLinkFigure linkFigure, boolean isAggregation)
          Create a RelationLink between two classes.
protected  CH.ifa.draw.framework.Tool createSelectionTool()
          Creates the selection tool used in this editor.
protected  JPanel createToolPalette()
          Creates the tools palette.
 void dragEnter(DropTargetDragEvent e)
           
 void dragExit(DropTargetEvent e)
           
 void dragOver(DropTargetDragEvent e)
           
 CH.ifa.draw.framework.Drawing drawing()
          Gets the current drawing.
 void drop(DropTargetDropEvent e)
           
 void dropActionChanged(DropTargetDragEvent e)
           
 void figureSelectionChanged(CH.ifa.draw.framework.DrawingView view)
           
 ClassFigure findClass(Class cl)
          Find the figure of a given class in the default drawing.
 ClassFigure findClass(CH.ifa.draw.framework.Drawing drawing, Class cl)
          Find the figure of a given model element
 CH.ifa.draw.framework.Figure findElement(ModelElement element)
          Find the figure of a given ModelElement
 CH.ifa.draw.framework.Figure findElement(TypedElement te)
          Find the figure of a given TypedElement
 ModelElementFigure findFigure(CH.ifa.draw.framework.Drawing drawing, ModelElement element)
          Find the figure of a given model element.
 Diagram getDiagram()
           
 String[] getRequiredVersions()
          Subclasses should override this method to specify to which versions of JHotDraw they are compatible.
 Object getSubstance()
           
protected  CH.ifa.draw.util.VersionControlStrategy getVersionControlStrategy()
           
 void importInheritance(InheritanceLink inheritance)
          Import an inheritance link in the diagram.
 void importRelation(RelationLink relation)
          Import a relation in the diagram.
 void importRelations(Class cl)
          Import all relations and inheritance links between a class with other classes on the diagram
 void init()
          Initializes the applet and creates its contents.
 void load()
          Initialize from the org.objectweb.jac.ide.Diagram
 void onAdd(Object substance, CollectionItem collection, Object value, Object added, Object param)
          Upcalled when an item is added in a collection.
 void onChange(Object substance, CollectionItem collection, Object value, Object param)
          Upcalled when the collection is changed (with a set or other methods such as clear, removeAll, addAll, ...).
 void onRemove(Object substance, CollectionItem collection, Object value, Object removed, Object param)
          Upcalled when an item is removed from a collection.
 void paletteUserOver(CH.ifa.draw.util.PaletteButton button, boolean inside)
          Handles when the mouse enters or leaves a palette button.
 void paletteUserSelected(CH.ifa.draw.util.PaletteButton button)
          Handles a user selection in the palette.
 void removeViewChangeListener(CH.ifa.draw.framework.ViewChangeListener vsl)
           
 void setCoord(int x, int y)
           
 void showStatus(String msg)
           
 CH.ifa.draw.framework.Tool tool()
          Gets the current tool.
 void toolDone()
          Sets the default tool of the editor.
 String toString()
           
 CH.ifa.draw.framework.DrawingView view()
          Gets the current drawing view.
 CH.ifa.draw.framework.DrawingView[] views()
           
 void viewSelectionChanged(CH.ifa.draw.framework.DrawingView oldView, CH.ifa.draw.framework.DrawingView newView)
           
 
Methods inherited from class org.objectweb.jac.aspects.gui.swing.AbstractView
equalsView, equalsView, getContext, getDescription, getFactory, getLabel, getMessage, getParameters, getParentView, getRootView, getStyle, getType, getViewBorder, invokeInContext, isClosed, isDescendantOf, setContext, setDescription, setFactory, setFocus, setLabel, setMessage, setParameters, setParentView, setSize, setStyle, setType, setViewBorder
 
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, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, 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, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

init

public static boolean init

diagram

protected Diagram diagram
Constructor Detail

DiagramView

public DiagramView(ViewFactory factory,
                   DisplayContext context,
                   Object diagram)
Method Detail

close

public void close(boolean validate)
Description copied from interface: View
Close this view. This should be upcalled when the view is closed in order to free resources or close other dependant views.

Specified by:
close in interface View
Overrides:
close in class AbstractView
Parameters:
validate - wether to validate any value contained in editors.

getSubstance

public Object getSubstance()

getDiagram

public final Diagram getDiagram()

addClass

public void addClass(Class cl,
                     Point location)
Add a figure for a class at a given location

Parameters:
cl - the class to add a figure for
location - where to put the class figure

importRelations

public void importRelations(Class cl)
Import all relations and inheritance links between a class with other classes on the diagram

Parameters:
cl - the class to import relations for

importRelation

public void importRelation(RelationLink relation)
                    throws Exception
Import a relation in the diagram.

Parameters:
relation - the relation to import
Throws:
Exception - if both classes of the relation are not on the diagram

importInheritance

public void importInheritance(InheritanceLink inheritance)
                       throws Exception
Import an inheritance link in the diagram. An exception

Parameters:
inheritance - the inheritance link to import
Exception

createRelation

public void createRelation(Class source,
                           Class target,
                           RelationLinkFigure linkFigure,
                           boolean isAggregation)
Create a RelationLink between two classes.

Parameters:
source - start class of the link
target - end class of the link
linkFigure - the figure that represents the relation
isAggregation - wether the relation is an aggregation

drop

public void drop(DropTargetDropEvent e)
Specified by:
drop in interface DropTargetListener

dragEnter

public void dragEnter(DropTargetDragEvent e)
Specified by:
dragEnter in interface DropTargetListener

dragExit

public void dragExit(DropTargetEvent e)
Specified by:
dragExit in interface DropTargetListener

dragOver

public void dragOver(DropTargetDragEvent e)
Specified by:
dragOver in interface DropTargetListener

dropActionChanged

public void dropActionChanged(DropTargetDragEvent e)
Specified by:
dropActionChanged in interface DropTargetListener

figureSelectionChanged

public void figureSelectionChanged(CH.ifa.draw.framework.DrawingView view)
Specified by:
figureSelectionChanged in interface CH.ifa.draw.framework.DrawingEditor

findClass

public ClassFigure findClass(Class cl)
Find the figure of a given class in the default drawing.

Parameters:
cl - the Class to search for
Returns:
a ModelElementFigure that matches cl, or null if none is found.

findClass

public ClassFigure findClass(CH.ifa.draw.framework.Drawing drawing,
                             Class cl)
Find the figure of a given model element

Parameters:
drawing - the Drawing to search the figure into
cl - the Class to search for
Returns:
a ModelElementFigure that matches cl, or null if none is found.

findFigure

public ModelElementFigure findFigure(CH.ifa.draw.framework.Drawing drawing,
                                     ModelElement element)
Find the figure of a given model element.

Parameters:
drawing - the Drawing to search the figure into
element - the ModelElement to search for
Returns:
a ModelElementFigure that matches element, or null if none is found.

findElement

public CH.ifa.draw.framework.Figure findElement(TypedElement te)
Find the figure of a given TypedElement


findElement

public CH.ifa.draw.framework.Figure findElement(ModelElement element)
Find the figure of a given ModelElement


init

public void init()
Initializes the applet and creates its contents.


addViewChangeListener

public void addViewChangeListener(CH.ifa.draw.framework.ViewChangeListener vsl)
Specified by:
addViewChangeListener in interface CH.ifa.draw.framework.DrawingEditor

removeViewChangeListener

public void removeViewChangeListener(CH.ifa.draw.framework.ViewChangeListener vsl)
Specified by:
removeViewChangeListener in interface CH.ifa.draw.framework.DrawingEditor

createColorChoice

protected JComboBox createColorChoice(String attribute)
Creates the color choice for the given attribute.


createButtonPanel

protected JPanel createButtonPanel()
Creates the buttons panel.


createButtons

protected void createButtons(JPanel panel)
Creates the buttons shown in the buttons panel. Override to add additional buttons.

Parameters:
panel - the buttons panel.

setCoord

public void setCoord(int x,
                     int y)

createToolPalette

protected JPanel createToolPalette()
Creates the tools palette.


createSelectionTool

protected CH.ifa.draw.framework.Tool createSelectionTool()
Creates the selection tool used in this editor. Override to use a custom selection tool.


createDrawing

protected CH.ifa.draw.framework.Drawing createDrawing()
Creates the drawing used in this application. You need to override this method to use a Drawing subclass in your application. By default a standard Drawing is returned.


createDrawingView

protected CH.ifa.draw.framework.DrawingView createDrawingView()
Creates the drawing view used in this application. You need to override this method to use a DrawingView subclass in your application. By default a standard DrawingView is returned.


paletteUserSelected

public void paletteUserSelected(CH.ifa.draw.util.PaletteButton button)
Handles a user selection in the palette.

Specified by:
paletteUserSelected in interface CH.ifa.draw.util.PaletteListener
See Also:
PaletteListener

paletteUserOver

public void paletteUserOver(CH.ifa.draw.util.PaletteButton button,
                            boolean inside)
Handles when the mouse enters or leaves a palette button.

Specified by:
paletteUserOver in interface CH.ifa.draw.util.PaletteListener
See Also:
PaletteListener

drawing

public CH.ifa.draw.framework.Drawing drawing()
Gets the current drawing.

See Also:
DrawingEditor

tool

public CH.ifa.draw.framework.Tool tool()
Gets the current tool.

Specified by:
tool in interface CH.ifa.draw.framework.DrawingEditor
See Also:
DrawingEditor

view

public CH.ifa.draw.framework.DrawingView view()
Gets the current drawing view.

Specified by:
view in interface CH.ifa.draw.framework.DrawingEditor
See Also:
DrawingEditor

views

public CH.ifa.draw.framework.DrawingView[] views()
Specified by:
views in interface CH.ifa.draw.framework.DrawingEditor

toolDone

public void toolDone()
Sets the default tool of the editor.

Specified by:
toolDone in interface CH.ifa.draw.framework.DrawingEditor
See Also:
DrawingEditor

viewSelectionChanged

public void viewSelectionChanged(CH.ifa.draw.framework.DrawingView oldView,
                                 CH.ifa.draw.framework.DrawingView newView)

getVersionControlStrategy

protected CH.ifa.draw.util.VersionControlStrategy getVersionControlStrategy()

getRequiredVersions

public String[] getRequiredVersions()
Subclasses should override this method to specify to which versions of JHotDraw they are compatible. A string array is returned so it is possible to specify several version numbers of JHotDraw to which the application is compatible with.

Specified by:
getRequiredVersions in interface CH.ifa.draw.util.VersionRequester
Returns:
all versions number of JHotDraw the application is compatible with.

load

public void load()
Initialize from the org.objectweb.jac.ide.Diagram


showStatus

public void showStatus(String msg)
Specified by:
showStatus in interface CH.ifa.draw.framework.DrawingEditor

toString

public String toString()
Overrides:
toString in class AbstractView

onChange

public void onChange(Object substance,
                     CollectionItem collection,
                     Object value,
                     Object param)
Description copied from interface: CollectionUpdate
Upcalled when the collection is changed (with a set or other methods such as clear, removeAll, addAll, ...).

Specified by:
onChange in interface CollectionUpdate
Parameters:
substance - the object of which a field was updated
collection - the updated collection
value - the new collection
param - extra data
See Also:
ViewControlWrapper.registerCollection(Wrappee,CollectionItem,CollectionUpdate,Object)

onAdd

public void onAdd(Object substance,
                  CollectionItem collection,
                  Object value,
                  Object added,
                  Object param)
Description copied from interface: CollectionUpdate
Upcalled when an item is added in a collection.

Specified by:
onAdd in interface CollectionUpdate
Parameters:
substance - the object of which a collection was updated
collection - the updated collection
value - the collection's value
added - the value added to the collection
param - extra data (e.g. index)
See Also:
ViewControlWrapper.registerCollection(Wrappee,CollectionItem,CollectionUpdate,Object)

onRemove

public void onRemove(Object substance,
                     CollectionItem collection,
                     Object value,
                     Object removed,
                     Object param)
Description copied from interface: CollectionUpdate
Upcalled when an item is removed from a collection.

Specified by:
onRemove in interface CollectionUpdate
Parameters:
substance - the object of which a collection was updated
collection - the updated collection
value - the collection's value
removed - the removed item
param - extra data (e.g. index)
See Also:
ViewControlWrapper.registerCollection(Wrappee,CollectionItem,CollectionUpdate,Object)