ch.claudio.pen
Class Paper

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 ch.claudio.pen.Paper
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class Paper
extends java.awt.Frame
implements java.awt.event.MouseMotionListener, java.awt.event.MouseListener

Electronic Paper.

Note: There are two layers: The ink layer which is the user interface (input, controller?) and the application layer (output, view?). The Inkstore is - even if rendered through redrawInk - a representation of the input. It then depends on the application, what the real output is, the same strokes in case of a plain notebook, or some drawing etc.

The recogniser is the connection from controller to model.

For a first incarnation, each paper sheet is bound to exactly one application. With time one can envision more intelligent sheets which are able to mix "applications" on one sheet.

This class listens to the mouse events. It relays the received information in form of InkDot objects to an own InkStore used for refreshing and to any other PenListener which installs itself.

One sheet should always appear as first. It will contain the most important notices of the user, e.g. I would use it to record my Todo items.

While pending appointments are important too, they would not be written there but handled by an application which superimposes the reminders when necessary.

A thread examines entered text or drawings and looks for anything looking like a command. If found an overlay appears on which the user can click to confirm the action. The overlay would appear near the current cursor position but in a way not hindering the user in writing and fade away within a few seconds if the user ignores it or if a new clue appears.

When the system recognises text, it should convert from ink to text or embellish drawings in a way which allows the user to easily correct mistakes done by the recogniser.

Heisse (geklaute) Idee: Wenn ich über einen bestehenden Buchstaben einen anderen zeichne, dann korrigiere ich damit den Text.

Ink ist nicht permanent. Wenn etwas interpretiert wird, z.b. ein Strich als "I" erkannt wurde, dann soll dass aus dem Ink verschwinden.

Modal und Modeless:

Die Applikation Papier sollte als solche so modeless wie nur möglich sein, d.h. ich kann beliebig hin- und her springen.

Die Eingabe ist zwangsläufig - weil nur ein Stift mit sehr beschränkten Möglichkeiten eingesetzt wird - modal, im Sinne, dass ich entweder etwas aus einem Menu auswähle, oder schreibe. Auch das schreiben kann modale Elemente enthalten, im Sinne davon, dass man sagt ob der Stift nun als Schreib- Selektions- oder Radierstift funktioniert. Letzteres sollte wenn möglich aber auch über Gesten möglich sein, z.b. löschen, in dem man etwas durchstreicht.

It would be nice if the user could switch between "recognize and replace as early as possible" and "let me sketch freely" mode. The second one would leave the display in the sketchy/handwritten state until the user explicitly ask for recognition. Yet some recognition would happen in the second mode too, to recognize command gestures needed e.g. "erase" or "switch to recognize mode".

Version:
$Id: Paper.java 253 2008-04-25 20:55:19Z claudio $
Author:
Claudio Nieder

Copyright (C) 2006 Claudio Nieder <private@claudio.ch>, CH-8610 Uster

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Paper(java.lang.String title)
          Default constructor.
 
Method Summary
 void addListener(PenListener penListener)
          Add a listener to the list.
 java.awt.Dimension getPreferredSize()
           
static void main(java.lang.String[] args)
          Print license.
 void mouseClicked(java.awt.event.MouseEvent e)
          Unused MouseListner method.
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
          Unused MouseListener method
 void mouseExited(java.awt.event.MouseEvent e)
          Unused MouseListener method
 void mouseMoved(java.awt.event.MouseEvent e)
          unused MouseListener method.
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paint(java.awt.Graphics g)
           
 void removListener(PenListener penListener)
          Remeove a listener from the list.
 void update(java.awt.Graphics g)
           
 
Methods inherited from class java.awt.Frame
addNotify, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, 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, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, 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, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Constructor Detail

Paper

public Paper(java.lang.String title)
Default constructor. Creates a new ink store and attaches all needed listeners to it.

Parameters:
title - of the window
Method Detail

addListener

public void addListener(PenListener penListener)
Add a listener to the list.

Parameters:
penListener - The listener to add.

removListener

public void removListener(PenListener penListener)
Remeove a listener from the list.

Parameters:
penListener - The listener to remove.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class java.awt.Container
See Also:
Component.getPreferredSize()

update

public void update(java.awt.Graphics g)
Overrides:
update in class java.awt.Container
See Also:
Component.update(java.awt.Graphics)

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Container
See Also:
Component.paint(java.awt.Graphics)

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
See Also:
MouseMotionListener.mouseDragged(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
unused MouseListener method.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
See Also:
MouseMotionListener.mouseMoved(java.awt.event.MouseEvent)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Unused MouseListner method.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseClicked(java.awt.event.MouseEvent)

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Unused MouseListener method

Specified by:
mouseEntered in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Unused MouseListener method

Specified by:
mouseExited in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)

main

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

Parameters:
args - ignored