com.levigo.jadice.swing.search.tool
Class TextCursorTool

java.lang.Object
  extended by com.levigo.jadice.swing.tool.Tool
      extended by com.levigo.jadice.swing.search.tool.TextCursorTool
All Implemented Interfaces:
MenuContributor

public class TextCursorTool
extends Tool

A Tool to visualize and manage a text cursor akin to a text cursor in a word processor or text editor. This tool can be used to navigate the document and to select text. However, no actual editing of the document content is supported at this point (and the foreseeable future).


Nested Class Summary
 
Nested classes/interfaces inherited from class com.levigo.jadice.swing.tool.Tool
Tool.ActivationRequest
 
Field Summary
 
Fields inherited from class com.levigo.jadice.swing.tool.Tool
DEFAULT_PRIORITY, MAX_PRIORITY, MIN_PRIORITY
 
Constructor Summary
TextCursorTool()
           
 
Method Summary
 void cursorAdvance(Granularity g)
          Advance the cursor one logical position of the given Granularity.
 void cursorBacktrack(Granularity g)
          Backtrack the cursor one logical position of the given Granularity.
 void cursorToEnd(Granularity g)
          Place the cursor at the end of the element of the given granularity at the current cursor position.
 void cursorToStart(Granularity g)
          Place the cursor at the start of the element of the given granularity at the current cursor position.
protected  Tool.ActivationRequest getActivationFeedback(MouseEditEvent e)
          Provide feedback for the user about what would happen, if the mouse were pressed at the current location.
 int getBlinkInterval()
          Get the blink interval of the cursor in milliseconds.
protected  void handleKeyPressed(KeyEditEvent e, boolean isActive)
          Invoked when a key has been pressed.
protected  void handleMouseClicked(MouseEditEvent e, boolean isActive)
          Invoked when the mouse button has been clicked (pressed and released) on a component.
 void hideCursor()
          Hide the cursor (if it is currently showing).
 boolean isCursorSet()
           
 boolean isSelectionMode()
           
protected  Granularity modifierToGranularityHomeEnd(KeyEditEvent e)
          Determine the Granularity to use when navigating using one of the keys KeyEvent.VK_HOME, KeyEvent.VK_END.
protected  Granularity modifierToGranularityLeftRight(KeyEditEvent e)
          Determine the Granularity to use when navigating using one of the keys KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT.
protected  Granularity modifierToGranularityUpDown(KeyEditEvent e)
          Determine the Granularity to use when navigating using one of the keys KeyEvent.VK_UP, KeyEvent.VK_DOWN.
protected  void render(RenderParameters parameters, boolean isActive)
          Renders the Tool's UI onto the given Graphics2D context using the given RenderControls.
 void setBlinkInterval(int interval)
          Set the blink interval of the cursor in milliseconds.
 
Methods inherited from class com.levigo.jadice.swing.tool.Tool
contribute, getActivationRequest, getActivationRequestForKeyPressed, getActivationRequestForMouseDragged, getActivationRequestForMousePressed, getCursor, getDispatchPriority, getManager, getRenderPriority, handleEditEvent, handleKeyReleased, handleKeyTyped, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseMoved, handleMousePressed, handleMouseReleased, handleMouseWheelMoved, propagatePropertyChange, setActive, setCursor, setEnabled, setManager, setStatusFeedback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextCursorTool

public TextCursorTool()
Method Detail

getActivationFeedback

protected Tool.ActivationRequest getActivationFeedback(MouseEditEvent e)
Description copied from class: Tool
Provide feedback for the user about what would happen, if the mouse were pressed at the current location. This method is called while handling MouseEvent.MOUSE_MOVED events. If this method returns null no feedback is provided at all. The activation request returned from this method is the same object that is used during Tool.getActivationRequestForKeyPressed(KeyEditEvent) to signal the auto-activation candidacy. This method should only return an activation request if it will actually candidate for auto-activation later on using Tool.getActivationRequestForMousePressed(MouseEditEvent) or Tool.getActivationRequestForMouseDragged(MouseEditEvent).

Overrides:
getActivationFeedback in class Tool

handleMouseClicked

protected void handleMouseClicked(MouseEditEvent e,
                                  boolean isActive)
Description copied from class: Tool
Invoked when the mouse button has been clicked (pressed and released) on a component.

Overrides:
handleMouseClicked in class Tool
isActive - whether this tool is currently active

handleKeyPressed

protected void handleKeyPressed(KeyEditEvent e,
                                boolean isActive)
Description copied from class: Tool
Invoked when a key has been pressed. See the class description for KeyEvent for a definition of a key pressed event.

Overrides:
handleKeyPressed in class Tool
isActive - whether this tool is currently active

modifierToGranularityHomeEnd

protected Granularity modifierToGranularityHomeEnd(KeyEditEvent e)
Determine the Granularity to use when navigating using one of the keys KeyEvent.VK_HOME, KeyEvent.VK_END. The default mapping is:
nothing Granularity.LINE
InputEvent.CTRL_MASK + InputEvent.ALT_MASK Granularity.PAGE
InputEvent.ALT_MASK Granularity.BLOCK
InputEvent.CTRL_MASK Granularity.DOCUMENT
otherwise null (don't handle this case)
InputEvent.SHIFT_MASK is ignored, as it is used to activate selection mode.

Parameters:
e -
Returns:

modifierToGranularityUpDown

protected Granularity modifierToGranularityUpDown(KeyEditEvent e)
Determine the Granularity to use when navigating using one of the keys KeyEvent.VK_UP, KeyEvent.VK_DOWN. The default mapping is:
nothing Granularity.LINE
InputEvent.CTRL_MASK Granularity.PAGE
InputEvent.ALT_MASK Granularity.BLOCK
otherwise null (don't handle this case)
InputEvent.SHIFT_MASK is ignored, as it is used to activate selection mode.

Parameters:
e -
Returns:

modifierToGranularityLeftRight

protected Granularity modifierToGranularityLeftRight(KeyEditEvent e)
Determine the Granularity to use when navigating using one of the keys KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT. The default mapping is:
nothing Granularity.GLYPH
InputEvent.CTRL_MASK Granularity.WORD
otherwise null (don't handle this case)
InputEvent.SHIFT_MASK is ignored, as it is used to activate selection mode.

Parameters:
e -
Returns:

cursorToEnd

public void cursorToEnd(Granularity g)
Place the cursor at the end of the element of the given granularity at the current cursor position. For example, in order to navigate the cursor to the end of the current word, use Granularity.WORD. Navigating with a granularity of Granularity.GLYPH does not make sense and has no effect.

Parameters:
g - the granularity of the element to navigate to

cursorToStart

public void cursorToStart(Granularity g)
Place the cursor at the start of the element of the given granularity at the current cursor position. For example, in order to navigate the cursor to the start of the current word, use Granularity.WORD. Navigating with a granularity of Granularity.GLYPH does not make sense and has no effect.

Parameters:
g - the granularity of the element to navigate to

cursorBacktrack

public void cursorBacktrack(Granularity g)
Backtrack the cursor one logical position of the given Granularity. For example, to navigate to the previous character (as in cursor-left) use Granularity.GLYPH.

Parameters:
g - the granularity of the navigation step

cursorAdvance

public void cursorAdvance(Granularity g)
Advance the cursor one logical position of the given Granularity. For example, to navigate to the next character (as in cursor-right) use Granularity.GLYPH.

Parameters:
g - the granularity of the navigation step

hideCursor

public void hideCursor()
Hide the cursor (if it is currently showing).


render

protected void render(RenderParameters parameters,
                      boolean isActive)
Description copied from class: Tool
Renders the Tool's UI onto the given Graphics2D context using the given RenderControls.

This render method is called within the context and during the rendering of a single page. The page being rendered is passed to implementors of this method in order to be able to control and influence the page rendering.

Overrides:
render in class Tool
Parameters:
parameters - the view component which is currently being rendered
isActive - whether the called tool is currently active

setBlinkInterval

public void setBlinkInterval(int interval)
Set the blink interval of the cursor in milliseconds. The cursor always blinks in equal on/off intervals.

Parameters:
interval - the interval in milliseconds

getBlinkInterval

public int getBlinkInterval()
Get the blink interval of the cursor in milliseconds. The cursor always blinks in equal on/off intervals.

Returns:
the interval the interval in milliseconds

isCursorSet

public boolean isCursorSet()

isSelectionMode

public boolean isSelectionMode()


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.