ARoad0.Gui2
Class GraphicView

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 ARoad0.Gui2.GraphicView
All Implemented Interfaces:
MVC_View, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible
Direct Known Subclasses:
GraphicEPRView, GraphicNoThanView

public class GraphicView
extends javax.swing.JPanel
implements MVC_View, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

This class is responsible for displaying a view and its graphical objects (nodes, links, arrows, rights) in the desktop.

The main work is done at the initialization of the instance, so that painting actions are very fast. The constructor calls initialize() which builds up the map of node pairs, each linked by none, one or many displayable links, in calling gWork.RightsFactory_Facade.detectXXXRights(). Then, initialize() sets the JPanel size, its GraphicNodes, sets its columns and defines the GraphicNode locations to obtain a clearer graphic representation. The constructor then calls buildUpArrowsAndRights() which sets the links and the visible rights in the view, as shapes or as strings which will be drawn in paintComponents() when the GraphicView is displayed.

The user may provide a drag&drop operation for moving a node in the view, and/or to permute two nodes. The user may also click on a node to select its BaseObject in the explorer. When he adds a new node in the view, it is put on the top left coin of the graphic view. Any updating is done by resetGraphicView and resetRights methods. When the nodes set changes, the method resetGraphicView() is called. When a right changes, the method resetRights() is called. No layout manager is used, because they do not allow to get the absolute position of a GraphicNode, that is necessary to draw the links between the nodes.

This class is directly used only for the 'Architecture' view. Its subclasses are GraphicEPRView and GraphicNoThanView, and they provide most of the work. However, this class is a strong support for all the subclasses methods, and should be well understood.

This class is designed to be updated, as any JComponent, by the event dispatch thread for most of the operations, but it allows the rights updating in a worker thread, through the call of resetRights(). For a presentation of the view threads, see GraphicViewBaseListernerImpl. A main design principle is that each view is independant, so it can be processed in any thread. On the other hand, it is not possible to reuse the access paths of a view in another view.

See Also:
ViewInBaseImpl, GraphicViewBaseListenerImpl, Serialized Form

Nested Class Summary
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected static float ARROW_HEAD_ANGLE
          angle in the arrow head
protected static float ARROW_HEAD_LENGTH
          length of the arrow head
protected static java.awt.BasicStroke BASIC_STROKE
          stroke generally used for drawing and filling the shapes
protected static int BORDER
          border of the graphic view panel
protected static java.awt.BasicStroke DASHED_DOUBLEWIDTH_STROKE
          dashed stroke for arrows or lines
protected static java.awt.BasicStroke DASHED_STROKE
          dashed stroke for arrows or lines
protected static java.awt.BasicStroke DOUBLEWIDTH_STROKE
          double-width stroke for arrows
protected  ImmutableName dragSourceNodeName_
          in a drag&drop operation, the name of the source node to move.
protected  ImmutableName dragTargetNodeName_
          in a drag&drop operation to move a node, the target node name, if the target is not empty.
protected static int INITIAL_CAPACITY
          initial capacity used for List and Map initialization the default value for Map is 101
protected  java.util.Set<BaseObject> l_allNodesInLinks_
          Set of all the implied BaseObjects that are nodes, displayable or not, in the GraphicView DisplayableLinkImpls
protected  java.lang.Object[] l_currentArrowsAndRightsStarts_
          image of l_LinksAndRights_, but with a Point2D at the rights place, to give to drawArrowsAndRights() the position of the rights to draw
protected  java.lang.Object[] l_LinksAndRights_
          array of objects ready to be drawn, as Shapes and associated Strings.
protected  java.util.HashSet<BaseObject> l_rightsRelatedBaseObjects_
          Set of all the BaseObjects implied in gWork to define the rights.
protected  java.util.Map<ImmutableName,GraphicNode> m_GraphicNodes_
          map of GraphicNodes, the associated BaseObject name is the key, sometimes extended by in GraphiSketchView, or the key is WAITING_TEXT in a name
protected  java.util.Map<ImmutableName,java.awt.geom.Rectangle2D> m_GraphicNodesBounds_
          map of the GraphicNode absolute cordinates in this panel Graphics2D, the associated BaseObject name is the key, Rectangle2D is the value type; get through GraphicNode.getShape().
protected  java.util.Map<ImmutableName,java.util.List<DisplayableLinkImpl>> m_l_DisplayableLinks_
          map of DisplayableLinkImpls; the compound name constructed with the two base objects names (eligible party first) is the key; the value is a List of DisplayableLinkImpls for getting all the visible or hiden links between two view base objects.
protected  boolean mouseDragged_
          true when there is a drag&drop operation.
protected static int NODE_DISTANCE
          distance to select the arrow construction algorithm in setPoint2DForArrowAndRights()
protected  int nodesNumber_
          number of nodes in the view.
protected static java.lang.Object[] NULL_SHAPE_ARRAY
          null shape array used to test the return value from buildUpArrows()
protected static int PRIME
           
protected static int RIGHTS_SHIFT
          shift along the y axis to display a second line for rights.
protected  ViewInBase viewInBase_
          ViewInBase associated to this GraphicView
protected static java.lang.String WAITING_TEXT
           
protected  javax.swing.JTextPane whyText_
          JTextPane displayed through the button "See why" in the view frame
 
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
GraphicView()
          This constructor is only for the subclasses.
GraphicView(ViewInBase _view, java.util.Map _m_positionIndex)
          This constructor add all the _view objects in this panel, each associated to a GraphicNode.
 
Method Summary
 void addWaitingMessage()
          Display at the top left corner of the view, the user message 'Please wait...' in green, as a GraphicText.
protected  java.lang.Object[] buildUpArrowsAndRights(java.util.Map _m_l_DisplayableLinks, java.util.Map _m_gNodeBoundsModel)
          Sets the property l_LinksAndRights_ which contains the links and rights as Shapes, to be painted by drawArrowsAndRights() in this GraphicView.
protected  void drawArrowsAndRights(java.awt.Graphics2D _g2)
          Draws the arrows and the rights in Serif 11 from the values in l_LinksAndRights_ and l_currentArrowsAndRightsStarts_.
 void finalizeForGui()
          Invoked by resetGraphicView() and ViewTreeBaseListenerImpl to finalize the instance, or to set it as a new object before the initialization, with the exception of whyText_ that is set to null to indicate the finalizing operation.
 java.util.Set getAllNodesInLinks()
           
 ViewInBase getEorDataModel()
           
 java.awt.image.BufferedImage getExportImage()
          Provides the image to be exported, as a PNG image for instance.
 java.util.Set getHiddenNodesInLinks()
          Called by InternalFrame.showViewFrame() for building up the extended view.
 java.util.Map getIndexesOfNodeLocations()
          Get the relative positions of nodes, for the GUI saving.
 int getLinksHashCode()
           
 java.awt.Dimension getMaximumSize()
           
 java.awt.Dimension getMinimumSize()
           
 java.awt.Dimension getPreferredSize()
           
 java.util.HashSet getRightsRelatedBaseObjects()
          Gets the set of all the BaseObjects implied in gWork to define the rights.
protected  BaseObject getSelectedObjectOnMouseClicked(java.awt.event.MouseEvent _e)
          Called by mouseClicked() to find the BaseObject in the view on which the user has clicked.
 java.lang.String getWhyText()
          Get the current comments that the program has generated to explain the current view rights.
protected  void initialize()
          Initializes nodesNumber_, m_l_DisplayableLinks_, l_allNodesInLinks_, and set the GraphicNodes locations.
 void mouseClicked(java.awt.event.MouseEvent _e)
          Through a click on a view object, select the object in the explorer and the beamer.
 void mouseDragged(java.awt.event.MouseEvent _e)
          If the mouse is dragged from a view node position to another view node position, the two nodes are permutted.
 void mouseEntered(java.awt.event.MouseEvent _e)
          No action.
 void mouseExited(java.awt.event.MouseEvent _e)
          No action.
 void mouseMoved(java.awt.event.MouseEvent _e)
          No action.
 void mousePressed(java.awt.event.MouseEvent _e)
          No action.
 void mouseReleased(java.awt.event.MouseEvent _e)
          If the mouse has been dragged from a view node position to another view node position, the two nodes are permutted when the mouse is released.
