edu.mit.sketch.chem
Class ChemSketch

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by edu.mit.sketch.ui.CESketchPanel
                      extended by edu.mit.sketch.chem.ChemSketch
All Implemented Interfaces:
CInkProcessor, StrokeDataListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, javax.accessibility.Accessible

public class ChemSketch
extends CESketchPanel
implements StrokeDataListener, java.lang.Runnable

to be done: read typeStrings from file general clean up

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static int backtrack
           
static boolean chemknowledge
           
static java.lang.String chempath
           
static double connectthreshold
           
static boolean demo
           
 boolean display
           
static double doublethreshold
           
static java.lang.String labelFilePath
           
 int mode
           
static double polythreshold
           
 java.lang.String[] strokeLabels
           
static java.lang.String trainFile
           
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
ChemSketch()
           
 
Method Summary
 void applyLabels()
           
 void buildGraph()
           
 void buildStructure()
           
 void compareResults(java.lang.String testfile, java.lang.String reffile)
           
 void correctSketch()
           
 boolean doubleBond(StrokeData sd1, StrokeData sd2)
           
 void evaluateLabels()
           
 void extractComponents()
          Extract individual chemistry components from strokes (e.g.
 java.lang.String[] generateLabels()
           
 void getStrokeEnds()
           
 void getStrokes()
           
 void handleStroke(StrokeData stroke)
          This method is called by classes that collect StrokeData objects.
 void labelAll()
           
 void labelAllDirs(java.lang.String path)
           
 void labelAllFiles(java.lang.String path)
           
 void labelStrokes(java.lang.String label)
           
static void main(java.lang.String[] args)
           
 void openFile(java.io.File file)
           
 void paintComponent(java.awt.Graphics g)
           
 void processComponents()
           
 void recognitionThread()
           
 void recognize(boolean incremental)
           
 void recognizeLabel()
           
 void refineLabels()
           
 void run()
           
 boolean sameLabel(java.lang.String l1, java.lang.String l2)
           
 void save(java.io.File file)
           
 void saveCDXML(java.lang.String path, boolean load)
           
 void saveTestLabels()
           
 void saveTestLabelsInt()
           
 void test(boolean incremental)
           
 void testAll()
           
 void testAllDirs(java.lang.String path)
           
 void testAllFiles(java.lang.String path)
           
 void testOne()
           
 void train(boolean append)
           
 void trainAll()
           
 void trainAllDirs(java.lang.String path)
           
 void trainAllFiles(java.lang.String path)
           
 
Methods inherited from class edu.mit.sketch.ui.CESketchPanel
addStrokeDataListener, click, endStroke, getStrokeDataListeners, isPaintingAsWeGo, isRecognizing, key, recognized, registerSample, removeStrokeDataListener, setIsPaintingAsWeGo, setIsRecognizing, startStroke
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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 java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

backtrack

public static int backtrack

chemknowledge

public static boolean chemknowledge

strokeLabels

public java.lang.String[] strokeLabels

trainFile

public static java.lang.String trainFile

labelFilePath

public static java.lang.String labelFilePath

polythreshold

public static double polythreshold

connectthreshold

public static double connectthreshold

doublethreshold

public static double doublethreshold

chempath

public static java.lang.String chempath

mode

public int mode

display

public boolean display

demo

public static boolean demo
Constructor Detail

ChemSketch

public ChemSketch()
Method Detail

saveCDXML

public void saveCDXML(java.lang.String path,
                      boolean load)

handleStroke

public void handleStroke(StrokeData stroke)
Description copied from interface: StrokeDataListener
This method is called by classes that collect StrokeData objects.

Specified by:
handleStroke in interface StrokeDataListener

trainAll

public void trainAll()

labelAll

public void labelAll()

testAll

public void testAll()

train

public void train(boolean append)

test

public void test(boolean incremental)

run

public void run()
Specified by:
run in interface java.lang.Runnable

recognitionThread

public void recognitionThread()

recognize

public void recognize(boolean incremental)

recognizeLabel

public void recognizeLabel()

buildStructure

public void buildStructure()

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

getStrokes

public void getStrokes()

getStrokeEnds

public void getStrokeEnds()

labelStrokes

public void labelStrokes(java.lang.String label)

applyLabels

public void applyLabels()

extractComponents

public void extractComponents()
Extract individual chemistry components from strokes (e.g. multi-bond strokes)


processComponents

public void processComponents()

doubleBond

public boolean doubleBond(StrokeData sd1,
                          StrokeData sd2)

buildGraph

public void buildGraph()

correctSketch

public void correctSketch()

openFile

public void openFile(java.io.File file)

save

public void save(java.io.File file)

main

public static void main(java.lang.String[] args)

saveTestLabels

public void saveTestLabels()

saveTestLabelsInt

public void saveTestLabelsInt()

labelAllDirs

public void labelAllDirs(java.lang.String path)

labelAllFiles

public void labelAllFiles(java.lang.String path)

trainAllDirs

public void trainAllDirs(java.lang.String path)

trainAllFiles

public void trainAllFiles(java.lang.String path)

testAllDirs

public void testAllDirs(java.lang.String path)

testAllFiles

public void testAllFiles(java.lang.String path)

testOne

public void testOne()

generateLabels

public java.lang.String[] generateLabels()

refineLabels

public void refineLabels()

sameLabel

public boolean sameLabel(java.lang.String l1,
                         java.lang.String l2)

compareResults

public void compareResults(java.lang.String testfile,
                           java.lang.String reffile)

evaluateLabels

public void evaluateLabels()