ui.recognizer
Class PlotRecognizer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by ui.recognizer.PlotRecognizer
All Implemented Interfaces:
DropTargetListener, ActionListener, ItemListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class PlotRecognizer
extends JFrame
implements ItemListener, ActionListener, DropTargetListener

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String DATA
           
static String DATA_FLATEN
           
static String DATA_MODIFY
           
static String DATA_OUTPUT_FORMAT_FITS
           
static String DATA_OUTPUT_FORMAT_TEXT
           
static String DATA_OUTPUT_FORMAT_XML
           
static String DATA_OVERLAY
           
static String DATA_SMOOTH
           
static String EDIT
           
static String EDIT_CALIBRATE
           
static String EDIT_CLEAN
           
static String EDIT_RECOGNIZE
           
static String EDIT_REMOVE_GRID
           
static String EDIT_WINDOW
           
static String FILE
           
static String FILE_LOAD
           
static String FILE_QUIT
           
static String FILE_SAVE
           
static int HEIGHT
           
static String VIEW
           
static String VIEW_ZOOM_IN
           
static String VIEW_ZOOM_NORMAL
           
static String VIEW_ZOOM_OUT
           
static int WIDTH
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, PROPERTIES, SOMEBITS
 
Constructor Summary
PlotRecognizer(String aTitle)
           
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void calibrate()
          Calibrate the image by asking for the user to click on the axes and to define a numerical value for the coordinates of those points.
 JMenuBar createMenu()
           
 void dragEnter(DropTargetDragEvent e)
           
 void dragExit(DropTargetEvent e)
           
 void dragOver(DropTargetDragEvent e)
           
 void dragScroll(DropTargetDragEvent e)
           
 void drop(DropTargetDropEvent e)
           
 void dropActionChanged(DropTargetDragEvent e)
           
 int getBlackThreshold()
          Get the gray color intensity below which a pixel is considered 'black'
 String getDataFileName()
          Get the file name for the plot data.
 String getDataFileType()
          Get the data file type.
 String getDataOutputFormat()
          Get the data output format such as text or xml.
 String getImageFileName()
          Get the file name for the image.
 int getSamples()
          Get the number of data samples in the plot
 String getXTextOutputFormat()
          Get the text output format string for the x data values, which determines the precision or number of significant digits when exporting the x value as text
 String getYTextOutputFormat()
          Get the text output format string for the y data values, which determines the precision or number of significant digits when exporting the y value as text
 void init()
           
 boolean isAxesCalibrated()
          Get the status of the axes calibration procedure.
 boolean isDataAvailable()
          Get the status of the available processed data.
 boolean isImageLoaded()
          Get the status of the image loading process.
 boolean isOverlay()
          Get the overlay option.
 void itemStateChanged(ItemEvent e)
           
 void loadImage()
           
 void loadImage(File aFile)
           
static void main(String[] argv)
           
 void overlay()
           
 void processFiles(List aListOfFiles)
          Process a list of image files.
 void recognize()
          Recognize the image by iterating over the pixexl columns of the calibrated image window and by searching for the plot 'trace' or 'pen' which represents the function y=f(x).
 void reDraw()
           
 void saveData()
          Bring up a file requestor and save the current data into that file.
 void saveData(File aFile)
          Save the current data as file, the file will be saved in the current export format
 void setAxesCalibrated(boolean aAxesCalibrated)
          Set the status of the axis calibration procedure.
 void setBlackThreshold(int aBlackThreshold)
          Set the gray color intensity below which a pixel is considered 'black'
 void setDataAvailable(boolean aDataAvailable)
          Set the status of the available processed data.
 void setDataFileName(String aDataFileName)
          Set the file name for the plot data.
 void setDataFileType(String aDataFileType)
          Set the file name for the plot data.
 void setDataOutputFormat(String aDataOutputFormat)
          Set the data output format such as text or xml.
 void setImageFileName(String anImageFileName)
           
 void setImageLoaded(boolean anImageLoaded)
          Set the status of the image loading process.
 void setOverlay(boolean anOverlay)
          Set the overlay option.
 void setSamples(int aSamples)
          Set the number of data samples in the plot
 void setXTextOutputFormat(String aXTextOutputFormat)
          Set the text output format string for the x data values.
 void setYTextOutputFormat(String aYTextOutputFormat)
          Set the text output format string for the y data values.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

FILE

public static final String FILE
See Also:
Constant Field Values

FILE_LOAD

public static final String FILE_LOAD
See Also:
Constant Field Values

FILE_SAVE

public static final String FILE_SAVE
See Also:
Constant Field Values

FILE_QUIT

public static final String FILE_QUIT
See Also:
Constant Field Values

EDIT

public static final String EDIT
See Also:
Constant Field Values

EDIT_CLEAN

public static final String EDIT_CLEAN
See Also:
Constant Field Values

EDIT_REMOVE_GRID

public static final String EDIT_REMOVE_GRID
See Also:
Constant Field Values

EDIT_CALIBRATE

public static final String EDIT_CALIBRATE
See Also:
Constant Field Values

EDIT_WINDOW

public static final String EDIT_WINDOW
See Also:
Constant Field Values

EDIT_RECOGNIZE

public static final String EDIT_RECOGNIZE
See Also:
Constant Field Values

VIEW

public static final String VIEW
See Also:
Constant Field Values

VIEW_ZOOM_IN

public static final String VIEW_ZOOM_IN
See Also:
Constant Field Values

VIEW_ZOOM_OUT

public static final String VIEW_ZOOM_OUT
See Also:
Constant Field Values

VIEW_ZOOM_NORMAL

public static final String VIEW_ZOOM_NORMAL
See Also:
Constant Field Values

DATA

public static final String DATA
See Also:
Constant Field Values

DATA_MODIFY

public static final String DATA_MODIFY
See Also:
Constant Field Values

DATA_SMOOTH

public static final String DATA_SMOOTH
See Also:
Constant Field Values

DATA_FLATEN

public static final String DATA_FLATEN
See Also:
Constant Field Values

DATA_OVERLAY

public static final String DATA_OVERLAY
See Also:
Constant Field Values

WIDTH

public static int WIDTH

HEIGHT

public static int HEIGHT

DATA_OUTPUT_FORMAT_TEXT

public static String DATA_OUTPUT_FORMAT_TEXT

DATA_OUTPUT_FORMAT_XML

public static String DATA_OUTPUT_FORMAT_XML

DATA_OUTPUT_FORMAT_FITS

public static String DATA_OUTPUT_FORMAT_FITS
Constructor Detail

PlotRecognizer

public PlotRecognizer(String aTitle)
Method Detail

init

public void init()

createMenu

public JMenuBar createMenu()

itemStateChanged

public void itemStateChanged(ItemEvent e)
Specified by:
itemStateChanged in interface ItemListener

reDraw

public void reDraw()

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

loadImage

public void loadImage()

loadImage

public void loadImage(File aFile)

saveData

public void saveData()
Bring up a file requestor and save the current data into that file.


saveData

public void saveData(File aFile)
Save the current data as file, the file will be saved in the current export format

Parameters:
aFile - a file in which to save the data

processFiles

public void processFiles(List aListOfFiles)
Process a list of image files. The list could be a product of a drag and drop operation involving multiple files or it could be constructed from a special file containing a list of filenames. The calibration and recognition steps are performed automatically. The calibration must be the same for all plots, they must have the same x-range.

Parameters:
aListOfFiles - a collection of File objects to be processed.

calibrate

public void calibrate()
Calibrate the image by asking for the user to click on the axes and to define a numerical value for the coordinates of those points.


recognize

public void recognize()
Recognize the image by iterating over the pixexl columns of the calibrated image window and by searching for the plot 'trace' or 'pen' which represents the function y=f(x).


overlay

public void overlay()

main

public static void main(String[] argv)

setDataOutputFormat

public void setDataOutputFormat(String aDataOutputFormat)
Set the data output format such as text or xml.

Parameters:
aDataOutputFormat - the data output format

getDataOutputFormat

public String getDataOutputFormat()
Get the data output format such as text or xml.

Returns:
the data output format

getXTextOutputFormat

public String getXTextOutputFormat()
Get the text output format string for the x data values, which determines the precision or number of significant digits when exporting the x value as text

Returns:
a decimal format string for the x values

setXTextOutputFormat

public void setXTextOutputFormat(String aXTextOutputFormat)
Set the text output format string for the x data values.

Parameters:
aXTextOutputFormat - a string representing the decimal text output format for the x values

getYTextOutputFormat

public String getYTextOutputFormat()
Get the text output format string for the y data values, which determines the precision or number of significant digits when exporting the y value as text

Returns:
a decimal format string for the y values

setYTextOutputFormat

public void setYTextOutputFormat(String aYTextOutputFormat)
Set the text output format string for the y data values.

Parameters:
aYTextOutputFormat - a string representing the decimal text output format for the y values

getBlackThreshold

public int getBlackThreshold()
Get the gray color intensity below which a pixel is considered 'black'

Returns:
the threshold intensity for black, an integer between 0 and 255

setBlackThreshold

public void setBlackThreshold(int aBlackThreshold)
Set the gray color intensity below which a pixel is considered 'black'

Parameters:
aBlackThreshold - the threshold intensity for black, an integer between 0 and 255

getSamples

public int getSamples()
Get the number of data samples in the plot

Returns:
the number of data samples in the plot

setSamples

public void setSamples(int aSamples)
Set the number of data samples in the plot

Parameters:
aSamples - the number of data samples in the plot

getDataFileType

public String getDataFileType()
Get the data file type.

Returns:
a string representing the data file type.

setDataFileType

public void setDataFileType(String aDataFileType)
Set the file name for the plot data.

Parameters:
aDataFileType - a string representing the data file name

getDataFileName

public String getDataFileName()
Get the file name for the plot data.

Returns:
a string representing the data file name.

setDataFileName

public void setDataFileName(String aDataFileName)
Set the file name for the plot data.

Parameters:
aDataFileName - a string representing the data file name

getImageFileName

public String getImageFileName()
Get the file name for the image.

Returns:
a string representing the image file name.

setImageFileName

public void setImageFileName(String anImageFileName)

isAxesCalibrated

public boolean isAxesCalibrated()
Get the status of the axes calibration procedure.

Returns:
true if the axes have been calibrated according to the axis labels

setAxesCalibrated

public void setAxesCalibrated(boolean aAxesCalibrated)
Set the status of the axis calibration procedure.

Parameters:
aAxesCalibrated - boolean flag indicating if axes have been calibrated

isDataAvailable

public boolean isDataAvailable()
Get the status of the available processed data.

Returns:
true if image has been processed and data is available for saving etc...

setDataAvailable

public void setDataAvailable(boolean aDataAvailable)
Set the status of the available processed data.

Parameters:
aDataAvailable - a boolean flag indicating if the data is available

isImageLoaded

public boolean isImageLoaded()
Get the status of the image loading process.

Returns:
true if image is loaded and ready for processing

setImageLoaded

public void setImageLoaded(boolean anImageLoaded)
Set the status of the image loading process.


isOverlay

public boolean isOverlay()
Get the overlay option.

Returns:
true if overlay is to be plotted when available

setOverlay

public void setOverlay(boolean anOverlay)
Set the overlay option.

Parameters:
anOverlay - a boolean flag representing the choice to plot data over the image

dragEnter

public void dragEnter(DropTargetDragEvent e)
Specified by:
dragEnter in interface DropTargetListener

dragOver

public void dragOver(DropTargetDragEvent e)
Specified by:
dragOver in interface DropTargetListener

dragExit

public void dragExit(DropTargetEvent e)
Specified by:
dragExit in interface DropTargetListener

drop

public void drop(DropTargetDropEvent e)
Specified by:
drop in interface DropTargetListener

dragScroll

public void dragScroll(DropTargetDragEvent e)

dropActionChanged

public void dropActionChanged(DropTargetDragEvent e)
Specified by:
dropActionChanged in interface DropTargetListener