|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.geom.RectangularShape
java.awt.geom.Rectangle2D
java.awt.geom.Rectangle2D.Double
tnt.metrics.KeyButton
public class KeyButton
A class to define keys on a keypad/keyboard.
Each key is defined by at least five arguments: a char
used
to identify this key when listing keystrokes, a String
representing the character(s) on the key, the key's center x
coordinate, the key's center y coordinate, and the key's target
width (i.e., the minimum of its width or height). The unit of measurement
does not matter, but for this implementation, pixels are assumed.
For example, the following represents the keypad on a Nokia 5110 mobile phone:
S S 13.25 27 6 2 abc 13.25 0 6 3 def 26.5 0 6 4 ghi 0 9 6 5 jkl 13.25 9 6 6 mno 26.5 9 6 7 pqrs 0 18 6 8 tuv 13.25 18 6 9 wxyz 26.5 18 6 N N 25.5 -9 6Note: Typically, the SPACE and NEXT keys are identified by "S" and "N" respectively and other key identifiers are all lowercase.
This class also inherits from Rectangle2D.Double, so its objects can be
illustrated in the TnToolkit GUI. Make sure to note the difference
between the key's dimensions (i.e., cx
, cy
,
and tw
) and those of its outlining rectangle (i.e.,
x
, y
, width
, and
height
).
Key.java
, 2001), KeyButton.java
)Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D |
---|
java.awt.geom.Rectangle2D.Double, java.awt.geom.Rectangle2D.Float |
Field Summary | |
---|---|
static int |
BOTH_THUMBS
Indicates that this key is to be pressed by either thumb equally. |
java.lang.String |
chars
The characters associated with this key. |
char |
key
This key's identifier. |
static int |
LEFT_THUMB
Indicates that this key is to be pressed by the left thumb only. |
static int |
RIGHT_THUMB
Indicates that this key is to be pressed by the right thumb only. |
int |
thumb
This key's thumb assignment. |
Fields inherited from class java.awt.geom.Rectangle2D.Double |
---|
height, width, x, y |
Fields inherited from class java.awt.geom.Rectangle2D |
---|
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP |
Constructor Summary | |
---|---|
KeyButton(char c,
java.lang.String s,
double x,
double y,
double tw)
Initializes a new object with minimal parameters. |
|
KeyButton(char c,
java.lang.String s,
double x,
double y,
double w,
double h,
int a)
Initializes a new object. |
Method Summary | |
---|---|
double |
distanceTo(KeyButton k)
Return the Pythagorean distance from this key to the
specified key. |
double |
getTW()
Returns this key's target width. |
java.lang.String |
toString()
Returns a concise String representation of this object to
be used in lists. |
java.lang.String |
toStringForExport()
Returns a white-space-delimited String representation of
this object for the purpose of exporting to an input file. |
Methods inherited from class java.awt.geom.Rectangle2D.Double |
---|
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRect |
Methods inherited from class java.awt.geom.Rectangle2D |
---|
add, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, union |
Methods inherited from class java.awt.geom.RectangularShape |
---|
clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public char key
public java.lang.String chars
public int thumb
LEFT_THUMB
,
RIGHT_THUMB
,
BOTH_THUMBS
public static final int LEFT_THUMB
public static final int RIGHT_THUMB
public static final int BOTH_THUMBS
Constructor Detail |
---|
public KeyButton(char c, java.lang.String s, double x, double y, double w, double h, int a)
c
- a char
used to identify this key when listing
keystrokes.s
- a String
representing the character(s) on
the key.x
- the x-coordinate of this key's rectangular outline.y
- the y-coordinate of this key's rectangular outline.w
- the width this key's rectangular outline.h
- the height coordinate of this key's rectangular outline.a
- the thumb assignment of this key.LEFT_THUMB
,
RIGHT_THUMB
,
BOTH_THUMBS
public KeyButton(char c, java.lang.String s, double x, double y, double tw)
RIGHT_THUMB
assignment.
This is primarily used for backwards compatibility with previous
versions.
c
- a char
used to identify this key when listing
keystrokes.s
- a String
representing the character(s) on
the key.x
- the x-coordinate of this key's rectangular outline.y
- the y-coordinate of this key's rectangular outline.tw
- the target width of this key.Method Detail |
---|
public double getTW()
public double distanceTo(KeyButton k)
this
key to the
specified key.
k
- the specified KeyButton
object to which to
compute the distance.
public java.lang.String toString()
String
representation of this object to
be used in lists. For example: Key: 8 tuv
toString
in class java.awt.geom.Rectangle2D.Double
String
representation of this object.public java.lang.String toStringForExport()
String
representation of
this object for the purpose of exporting to an input file.
Specifically, it returns the following:
return "" + key + "\t" + chars + "\t" + getCenterX() + "\t" +
getCenterY() + "\t" + getTW();
String
representation of this object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |