|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jfig.objects.FigBaseobject jfig.objects.FigText
FIG text object with Unicode and restricted math support. Instances of this class are used to represent FIG text objects, each with a single line of text. Attributes include one of the fonts defined in the FIG format, with an optional mapping to different TrueType fonts on your system. The default settings of jfig.gui.FontCache substitute the Postscript fonts with the standard fonts of JDK 1.2+, namely Serif, SansSerif, and Monospaced, which usually map to the Lucida fonts. A text may be left, center, or right aligned, and can be rotated around its base point.
Notes:
\\uxxxx
syntax
to directly reference Unicode characters. Naturally, rendering of
such characters is only possible if the selected font actually
contains a glyph for the characters.
Field Summary | |
(package private) java.awt.Polygon |
border
|
(package private) java.awt.FontMetrics |
fm
|
(package private) FigRenderer |
renderer
|
(package private) boolean |
showCursorFlag
|
(package private) java.lang.String |
str
|
(package private) int |
textCursorIndex
|
Fields inherited from class jfig.objects.FigBaseobject |
attribs, bbox, comment, debug, painter, printer, sc_bbox, sc_bbox_timestamp, selected, showPoints, syncRedrawFlag, timestamp, trafo, visible, x, y |
Constructor Summary | |
FigText()
Basic FigBaseobject constructor. |
|
FigText(java.awt.Point pos,
java.lang.String s,
FigAttribs attribs,
FigTrafo2D trafo)
Advanced constructor |
Method Summary | |
boolean |
canRotate(double angle_in_rad)
xfig allows to rotate text objects to any angle |
FigObject |
copy()
build a copy of this FigText object. |
void |
createRenderer()
|
java.awt.Point[] |
getPoints()
return a list of all Points of this objects. |
java.lang.String |
getText()
Get the current text string |
int |
getTextCursorIndex()
|
int |
initializeCursor(int x,
int y)
initialize the current text cursor from the given screen-coordinates. |
boolean |
isShowCursor()
|
void |
keyPressed(java.awt.event.KeyEvent evt)
handleKeyDown(): move the textCursor, append or insert a character right from the textCursor, delete the character right from the text cursor (or the last character). |
double |
minDistance_OLD(java.awt.Point wp)
return the minimum distance of any points (edges,corners) of this object and the Point wp. |
double |
minDistance(java.awt.Point wp)
returns the minimum distance of this text object to the target point. |
double |
minDistanceEuclid(java.awt.Point wp)
returns the euclidean distance of the target point to this text object. |
void |
mirrorX(int mirror_x,
int mirror_y)
method stub for the mirrorX() method |
void |
mirrorY(int mirror_x,
int mirror_y)
mirrorY(): we do not actually put the text upside down, but we do set a new basepoint. |
void |
move(int dx,
int dy)
the move() method for a FigText |
void |
moveCursorTo(int index)
move the (abstract) cursor to position index in our text string. |
void |
paint(java.awt.Graphics g)
paint(): draw the String str at position (x,y). |
void |
paint(java.awt.Graphics g,
FigTrafo2D trafo)
paint this object using the specified transformation and Graphics g |
void |
paintSave(java.awt.Graphics g,
FigTrafo2D trafo)
|
void |
rebuild()
rebuild (=re-initialize) this object given its current points, attributes, transformation, and the global Java2D enable status. |
void |
rotate(java.awt.Point anchor,
double angle)
rotate this text. |
void |
scale(java.awt.Point origin,
double factor_x,
double factor_y)
scale this text object. |
void |
setColor(java.awt.Color c)
|
void |
setCursor(int x,
int y)
set the text cursor at the character near the position (x,y) in screen-coordinates. |
void |
setFont(int fig_font_index)
set the font for this text objects from the FIG 3.2 font index. |
void |
setFontSize(int pt)
set the size (in pt units) for this text object |
void |
setPoints(java.awt.Point[] pp)
set PointList (if any), world-coordinates. |
void |
setText(java.lang.String str)
Set the text string |
void |
setTextAlignment(int mode)
set the text alignment for this text object |
void |
setTrafo(FigTrafo2D trafo)
Set a new transformation |
void |
showCursor(boolean flag)
showCursor(): activate or hide the textCursor |
static java.lang.String |
symbol_recode(java.lang.String s)
hack to handle xfig/FIG symbol font: we use Times font, and recode the string to use the Unicode chars corresponding to the necessary greek and math chars... |
java.lang.String |
toString()
debug object information |
void |
update_bbox()
update the bounding box of this text object including base point, selected font, and rotation. |
void |
update(FigAttribs new_attribs)
update(): get the new text attribs and recalculate the bbox. |
Methods inherited from class jfig.objects.FigBaseobject |
appendPoint, build_sc_bbox, clonePoints, deletePoint, deselect, get_sc_bbox, getAttributes, getBbox, getComment, getLayer, getMovePointNeighbors, getNearestPoint, getNeighborPoints, getPosition, getSyncRedrawFlag, getTimestamp, getTrafo, initialize, insertPoint, isClosed, isSelected, isShowPoints, isVisible, isVisible, manhattan, message, movePoint, numPoints, reset_debug, select, set_debug, setAttributes, setComment, setConsole, setObjectPainter, setSyncRedrawFlag, setVisible, showPoints, supportsPointOps, updateAttributes, writeAsResource |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
int textCursorIndex
boolean showCursorFlag
java.lang.String str
java.awt.FontMetrics fm
FigRenderer renderer
java.awt.Polygon border
Constructor Detail |
public FigText()
public FigText(java.awt.Point pos, java.lang.String s, FigAttribs attribs, FigTrafo2D trafo)
Method Detail |
public void createRenderer()
public boolean isShowCursor()
public int getTextCursorIndex()
public void rebuild()
FigObject
rebuild
in interface FigObject
rebuild
in class FigBaseobject
public void update_bbox()
public void paint(java.awt.Graphics g)
paint
in interface FigObject
paint
in class FigBaseobject
public void paint(java.awt.Graphics g, FigTrafo2D trafo)
FigDrawable
paint
in interface FigObject
paint
in class FigBaseobject
public void paintSave(java.awt.Graphics g, FigTrafo2D trafo)
paintSave
in interface FigObject
paintSave
in class FigBaseobject
public void showCursor(boolean flag)
public void setCursor(int x, int y)
public int initializeCursor(int x, int y)
public void moveCursorTo(int index)
public void move(int dx, int dy)
move
in interface FigObject
move
in class FigBaseobject
public FigObject copy()
copy
in interface FigObject
copy
in class FigBaseobject
public boolean canRotate(double angle_in_rad)
canRotate
in interface FigObject
canRotate
in class FigBaseobject
public void rotate(java.awt.Point anchor, double angle)
rotate
in interface FigObject
rotate
in class FigBaseobject
public void scale(java.awt.Point origin, double factor_x, double factor_y)
scale
in interface FigObject
scale
in class FigBaseobject
public void mirrorX(int mirror_x, int mirror_y)
FigBaseobject
mirrorX
in interface FigObject
mirrorX
in class FigBaseobject
public void mirrorY(int mirror_x, int mirror_y)
mirrorY
in interface FigObject
mirrorY
in class FigBaseobject
public void update(FigAttribs new_attribs)
update
in interface FigObject
update
in class FigBaseobject
public double minDistance_OLD(java.awt.Point wp)
To allow easy selection of text objects, this method uses the following algorithm. If Point wp is outside of the bounding box of this text object, we return the actual minimum (Manhattan) distance to the text object, see class jfig.objects.FigBbox for details. However, if wp lies inside the text object, we return a value of one grid snap distance, in order not to hide other objects lying under/near the text object.
public double minDistance(java.awt.Point wp)
To allow easy selection of text objects, this method uses the following algorithm: If Point wp is the base point (origin) of this text, we return 0. If Point wp lies outside of the (axis-parallel) bounding box of this text object, we return Double.MAX_VALUE. If wp lies inside the bounding box, we use a more elaborate, rotation-aware calculation, and return a value of 0.9*snap, where snap is the current object canvas setting of its magnetic grid. This magical value ensures that the text object can be selected but will not hide other objects with vertices nearer to wp.
minDistance
in interface FigObject
minDistance
in class FigBaseobject
public double minDistanceEuclid(java.awt.Point wp)
However, in the context of jfig it does not really make sense to do the full calculation here. Instead, we simply dispatch to minDistance(wp), whose return value should be ok for most uses.
minDistanceEuclid
in interface FigObject
minDistanceEuclid
in class FigBaseobject
public java.awt.Point[] getPoints()
FigBaseobject
getPoints
in interface FigObject
getPoints
in class FigBaseobject
public void setPoints(java.awt.Point[] pp)
FigObject
setPoints
in interface FigObject
setPoints
in class FigBaseobject
public java.lang.String getText()
getText
in interface FigObject
getText
in class FigBaseobject
public void setText(java.lang.String str)
setText
in interface FigObject
setText
in class FigBaseobject
public void setTrafo(FigTrafo2D trafo)
setTrafo
in interface FigObject
setTrafo
in class FigBaseobject
public void setFont(int fig_font_index)
public void setFontSize(int pt)
public void setTextAlignment(int mode)
for possible values
public void setColor(java.awt.Color c)
public void keyPressed(java.awt.event.KeyEvent evt)
This method contains a hack to correct a problem with compose characters under Solaris, because Solaris/JDK 1.1.x won't react to the 'COMPOSE' key on the Sun keyboard. Therefore, it will interpret the keys ALT+a, ALT+A, ALT+u, ALT+U, ALT+o, ALT+O, and ALT+s as the corresponding German Umlauts.
keyPressed
in interface FigObject
keyPressed
in class FigBaseobject
public static java.lang.String symbol_recode(java.lang.String s)
public java.lang.String toString()
toString
in interface FigObject
toString
in class FigBaseobject
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |