unbbayes.gui
Class GraphPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLayeredPane
                  extended by unbbayes.draw.UCanvas
                      extended by unbbayes.gui.GraphPane
All Implemented Interfaces:
ComponentListener, KeyListener, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
LearningPNEditionPane

public class GraphPane
extends UCanvas
implements MouseListener, MouseMotionListener

Essa classe ÔøΩ responsÔøΩvel por desenhar a rede Bayesiana ou a MFrag na tela. Ela extende a classe JPanel. Ela tambÔøΩm implementa as interfaces MouseListener e MouseMotionListener, para poder tratar os eventos de mouse e desenhar a rede Bayesiana.

Author:
Michael S. Onishi, Rommel N. Carvalho
See Also:
Modified by Young, 4.13.2009, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JLayeredPane
JLayeredPane.AccessibleJLayeredPane
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 GraphAction action
           
static Color backgroundColor
           
 List<Edge> edgeList
           
 Dimension graphDimension
           
 JViewport graphViewport
           
 IconController iconController
           
static int iUpdate
           
 ProbabilisticNetwork net
           
 ArrayList<Node> nodeList
           
 String PANEMODE_COMPILE
           
 String PANEMODE_NONE
           
 List<Node> selectedGroup
           
 String strPaneMode
           
 Dimension visibleDimension
           
 
Fields inherited from class unbbayes.draw.UCanvas
controller, dragPoint, dragRect, layerID, m_state, NODE_ALIGN_BOTTOM, NODE_ALIGN_LEFT, NODE_ALIGN_RIGHT, NODE_ALIGN_TOP, resizeRect, selectedShapes, selectRect, shapeTest, STATE_CONNECT_COMP, STATE_CTRL, STATE_NONE, STATE_RESIZE_COMP, STATE_UPDATE, strTextOutputMode, TEXTOUTPUTMODEMODE_NONE, TEXTOUTPUTMODEMODE_USE_DESC, TEXTOUTPUTMODEMODE_USE_NAME
 
Fields inherited from class javax.swing.JLayeredPane
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER
 
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
GraphPane(JDialog dlg, ProbabilisticNetwork n)
           
GraphPane(NetworkController controller, JViewport graphViewport)
          O construtor ÔøΩ responsÔøΩvel por iniciar todas as variÔøΩveis que serÔøΩo utilizadas por essa classe para que se possa desenhar a rede Bayesiana.
 
Method Summary
 void compiled(boolean reset, Node selectedNode)
           
 void createNode(Node newNode)
          This method literally re-generates the UShape instance for a given newNode parameter.
 GraphAction getAction()
          Get the action to be taken.
 Point2D.Double getBiggestPoint()
          Pega o maior ponto (Point2D.Double) do objeto da classe GraphPane
 Dimension getGraphDimension()
          Pega a Dimension tamanhoRede do objeto da classe GraphPane
 JViewport getGraphViewport()
          Pega o atributo graphViewport (JViewport) do objeto da classe GraphPane
 INodeClassDataTransferObject getNodeDataTransferObject()
          This object is used by GraphPane in order to temporally store all informations about a node loaded by plugins, between the moment that a user clicks the "add" button and the moment that the node is actually created and inserted into canvas.
 String getPaneMode()
           
protected  CorePluginNodeManager getPluginNodeManager()
          This object manages plugin-loaded nodes.
 Object getSelected()
          Retorna o objeto selecionado (Object), que pode ser um Node ou Edge
 List<Node> getSelectedGroup()
          Retorna uma lista de selecionados (List), que podem ser um Node e/ou Edge
 boolean insertEdge(Edge edge)
           
 boolean isFocusable()
          Pega o atributo focusTransversable do objeto da classe GraphPane
 boolean isToUseSelectionForLines()
          update() will set UShape.getUseSelection() to same value;
 void mouseClicked(MouseEvent e)
          This method is responsible to treat mouse button events
 void mouseReleased(MouseEvent e)
           
 UShapeLine onDrawConnectLineReleased(UShape shapeParent, int x, int y)
           
 void onSelectionChanged()
           
 void onShapeChanged(UShape s)
           
 void onShapeDeleted(UShape s)
           
 void resetGraph()
           
 void resetPopup()
           
 void resizeAllToFitText()
           
 void selectNode(Node n)
           
 void setAction(GraphAction action)
          Set the action to be taken.
 void setAction(GraphAction action, INodeClassDataTransferObject dto)
          This is equivalent to setNodeDataTransferObject(INodeClassDataTransferObject) followed by setAction(GraphAction)
 void setGraphDimension(Dimension graphDimension)
          Seta o atributo graphDimension (tamanho da rede Bayesiana) do objeto da classe GraphPane
protected  void setNodeDataTransferObject(INodeClassDataTransferObject nodeClassDataTransferObject)
          This object is used by GraphPane in order to temporally store all informations about a node loaded by plugins, between the moment that a user clicks the "add" button and the moment that the node is actually created and inserted into canvas.
 void setPaneMode(String str)
           
protected  void setPluginNodeManager(CorePluginNodeManager pluginNodeManager)
          This object manages plugin-loaded nodes.
 void setState(String s)
           
 void setToUseSelectionForLines(boolean toUseSelectionForLines)
          update() will set UShape.getUseSelection() to same value;
 void showCPT(Node newNode)
           
 void update()
           
 void updateAllNodesName()
           
 void updateSelectedNode()
           
 void useDescAllShape()
           
 void useNameAllShape()
           
 
Methods inherited from class unbbayes.draw.UCanvas
addShape, checkSelectArea, componentHidden, componentMoved, componentResized, componentShown, connectLinesForAllSelectedShape, DeleteSelectedShape, delShape, drawResizeRectEnter, drawResizeRectReleased, fitCanvasSizeToAllUShapes, getController, getNodeUShape, getNodeUShape, getSelectedShape, getSelectedShapes, getSelectedShapesNode, GetShape, GetShape, getState, getTextOutputMode, keyPressed, keyReleased, keyTyped, mouseDragged, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mousePressed, mouseReleased, onAlignNodes, onDrawConnectLineEnter, onPositionChanged, onResized, onResizeToFitText, onShapeColorChanged, onShapeMoved, onShapeTypeChanged, paintComponent, setController, setDiamond, setEllipse, setFrame, setPentagon, setRect, setRoundRect, setShapeStateAll, setShapeStateAll, setTextOutputMode, setTrapezoid, updateLines
 
Methods inherited from class javax.swing.JLayeredPane
addImpl, getAccessibleContext, getComponentCountInLayer, getComponentsInLayer, getComponentToLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getObjectForLayer, getPosition, highestLayer, insertIndexForLayer, isOptimizedDrawingEnabled, lowestLayer, moveToBack, moveToFront, paint, paramString, putLayer, remove, removeAll, setLayer, setLayer, setPosition
 
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, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, 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, 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
 
Methods inherited from interface java.awt.event.MouseListener
mouseEntered, mouseExited, mousePressed
 
Methods inherited from interface java.awt.event.MouseMotionListener
mouseDragged, mouseMoved
 

Field Detail

edgeList

public List<Edge> edgeList

nodeList

public ArrayList<Node> nodeList

selectedGroup

public List<Node> selectedGroup

action

public GraphAction action

backgroundColor

public static Color backgroundColor

graphViewport

public JViewport graphViewport

visibleDimension

public Dimension visibleDimension

graphDimension

public Dimension graphDimension

iconController

public final IconController iconController

net

public ProbabilisticNetwork net

PANEMODE_NONE

public String PANEMODE_NONE

PANEMODE_COMPILE

public String PANEMODE_COMPILE

strPaneMode

public String strPaneMode

iUpdate

public static int iUpdate
Constructor Detail

GraphPane

public GraphPane(JDialog dlg,
                 ProbabilisticNetwork n)

GraphPane

public GraphPane(NetworkController controller,
                 JViewport graphViewport)
O construtor ÔøΩ responsÔøΩvel por iniciar todas as variÔøΩveis que serÔøΩo utilizadas por essa classe para que se possa desenhar a rede Bayesiana.

Parameters:
controlador - o controlador (TControladorTelaPrincipal)
graphViewport - a tela, (TViewport), onde serÔøΩ inserida essa classe
Method Detail

setGraphDimension

public void setGraphDimension(Dimension graphDimension)
Seta o atributo graphDimension (tamanho da rede Bayesiana) do objeto da classe GraphPane

Parameters:
graphDimension - O novo valor do tamanho da rede (Dimension)
See Also:
Dimension

getSelected

public Object getSelected()
Retorna o objeto selecionado (Object), que pode ser um Node ou Edge

Returns:
O valor do Object selected
See Also:
Object, Node, Edge

updateSelectedNode

public void updateSelectedNode()

setPaneMode

public void setPaneMode(String str)

getPaneMode

public String getPaneMode()

getSelectedGroup

public List<Node> getSelectedGroup()
Retorna uma lista de selecionados (List), que podem ser um Node e/ou Edge

Returns:
O valor do List selectedGroup
See Also:
List, Node, Edge

getGraphDimension

public Dimension getGraphDimension()
Pega a Dimension tamanhoRede do objeto da classe GraphPane

Returns:
A Dimension graphDimension

setState

public void setState(String s)
Overrides:
setState in class UCanvas

isFocusable

public boolean isFocusable()
Pega o atributo focusTransversable do objeto da classe GraphPane

Overrides:
isFocusable in class Component
Returns:
True como valor do focusTransversable (mÔøΩtodo necessÔøΩrio para que se possa tratar evento de tecla)

getGraphViewport

public JViewport getGraphViewport()
Pega o atributo graphViewport (JViewport) do objeto da classe GraphPane

Returns:
O graphViewport (container onde essa classe se encontra inserida)
See Also:
JViewport

getBiggestPoint

public Point2D.Double getBiggestPoint()
Pega o maior ponto (Point2D.Double) do objeto da classe GraphPane

Returns:
O maior ponto (x,y) existente nessa rede Bayesiana
See Also:
Point2D.Double

showCPT

public void showCPT(Node newNode)

mouseClicked

public void mouseClicked(MouseEvent e)
This method is responsible to treat mouse button events

Specified by:
mouseClicked in interface MouseListener
Overrides:
mouseClicked in class UCanvas
Parameters:
e - MouseEvent
See Also:
MouseEvent

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class UCanvas

selectNode

public void selectNode(Node n)

insertEdge

public boolean insertEdge(Edge edge)

setAction

public void setAction(GraphAction action,
                      INodeClassDataTransferObject dto)
This is equivalent to setNodeDataTransferObject(INodeClassDataTransferObject) followed by setAction(GraphAction)

Parameters:
action - : The action to be taken.
dto - : the data transfer object to set
See Also:
setAction(GraphAction), setNodeDataTransferObject(INodeClassDataTransferObject)

setAction

public void setAction(GraphAction action)
Set the action to be taken.

Parameters:
action - The action to be taken.

getAction

public GraphAction getAction()
Get the action to be taken.

Returns:
The action to be taken.

createNode

public void createNode(Node newNode)
This method literally re-generates the UShape instance for a given newNode parameter. This is useful when we temporally destroy a GraphPane's content and want to re-generate it again (e.g. compiling a network and showing the compilation pane, and then turning back), or loading a network from file.

Parameters:
newNode -

resizeAllToFitText

public void resizeAllToFitText()

compiled

public void compiled(boolean reset,
                     Node selectedNode)

update

public void update()
Overrides:
update in class UCanvas

resetGraph

public void resetGraph()

updateAllNodesName

public void updateAllNodesName()

useNameAllShape

public void useNameAllShape()

useDescAllShape

public void useDescAllShape()

resetPopup

public void resetPopup()

onDrawConnectLineReleased

public UShapeLine onDrawConnectLineReleased(UShape shapeParent,
                                            int x,
                                            int y)
Overrides:
onDrawConnectLineReleased in class UCanvas

onShapeChanged

public void onShapeChanged(UShape s)
Overrides:
onShapeChanged in class UCanvas

onShapeDeleted

public void onShapeDeleted(UShape s)
Overrides:
onShapeDeleted in class UCanvas

onSelectionChanged

public void onSelectionChanged()
Overrides:
onSelectionChanged in class UCanvas

getNodeDataTransferObject

public INodeClassDataTransferObject getNodeDataTransferObject()
This object is used by GraphPane in order to temporally store all informations about a node loaded by plugins, between the moment that a user clicks the "add" button and the moment that the node is actually created and inserted into canvas. CAUTION: set this before calling setAction(GraphAction)

Returns:
the nodeClassDataTransferObject

setNodeDataTransferObject

protected void setNodeDataTransferObject(INodeClassDataTransferObject nodeClassDataTransferObject)
This object is used by GraphPane in order to temporally store all informations about a node loaded by plugins, between the moment that a user clicks the "add" button and the moment that the node is actually created and inserted into canvas. CAUTION: set this before calling setAction(GraphAction)

Parameters:
nodeClassDataTransferObject - the nodeClassDataTransferObject to set

getPluginNodeManager

protected CorePluginNodeManager getPluginNodeManager()
This object manages plugin-loaded nodes.

Returns:
the pluginNodeManager

setPluginNodeManager

protected void setPluginNodeManager(CorePluginNodeManager pluginNodeManager)
This object manages plugin-loaded nodes.

Parameters:
pluginNodeManager - the pluginNodeManager to set

isToUseSelectionForLines

public boolean isToUseSelectionForLines()
update() will set UShape.getUseSelection() to same value;

Returns:
the toUseSelectionForLines
See Also:
update(), UShapeLine#getUseSelection()}

setToUseSelectionForLines

public void setToUseSelectionForLines(boolean toUseSelectionForLines)
update() will set UShape.getUseSelection() to same value;

Parameters:
toUseSelectionForLines - the toUseSelectionForLines to set
See Also:
update(), UShapeLine#getUseSelection()}


Copyright © 2001-2010 University of Brasilia - UnB. All Rights Reserved.