protected  void paintComponent(java.awt.Graphics _g)
          Paint the GraphicView.
 void removeWaitingMessage()
          Removes at the top left corner of the view, the user message 'Please wait...' in green.
 void resetGraphicView()
          This central method resets the view after a view nodes changing.
 void resetRights()
          Draws the new arrows and rights after a change in the rights, with no change in GraphicNodes.
protected  void setGraphicNodeLocations(ImmutableName _newNodeName, java.util.Map _m_GraphicNodesPosition)
          Add/remove to the graphic view a base object and its location, if non-null, and restores the old locations for the old objects.
protected  void setGraphicNodes()
          Sets the GraphicNodes in a 16, 25, 49 or 100 nodes layout in the JPanel, with their absolute coordinates.
protected  java.awt.Point[] setGraphicNodesPositions(int _nodesNumber, boolean _initial)
          Sets the space of all the allowed positions for the nodes in the view, while the method setGraphicNodeLocations provides the effective location of each node.
 void setIndexesOfNodeLocations(java.util.Map<ImmutableName,java.lang.Integer> _m_positionIndex)
          Sets the relative positions of nodes, after a GUI saving.
protected static java.awt.geom.Point2D.Float[] setPoint2DForArrowAndRights(ImmutableName _end_one, ImmutableName _end_two, java.util.Map _m_gNodeBoundsModel, int _epArrowsCount)
          Sets the absolute positions of the line or arrow for a pair of GraphicNodes, by the mean of the shape positions for the 2 GraphicRects that are associated to the pair.
 void setRightsRelatedBaseObjects(java.util.HashSet _l_baseObjects)
          These BaseObjects are provided by the gWork classes.
protected  void setViewSize(int _nodesNumber)
          Set the size of the JPanel when the view contains less than 47 elements.
 javax.swing.JTextPane setWhyText()
          Sets the comments that the gWork package generates to explain the view rights.
 
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, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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

PRIME

protected static final int PRIME
See Also:
Constant Field Values

INITIAL_CAPACITY

protected static final int INITIAL_CAPACITY
initial capacity used for List and Map initialization the default value for Map is 101

See Also:
Constant Field Values

RIGHTS_SHIFT

protected static final int RIGHTS_SHIFT
shift along the y axis to display a second line for rights. No use.

See Also:
Constant Field Values

BORDER

protected static final int BORDER
border of the graphic view panel

See Also:
Constant Field Values

ARROW_HEAD_LENGTH

protected static final float ARROW_HEAD_LENGTH
length of the arrow head

See Also:
Constant Field Values

ARROW_HEAD_ANGLE

protected static final float ARROW_HEAD_ANGLE
angle in the arrow head

See Also:
Constant Field Values

DASHED_STROKE

protected static final java.awt.BasicStroke DASHED_STROKE
dashed stroke for arrows or lines


DOUBLEWIDTH_STROKE

protected static final java.awt.BasicStroke DOUBLEWIDTH_STROKE
double-width stroke for arrows


DASHED_DOUBLEWIDTH_STROKE

protected static final java.awt.BasicStroke DASHED_DOUBLEWIDTH_STROKE
dashed stroke for arrows or lines


BASIC_STROKE

protected static final java.awt.BasicStroke BASIC_STROKE
stroke generally used for drawing and filling the shapes


NULL_SHAPE_ARRAY

protected static final java.lang.Object[] NULL_SHAPE_ARRAY
null shape array used to test the return value from buildUpArrows()


NODE_DISTANCE

protected static final int NODE_DISTANCE
distance to select the arrow construction algorithm in setPoint2DForArrowAndRights()

See Also:
Constant Field Values

WAITING_TEXT

protected static final java.lang.String WAITING_TEXT
See Also:
Constant Field Values

m_GraphicNodes_

protected final java.util.Map<ImmutableName,GraphicNode> m_GraphicNodes_
map of GraphicNodes, the associated BaseObject name is the key, sometimes extended by in GraphiSketchView, or the key is WAITING_TEXT in a name


m_GraphicNodesBounds_

protected final java.util.Map<ImmutableName,java.awt.geom.Rectangle2D> m_GraphicNodesBounds_
map of the GraphicNode absolute cordinates in this panel Graphics2D, the associated BaseObject name is the key, Rectangle2D is the value type; get through GraphicNode.getShape().


m_l_DisplayableLinks_

protected java.util.Map<ImmutableName,java.util.List<DisplayableLinkImpl>> m_l_DisplayableLinks_
map of DisplayableLinkImpls; the compound name constructed with the two base objects names (eligible party first) is the key; the value is a List of DisplayableLinkImpls for getting all the visible or hiden links between two view base objects. All links in a list have the SAME 2 ENDS.


l_LinksAndRights_

protected java.lang.Object[] l_LinksAndRights_
array of objects ready to be drawn, as Shapes and associated Strings. Updated directly by some subclasses.


l_currentArrowsAndRightsStarts_

protected java.lang.Object[] l_currentArrowsAndRightsStarts_
image of l_LinksAndRights_, but with a Point2D at the rights place, to give to drawArrowsAndRights() the position of the rights to draw


viewInBase_

protected ViewInBase viewInBase_
ViewInBase associated to this GraphicView


whyText_

protected javax.swing.JTextPane whyText_
JTextPane displayed through the button "See why" in the view frame


l_allNodesInLinks_

protected java.util.Set<BaseObject> l_allNodesInLinks_
Set of all the implied BaseObjects that are nodes, displayable or not, in the GraphicView DisplayableLinkImpls


l_rightsRelatedBaseObjects_

protected java.util.HashSet<BaseObject> l_rightsRelatedBaseObjects_
Set of all the BaseObjects implied in gWork to define the rights. Updated by gWork classes.


nodesNumber_

protected int nodesNumber_
number of nodes in the view.


dragSourceNodeName_

protected ImmutableName dragSourceNodeName_
in a drag&drop operation, the name of the source node to move.


dragTargetNodeName_

protected ImmutableName dragTargetNodeName_
in a drag&drop operation to move a node, the target node name, if the target is not empty.


mouseDragged_

protected boolean mouseDragged_
true when there is a drag&drop operation.

Constructor Detail

GraphicView

public GraphicView()
This constructor is only for the subclasses.


GraphicView

public GraphicView(ViewInBase _view,
                   java.util.Map _m_positionIndex)
            throws ProcessError
This constructor add all the _view objects in this panel, each associated to a GraphicNode. Build up the map of (EP, Resource) pair linked by displayable links, then set the JPanel size, its GraphicNodes and its columns, construct the arrows and the visible rights shapes to be drawn in paintComponents(). The main work is done there by buildUpArrowsAndRights(), so that the paint action is fast. But an important condition is to have a stable set of BaseObjects in the view, without updating. Any BaseObject updating is done by GraphicViewBaseListenerImpl, which finalizes the previous GraphicView instance and then, creates a new one. Mantain an External Object Reference to _view. This constructor is not called by the constructors of the subclasses.

Parameters:
_view - EPRViewInBase to associate to this instance.
_m_positionIndex - is the map (name, Integer) of the map returned by getIndexesOfNodeLocations() at the previous view opening. May be null.
Throws:
ProcessError - if there is a loop in the access paths searching
Method Detail

initialize

protected void initialize()
                   throws ProcessError,
                          java.lang.InterruptedException
Initializes nodesNumber_, m_l_DisplayableLinks_, l_allNodesInLinks_, and set the GraphicNodes locations. Display an user message if the view size is superior to 46. Called by the constructor and resetGraphicView(). Calls RightsFactory_Facade.detectRights(). Synchronized on viewInBase_. Overridden method.

Throws:
InterruptedException, - ProcessError if there is a loop in the rights search
ProcessError
java.lang.InterruptedException

getExportImage

public final java.awt.image.BufferedImage getExportImage()
Provides the image to be exported, as a PNG image for instance. Not used by ActionExportPNG, since it does not provide the true colors.

Returns:
the image

resetRights

public void resetRights()
                 throws ProcessError,
                        java.lang.InterruptedException
Draws the new arrows and rights after a change in the rights, with no change in GraphicNodes. Called in a worker thread by GraphicViewBaseListener.updateFrameViewRights() and GraphicViewPropertyEditor.propertyChange(). Calls RightsFactory_Facade.detectRights(), buildUpArrowsAndRights(). This method call must be preceded by addWaitingMessage() and must be followed by a call to removeWaitingMesage() and repaint(), both in the event dispatch thread. Overridden by GraphicEPRView and GraphicNoThanView.

Throws:
ProcessError - if there is a loop in the rights search
java.lang.InterruptedException

resetGraphicView

public void resetGraphicView()
                      throws ProcessError,
                             java.lang.InterruptedException
This central method resets the view after a view nodes changing. It finalizes the previous graphic nodes which are no more there. Called in a worker thread from GraphicViewBaseListener.changeFrameView() and GraphicViewPropertyEditor.propertyChange(). Calls addWaitingMessage() and repaint() in the Event Dispatch Thread, before the reinitialization of the GraphicNodes. Calls finalizeForGui(), initialize(), addNewGraphicNodeLocation(), buildUpArrowsAndRights(). There is no removeGraphicNodeLocation() method. This method is used directly by GraphicEPRView and GraphicNoThanView when a node has been added or removed. It is overridden by GraphicSketchView.

Throws:
ProcessError - if there is a loop in the rights search
java.lang.InterruptedException

mouseClicked

public final void mouseClicked(java.awt.event.MouseEvent _e)
Through a click on a view object, select the object in the explorer and the beamer. Use m_GraphicNodesBounds_ to find the right object on which the user clicks on. In GraphicNoThanView, it works also for the two GraphicTexts for right criteria, where the keys in m_GraphicNodesBounds_ are the two values GraphicNoThanView.NO_MORE or LESS_RIGHT_GRAPHICTEXT_BOUNDS_KEY. Calls getSelectedObjectOnMouseClicked().

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
_e - is the event

getSelectedObjectOnMouseClicked

protected BaseObject getSelectedObjectOnMouseClicked(java.awt.event.MouseEvent _e)
Called by mouseClicked() to find the BaseObject in the view on which the user has clicked. Overidden method by GraphicSketchView.

Parameters:
_e - is the event
Returns:
the selected BaseObject or null
Since:
0.7.0

mouseEntered

public final void mouseEntered(java.awt.event.MouseEvent _e)
No action.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
_e - is the event

mouseExited

public final void mouseExited(java.awt.event.MouseEvent _e)
No action.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
_e - is the event

mousePressed

public final void mousePressed(java.awt.event.MouseEvent _e)
No action.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
_e - is the event

mouseMoved

public final void mouseMoved(java.awt.event.MouseEvent _e)
No action.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
_e - is the event

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent _e)
If the mouse has been dragged from a view node position to another view node position, the two nodes are permutted when the mouse is released. If the mouse is dragged and released to an empty node position, the first node is moved to this empty position if it is not the index 0 in the positions array. Noop on the WAITING_TEXT node.

Caution: dragSourceNodeName_ is set by mouseDragged() that searches among the node positions. The user has to not be too fast, if there are a big number of nodes.

Overridden method in GraphicSketchView and GraphicNoThanView.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
_e - is the event

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent _e)
If the mouse is dragged from a view node position to another view node position, the two nodes are permutted. If it is dragged to an empty node position, the first node is moved to this position. For large views, the search of the right node is quite slow. Overridden method in GraphicSketchView.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
_e - is the event
See Also:
mouseReleased(java.awt.event.MouseEvent)

