ARoad0.Gui2
Class GraphicEPRView

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
                      extended by ARoad0.Gui2.GraphicEPRView
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:
GraphicSketchView

public class GraphicEPRView
extends GraphicView

This class is responsible for displaying an EPRViewInBase and its graphical objects (nodes, links, arrows, rights) in the desktop. The BaseObjects map is a map of (Source, Target) pairs, that is in fact (EligibleParty/VirtualFolder, Resource/VirtualFolder) pairs, and the GraphicNodes are GraphicAccount/Group/Resource/Actor/VirtualFolder. Study the parent GraphicView class for a good understanding of this class. Its subclasses are GraphicSketchView and GraphicNoThanView.

See Also:
EPRViewInBaseImpl, 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
private  boolean detectAcl_
           
private  boolean detectUserGroupLinks_
           
protected  java.util.List l_AccessTargetSources_
          After the search of the DisplayableLinkImpls, list of EligibleParties that are access targets for other Sources in viewInBase_.
protected  java.util.List l_NoSourceTargets_
          List of Targets in viewInBase_ that are not ImmutableSources, then this is the list of Resources which are not EligibleParties.
protected  int noSourceTargetsCount_
          l_NoSourceTargets_.size().
protected  int sourcesCount_
          number of Sources in viewInBase_
 
Fields inherited from class ARoad0.Gui2.GraphicView
ARROW_HEAD_ANGLE, ARROW_HEAD_LENGTH, BASIC_STROKE, BORDER, DASHED_DOUBLEWIDTH_STROKE, DASHED_STROKE, DOUBLEWIDTH_STROKE, dragSourceNodeName_, dragTargetNodeName_, INITIAL_CAPACITY, l_allNodesInLinks_, l_currentArrowsAndRightsStarts_, l_LinksAndRights_, l_rightsRelatedBaseObjects_, m_GraphicNodes_, m_GraphicNodesBounds_, m_l_DisplayableLinks_, mouseDragged_, NODE_DISTANCE, nodesNumber_, NULL_SHAPE_ARRAY, PRIME, RIGHTS_SHIFT, viewInBase_, WAITING_TEXT, whyText_
 
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
GraphicEPRView()
          This constructor is only for the subclasses.
GraphicEPRView(EPRViewInBase _view, java.util.Map _m_positionIndex)
          This constructor adds all the _view objects in this panel, each associated to a GraphicNode.
 
Method Summary
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..
 void finalizeForGui()
          Invoked by resetGraphicView() and ViewTreeBaseListenerImpl to finalize the instance and set it as a new object before the initialization.
private static java.awt.Shape formRightsShape(java.awt.Graphics2D _g2, java.lang.String _rights, java.awt.geom.Point2D.Float _point)
          NO USE.
 boolean hasFirstRateLinkInOneDLink(java.util.List _l_links)
          Checks up if there is at most one DisplayableLink which has a first rate link as last AccessControlLink.
 boolean hasOwnerContainLinkToGroupIDMember(java.util.List _l_links)
          Checks if there is at most one DisplayableLink which has all of its AccessControlLinks with a OWNER or CONTAIN relation.
 boolean hasStrengthenLinksInOneDLink(java.util.List _l_links)
          Check if there is at most one DisplayableLink which has all of its AccessControlLinks with a strengthen relation (OWNER, HAS_MEMBER, HAS_CHILD, IS_ALIAS, RUN_UNDER).
protected  void initialize()
          This central method is the main manager of the instance.
 void resetRights()
          Draws the new arrows and rights after a change in the rights, without changing in GraphicNodes.
protected static java.awt.geom.Line2D.Float setArrowHead(java.awt.geom.Point2D.Float _pointOne, java.awt.geom.Point2D.Float _pointTwo, boolean _aboveLine)
          Sets each side of an arrow head as a Line2D at the right position.
protected  void setGraphicNodes()
          Sets the GraphicNodes in a 16, 25, 49 or 100-positions layout in the JPanel, with their absolute coordinates.
 void setRightsRelatedBaseObjects(java.util.HashSet _l_baseObjects)
          These BaseObjects are provided by the gWork classes, and cannot be view objects.
 javax.swing.JTextPane setWhyText()
          This why text depends on the comments.
 
Methods inherited from class ARoad0.Gui2.GraphicView
addWaitingMessage, drawArrowsAndRights, getAllNodesInLinks, getEorDataModel, getExportImage, getHiddenNodesInLinks, getIndexesOfNodeLocations, getLinksHashCode, getMaximumSize, getMinimumSize, getPreferredSize, getRightsRelatedBaseObjects, getSelectedObjectOnMouseClicked, getWhyText, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, paintComponent, removeWaitingMessage, resetGraphicView, setGraphicNodeLocations, setGraphicNodesPositions, setIndexesOfNodeLocations, setPoint2DForArrowAndRights, setViewSize
 
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

l_NoSourceTargets_

protected java.util.List l_NoSourceTargets_
List of Targets in viewInBase_ that are not ImmutableSources, then this is the list of Resources which are not EligibleParties. Caution: in the subclass GraphicSketchView, it never contains the center node.


l_AccessTargetSources_

protected final java.util.List l_AccessTargetSources_
After the search of the DisplayableLinkImpls, list of EligibleParties that are access targets for other Sources in viewInBase_. Do not contain the VirtualFolders. Caution: in the subclass GraphicSketchView, it never contains the center node.


noSourceTargetsCount_

protected int noSourceTargetsCount_
l_NoSourceTargets_.size().


sourcesCount_

protected int sourcesCount_
number of Sources in viewInBase_


detectAcl_

private boolean detectAcl_

detectUserGroupLinks_

private boolean detectUserGroupLinks_
Constructor Detail

GraphicEPRView

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


GraphicEPRView

public GraphicEPRView(EPRViewInBase _view,
                      java.util.Map _m_positionIndex)
               throws ProcessError
This constructor adds all the _view objects in this panel, each associated to a GraphicNode. Builds up the map of (Source, Target) pair linked by displayable links, then sets the JPanel size, its GraphicNodes, constructs 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. Any BaseObject updating is done by GraphicViewBaseListenerImpl, which resets the instance through resetRights() and resetGraphicView(). Called by ActionOpenGraphicView.openViewInGui() in the event dispatch thread.

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

initialize

protected void initialize()
                   throws ProcessError,
                          java.lang.InterruptedException
This central method is the main manager of the instance. It initializes nodesNumber_, m_l_DisplayableLinks_, l_allNodesInLinks_, and set the Graphicnodes locations, and initializes l_NoSourceTargets_, l_AccessTargetSources_, noSourceTargetsCount_, sourcesCount_, detectAcl_, detectUserGroupLinks_, detectPriv_, detectCompoundLinks_. Called by the constructor and resetGraphicView() to do the main work. Calls RightsFactory_Facade.detectEPRRights(). Synchronized on viewInBase_. Overrides the GraphicView method.

Overrides:
initialize in class GraphicView
Throws:
InterruptedException, - ProcessError if there is a loop in the rights searching
ProcessError
java.lang.InterruptedException

setGraphicNodes

protected void setGraphicNodes()
Sets the GraphicNodes in a 16, 25, 49 or 100-positions layout in the JPanel, with their absolute coordinates. Called by intialize(). Calls super.setGraphicNodesPositions(). Clears then updates m_GraphicNodes_, updates m_GraphicNodesBounds_. Overridden by the GraphicSketchView and the GraphicNoThanView methods. Overrides the GraphicView method.

Overrides:
setGraphicNodes in class GraphicView

setWhyText

public final javax.swing.JTextPane setWhyText()
This why text depends on the comments. This method is used to test if the instance has been finalized. Its height is used by the GraphicViewBaseListener. Overridden by the GraphicNoThanView. Overrides the GraphicView method

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

finalizeForGui

public void finalizeForGui()
Invoked by resetGraphicView() and ViewTreeBaseListenerImpl to finalize the instance and set it as a new object before the initialization. There is the exception of whyText_ that is set to null to indicate the finalizing operation. Overrides the GraphicView method.

Overrides:
finalizeForGui in class GraphicView

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.. This complex method has to be fast.

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.

The strengthen path is associated to a strengthen relation including the OWNER, HAS_MEMBER, HAS_CHILD, IS_ALIAS, RUN_UNDER links. When it is a strengthen relation in the last link between 2 GroupIDMembers, to draw a line and not an arrow, there is one element for a line, two empty elements, and one text for the comments and rights.

Otherwise, there are plain arrows, but not from a starting node with a dashed_stroke arrow to show that this link is weak (marked by a 'WEAK' property of the first link).

The first-rate path is associated to a direct path which is superior to the other indirect paths between the two nodes, and its arrow is drawn with a larger width.

In GraphicSketchView, when a BaseObject is drawn twice in the graphic view, the second node is put on the bottom line of the access targets, and its key in m_GraphicNodes_ and m_GraphicNodesBounds_ is its name extended by ''.

This method selects only the first DisplayableLinkImpl to get the two ends, and to call link.getEorLastLink().getActivatedStrengthenTypes() and link.isWeak() The view Shapes and Strings are actually drawn in drawArrowsAndRights(). Called by the contructor, by resetRights() in this class and its subclass, and by the super class method GraphicView.mouseReleased(). Calls RightsFactory_Facade.getEffectiveRightsForPair(). Calls the super class method setPoint2DForArrowAndRights(), setArrowHead(). Synchronized on m_l_DisplayableLinks_. Puts the absolute positionning in l_currentArrowsAndRightsStarts_. Overridden by GraphicNoThanView, but not by GraphicSketchView. Overrides the GraphicView method.

Overrides:
buildUpArrowsAndRights in class GraphicView
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 GraphicEPRView.
Returns:
Object[] to draw in paintComponent(), with both the lines/arrows at absolute positionning (1 Shape for the line and 2 Shapes for the head) and the access rights and comments (1 String).

resetRights

public void resetRights()
                 throws ProcessError,
                        java.lang.InterruptedException
Draws the new arrows and rights after a change in the rights, without changing in GraphicNodes. Called in a worker thread by GraphicViewBaseListener.changeFrameView() and GraphicViewPropertyEditor.propertyChange(). Calls RightsFactory_Facade.detectEPRRights(), buildUpArrowsAndRights(). This method call must be preceded by addWaitingMessage() and must be followed by a call to removeWaitingMessage() and repaint(), both in the event dispatch thread. Overridden by GraphicSketchView. Overrides the super class.

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

setRightsRelatedBaseObjects

public final void setRightsRelatedBaseObjects(java.util.HashSet _l_baseObjects)
These BaseObjects are provided by the gWork classes, and cannot be view objects. Called by the gWork core algorithms. Overrides the super method to remove the view BaseObjects

Overrides:
setRightsRelatedBaseObjects in class GraphicView
Parameters:
_l_baseObjects - BaseObject set. May be null.

hasStrengthenLinksInOneDLink

public final boolean hasStrengthenLinksInOneDLink(java.util.List _l_links)
Check if there is at most one DisplayableLink which has all of its AccessControlLinks with a strengthen relation (OWNER, HAS_MEMBER, HAS_CHILD, IS_ALIAS, RUN_UNDER). The typical case is a simple dLink with one strengthen relation betwen the two nodes. Called by buildUpArrowsAndRights().

Parameters:
_l_links - list of DisplayableLinkImpl
Returns:
true if has one strengthen links in one dLink.

hasFirstRateLinkInOneDLink

public final boolean hasFirstRateLinkInOneDLink(java.util.List _l_links)
Checks up if there is at most one DisplayableLink which has a first rate link as last AccessControlLink. The arrow for this couple of nodes is then drawn with a double width by GraphicView. The typical case is a simple dLink with one NEG_ACL relation betwen the two nodes. This is a first-rate relation because it defines the true rights between the ends, overriding the meaning of the other indirect paths through other nodes in the view. These indirect paths are also drawn. Called by buildUpArrowsAndRights(). Calls AccessControlLinkImpl.isFirstRateLink(). See gWork.FactoryUtilities.getDLinksFromNegativePaths() as an exemple of the creation of such first-rate links.

Parameters:
_l_links - list of DisplayableLinkImpl
Returns:
true if there is a first-rate link in the argument.

hasOwnerContainLinkToGroupIDMember

public final boolean hasOwnerContainLinkToGroupIDMember(java.util.List _l_links)
Checks if there is at most one DisplayableLink which has all of its AccessControlLinks with a OWNER or CONTAIN relation. The typical case is a simple dLink with one CONTAIN relation betwen the two nodes, without a Resource as second end since they may use these links from GroupIDMembers or Actors. Return true for a link typically from an Actor to its current UserID or GroupID. Called by buildUpArrowsAndRights().

Parameters:
_l_links - list of DisplayableLinkImpl
Returns:
true if contain links in one dLink.

setArrowHead

protected static final java.awt.geom.Line2D.Float setArrowHead(java.awt.geom.Point2D.Float _pointOne,
                                                               java.awt.geom.Point2D.Float _pointTwo,
                                                               boolean _aboveLine)
Sets each side of an arrow head as a Line2D at the right position. Called by buildUpArrowsAndRights() from this class and GraphicNoThanView.

Parameters:
_pointOne - starting point of the arrow
_pointTwo - ending point of the arrow
_aboveLine - true to set the superior side of the arrow head, else set the inferior side
Returns:
one of the two sides of the arrow head

formRightsShape

private static final java.awt.Shape formRightsShape(java.awt.Graphics2D _g2,
                                                    java.lang.String _rights,
                                                    java.awt.geom.Point2D.Float _point)
NO USE. Forms the true shape of the rights for an arrow, on one line. If rights length is superior to 14, cuts in two lines at the next space character after the index 10. Synchronized on m_l_DisplayableLinks_.

Parameters:
_g2 -
_rights - String.
_point - Point2D.Float where the rights have to be drawn.
Returns:
Shape of the rights.