org.geotoolkit.gui.swing.image
Class MosaicBuilderEditor

Object
  extended by Component
      extended by Container
          extended by JComponent
              extended by MosaicBuilderEditor
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Dialog, MosaicPerformanceGraph.Delayed

public class MosaicBuilderEditor
extends JComponent
implements MosaicPerformanceGraph.Delayed, Dialog

Configures a MosaicBuilder according the input provided by a user. The caller can invoke one of the one-argument constructors (optional but recommended) in order to initialize the widgets with a set of default values. After the widget has been displayed, the caller can invoke getTileManager() in order to get the user's choices in an object ready for use.

Example:

MosaicBuilderEditor editor = new MosaicBuilderEditor(boundsOfTheWholeMosaic);
if (editor.showDialog(null, "Define pyramid tiling")) {
    TileManager mosaic = editor.getTileManager();
    // Process here.
}

Since:
3.00
Version:
3.12
Author:
Martin Desruisseaux (Geomatys)
See Also:
Serialized Form
Module:
display/geotk-widgets-swing (download)    View source code for this class

Nested Class Summary
 
Nested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class 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 Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MosaicBuilderEditor()
          Creates a new panel for configuring a default mosaic builder.
MosaicBuilderEditor(MosaicBuilder builder)
          Creates a new panel for configuring the given mosaic builder.
MosaicBuilderEditor(Rectangle bounds)
          Creates a new panel suitable for tiles in a mosaic of the given size.
MosaicBuilderEditor(TileManager... managers)
          Creates a new panel suitable for the given tiles, specified as TileManager objects.
 
Method Summary
 void commitEdit()
          Forces the current value to be taken from the editable fields and set them as the current values.
 void done(TileManager mosaic)
          Notifies that a TileManager has been created from the parameter edited in this widget.
 void failed(Throwable exception)
          Notifies that the creation of a TileManager failed with the given exception.
 MosaicBuilder getMosaicBuilder()
          Configures the MosaicBuilder with the informations provided by the user and return it.
 TileManager getTileManager()
          Configures the MosaicBuilder with the informations provided by the user and create the mosaic.
 void initializeForBounds(Rectangle bounds)
          Proposes default values suitable for tiles in a mosaic of the given size.
 void initializeForTiles(TileManager... managers)
          Proposes default values suitable for the given tiles, specified as TileManager objects.
protected  void plotEfficiency(long delay)
          Refreshes the plot of estimated efficiency.
 boolean showDialog(Component owner, String title)
          Shows a dialog box requesting input from the user.
 
Methods inherited from class 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, 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 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 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MosaicBuilderEditor

public MosaicBuilderEditor()
Creates a new panel for configuring a default mosaic builder.


MosaicBuilderEditor

public MosaicBuilderEditor(Rectangle bounds)
Creates a new panel suitable for tiles in a mosaic of the given size.

Parameters:
bounds - The bounds of the whole mosaic.

MosaicBuilderEditor

public MosaicBuilderEditor(TileManager... managers)
                    throws IOException
Creates a new panel suitable for the given tiles, specified as TileManager objects. Only one tile manager is usually provided. However more managers can be provided if, for example, TileManagerFactory failed to create only one instance from a set of tiles.

Parameters:
managers - The tiles for which to setup default values.
Throws:
IOException - If an I/O operation was necessary and failed.

MosaicBuilderEditor

public MosaicBuilderEditor(MosaicBuilder builder)
Creates a new panel for configuring the given mosaic builder.

Parameters:
builder - The mosaic builder to be configured by this panel.
Method Detail

initializeForTiles

public void initializeForTiles(TileManager... managers)
                        throws IOException
Proposes default values suitable for the given tiles, specified as TileManager objects. Only one tile manager is usually provided. However more managers can be provided if, for example, TileManagerFactory failed to create only one instance from a set of tiles.

Parameters:
managers - The tiles for which to setup default values.
Throws:
IOException - If an I/O operation was necessary and failed.

initializeForBounds

public void initializeForBounds(Rectangle bounds)
Proposes default values suitable for tiles in a mosaic of the given size.

Parameters:
bounds - The bounds of the whole mosaic.

plotEfficiency

protected void plotEfficiency(long delay)
Refreshes the plot of estimated efficiency. This method is invoked automatically when the values of some fields changed. The default implementation starts the calculation in a background thread.

Parameters:
delay - How long to wait (in milliseconds) before to perform the calculation.

getMosaicBuilder

public MosaicBuilder getMosaicBuilder()
                               throws IOException
Configures the MosaicBuilder with the informations provided by the user and return it.
Note: Use this method when the widget state will not change anymore. If the user is still editing the values in the widget, then invoking getTileManager() is preferable than getTileBuilder().getTileManager() for synchronization reasons.

Returns:
The configured mosaic builder.
Throws:
IOException - if an I/O operation was required and failed.

getTileManager

public TileManager getTileManager()
                           throws IOException
Configures the MosaicBuilder with the informations provided by the user and create the mosaic. This method is automatically invoked when a graph is about to be plot. It can also be invoked directly by the user, but may block if the builder is currently in use by an other thread.

Specified by:
getTileManager in interface MosaicPerformanceGraph.Delayed
Returns:
The selected tiles as a TileManager object.
Throws:
IOException - if an I/O operation was required and failed.

done

public void done(TileManager mosaic)
Notifies that a TileManager has been created from the parameter edited in this widget. This method is invoked automatically after the fields in this widget has been edited. It can also be invoked directly by the user. Current implementation does nothing, but subclasses can override this method for remembering the TileManager.

Specified by:
done in interface MosaicPerformanceGraph.Delayed
Parameters:
mosaic - The mosaic created from the information provided in this widget, or null if the TileManager creation has been canceled before completion.

failed

public void failed(Throwable exception)
Notifies that the creation of a TileManager failed with the given exception. This method is invoked instead than done(TileManager) if an exception occurred during the execution of MosaicPerformanceGraph.plotEfficiency(String, TileManager).

The default implementation does nothing. Subclasses can override this method in order to report the error in the way that best suite their application.

Specified by:
failed in interface MosaicPerformanceGraph.Delayed
Parameters:
exception - The exception which occurred.

commitEdit

public void commitEdit()
                throws ParseException
Forces the current value to be taken from the editable fields and set them as the current values. If this operation fails for at least one field, this method will set the focus on the offending field before to throw the exception.

This method is typically invoked after Dialog.showDialog(Component, String) returned true and before to read the values from the dialog widget.

Specified by:
commitEdit in interface Dialog
Throws:
ParseException - If at least one values couldn't be commited.
Since:
3.12
See Also:
JFormattedTextField.commitEdit(), JSpinner.commitEdit()

showDialog

public boolean showDialog(Component owner,
                          String title)
Shows a dialog box requesting input from the user. The dialog box will be parented to owner. If owner is contained into a JDesktopPane, the dialog box will appears as an internal frame.

Multi-threading
Geotk implementations allow this method to be invoked from any thread. If the caller thread is not the Swing thread, then the execution of this method will be registered in the AWT Event Queue and the caller thread will block until completion.

Specified by:
showDialog in interface Dialog
Parameters:
owner - The parent component for the dialog box, or null if there is no parent.
title - The dialog box title.
Returns:
true if user pressed the "Ok" button, or false otherwise (e.g. pressing "Cancel" or closing the dialog box from the title bar).


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.