org.geotools.gui.swing.referencing
Class CoordinateChooser

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.geotools.gui.swing.referencing.CoordinateChooser
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
CoordinateChooser

public class CoordinateChooser
extends javax.swing.JPanel

A pane of controls designed to allow a user to select spatio-temporal coordinates. Current implementation uses geographic coordinates (longitudes/latitudes) and dates according some locale calendar. Future version may allow the use of user-specified coordinate system. Latitudes are constrained in the range 90?S to 90?N inclusive. Longitudes are constrained in the range 180?W to 180?E inclusive. By default, dates are constrained in the range January 1st, 1970 up to the date at the time the widget was created.

 

 

Since:
2.3
Version:
$Id: CoordinateChooser.java 17934 2006-02-09 09:08:30Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
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
static int GEOGRAPHIC_AREA
          An enumeration constant for showing or hidding the geographic area selector.
static int RESOLUTION
          An enumeration constant for showing or hidding the resolution selector.
static int TIME_RANGE
          An enumeration constant for showing or hidding the time range selector.
 
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
CoordinateChooser()
          Constructs a default coordinate chooser.
CoordinateChooser(java.util.Date minTime, java.util.Date maxTime)
          Constructs a coordinate chooser with date constrained in the specified range.
 
Method Summary
 void addChangeListener(int selectors, javax.swing.event.ChangeListener listener)
          Adds a change listener to the listener list.
 void commitEdit()
          Commits the currently edited values.
 javax.swing.JComponent getAccessory()
          Returns the accessory component.
 java.util.Date getEndTime()
          Returns the end time, or if there is none.
 java.awt.geom.Rectangle2D getGeographicArea()
          Gets the geographic area, in latitude and longitude degrees.
 java.awt.geom.Dimension2D getPreferredResolution()
          Returns the preferred resolution.
 java.util.Date getStartTime()
          Returns the start time, or if there is none.
 java.util.TimeZone getTimeZone()
          Returns the time zone used for displaying dates.
 boolean isSelectorVisible(int selector)
          Tells if a selector is currently visible or not.
static void main(java.lang.String[] args)
          Show the dialog box.
 void removeChangeListener(int selectors, javax.swing.event.ChangeListener listener)
          Removes a change listener from the listener list.
 void setAccessory(javax.swing.JComponent accessory)
          Sets the accessory component.
 void setGeographicArea(java.awt.geom.Rectangle2D area)
          Sets the geographic area, in latitude and longitude degrees.
 void setPreferredResolution(java.awt.geom.Dimension2D resolution)
          Sets the preferred resolution.
 void setSelectorVisible(int selectors, boolean visible)
          Set the visible state of one or many selectors.
 void setTimeRange(java.util.Date startTime, java.util.Date endTime)
          Sets the time range.
 void setTimeZone(java.util.TimeZone timezone)
          Sets the time zone.
 boolean showDialog(java.awt.Component owner)
          Shows a dialog box requesting input from the user.
 boolean showDialog(java.awt.Component owner, java.lang.String title)
          Shows a dialog box requesting input from the user.
 
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, paintComponent, 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

GEOGRAPHIC_AREA

public static final int GEOGRAPHIC_AREA
An enumeration constant for showing or hidding the geographic area selector. Used as argument for isSelectorVisible(int) and setSelectorVisible(int, boolean).

See Also:
TIME_RANGE, RESOLUTION, isSelectorVisible(int), setSelectorVisible(int, boolean), addChangeListener(int, javax.swing.event.ChangeListener), removeChangeListener(int, javax.swing.event.ChangeListener), Constant Field Values

TIME_RANGE

public static final int TIME_RANGE
An enumeration constant for showing or hidding the time range selector. Used as argument for isSelectorVisible(int) and setSelectorVisible(int, boolean).

See Also:
GEOGRAPHIC_AREA, RESOLUTION, isSelectorVisible(int), setSelectorVisible(int, boolean), addChangeListener(int, javax.swing.event.ChangeListener), removeChangeListener(int, javax.swing.event.ChangeListener), Constant Field Values

RESOLUTION

public static final int RESOLUTION
An enumeration constant for showing or hidding the resolution selector. Used as argument for isSelectorVisible(int) and setSelectorVisible(int, boolean).

See Also:
GEOGRAPHIC_AREA, TIME_RANGE, isSelectorVisible(int), setSelectorVisible(int, boolean), addChangeListener(int, javax.swing.event.ChangeListener), removeChangeListener(int, javax.swing.event.ChangeListener), Constant Field Values
Constructor Detail

CoordinateChooser

public CoordinateChooser()
Constructs a default coordinate chooser. Date will be constrained in the range from January 1st, 1970 00:00 UTC up to the current time.


CoordinateChooser

public CoordinateChooser(java.util.Date minTime,
                         java.util.Date maxTime)
Constructs a coordinate chooser with date constrained in the specified range. Note that the range is not the same than the range given to setTimeRange(java.util.Date, java.util.Date). The later set only the time range shown in the widget, while this constructor set also the minimum and maximum dates allowed.

Parameters:
minTime - The minimal date allowed.
maxTime - the maximal date allowed.
Method Detail

isSelectorVisible

public boolean isSelectorVisible(int selector)
Tells if a selector is currently visible or not. The default contains three selectors: one for geographic area, one for time range and one for the preferred resolution.

Parameters:
selector - One of the following constants: GEOGRAPHIC_AREA, TIME_RANGE or RESOLUTION.
Returns:
if the specified selector is visible, or otherwise.
Throws:
java.lang.IllegalArgumentException - if is not legal.

setSelectorVisible

public void setSelectorVisible(int selectors,
                               boolean visible)
Set the visible state of one or many selectors. All selectors are visible by default.

Parameters:
selectors - Any bitwise combinaisons of GEOGRAPHIC_AREA, TIME_RANGE and/or RESOLUTION.
visible - to show the selectors, or to hide them.
Throws:
java.lang.IllegalArgumentException - if contains illegal bits.

getGeographicArea

public java.awt.geom.Rectangle2D getGeographicArea()
Gets the geographic area, in latitude and longitude degrees.


setGeographicArea

public void setGeographicArea(java.awt.geom.Rectangle2D area)
Sets the geographic area, in latitude and longitude degrees.


getPreferredResolution

public java.awt.geom.Dimension2D getPreferredResolution()
Returns the preferred resolution. A value means that the best available resolution should be used.


setPreferredResolution

public void setPreferredResolution(java.awt.geom.Dimension2D resolution)
Sets the preferred resolution. A value means that the best available resolution should be used.


getTimeZone

public java.util.TimeZone getTimeZone()
Returns the time zone used for displaying dates.


setTimeZone

public void setTimeZone(java.util.TimeZone timezone)
Sets the time zone. This method change the control's display. It doesn't change the date values, i.e. it have no effect on previous or future call to setTimeRange(java.util.Date, java.util.Date).


getStartTime

public java.util.Date getStartTime()
Returns the start time, or if there is none.


getEndTime

public java.util.Date getEndTime()
Returns the end time, or if there is none.


setTimeRange

public void setTimeRange(java.util.Date startTime,
                         java.util.Date endTime)
Sets the time range.

Parameters:
startTime - The start time.
endTime - The end time.
See Also:
getStartTime(), getEndTime()

getAccessory

public javax.swing.JComponent getAccessory()
Returns the accessory component.

Returns:
The accessory component, or if there is none.

setAccessory

public void setAccessory(javax.swing.JComponent accessory)
Sets the accessory component. An accessory is often used to show available data. However, it can be used for anything that the programmer wishes, such as extra custom coordinate chooser controls.

Note: If there was a previous accessory, you should unregister any listeners that the accessory might have registered with the coordinate chooser.

Parameters:
accessory - The accessory component, or to remove any previous accessory.

commitEdit

public void commitEdit()
                throws java.text.ParseException
Commits the currently edited values. If commit fails, focus will be set on the offending field.

Throws:
java.text.ParseException - If at least one of currently edited value couldn't be commited.

addChangeListener

public void addChangeListener(int selectors,
                              javax.swing.event.ChangeListener listener)
Adds a change listener to the listener list. This change listener will be notify when a value changed. The change may be in a geographic coordinate field, a date field, a resolution field, etc. The watched values depend on the arguments: GEOGRAPHIC_AREA will watches for the bounding box (East, West, North and South value); TIME_RANGE watches for start time and end time; RESOLUTION watches for the resolution along East-West and North-South axis. Bitwise combinaisons are allowed. For example, GEOGRAPHIC_AREA | TIME_RANGE will register a listener for both geographic area and time range.

The source of ChangeEvents delivered to ChangeListeners will be in most case the SpinnerModel for the edited field.

Parameters:
selectors - Any bitwise combinaisons of GEOGRAPHIC_AREA, TIME_RANGE and/or RESOLUTION.
listener - The listener to add to the specified selectors.
Throws:
java.lang.IllegalArgumentException - if contains illegal bits.

removeChangeListener

public void removeChangeListener(int selectors,
                                 javax.swing.event.ChangeListener listener)
Removes a change listener from the listener list.

Parameters:
selectors - Any bitwise combinaisons of GEOGRAPHIC_AREA, TIME_RANGE and/or RESOLUTION.
listener - The listener to remove from the specified selectors.
Throws:
java.lang.IllegalArgumentException - if contains illegal bits.

showDialog

public boolean showDialog(java.awt.Component owner)
Shows a dialog box requesting input from the user. The dialog box will be parented to . If is contained into a JDesktopPane, the dialog box will appears as an internal frame. This method can be invoked from any thread (may or may not be the Swing thread).

Parameters:
owner - The parent component for the dialog box, or if there is no parent.
Returns:
if user pressed the "Ok" button, or otherwise (e.g. pressing "Cancel" or closing the dialog box from the title bar).

showDialog

public boolean showDialog(java.awt.Component owner,
                          java.lang.String title)
Shows a dialog box requesting input from the user. If is contained into a JDesktopPane, the dialog box will appears as an internal frame. This method can be invoked from any thread (may or may not be the Swing thread).

Parameters:
owner - The parent component for the dialog box, or if there is no parent.
title - The dialog box title.
Returns:
if user pressed the "Ok" button, or otherwise (e.g. pressing "Cancel" or closing the dialog box from the title bar).

main

public static void main(java.lang.String[] args)
Show the dialog box. This method is provided only as an easy way to test the dialog appearance from the command line.



Copyright © GeoTools. All Rights Reserved.