org.freehep.swing.graphics
Class GraphicalSelectionPanel

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 org.freehep.swing.graphics.GraphicalSelectionPanel
All Implemented Interfaces:
KeyListener, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
AbstractRegionSelectionPanel, PointSelectionPanel

public class GraphicalSelectionPanel
extends JPanel
implements MouseListener, KeyListener, MouseMotionListener, Serializable

The primary superclass of all graphical selection panels. These panels are expected to handle all of the interaction with the user, and generate a GraphicalSelectionEvent when a selection has been made. Note that GraphicalSelectionPanels use the information about the size of the component to send back meaningful zoom transformation and the like. To keep these calculations simple, Borders are not allowed on these components. If a Border is desired, then embed the selection panel within a container and put the Border on the container.

Version:
$Id: GraphicalSelectionPanel.java 8584 2006-08-10 23:06:37Z duns $
Author:
Charles Loomis
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
GraphicalSelectionPanel()
          Creates a selection panel which is transparent.
 
Method Summary
 void addGraphicalSelectionListener(GraphicalSelectionListener listener)
          Add a GraphicalSelectionListener.
 Border getBorder()
          This component does not support borders.
 JPopupMenu getPopupMenu()
          This method returns the popup menu for this component.
 boolean isProcessingPopup(MouseEvent e)
          This method determines whether or not a popup menu is being processed.
 void keyPressed(KeyEvent e)
          Invoked when a key has been pressed.
 void keyReleased(KeyEvent e)
          Process key-released events.
 void keyTyped(KeyEvent e)
          Invoked when a key has been typed.
 void mouseClicked(MouseEvent e)
          Invoked when the mouse has been clicked on a component.
 void mouseDragged(MouseEvent e)
          Invoked when a mouse button is pressed on a component and then dragged.
 void mouseEntered(MouseEvent e)
          Invoked when the mouse enters a component.
 void mouseExited(MouseEvent e)
          Invoked when the mouse exits a component.
 void mouseMoved(MouseEvent e)
          Invoked when the mouse button has been moved on a component (with no buttons down).
 void mousePressed(MouseEvent e)
          Invoked when the mouse button has been pressed on a component.
 void mouseReleased(MouseEvent e)
          Invoked when a mouse button has been released on a component.
 void removeGraphicalSelectionListener(GraphicalSelectionListener listener)
          Remove a GraphicalSelectionListener.
 void resetSelection()
          The default implementation of this method does nothing.
 void setBorder(Border border)
          This component does not support borders.
 void setBounds(int x, int y, int width, int height)
          Moves and resizes this component.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBounds, getClientProperty, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphicalSelectionPanel

public GraphicalSelectionPanel()
Creates a selection panel which is transparent.

Method Detail

resetSelection

public void resetSelection()
The default implementation of this method does nothing. Subclasses should provide the needed functionality to ensure that the selection is no longer visible after this method is called.


getPopupMenu

public JPopupMenu getPopupMenu()
This method returns the popup menu for this component. This may be modified by subclasses of this event to provide needed menu items.

Returns:
the component's popup menu

isProcessingPopup

public boolean isProcessingPopup(MouseEvent e)
This method determines whether or not a popup menu is being processed. If it is then this will return true and the mouse event should be ignored.

Parameters:
e - MouseEvent passed into mouse handling routine
Returns:
a boolean indicating whether or not to ignore the mouse event

setBorder

public final void setBorder(Border border)
This component does not support borders. If this method is called with any non-null argument, then an IllegalArgumentException is thrown. If a border is desired, then this component should be embedded within container which has one.

Overrides:
setBorder in class JComponent
Parameters:
border - must be null

getBorder

public final Border getBorder()
This component does not support borders. Null is always returned by this method.

Overrides:
getBorder in class JComponent
Returns:
null

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Moves and resizes this component. This is overridden so that the selection can be reset if the size changes.

Overrides:
setBounds in class Component
Parameters:
x - x-coordinate of component
y - y-coordinate of component
width - width of the component
height - height of the component

addGraphicalSelectionListener

public void addGraphicalSelectionListener(GraphicalSelectionListener listener)
Add a GraphicalSelectionListener.

Parameters:
listener - the GraphicalSelectionListener to add

removeGraphicalSelectionListener

public void removeGraphicalSelectionListener(GraphicalSelectionListener listener)
Remove a GraphicalSelectionListener.

Parameters:
listener - the GraphicalSelectionListener to remove

mouseClicked

public void mouseClicked(MouseEvent e)
Invoked when the mouse has been clicked on a component. This is an empty method which subclasses should override if necessary.

Specified by:
mouseClicked in interface MouseListener
Parameters:
e - MouseEvent describing action

mouseEntered

public void mouseEntered(MouseEvent e)
Invoked when the mouse enters a component. This method just requests the keyboard focus. Subclasses which override this method should also request the keyboard focus with a call to requestFocus().

Specified by:
mouseEntered in interface MouseListener
Parameters:
e - MouseEvent describing action

mouseExited

public void mouseExited(MouseEvent e)
Invoked when the mouse exits a component. This is an empty method which subclasses should override if necessary.

Specified by:
mouseExited in interface MouseListener
Parameters:
e - MouseEvent describing action

mousePressed

public void mousePressed(MouseEvent e)
Invoked when the mouse button has been pressed on a component. This is an empty method which subclasses should override if necessary.

Specified by:
mousePressed in interface MouseListener
Parameters:
e - MouseEvent describing action

mouseReleased

public void mouseReleased(MouseEvent e)
Invoked when a mouse button has been released on a component. This is an empty method which subclasses should override if necessary.

Specified by:
mouseReleased in interface MouseListener
Parameters:
e - MouseEvent describing action

mouseDragged

public void mouseDragged(MouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged. This is an empty method which subclasses should override if necessary.

Specified by:
mouseDragged in interface MouseMotionListener
Parameters:
e - MouseEvent describing action

mouseMoved

public void mouseMoved(MouseEvent e)
Invoked when the mouse button has been moved on a component (with no buttons down). This is an empty method which subclasses should override if necessary.

Specified by:
mouseMoved in interface MouseMotionListener
Parameters:
e - MouseEvent describing action

keyPressed

public void keyPressed(KeyEvent e)
Invoked when a key has been pressed. This is an empty method which subclasses should override if necessary.

Specified by:
keyPressed in interface KeyListener
Parameters:
e - KeyEvent describing key which has been pressed.

keyReleased

public void keyReleased(KeyEvent e)
Process key-released events. This defines and uses the following key bindings: Subclasses may override this method to provide additional key-bindings. However if the subclass doesn't handle a particular key event, this method should be called.

Specified by:
keyReleased in interface KeyListener
Parameters:
e - KeyEvent describing the key which has been released

keyTyped

public void keyTyped(KeyEvent e)
Invoked when a key has been typed. This is an empty method which subclasses should override if necessary.

Specified by:
keyTyped in interface KeyListener
Parameters:
e - KeyEvent describing key which has been typed.


Copyright © 2000-2013 FreeHEP. All Rights Reserved.