getIndexesOfNodeLocations

public final java.util.Map getIndexesOfNodeLocations()
Get the relative positions of nodes, for the GUI saving. The position is an index in the Points array which is applicable to this view, according to its size, which is returned by setGraphicNodesPositions(). Do not process the WAITING_TEXT node. No use for the sketch views, and usuful for NoThan views.

Returns:
Map of indexes in the GraphicNode Points array, where the node name is the key and the value is an Integer

setIndexesOfNodeLocations

public final void setIndexesOfNodeLocations(java.util.Map<ImmutableName,java.lang.Integer> _m_positionIndex)
Sets the relative positions of nodes, after a GUI saving. The argument is typically the returned value from getIndexesOfNodeLocations() at the previous opening of the view. As any new node changes the view size, the array of points may then be not relevant for the locations which are set by _m_positionIndex. So this method does not operate if the number of nodes is not the previous number at the saving time. Called by the constructor. No use for the sketch views. For the NoThan views, noop since the number of nodes is not the previous number at the saving time. Caution: view nodes added after the saving are not processed. Rights may change.

Parameters:
_m_positionIndex - Map of indexes in the GraphicNode Points array, where the node name is the key. Never null.

getEorDataModel

public ViewInBase getEorDataModel()
Returns:
ViewInBase drawn by the GraphicView

getAllNodesInLinks

public java.util.Set getAllNodesInLinks()
Returns:
Set of all the implied BaseObjects that are nodes, displayable or not, in the GraphicView DisplayableLinkImpls

getHiddenNodesInLinks

public java.util.Set getHiddenNodesInLinks()
Called by InternalFrame.showViewFrame() for building up the extended view.

Returns:
Set of the implied BaseObjects that are hidden, not displayable in the GraphicView DisplayableLinkImpls since they are not in the view

getRightsRelatedBaseObjects

public java.util.HashSet getRightsRelatedBaseObjects()
Gets the set of all the BaseObjects implied in gWork to define the rights. These BaseObjects are provided by the gWork classes (CompoundRightsFactoryImpl). They include l_allNodesInLinks_. Called by ViewModel, GraphicViewBaseListenerImpl.changeView(), gWork.RightsFactoryUtilities.setWhyText().

Returns:
the rights-related BaseObjects or ImmutableNames. Never null.

setRightsRelatedBaseObjects

public void setRightsRelatedBaseObjects(java.util.HashSet _l_baseObjects)
These BaseObjects are provided by the gWork classes. Called by the gWork core algorithms. Overridden method.

Parameters:
_l_baseObjects - BaseObject set. May be null.

getLinksHashCode

public int getLinksHashCode()
Returns:
the hashCode from the DisplayableLinks map

getWhyText

public java.lang.String getWhyText()
Get the current comments that the program has generated to explain the current view rights.

Returns:
the text which explains the rights in the view. Null if finalized or at the GraphicView initialization.

setWhyText

public javax.swing.JTextPane setWhyText()
Sets the comments that the gWork package generates to explain the view rights. No use. This method is operating only in the subclasses. Also used to test if this instance has been finalized. Its height is used by the GraphicViewBaseListener.

Returns:
the text which explains the rights in the view. Null if finalized. Empty at the GraphicView initialization.

finalizeForGui

public void finalizeForGui()
Invoked by resetGraphicView() and ViewTreeBaseListenerImpl to finalize the instance, or to set it as a new object before the initialization, with the exception of whyText_ that is set to null to indicate the finalizing operation. viewInBase_ may be already finalized when this method is called (see InternalFrame.openSketcher()). Overridden by GraphicEPRView and GraphicNoThanView.


getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides:
getMinimumSize in class javax.swing.JComponent
Returns:
Dimension of the minimum GraphicView size

getMaximumSize

public java.awt.Dimension getMaximumSize()
Overrides:
getMaximumSize in class javax.swing.JComponent
Returns:
Dimension of the maximum GraphicView size

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
Dimension of the preferred GraphicView size

