|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
ch.epfl.craft.maglib.MagnetView
A component that displays a set of data nodes that can be organized through the use of virtual magnets. This component is only a visualization (+ some interaction) tool, it does not allow to edit its content
The view handles nodes moving, mouse over nodes, near mouse over and selection.
It can be used in a similar way to JTree, JList & co, as it is based on the same MVC architecture
JTree,
How to use JTree,
Understanding JTree,
Serialized Form| Nested Class Summary |
| Nested classes inherited from class javax.swing.JPanel |
javax.swing.JPanel.AccessibleJPanel |
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
protected MagnetNode |
currentNode
The node being dragged/clicked/popuped |
protected MagnetNode |
currentSelectedNode
The current selected node |
protected javax.swing.JMenuItem |
demagnetAllItem
The menu item that demagnetize all magnets |
protected java.lang.String |
DEMAGNETIZE
The alternate string label attached to makeMagnetItem |
protected java.lang.String |
DEMAGNETIZE_ALL
The string label attached to demagnetAllItem |
protected java.awt.Point |
drawingOffset
The offset for drawing. |
protected javax.swing.JSlider |
forceSlider
The horizontal slider that will vary the field force of magnets. |
protected MagnetCellRenderer |
magnetCellRenderer
|
protected java.lang.String |
MAGNETIZE
The string label attached to makeMagnetItem |
protected MagnetLayout |
magnetLayout
|
protected MagnetModel |
magnetModel
|
protected javax.swing.JMenuItem |
makeMagnetItem
The menu item that (de)magnetize a magnet node |
protected java.awt.Rectangle |
mouseOverRectangle
The rectangle (around the mouse cursor) in which nodes are considered near the mouse |
protected java.awt.Point |
mousePosition
The last know mouse position on the components |
protected java.awt.Point |
mousePressedPoint
The position of the click in the view when mouse pressed |
protected java.util.HashSet |
nodesNearMouse
The last known components near the mouse |
protected MagnetNode |
nodeUnderMouse
The last known component under the mouse |
protected java.awt.Point |
offsetFromNodeOrigin
The position of the click in the node being dragged/clicked |
protected javax.swing.JPopupMenu |
popup
The menu called when right-click on a mouse |
| 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 | |
MagnetView()
Returns a MagnetView with a sample model. |
|
MagnetView(MagnetModel newModel)
Returns an instance of MagnetView -- the view is created using the specified data model. |
|
MagnetView(MagnetNode[] nodes)
Returns an instance of MagnetView -- the view is created using the specified nodes,
with DefaultMagnetModel. |
|
| Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent e)
Invoked when an action occurs on this instance. |
protected static MagnetModel |
createMagnetModel(java.lang.Object value)
Returns a MagnetModel wrapping the specified object.
|
boolean |
getDisplayForceField()
Returns true if the force field around magnet
is displayed in the view, else false. |
MagnetCellRenderer |
getMagnetCellRenderer()
Returns the MagnetCellRenderer that is used by the this MagnetView instance. |
MagnetLayout |
getMagnetLayout()
Returns the MagnetLayout that is used by the this MagnetView. |
MagnetModel |
getMagnetModel()
Returns the MagnetModel that is used by the this MagnetView instance. |
java.awt.Point |
getMousePosition()
Returns the last known position of the mouse on this component. |
void |
keyPressed(java.awt.event.KeyEvent e)
|
void |
keyReleased(java.awt.event.KeyEvent e)
|
void |
keyTyped(java.awt.event.KeyEvent e)
KeyListener IMPLEMENTATION |
void |
layoutHasChanged()
Implementation of the MagnetLayoutListener interface. |
void |
modelHasChanged()
MAGNETMODELLISTENER IMPLEMENTATION |
void |
mouseClicked(java.awt.event.MouseEvent e)
Handle mouse click on this component. |
void |
mouseDragged(java.awt.event.MouseEvent e)
Handle mouse drag on this component. |
void |
mouseEntered(java.awt.event.MouseEvent e)
Handle mouse enter on this component. |
void |
mouseExited(java.awt.event.MouseEvent e)
Handle mouse exit on this component. |
void |
mouseMoved(java.awt.event.MouseEvent e)
Handle mouse move on this component. |
void |
mousePressed(java.awt.event.MouseEvent e)
Handle pression of mouse button on this component. |
void |
mouseReleased(java.awt.event.MouseEvent e)
Handle release of mouse button on this component. |
protected java.util.HashSet |
nodeNearPoint(java.awt.Point p)
Returns the MagnetNodes near location p.
|
protected MagnetNode |
nodeUnderPoint(java.awt.Point p)
Returns the MagnetNode at location p.
|
void |
paintComponent(java.awt.Graphics g)
Invoked by Swing to draw components. |
void |
setDisplayForceField(boolean bool)
Toggles the display of the force field around magnet boolean bool true if the force field around magnet is displayed, else false |
void |
setMagnetCellRenderer(MagnetCellRenderer newMagnetCellRenderer)
Sets the cell renderer that will be used by the this MagnetView to display the nodes in the view.
|
void |
setMagnetLayout(MagnetLayout newMagnetLayout)
Sets the layout algorithm that will be used by the this MagnetView.
|
void |
setMagnetModel(MagnetModel newMagnetModel)
Sets the model that will be used by the this MagnetView.
|
void |
setMouseOverArea(java.awt.Dimension dim)
Sets the size of the virtual rectangle area around the mouse cursor such that nodes will be considered near the mouse. |
void |
stateChanged(javax.swing.event.ChangeEvent e)
Invoked when the target of the listener has changed its state. |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected transient MagnetLayout magnetLayout
protected transient MagnetCellRenderer magnetCellRenderer
protected transient MagnetModel magnetModel
protected java.awt.Point mousePosition
protected MagnetNode nodeUnderMouse
protected java.util.HashSet nodesNearMouse
protected MagnetNode currentNode
protected MagnetNode currentSelectedNode
protected java.awt.Point offsetFromNodeOrigin
protected java.awt.Point mousePressedPoint
protected java.awt.Rectangle mouseOverRectangle
protected javax.swing.JPopupMenu popup
protected javax.swing.JMenuItem makeMagnetItem
protected java.lang.String MAGNETIZE
protected java.lang.String DEMAGNETIZE
protected javax.swing.JMenuItem demagnetAllItem
protected java.lang.String DEMAGNETIZE_ALL
protected java.awt.Point drawingOffset
protected javax.swing.JSlider forceSlider
| Constructor Detail |
public MagnetView()
MagnetView with a sample model.
public MagnetView(MagnetModel newModel)
MagnetView -- the view is created using the specified data model.
newModel - the MagnetModel to use as the data modelpublic MagnetView(MagnetNode[] nodes)
MagnetView -- the view is created using the specified nodes,
with DefaultMagnetModel.
nodes - the nodes to use as the data| Method Detail |
protected static MagnetModel createMagnetModel(java.lang.Object value)
MagnetModel wrapping the specified object.
To do :
value - the Object used as the foundation for the TreeModel
MagnetModel wrapping the specified objectpublic void setMagnetLayout(MagnetLayout newMagnetLayout)
MagnetView.
If none has been set or if the given parameter is null, a default layout
(DefaultMagnetLayout) is used.
newMagnetLayout - the layouter to be used by this MagnetView instanceDefaultMagnetLayoutpublic MagnetLayout getMagnetLayout()
MagnetLayout that is used by the this MagnetView.
MagnetView instanceDefaultMagnetLayoutpublic void setMagnetModel(MagnetModel newMagnetModel)
MagnetView.
If the given parameter is null, the previous or a default one
(DefaultMagnetCellRenderer) is used.
newMagnetModel - the model to be used by this MagnetView instance.DefaultMagnetModelpublic MagnetModel getMagnetModel()
MagnetModel that is used by the this MagnetView instance.
MagnetView objectpublic void setMagnetCellRenderer(MagnetCellRenderer newMagnetCellRenderer)
MagnetView to display the nodes in the view.
If none has been set or if the given parameter is null, a default renderer
(DefaultMagnetCellRenderer) is used.
newMagnetCellRenderer - the cell renderer to be used by this MagnetView instance.DefaultMagnetCellRendererpublic MagnetCellRenderer getMagnetCellRenderer()
MagnetCellRenderer that is used by the this MagnetView instance.
MagnetView objectDefaultMagnetCellRendererpublic java.awt.Point getMousePosition()
public void setDisplayForceField(boolean bool)
true if the force field around magnet is displayed, else false
public boolean getDisplayForceField()
true if the force field around magnet
is displayed in the view, else false.
true if the force field around magnet is displayed, else false.public void paintComponent(java.awt.Graphics g)
MagnetCellRenderer.
If none was specified, it uses DefaultMagnetCellRenderer.
g - the Graphics context in which to paintDefaultMagnetCellRendererprotected MagnetNode nodeUnderPoint(java.awt.Point p)
MagnetNode at location p.
If there is no node at p, returns null.
The point coordinates must be relative to this MagnetView.
p - the point to test
pprotected java.util.HashSet nodeNearPoint(java.awt.Point p)
MagnetNodes near location p.
If there is no node near p, returns emptyHashSet.
The point coordinates must be relative to this MagnetView.
The near factor can be set with setMouseOverArea(java.awt.Dimension).
p - the point to test
ppublic void setMouseOverArea(java.awt.Dimension dim)
dim - the dimension of the rectangle areapublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenere - the event associated with the actionpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenere - the event associated with the actionpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenere - the event associated with the actionpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenere - the event associated with the actionpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenere - the event associated with the actionpublic void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListenere - the event associated with the actionpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenere - the event associated with the actionpublic void layoutHasChanged()
MagnetLayoutListener interface. Called
when the model has changed
layoutHasChanged in interface MagnetLayoutListenerpublic void modelHasChanged()
modelHasChanged in interface MagnetModelListenerpublic void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListenere - the associated eventpublic void stateChanged(javax.swing.event.ChangeEvent e)
stateChanged in interface javax.swing.event.ChangeListenere - a ChangeEvent objectpublic void keyTyped(java.awt.event.KeyEvent e)
keyTyped in interface java.awt.event.KeyListenerpublic void keyPressed(java.awt.event.KeyEvent e)
keyPressed in interface java.awt.event.KeyListenerpublic void keyReleased(java.awt.event.KeyEvent e)
keyReleased in interface java.awt.event.KeyListener
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||