ucot.ui.gui
Class DotPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by ucot.ui.gui.DotPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.Observer, javax.accessibility.Accessible

public class DotPanel
extends javax.swing.JPanel
implements java.util.Observer

A dot panel class inherited from JPanel class which is used for drawing dot graphs from the given analyze model. This class implements the observer interface which allows objects to keep track on the current status of this panel. This panel also observes the given analyze model and updates the graph when the model changes. There is also a method which allows highlighting any submodels from the given analyze model.

Author:
ilanliuk, tujupien.
See Also:
Serialized Form

Nested Class Summary
static class DotPanel.ExportImageType
           
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  AnalyzeModel analyzeModel
           
private  java.util.Set<java.util.Vector<java.lang.String>> attributesInCurrentModel
           
private  java.util.Set<java.util.Vector<java.lang.String>> attributesRequestedForHighlighting
           
private  java.util.Set<java.util.Vector<java.lang.String>> attributesToBeHighlighted
           
private static DotColorTheme colorTheme
           
protected static java.lang.String DOT_PATH
           
private  java.util.Set<java.lang.String> entitiesInCurrentModel
           
private  java.util.Set<java.lang.String> entitiesRequestedForHighlighting
           
private  java.util.Set<java.lang.String> entitiesToBeHighlighted
           
private  boolean isUpdating
           
private  java.util.Set<java.util.Vector<java.lang.String>> methodsInCurrentModel
           
private  java.util.Set<java.util.Vector<java.lang.String>> methodsRequestedForHighlighting
           
private  java.util.Set<java.util.Vector<java.lang.String>> methodsToBeHighlighted
           
private  java.awt.image.BufferedImage modelImage
           
private  java.util.Set<java.util.Vector<java.lang.String>> parentsInCurrentModel
           
private  java.util.Set<java.util.Vector<java.lang.String>> parentsRequestedForHighlighting
           
private  java.util.Set<java.util.Vector<java.lang.String>> parentsToBeHighlighted
           
protected static java.lang.String TEMP_INPUT_FILE
           
protected static java.lang.String TEMP_OUTPUT_FILE
           
 
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
DotPanel(AnalyzeModel analyzeModel)
          Constructor for DotPanel.
 
Method Summary
private  java.io.File createDotFile()
          Writes the analyze model to an external file in dot syntax.
 void exportImage(java.io.File target, DotPanel.ExportImageType imageFormat)
          Saves current image to given file in given format.
 void highlight(AnalyzeModel highlight)
          Method for highlighting submodels from the analyze model.
 void highlight(AnalyzeModel highlight, boolean drawNewElements)
          Method for highlighting submodels from the analyze model.
private  void mapCurrentModel()
          Method for mapping the current analyze model.
private  void mapHighlightRequest(AnalyzeModel highlight, boolean drawNewElements)
          Method for mapping the submodel for highlight request.
 void paintComponent(java.awt.Graphics g)
          This method draws the graph generated by dot to the panel's canvas.
private  java.io.File runDot(java.io.File dotInputFile)
          This method runs the dot executable with the given dot input file and returns the location of the image file.
 void update(java.util.Observable observableObject, java.lang.Object updationArg)
           
 void updateModel(AnalyzeModel model)
          Method for updating the analyze model.
private  void writeEntities(java.io.BufferedWriter writer)
          Method for writing all entities to the dot file with all their attribute, method and parent relationships.
private  void writeEntityAttributes(java.io.BufferedWriter writer, java.lang.String entity)
          Method for writing the attributes of one entity to the dot file.
private  void writeEntityMethods(java.io.BufferedWriter writer, java.lang.String entity)
          Method for writing the methods of one entity to the dot file.
private  void writeEntityParents(java.io.BufferedWriter writer, java.lang.String entity)
          Method for writing the parents of one entity to the dot file.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getWidth, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TEMP_INPUT_FILE

protected static java.lang.String TEMP_INPUT_FILE

TEMP_OUTPUT_FILE

protected static java.lang.String TEMP_OUTPUT_FILE

DOT_PATH

protected static java.lang.String DOT_PATH

analyzeModel

private AnalyzeModel analyzeModel

colorTheme

private static DotColorTheme colorTheme

entitiesToBeHighlighted

private java.util.Set<java.lang.String> entitiesToBeHighlighted

entitiesInCurrentModel

private java.util.Set<java.lang.String> entitiesInCurrentModel

entitiesRequestedForHighlighting

private java.util.Set<java.lang.String> entitiesRequestedForHighlighting

parentsToBeHighlighted

private java.util.Set<java.util.Vector<java.lang.String>> parentsToBeHighlighted

parentsInCurrentModel

private java.util.Set<java.util.Vector<java.lang.String>> parentsInCurrentModel

parentsRequestedForHighlighting