addWaitingMessage

public void addWaitingMessage()
Display at the top left corner of the view, the user message 'Please wait...' in green, as a GraphicText.

The map m_GraphicNodes_ is updated, but not m_GraphicNodesBounds_.

Called by GraphicViewBaseListenerImpl.updateFrameViewRights(), GraphicViewPropertyEditor.propertyChange() just before the call of resetRights(), and resetGraphicView() just before a call to repaint(). After the call of one of this method, the user message has to be removed through a call to removeWaitingMessage(). No use with resetGraphicView().

This method has to be called only in the event dispatch thread, to avoir any thread collision.


removeWaitingMessage

public void removeWaitingMessage()
Removes at the top left corner of the view, the user message 'Please wait...' in green.

The map m_GraphicNodes_ is updated, but not m_GraphicNodesBounds_.

Called by GraphicViewBaseListenerImpl.changeFrameView() and updateFrameViewRights(), and by GraphicViewPropertyEditor.propertyChange() just before the call to repaint().

Called only in the event dispatch thread, but the method is synchronized to detect any thread collision. No operation if there is no waiting message in the view.


paintComponent

protected void paintComponent(java.awt.Graphics _g)
Paint the GraphicView. This method is designed to be fast. It draws Shapes and Strings. Overrides the super method and calls it.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
_g - Graphics.

setGraphicNodes

protected void setGraphicNodes()
Sets the GraphicNodes in a 16, 25, 49 or 100 nodes layout in the JPanel, with their absolute coordinates. Called by intialize(). Updates m_GraphicNodes_, m_GraphicNodesBounds_. Overridden method.


setGraphicNodesPositions

protected final java.awt.Point[] setGraphicNodesPositions(int _nodesNumber,
                                                          boolean _initial)
Sets the space of all the allowed positions for the nodes in the view, while the method setGraphicNodeLocations provides the effective location of each node. There are 4 sets of node positions: one if _nodesNumber is inferior to 8 (offering 16 possible positions),

one between 8 and 12 nodes (25 positions);

one between 13 and 20 nodes (49 possible positions),

and one for the values from 21 to 46 nodes (100 possible positions).

Each node position is at the top left corner of the node. Must be called always after setViewSize(). Called by setGraphicNodes(), mouseReleased(), setGraphicNodeLocations(), GraphicEPRView.setGraphicNodes() and GraphicNoThanView.setGraphicNodes(). Overridden by the GraphicSketchView method.

Parameters:
_nodesNumber - is the number of BaseObjects in the view. May be 0. No operation if it is superior to 46 or negative.
_initial - true if it is for the initial view where the nodes are put on a circle or a scare
Returns:
the array of node positions, in the correct order; equal to Point[0] if no operation. No null item in the array.

setGraphicNodeLocations

protected void setGraphicNodeLocations(ImmutableName _newNodeName,
                                       java.util.Map _m_GraphicNodesPosition)
Add/remove to the graphic view a base object and its location, if non-null, and restores the old locations for the old objects. Adapts the locations to the new grid if necessary. Works even if there are more than one new node, for instance with an ACSObject and its alias EPRViewInBase adds to itself. When the ViewInBase contains a new object that is not named by _newNodeName, this object is unknown in m_GraphicNodesBounds_, and it is put at the end of the possible node locations. Called only by resetGraphicView() and after initialize(). Overridden by GraphicNoThanView which do nothing, since its initialize() method makes the job.

Parameters:
_newNodeName - name of the base object to add. May be null.
_m_GraphicNodesPosition - is the map of the old locations. May be empty.

setViewSize

protected void setViewSize(int _nodesNumber)
Set the size of the JPanel when the view contains less than 47 elements. If _nodesNumber is inferior to 8, the size is GraphicNode.EIGHT_NODES_VIEW_SIZE. Else if _nodesNumber is inferior to 13, the size is GraphicNode.TWELVE_NODES_VIEW_SIZE. Else if _nodesNumber is inferior to 21, the size is GraphicNode.TWENTY_FOUR_NODES_VIEW_SIZE. Else the size is GraphicNode.FORTY_SIX_NODES_VIEW_SIZE. Called by setGraphicNodes(). Overridden method in GraphicSketchView.

Parameters:
_nodesNumber - is the number of BaseObjects in the view. No operation if it is superior to 47 or negative.

buildUpArrowsAndRights

protected java.lang.Object[] buildUpArrowsAndRights(java.util.Map _m_l_DisplayableLinks,
                                                    java.util.Map _m_gNodeBoundsModel)
Sets the property l_LinksAndRights_ which contains the links and rights as Shapes, to be painted by drawArrowsAndRights() in this GraphicView. There are 4 elements for each typical arrow: 3 for the arrow and 1 text for the description, which are often the rights to display. Only structural path is drawn; it is associated to a BRIDGE relation. These Shapes and Strings are actually drawn in drawArrowsAndRights(). Called by the contructor after initialize(), by resetRights() and mouseReleased(). Calls setPoint2DForArrowAndRights(). Synchronized on m_l_DisplayableLinks_. Overridden method.

Parameters:
_m_l_DisplayableLinks - is the Map of DisplayableLinks lists (one per pair) associated to the view.
_m_gNodeBoundsModel - is the Map of the node bounds for the shapes in the GraphicView.
Returns:
Object[] to draw in paintComponent(), with both the arrows at absolute positionning (1 Shape for the line and 2 empty Shapes for the head) and the access rights and comments (1 String).

setPoint2DForArrowAndRights

protected static final java.awt.geom.Point2D.Float[] setPoint2DForArrowAndRights(ImmutableName _end_one,
                                                                                 ImmutableName _end_two,
                                                                                 java.util.Map _m_gNodeBoundsModel,
                                                                                 int _epArrowsCount)
Sets the absolute positions of the line or arrow for a pair of GraphicNodes, by the mean of the shape positions for the 2 GraphicRects that are associated to the pair. Defines the default value for the rights string start, which is near the start of the arrow, with a shift that is RIGHTS_SHIFT. Takes account of the relative positions of the two base objects. Called by buildUpArrowsAndRights(), in this class and in the subclasses, but not by GraphicNoThanView. Synchronized on m_l_DisplayableLinks_ through buildUpArrowsAndRights().

Parameters:
_end_one - is the name of a GraphicNode to display
_end_two - is the name of a GraphicNode to display
_m_gNodeBoundsModel - is the Map of the node bounds in the GraphicView, where the GraphiNode name is the key.
_epArrowsCount - is the number of arrows already drawn for the node, + 1.
Returns:
Point2D.Float[] array of 3 items: arrowStartPoint2D and arrowEndPoint2D defines the line (or arrrow) start and end points, and defaultRightsStartPoint2D defines the start point where the String is drawn.

drawArrowsAndRights

protected void drawArrowsAndRights(java.awt.Graphics2D _g2)
Draws the arrows and the rights in Serif 11 from the values in l_LinksAndRights_ and l_currentArrowsAndRightsStarts_. The GraphicNodes are painted by paintComponent() and getExportImage() which call this method. This method is designed to be fast, since Shapes and Strings to draw has been put in the l_LinksAndRights_ array by buildUpArrowsAndRights() before the call of this method. The links are in black, dark grey or blue, dashed or not, as lines or arrows. The texts are in black or blue. Arrows are in dark grey and may be dashed. Only simple lines are in blue. Simple lines and arrows are dashed only if the text begins with '<>', which is then removed. Arrows have double lenght only if the text begins with '><', (>) which is then removed. Arrows are dashed with double lenght only if the text begins with '>>', which is then removed. The text is in blue only if it contains more than one '!', which are not removed. Uses antialiasing on shapes and texts. Called by paintComponent(), getExportImage() and the subclasses, excepted in GraphicNoThanView that Overrides it.

Parameters:
_g2 - is the Graphics2D to draw