FreeHEP API
Version current

org.freehep.swing.graphics
Class PointSelectionPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.freehep.swing.graphics.GraphicalSelectionPanel
                      extended byorg.freehep.swing.graphics.PointSelectionPanel
All Implemented Interfaces:
Accessible, EventListener, ImageObserver, KeyListener, MenuContainer, MouseListener, MouseMotionListener, Serializable

public class PointSelectionPanel
extends GraphicalSelectionPanel

This panel allows the user to select a point on the screen. The crosshair cursor fill follow the system pointer when the left mouse button is pressed. The system pointer will become invisible while the user is actively repositioning the crosshair. This panel will also respond to keystroke input.

Normally, the arrow keys move the cursor by 2 pixels per key release; however if the shift key is pressed simultaneously, then the arrow keys move the cursor by 1 pixel.

Version:
$Id: PointSelectionPanel.java,v 1.7 2001/04/03 10:25:37 loomis Exp $
Author:
Charles Loomis
See Also:
Serialized Form
Source Code:
PointSelectionPanel.java

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class org.freehep.swing.graphics.GraphicalSelectionPanel
actionMap, defaultModeAction, nextAction, previousAction, selectionActions, thickStroke, thinStroke
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
PointSelectionPanel()
          Construct a PointSelectionPanel.
 
Method Summary
 boolean getCursorVisible()
          Get the visibility of the crosshair cursor.
 void keyReleased(KeyEvent e)
          Process key-released events.
 AffineTransform makeAffineTransform()
          Make the affine transform which will center the display on the current point if applied.
protected  void makeSelectionEvent(int actionCode)
          A utility function which creates an appropriate selection event when the user accepts the current selection.
 void mouseDragged(MouseEvent e)
          The crosshair cursor follows the system pointer during a mouse drag event.
 void mousePressed(MouseEvent e)
          The crosshair cursor will begin to follow the system pointer; the system pointer is made invisible.
 void mouseReleased(MouseEvent e)
          The crosshair cursor will stop following the system pointer when the mouse is released.
 void paintComponent(Graphics g)
           
 void resetSelection()
          Reset the selection; this remove the crosshair cursor from the screen.
 void setCursorVisible(boolean visible)
          Set the visiblility of the crosshair cursor.
 void updatePosition(int x, int y)
          This method updates the position of the crosshair cursor.
 
Methods inherited from class org.freehep.swing.graphics.GraphicalSelectionPanel
addActionEntry, addActionEntry, addGraphicalSelectionListener, cancelPopupProcessing, fireGraphicalSelectionMade, getBorder, getPopupMenu, isProcessingPopup, keyPressed, keyTyped, mouseClicked, mouseEntered, mouseExited, mouseMoved, removeGraphicalSelectionListener, setBorder, setBounds, setSelectionActionsEnabled, testPopupTrigger
 
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, 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, 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, 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
 

Constructor Detail

PointSelectionPanel

public PointSelectionPanel()
Construct a PointSelectionPanel. Initially the cursor is not visible.

Method Detail

keyReleased

public void keyReleased(KeyEvent e)
Process key-released events. This allow the selection panel to move the cursor with the keyboard arrows. Normally, the arrow keys move the cursor by 2 pixels per key release; however if the shift key is pressed simultaneously, then the arrow keys move the cursor by 1 pixel.

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

mousePressed

public void mousePressed(MouseEvent e)
The crosshair cursor will begin to follow the system pointer; the system pointer is made invisible.

Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class GraphicalSelectionPanel
Parameters:
e - the mouse pressed event to which to respond

mouseReleased

public void mouseReleased(MouseEvent e)
The crosshair cursor will stop following the system pointer when the mouse is released. The system pointer will again be visible.

Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class GraphicalSelectionPanel
Parameters:
e - the mouse release event to which to respond

mouseDragged

public void mouseDragged(MouseEvent e)
The crosshair cursor follows the system pointer during a mouse drag event.

Specified by:
mouseDragged in interface MouseMotionListener
Overrides:
mouseDragged in class GraphicalSelectionPanel
Parameters:
e - the mouse drag event to which to respond

updatePosition

public void updatePosition(int x,
                           int y)
This method updates the position of the crosshair cursor. Normally this is called internally; however, it can be called programatically by other object, for example, to move the cursor on top of a selected object.

Parameters:
x - the x coordinate for the cursor (in pixels in the PointSelectionPanel's coordinate system)
y - the y coordinate for the cursor (in pixels in the PointSelectionPanel's coordinate system)

setCursorVisible

public void setCursorVisible(boolean visible)
Set the visiblility of the crosshair cursor.

Parameters:
visible - boolean indicating whether or not the crosshair cursor should be visible

getCursorVisible

public boolean getCursorVisible()
Get the visibility of the crosshair cursor.

Returns:
boolean indicating whether or not the crosshair cursor is visible

resetSelection

public void resetSelection()
Reset the selection; this remove the crosshair cursor from the screen.

Overrides:
resetSelection in class GraphicalSelectionPanel

paintComponent

public void paintComponent(Graphics g)

makeAffineTransform

public AffineTransform makeAffineTransform()
Make the affine transform which will center the display on the current point if applied.

Returns:
AffineTransform will center the current point

makeSelectionEvent

protected void makeSelectionEvent(int actionCode)
A utility function which creates an appropriate selection event when the user accepts the current selection.

Overrides:
makeSelectionEvent in class GraphicalSelectionPanel

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.