Package com.ibm.icu.dev.demo.impl
Class DumbTextComponent
java.lang.Object
java.awt.Component
java.awt.Canvas
com.ibm.icu.dev.demo.impl.DumbTextComponent
- All Implemented Interfaces:
FocusListener
,KeyListener
,MouseListener
,MouseMotionListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
- Direct Known Subclasses:
TransliteratingTextComponent
public class DumbTextComponent
extends Canvas
implements KeyListener, MouseListener, MouseMotionListener, FocusListener
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.awt.Canvas
Canvas.AccessibleAWTCanvas
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Point
private int
private Image
private Point
private BreakIterator
private String
private static final char
private static boolean
private boolean
private boolean
private Point
private FontMetrics
private boolean
private int
private int
private int
private BreakIterator
private int
private int
private int
private int[]
private static final int
private Dimension
private boolean
private boolean
private Selection
private ActionListener
private static final long
For serializationprivate Point
private Selection
private TextListener
private boolean
private BreakIterator
private int
private int
Fields inherited from class java.awt.Component
accessibleContext, 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
(package private) void
copy()
void
drawSelection
(Graphics g, String lastSubstring) private int
findFittingBreak
(FontMetrics fMtr, String line, int width, BreakIterator breaker) LIU: Finds the longest substring that fits a given width composed of subunits returned by a BreakIterator.private int
findLine
(int off, boolean start) private void
fixHex()
private void
fixLineStarts
(int width) void
void
protected int
int
int
getText()
protected void
static String
hex
(char ch) void
insertText
(String text) boolean
void
void
void
private int
lineDelta
(int off, int delta) LIU: Given an offset into contents, moves up or down by lines, according to lineStarts[].void
void
void
void
void
void
void
int
nextLine
(FontMetrics fMtr, int start, int width) offset2Point
(int off, boolean start, Point p) void
void
(package private) void
(package private) void
paste()
point2Offset
(Point p, Selection o) void
void
void
replaceRange
(String s, int start, int end) void
select
(int start, int end) void
select
(int start, int end, boolean clickAfter) void
void
select
(MouseEvent e, boolean first) void
setBounds
(int x, int y, int w, int h) void
setEditable
(boolean b) void
protected void
setKeyStart
(int keyStart) void
void
void
protected void
int
visibleWidth
(FontMetrics fMtr, String s) Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor serialization- See Also:
-
DEBUG
private static transient boolean DEBUG -
contents
-
selection
-
activeStart
private int activeStart -
editable
private boolean editable -
tempSelection
-
focus
private transient boolean focus -
lineBreaker
-
wordBreaker
-
charBreaker
-
lineAscent
private transient int lineAscent -
lineHeight
private transient int lineHeight -
lineLeading
private transient int lineLeading -
lastHeight
private transient int lastHeight -
lastWidth
private transient int lastWidth -
MAX_LINES
private static final int MAX_LINES- See Also:
-
lineStarts
private transient int[] lineStarts -
lineCount
private transient int lineCount -
valid
private transient boolean valid -
fm
-
redoLines
private transient boolean redoLines -
doubleClick
private transient boolean doubleClick -
textListener
-
selectionListener
-
cacheImage
-
mySize
-
xInset
private transient int xInset -
yInset
private transient int yInset -
startPoint
-
endPoint
-
caretPoint
-
activePoint
-
CR
private static final char CR- See Also:
-
pressed
private transient boolean pressed
-
-
Constructor Details
-
DumbTextComponent
public DumbTextComponent()
-
-
Method Details
-
addActionListener
-
removeActionListener
-
addTextListener
-
removeTextListener
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseDragged
- Specified by:
mouseDragged
in interfaceMouseMotionListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseMoved
- Specified by:
mouseMoved
in interfaceMouseMotionListener
-
focusGained
- Specified by:
focusGained
in interfaceFocusListener
-
focusLost
- Specified by:
focusLost
in interfaceFocusListener
-
select
-
keyPressed
- Specified by:
keyPressed
in interfaceKeyListener
-
copy
void copy() -
paste
void paste() -
lineDelta
private int lineDelta(int off, int delta) LIU: Given an offset into contents, moves up or down by lines, according to lineStarts[].- Parameters:
off
- the offset into contentsdelta
- how many lines to move up (< 0) or down (> 0)- Returns:
- the new offset into contents
-
keyReleased
- Specified by:
keyReleased
in interfaceKeyListener
-
keyTyped
- Specified by:
keyTyped
in interfaceKeyListener
-
handleKeyTyped
-
setKeyStart
protected void setKeyStart(int keyStart) -
validateKeyStart
protected void validateKeyStart() -
getKeyStart
protected int getKeyStart() -
setEditable
public void setEditable(boolean b) -
isEditable
public boolean isEditable() -
select
-
select
public void select(int start, int end) -
select
public void select(int start, int end, boolean clickAfter) -
getSelectionStart
public int getSelectionStart() -
getSelectionEnd
public int getSelectionEnd() -
setBounds
public void setBounds(int x, int y, int w, int h) -
getPreferredSize
- Overrides:
getPreferredSize
in classComponent
-
getMaximumSize
- Overrides:
getMaximumSize
in classComponent
-
getMinimumSize
- Overrides:
getMinimumSize
in classComponent
-
setText
-
setText2
-
insertText
-
replaceRange
-
getText
-
setFont
-
update
-
paint
-
paint2
-
paintRect
-
drawSelection
-
offset2Point
-
findLine
private int findLine(int off, boolean start) -
point2Offset
-
fixLineStarts
private void fixLineStarts(int width) -
nextLine
-
findFittingBreak
LIU: Finds the longest substring that fits a given width composed of subunits returned by a BreakIterator. If the smallest subunit is too long, returns 0.- Parameters:
fMtr
- metrics to useline
- the string to be fix into widthwidth
- line.substring(0, result) must be <= widthbreaker
- the BreakIterator that will be used to find subunits- Returns:
- maximum characters, at boundaries returned by breaker, that fit into width, or zero on failure
-
visibleWidth
-
fixHex
private void fixHex() -
hex
-