org.openbp.jaspira.gui.interaction
Class DragDropPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.openbp.jaspira.gui.interaction.DragDropPane
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class DragDropPane
extends javax.swing.JComponent

A drag and drop pane is a component that is to be used as glass pane for a window. It is used to handle drag and drop events and propagate them to InteractionClient s via DragAwareRegion s. It also provides support for break out box (bob) menus. A bob is a circular overlay window that presents items that can be imported into the underlying drop client. The user may select the item by simply clicking on it. A bob menu is always initiated by a hot key.

Author:
Stephan Moritz
See Also:
Serialized Form

Nested Class Summary
 
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
static CursorPrototype acceptCursorPrototype
          Accept cursor.
static CursorPrototype rejectCursorPrototype
          Reject cursor.
 
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
 
Method Summary
 void addDropClient(InteractionClient client)
          Adds a drop client.
 void cancelDrag()
          Cancels any currently ongoing drag action.
 void clearDropClients()
          Removes all drop clients.
 void endBreakOutMode()
          Ends the bob mode
 void endDrag()
          Called when the drag ends.
 DragOrigin getDragOrigin()
          Returns the originator of the current dnd action.
 java.awt.Point getLastLocation()
          Returns the last mouse location.
 java.awt.event.MouseEvent getMouseEvent()
          Gets the mouse event that triggered the drag action.
 java.lang.String getToolTipText(java.awt.event.MouseEvent event)
          Returns the tool tip appropriate for the given region.
static DragDropPane installDragDropPane(DropPaneContainer container)
          Creates a new drag drop pane and installs it as a glass pane for the givent container.
 void mouseDragged(java.awt.Point p)
          Handler for 'mouse dragged' events.
 void mouseReleased(java.awt.Point p)
          Handler for 'mouse released' events.
 void paint(java.awt.Graphics g)
          Draws the Pane (i\.e\. the active DropRegions)
 void regionsInvalidated()
          Rebuilds the DragAwareRegions of the pane.
 void removeDropClient(InteractionClient client)
          Removes a drop client.
 void setComposite(java.awt.Composite composite)
          Sets the composite used to draw the glasPaneElements.
 void setTransparency(float alpha)
          Sets the alpha Component, i\.e\. the transparency of the drop pane.
 void startBreakOutMode(BreakoutProvider provider, java.awt.Point position)
          Starts the bob mode using the given provider.
 void startDrag(java.awt.datatransfer.Transferable transferable, DragOrigin dragOrigin, java.awt.event.MouseEvent mouseEvent)
          Initiates a dragging action.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, 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, 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

acceptCursorPrototype

public static CursorPrototype acceptCursorPrototype
Accept cursor. Indicates that a drop is possible at the current position.


rejectCursorPrototype

public static CursorPrototype rejectCursorPrototype
Reject cursor. Indicates that a drop is not possible at the current position.

Method Detail

installDragDropPane

public static DragDropPane installDragDropPane(DropPaneContainer container)
Creates a new drag drop pane and installs it as a glass pane for the givent container. Does nothing if a dnd pane has already been installed

Parameters:
container - Container to install the pane for
Returns:
The installed dnd pane

paint

public void paint(java.awt.Graphics g)
Draws the Pane (i\.e\. the active DropRegions)

Overrides:
paint in class javax.swing.JComponent
See Also:
Component.paint(Graphics)

regionsInvalidated

public void regionsInvalidated()
Rebuilds the DragAwareRegions of the pane.


startDrag

public void startDrag(java.awt.datatransfer.Transferable transferable,
                      DragOrigin dragOrigin,
                      java.awt.event.MouseEvent mouseEvent)
Initiates a dragging action. Determines the flavors supported by the transferable and notifies the drop clients.

Parameters:
transferable - Transferable to be dragged
dragOrigin - Originator of the dragging action
mouseEvent - Mouse event that triggered the drag action

cancelDrag

public void cancelDrag()
Cancels any currently ongoing drag action.


endDrag

public void endDrag()
Called when the drag ends. Clears all regions and notifies the drop clients.


startBreakOutMode

public void startBreakOutMode(BreakoutProvider provider,
                              java.awt.Point position)
Starts the bob mode using the given provider.

Parameters:
provider - Provider for bob entries
position - Center of the bob in screen coordinates

endBreakOutMode

public void endBreakOutMode()
Ends the bob mode


mouseDragged

public void mouseDragged(java.awt.Point p)
Handler for 'mouse dragged' events. Passes the event to the current region in dnd mode and updates the dnd cursor.

Parameters:
p - Current mouse position

mouseReleased

public void mouseReleased(java.awt.Point p)
Handler for 'mouse released' events. Notifies the current drag originator of the drop and ends dnd mode.

Parameters:
p - Current mouse position in glass coordinates

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
Returns the tool tip appropriate for the given region.

Overrides:
getToolTipText in class javax.swing.JComponent
Parameters:
event - Mouse event containing the coordinates that should be used to determine the hovered bob entry if the bob is active.
Returns:
The tip or null

addDropClient

public void addDropClient(InteractionClient client)
Adds a drop client.

Parameters:
client - Client to add

removeDropClient

public void removeDropClient(InteractionClient client)
Removes a drop client.

Parameters:
client - Client to remove

clearDropClients

public void clearDropClients()
Removes all drop clients.


setComposite

public void setComposite(java.awt.Composite composite)
Sets the composite used to draw the glasPaneElements. This will usually be an instance of AlphaComposite. Note that it is usually more convient to set the transparency directly via setTransparency(float), which incidently just creates a new AlphaComposite object.

Parameters:
composite - The composite to set
See Also:
AlphaComposite

setTransparency

public void setTransparency(float alpha)
Sets the alpha Component, i\.e\. the transparency of the drop pane.

Parameters:
alpha - New alpha value, between 0f (opaque) 1f (fully transparent)

getDragOrigin

public DragOrigin getDragOrigin()
Returns the originator of the current dnd action.

Returns:
The drag originator or null if no dnd action is going on

getLastLocation

public java.awt.Point getLastLocation()
Returns the last mouse location.

Returns:
The mouse location in screen coordinates

getMouseEvent

public java.awt.event.MouseEvent getMouseEvent()
Gets the mouse event that triggered the drag action.



Copyright © 2011. All Rights Reserved.