private java.util.Set<java.util.Vector<java.lang.String>> parentsRequestedForHighlighting

methodsToBeHighlighted

private java.util.Set<java.util.Vector<java.lang.String>> methodsToBeHighlighted

methodsInCurrentModel

private java.util.Set<java.util.Vector<java.lang.String>> methodsInCurrentModel

methodsRequestedForHighlighting

private java.util.Set<java.util.Vector<java.lang.String>> methodsRequestedForHighlighting

attributesToBeHighlighted

private java.util.Set<java.util.Vector<java.lang.String>> attributesToBeHighlighted

attributesInCurrentModel

private java.util.Set<java.util.Vector<java.lang.String>> attributesInCurrentModel

attributesRequestedForHighlighting

private java.util.Set<java.util.Vector<java.lang.String>> attributesRequestedForHighlighting

modelImage

private java.awt.image.BufferedImage modelImage

isUpdating

private boolean isUpdating
Constructor Detail

DotPanel

public DotPanel(AnalyzeModel analyzeModel)
Constructor for DotPanel. This constructor adds an observer to the analyze model and sets its own status to updating.

Parameters:
analyzeModel - analyzeModel to use with this DotPanel.
Method Detail

update

public void update(java.util.Observable observableObject,
                   java.lang.Object updationArg)
Specified by:
update in interface java.util.Observer

exportImage

public void exportImage(java.io.File target,
                        DotPanel.ExportImageType imageFormat)
Saves current image to given file in given format.

Parameters:
target - Target file.
imageFormat - Image format to use.

runDot

private java.io.File runDot(java.io.File dotInputFile)
This method runs the dot executable with the given dot input file and returns the location of the image file.

Parameters:
dotInputFile - Input file for dot executable.
Returns:
File where the image is located. Null is returned if something went wrog.

writeEntityMethods

private void writeEntityMethods(java.io.BufferedWriter writer,
                                java.lang.String entity)
                         throws java.io.IOException
Method for writing the methods of one entity to the dot file.

Parameters:
writer - BufferedWriter to use for writing.
entity - Name of the entity whose methods are being written.
Throws:
java.io.IOException - If something goes wrong an exception is thrown.

writeEntityAttributes

private void writeEntityAttributes(java.io.BufferedWriter writer,
                                   java.lang.String entity)
                            throws java.io.IOException
Method for writing the attributes of one entity to the dot file.

Parameters:
writer - BufferedWriter to use for writing.
entity - Name of the entity whose attributes are being written.
Throws:
java.io.IOException - If something goes wrong an exception is thrown.

writeEntityParents

private void writeEntityParents(java.io.BufferedWriter writer,
                                java.lang.String entity)
                         throws java.io.IOException
Method for writing the parents of one entity to the dot file.

Parameters:
writer - BufferedWriter to use for writing.
entity - Name of the entity whose parents are being written.
Throws:
java.io.IOException - If something goes wrong an exception is thrown.

writeEntities

private void writeEntities(java.io.BufferedWriter writer)
                    throws java.io.IOException
Method for writing all entities to the dot file with all their attribute, method and parent relationships.

Parameters:
writer - BufferedWriter to use for writing.
Throws:
java.io.IOException - An exception is thrown if something goes wrong.

createDotFile

private java.io.File createDotFile()
Writes the analyze model to an external file in dot syntax.

Returns:
File containing the analyze model in dot syntax. Null is returned if something went wrong.

mapCurrentModel

private void mapCurrentModel()
Method for mapping the current analyze model. This is required to figure out differences with the submodel that is required to be highlighted.


mapHighlightRequest

private void mapHighlightRequest(AnalyzeModel highlight,
                                 boolean drawNewElements)
Method for mapping the submodel for highlight request.

Parameters:
highlight - Submodel to be highlighted.
drawNewElements - Indicates wether or not the new elements are supposed to be drawn in the highlighted model. New elements are those that exist in the highlight request but do not exist in the current analyze model.

highlight

public void highlight(AnalyzeModel highlight,
                      boolean drawNewElements)
Method for highlighting submodels from the analyze model.

Parameters:
highlight - The submodel to be highlighted. If this argument is null, then all applied highlights are removed.
drawNewElements - Indicates wether or not those elements which do not exist in the current analyze model should be also drawn and highlighted.

highlight

public void highlight(AnalyzeModel highlight)
Method for highlighting submodels from the analyze model. As default we assume that new entities don't need to be drawn.

Parameters:
highlight - Submodel to be highlighted.

updateModel

public void updateModel(AnalyzeModel model)
Method for updating the analyze model.

Parameters:
model - New analyze model.

paintComponent

public void paintComponent(java.awt.Graphics g)
This method draws the graph generated by dot to the panel's canvas.

Overrides:
paintComponent in class javax.swing.JComponent