org.geotoolkit.gui.swing.image
Class MosaicPerformanceGraph

Object
  extended by Component
      extended by Container
          extended by JComponent
              extended by ZoomPane
                  extended by Plot2D
                      extended by MosaicPerformanceGraph
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, DeformableViewer, Dialog

public class MosaicPerformanceGraph
extends Plot2D
implements Dialog

A plot of the estimated efficiency of loading tiles using a given mosaic. Given a TileManager, this method computes an estimation of the efficiency of loading tiles at different subsampling levels. The details of the calculation is documented in the MosaicProfiler class.

The calculations are performed by the plotEfficiency method, which may require a long execution time. Consequently this method should be invoked from a background thread rather than the Swing thread. As a convenience, the plotLater method is provided for delegating the calculation to a background thread.

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

Nested Class Summary
static interface MosaicPerformanceGraph.Delayed
          Specifies a mosaic to be profiled in a background thread.
 
Nested classes/interfaces inherited from class Plot2D
Plot2D.Series
 
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 Plot2D
DEFAULT_COLORS
 
Fields inherited from class ZoomPane
DEFAULT_ZOOM, RESET, ROTATE, SCALE_X, SCALE_Y, TRANSLATE_X, TRANSLATE_Y, UNIFORM_SCALE, zoom
 
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
MosaicPerformanceGraph()
          Creates a default graph.
 
Method Summary
 void commitEdit()
          Forces the current values to be taken from the editable fields and set them as the current values.
protected  MosaicProfiler createProfiler(TileManager tiles)
          Creates a profiler for the given mosaic.
 boolean getClearBeforePlot()
          If true, any call to plotEfficiency will clear the previous plot before to add the result of a new calculation.
 int getImagesPerSubsampling()
          Returns the number of images to be requested for each subsampling level.
 JProgressBar getProgressBar()
          Returns the progress bar given to the last to setProgressBar(JProgressBar).
 void plotEfficiency(String name, TileManager tiles)
          Adds a plot calculated for the given mosaic.
 void plotLater(String name, MosaicPerformanceGraph.Delayed delayed, long delay)
          Adds a plot for the mosaic created by a given builder.
 void setClearBeforePlot(boolean clear)
          Sets whatever the result of plotEfficiency should replace any previous plot.
 void setImagesPerSubsampling(int n)
          Sets the number of images to be requested for each subsampling level.
 void setProgressBar(JProgressBar bar)
          Sets the progress bar to inform of lengthly operation, or null if none.
 boolean showDialog(Component owner, String title)
          Shows a dialog box requesting input from the user.
 
Methods inherited from class Plot2D
addSeries, addSeries, addSeries, addSeries, addXAxis, addYAxis, clear, getArea, getAxes, getGridColor, getMargin, getSeries, getZoomableBounds, paintComponent, reset, setGridColor, setMargin, transform
 
Methods inherited from class ZoomPane
addMouseListener, addZoomChangeListener, buildNavigationMenu, correctApparentPixelPosition, createScrollPane, fireZoomChanged, getDefaultSize, getInsets, getMagnifierBorder, getMagnifierGlass, getMagnifierMenu, getMouseSelectionShape, getPopupMenu, getPreferredArea, getPreferredPixelSize, getScaleFactor, getTransform, getVisibleArea, hasPreferredArea, isMagnifierEnabled, isMagnifierVisible, isPaintingWhileAdjusting, mouseSelectionPerformed, paintComponent, paintMagnifier, printComponent, printComponent, removeZoomChangeListener, repaint, reset, scrollRectToVisible, setMagnifierBorder, setMagnifierEnabled, setMagnifierGlass, setMagnifierVisible, setPaintingWhileAdjusting, setPreferredArea, setResetPolicy, setTransform, setVisibleArea, tieModels, transformPixels, untieModels, updateUI
 
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, 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, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, 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
 
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, 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

MosaicPerformanceGraph

public MosaicPerformanceGraph()
Creates a default graph.

Method Detail

createProfiler

protected MosaicProfiler createProfiler(TileManager tiles)
                                 throws IOException
Creates a profiler for the given mosaic. This method is invoked automatically by plotEfficiency(String, TileManager) when a new plot has been requested. The default implementation creates a profiler with subsampling change allowed. Subclasses can overwrite this method for configuring the profiler in a different way.

Parameters:
tiles - The mosaic to profile.
Returns:
A profiler for the given mosaic.
Throws:
IOException - if an I/O operation was required and failed.

getImagesPerSubsampling

public int getImagesPerSubsampling()
Returns the number of images to be requested for each subsampling level.

Returns:
The current number of image loadings to be done or simulated per subsampling level.

setImagesPerSubsampling

public void setImagesPerSubsampling(int n)
Sets the number of images to be requested for each subsampling level.

Parameters:
n - The new number of image loadings to be done or simulated per subsampling level.

getProgressBar

public JProgressBar getProgressBar()
Returns the progress bar given to the last to setProgressBar(JProgressBar). The default value is null, i.e. this widget do not provides any progress bar by itself.

Returns:
The progress bar given to the last to setProgressBar.

setProgressBar

public void setProgressBar(JProgressBar bar)
Sets the progress bar to inform of lengthly operation, or null if none. The given progress bar is expected to accept a range of values from 0 to 100 inclusive. If the progress bar accepts a wider range of values, only the [0 … 100] range will be used.

The given progress bar is not displayed in this widget. It is caller responsibility to provide a progress bar visible in his own widget.

Parameters:
bar - The progress bar, or null if none.

getClearBeforePlot

public boolean getClearBeforePlot()
If true, any call to plotEfficiency will clear the previous plot before to add the result of a new calculation. If false, then the result of plotEfficiency will be a new series added to the existing ones.

The default value is true.

Returns:
Whatever the result of plotEfficiency will replace any previous plot.

setClearBeforePlot

public void setClearBeforePlot(boolean clear)
Sets whatever the result of plotEfficiency should replace any previous plot.

Parameters:
clear - Whatever the result of plotEfficiency should replace any previous plot.

plotEfficiency

public final void plotEfficiency(String name,
                                 TileManager tiles)
                          throws IOException
Adds a plot calculated for the given mosaic. This method will run the profiler for every uniform subsampling values ranging from the minimum to the maximum subsampling value, inclusives.

This method can be invoked from any thread - it doesn't need to be the Swing one. Since this method may take a while, it is recommended to invoke it from a background thread.

Parameters:
name - The name to given to the plot, or null if none.
tiles - The mosaic for which to plot the estimated cost of loading images.
Throws:
IOException - if an I/O operation was required and failed.

plotLater

public void plotLater(String name,
                      MosaicPerformanceGraph.Delayed delayed,
                      long delay)
Adds a plot for the mosaic created by a given builder. This method can be invoked from any thread and returns immediately. The actual plot calculation is delegated to a background thread.

Parameters:
name - The name to given to the plot, or null if none.
delayed - Provides the TileManager and the methods to callback on success or failure.
delay - How long to wait (in milliseconds) before to perform the calculation.

commitEdit

public void commitEdit()
                throws ParseException
Forces the current values to be taken from the editable fields and set them as the current values. The default implementation does nothing since there is no editable fields in this 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-2013 Geotoolkit.org. All Rights Reserved.