|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.event.WindowAdapter
strokes.StrokeShortcuts
public class StrokeShortcuts
A stroke shortcuts manager used to register:
A stroke shortcuts manager has an underlying shape matching classifier. Each time, the user inputs a stroke on a strokable component, the manager invokes the command corresponding to this stroke if exists.
A stroke shortcuts manager can implement several visual clues for available stroke shortcuts: Strokes Sheet, Menu Preview and Tooltip. For more information about these features, see the StrokeShortcuts' tutorial.
StrokeListeners
or StateMachine
can be attached to this
manager to be notified each time a stroke event occurs: a stroke begins,
a point is added to a stroke, a stroke ends as a shortcut,
a stroke ends as a command or a stroke ends as non recognized.
strokes.listeners
,
strokes.transitions
Constructor Summary | |
---|---|
StrokeShortcuts()
Builds a strokes shortcuts manager. |
Method Summary | |
---|---|
void |
addShortcut(java.lang.String actionName,
java.util.Vector<java.awt.geom.Point2D> stroke,
boolean inline,
boolean tooltip)
Registers a new stroke shortcut in this strokes shortcuts manager. |
void |
addShortcuts(java.io.File recognizer,
boolean inline,
boolean tooltip)
Registers a set of stroke shortcuts contained in a shape matching classifier in this strokes shortcuts manager. |
void |
addShortcuts(fr.lri.swingstates.gestures.shapeMatching.ShapeMatchingClassifier recognizer,
boolean inline,
boolean tooltip)
Registers a set of stroke shortcuts contained in a shape matching classifier in this strokes shortcuts manager. |
void |
addShortcuts(java.lang.String recognizerFile,
boolean inline,
boolean tooltip)
Registers a set of stroke shortcuts contained in a shape matching classifier in this strokes shortcuts manager. |
void |
addStrokeListener(fr.lri.swingstates.sm.StateMachine stateMachine)
Adds a state machine to this strokes shortcuts manager so this state machine will be notified each time: a stroke begins, a new point is added to a stroke, a stroke ends and has been recognized, a stroke ends but has not been recognized. |
void |
addStrokeListener(StrokeListener strokeListener)
Adds a StrokeListener to this strokes shortcuts manager so this listener will be notified
each time:
a stroke begins,
a new point is added to a stroke,
a stroke ends and has been recognized,
a stroke ends but has not been recognized. |
void |
addWindow(java.awt.Window window)
Registers a window in this strokes shortcuts manager. |
java.lang.String |
classify(fr.lri.swingstates.gestures.Gesture gesture)
Return the command name that minimizes the distance to an input stroke within the set of stroke templates registered in this strokes shortcuts manager. |
void |
disableStrokes(java.awt.Component strokableComponent)
Disables stroke recognition for strokes started on a given component. |
void |
disableStrokes(java.awt.Component strokableComponent,
boolean hierarchy)
Disables stroke recognition for strokes started on a given component. |
void |
enableStrokes(java.awt.Component strokableComponent,
boolean hierarchy,
boolean drawInkOnGlassPane)
Registers a component to enable stroke when a drag interaction starts on it. |
void |
enableStrokes(java.awt.Component strokableComponent,
boolean hierarchy,
boolean drawInkOnGlassPane,
Criterion criterion)
Registers a component to enable stroke when a drag interaction starts on when a given criterion is verified. |
void |
enableStrokesSheet()
Enables the strokes sheet: when pausing for 300 milliseconds while tracing a strokes, the strokes sheet pops up close to the mouse cursor. |
fr.lri.swingstates.gestures.shapeMatching.ShapeMatchingClassifier |
getClassifier()
|
Criterion |
getCriterion(javax.swing.JComponent component)
|
StrokeIcon |
getIcon(java.lang.String command,
int width,
int height)
Creates a StrokeIcon of a stroke given its command name. |
StrokeIcon |
getIcon(java.lang.String command,
int width,
int height,
java.awt.Color colorStroke,
int sizeStartingPoint,
java.awt.Color colorStartingPoint)
Creates a StrokeIcon of a stroke given its command name. |
java.awt.Color |
getInkColorWhenNonRecognized()
In case of bad recognition, the stroke will stay displayed for 200 milliseconds in a this color. |
java.awt.Color |
getInkColorWhileBeautifying()
In case of good recognition, the stroke will be beautified to match its template stroke. |
java.awt.Color |
getInkColorWhileStroking()
|
fr.lri.swingstates.canvas.CPolyLine |
getInkTrail()
|
int |
getMinimumStrokeLength()
|
void |
getPngImage(java.io.File file,
java.lang.String command,
int sideSizeImage,
java.awt.Color colorStroke,
int sizeStartingPoint,
java.awt.Color colorStartingPoint)
Creates a squared png image of a stroke given its command name. |
void |
getPngImage(java.io.File file,
java.lang.String command,
int sideSizeImage,
int sizeStartingPoint)
Creates a squared png image of a stroke given its command name. |
fr.lri.swingstates.canvas.CEllipse |
getStartingPoint()
|
java.awt.Color |
getStartPointColor()
|
double |
getThreshold()
|
static boolean |
invokeAccessibleAction(javax.accessibility.Accessible accessible,
java.lang.String actionName)
Looks for the first occurrence of a named action in the hierarchy of an Accessible component. |
boolean |
invokeCommand(java.lang.String accessibleAction)
Invokes an accessible action |
boolean |
isStrokable(java.awt.Component c)
|
void |
removeStrokeListener(fr.lri.swingstates.sm.StateMachine stateMachine)
Adds a state machine from this strokes shortcuts manager. |
void |
removeStrokeListener(StrokeListener strokeListener)
Removes a listener from this strokes shortcuts manager. |
boolean |
setCriterion(java.awt.Component component,
Criterion criterion)
Sets the criterion for one component that is already registered in this strokes shortcuts manager. |
void |
setInkColorWhenNonRecognized(java.awt.Color inkColorWhenNonRecognized)
In case of bad recognition, the stroke will stay displayed for 200 milliseconds in a this color. |
void |
setInkColorWhileBeautifying(java.awt.Color inkColorWhileBeautifying)
In case of good recognition, the stroke will be beautified to match its template stroke. |
void |
setInkColorWhileStroking(java.awt.Color inkColorWhileStroking)
|
void |
setMinimumStrokeLength(int minimumStrokeLength)
|
void |
setStartPointColor(java.awt.Color startPointColor)
|
void |
setThreshold(double maximumDistance)
|
void |
windowGainedFocus(java.awt.event.WindowEvent e)
|
Methods inherited from class java.awt.event.WindowAdapter |
---|
windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowLostFocus, windowOpened, windowStateChanged |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StrokeShortcuts()
Method Detail |
---|
public void addStrokeListener(StrokeListener strokeListener)
StrokeListener
to this strokes shortcuts manager so this listener will be notified
each time:
strokeListener
- The listener to addStrokeListener
,
StrokeAdapter
public void addStrokeListener(fr.lri.swingstates.sm.StateMachine stateMachine)
stateMachine
- The state machine to add.StrokeBegun
,
StrokePointAdded
,
ShortcutRecognized
,
StrokeNotRecognized
public void removeStrokeListener(StrokeListener strokeListener)
strokeListener
- The listener to removepublic void removeStrokeListener(fr.lri.swingstates.sm.StateMachine stateMachine)
stateMachine
- The state machine to add.public boolean invokeCommand(java.lang.String accessibleAction)
accessibleAction
- The name of the accessible action to invoke
public static boolean invokeAccessibleAction(javax.accessibility.Accessible accessible, java.lang.String actionName)
Accessible
component.
accessible
- the Accessible
component.actionName
- the action name.
public void addShortcut(java.lang.String actionName, java.util.Vector<java.awt.geom.Point2D> stroke, boolean inline, boolean tooltip)
actionName
- The action to invokestroke
- The stroke that invokes actionName
inline
- True if this stroke shortcut must be displayed beside the menu item that also invokes actionName
tooltip
- True if this stroke shortcut must be displayed in the tooltip of components that also invoke actionName
public void addShortcuts(fr.lri.swingstates.gestures.shapeMatching.ShapeMatchingClassifier recognizer, boolean inline, boolean tooltip)
recognizer
- The shape matching classifierinline
- True if stroke shortcuts must be displayed beside their corresponding menu itemstooltip
- True if stroke shortcuts must be displayed in the tooltip of corresponding componentsaddShortcut(String, Vector, boolean, boolean)
public void addShortcuts(java.io.File recognizer, boolean inline, boolean tooltip)
recognizer
- The file containing the shape matching recognizer definitioninline
- True if stroke shortcuts must be displayed beside their corresponding menu itemstooltip
- True if stroke shortcuts must be displayed in the tooltip of corresponding componentsaddShortcut(String, Vector, boolean, boolean)
public void addShortcuts(java.lang.String recognizerFile, boolean inline, boolean tooltip)
recognizerFile
- The name of the file containing the shape matching recognizer definitioninline
- True if stroke shortcuts must be displayed beside their corresponding menu itemstooltip
- True if stroke shortcuts must be displayed in the tooltip of corresponding componentsaddShortcut(String, Vector, boolean, boolean)
,
addWindow(Window)
public void windowGainedFocus(java.awt.event.WindowEvent e)
windowGainedFocus
in interface java.awt.event.WindowFocusListener
windowGainedFocus
in class java.awt.event.WindowAdapter
public void addWindow(java.awt.Window window)
window
- The window to register.public void enableStrokes(java.awt.Component strokableComponent, boolean hierarchy, boolean drawInkOnGlassPane)
strokableComponent
- The component where stroke recognition must be enabled.hierarchy
- If the component children of strokableComponent
must also be added.drawInkOnGlassPane
- If stroke ink must be drawn on the glasspane.public boolean setCriterion(java.awt.Component component, Criterion criterion)
component
- The componentcriterion
- The new criterion
component
was not already registered (in this latter case, this method does nothing).public void enableStrokes(java.awt.Component strokableComponent, boolean hierarchy, boolean drawInkOnGlassPane, Criterion criterion)
criterion
. If this component
is a RootPaneContainer, its content pane is registered.
JComponent
s can be defined as strokable.
strokableComponent
- The component where stroke recognition must be enabled.hierarchy
- If the component children of strokableComponent
must also be added.drawInkOnGlassPane
- If stroke ink must be drawn on the glasspane.criterion
- The criterion that specifies when a stroke begins.public boolean isStrokable(java.awt.Component c)
c
- the component
public void enableStrokesSheet()
public fr.lri.swingstates.gestures.shapeMatching.ShapeMatchingClassifier getClassifier()
public void disableStrokes(java.awt.Component strokableComponent)
strokableComponent
- The component on which stroke recognition must be disabled.public void disableStrokes(java.awt.Component strokableComponent, boolean hierarchy)
strokableComponent
- The component on which stroke recognition must be disabled.public int getMinimumStrokeLength()
public void setMinimumStrokeLength(int minimumStrokeLength)
minimumStrokeLength
- The minimum length that must have a mouse drag to be considered as a stroke.public double getThreshold()
public void setThreshold(double maximumDistance)
maximumDistance
- The distance threshold
(i.e. if the distance between the input stroke and the best template is greater than this threshold, the stroke is not recognized).public Criterion getCriterion(javax.swing.JComponent component)
component
- a component
component
or null if this component
is not registered or does not have any criterion associated with it.public java.awt.Color getStartPointColor()
public void setStartPointColor(java.awt.Color startPointColor)
startPointColor
- the color used for the rendering the first point of a stroke.public java.awt.Color getInkColorWhileStroking()
public void setInkColorWhileStroking(java.awt.Color inkColorWhileStroking)
inkColorWhileStroking
- the color used for the rendering of a stroke ink while it is tracing.public java.awt.Color getInkColorWhenNonRecognized()
public void setInkColorWhenNonRecognized(java.awt.Color inkColorWhenNonRecognized)
inkColorWhenNonRecognized
- the color used for the rendering of a stroke when it is not recognized.public java.awt.Color getInkColorWhileBeautifying()
public void setInkColorWhileBeautifying(java.awt.Color inkColorWhileBeautifying)
inkColorWhileBeautifying
- the color used for the rendering of a stroke while it is beautified.public java.lang.String classify(fr.lri.swingstates.gestures.Gesture gesture)
gesture
- The stroke
public StrokeIcon getIcon(java.lang.String command, int width, int height)
StrokeIcon
of a stroke given its command name.
The stroke is drawn in black with a red starting point of diameter 6.
command
- The name of the command activated by the strokewidth
- The width of the iconheight
- The height of the iconpublic StrokeIcon getIcon(java.lang.String command, int width, int height, java.awt.Color colorStroke, int sizeStartingPoint, java.awt.Color colorStartingPoint)
StrokeIcon
of a stroke given its command name.
command
- The name of the command activated by the strokewidth
- The width of the iconheight
- The height of the iconcolorStroke
- The color of the strokesizeStartingPoint
- The diameter of the starting pointcolorStartingPoint
- The color of the starting pointpublic void getPngImage(java.io.File file, java.lang.String command, int sideSizeImage, java.awt.Color colorStroke, int sizeStartingPoint, java.awt.Color colorStartingPoint)
file
- The image filecommand
- The name of the command activated by the strokesideSizeImage
- The size of image sidecolorStroke
- The stroke colorsizeStartingPoint
- The diameter of the stroke's starting pointcolorStartingPoint
- The color of the stroke's starting pointpublic fr.lri.swingstates.canvas.CPolyLine getInkTrail()
public fr.lri.swingstates.canvas.CEllipse getStartingPoint()
public void getPngImage(java.io.File file, java.lang.String command, int sideSizeImage, int sizeStartingPoint)
file
- The image filecommand
- The name of the command activated by the strokesideSizeImage
- The size of image sidesizeStartingPoint
- The diameter of the stroke's starting point
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |