public class MTextBox extends MRectangle
Modifier and Type | Field and Description |
---|---|
static int |
ALIGN_BOTTOM
Align text to bottom of box.
|
static int |
ALIGN_CENTER
Align text to center of box.
|
static int |
ALIGN_LEFT
Align text to left edge of box.
|
static int |
ALIGN_RIGHT
Align text to right edge of box.
|
static int |
ALIGN_TOP
Align text to top of box.
|
static int |
FONT_DEFAULT_SCALE |
P_CENTER, P_E, P_N, P_NE, P_NW, P_S, P_SE, P_SW, P_W, T_NOROT
ARROW_BACK_FLAG, ARROW_CROSSED_FLAG, ARROW_CURVED_FLAG, ARROW_DASHED_FLAG, ARROW_EQUILIBRIUM_FLAG, ARROW_GROUP1_MASK, ARROW_GROUP2_MASK, ARROW_HALF_LEFT, ARROW_HALF_MASK, ARROW_HALF_RIGHT, ARROW_RETROSYNTHETIC_FLAG, arrowFlags, CLOSED_FLAG, DEFAULT_ARROW_HEAD_LENGTH, DEFAULT_ARROW_HEAD_WIDTH, DEFAULT_EQUILIBRIUM_HEAD_WIDTH, DEFAULT_MAX_CROSS_SIZE, DEFAULT_RETROSYNTHETIC_HEAD_WIDTH, DEFAULT_THICKNESS, HEAD, points, TAIL, THICKNESS_SET_FLAG
PAINT_ANTIALIAS, PAINT_FOCUSED, TRANSFORM_DISTORT
Modifier | Constructor and Description |
---|---|
|
MTextBox()
Contructs an empty text box.
|
protected |
MTextBox(MTextBox t)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttributeKeys(List<String> l)
Adds the attribute names to the specified list.
|
void |
addCdataAttributeKeys(List<String> l)
Adds attribute names to the specified list.
|
void |
addChar(char c)
Adds a character to the text.
|
void |
addLine(MTextDocument.Portion s) |
void |
addString(String s)
Adds a string to the text.
|
void |
clearLines()
Clears all lines.
|
MTextBox |
clone()
Creates a clone.
|
void |
cursorDown(boolean select)
Move the cursor down.
|
void |
cursorToRowEnd(boolean select) |
void |
cursorToRowStart(boolean select) |
void |
cursorUp(boolean select)
Moves the cursor up.
|
void |
deleteChar()
Removes the character under the cursor.
|
void |
deleteCharBackward()
Removes the character before the cursor (backspace).
|
int |
determinePosition(DPoint3 p,
boolean allowExternalPoints) |
ActionMap |
getActionMap()
Returns the ActionMap used to determine what Action to fire for
particular KeyStroke binding.
|
String |
getAttribute(String s)
Gets the value of an attribute.
|
MFont |
getBaseFont()
Gets the base font.
|
String |
getBaseFontFamily()
Gets the base font family.
|
int |
getBaseFontStyle()
Gets the base font style.
|
String |
getBreakingChars()
Gets the breaking characters after that the text in the text
box can be broken if it doesn't fit into the text box.
|
FontMetrics |
getCurrentDefaultFontMetrics()
Gets the current default FontMetrics.
|
Color |
getCurrentForeground()
Gets the current color.
|
double |
getCurrentHeight()
Gets the current height of the text.
|
int |
getCurrentScriptCount(int subl)
Gets the number of subscripts or superscripts on the last normal
character.
|
int |
getCurrentSubLevel()
Gets the current subscript/superscript level.
|
MTextAttributes |
getCurrentTextAttributes(int set0)
Gets the common attributes of the selected text or attributes for the
next character to be typed.
|
double |
getCurrentWidth()
Gets the current width of the text.
|
int |
getCursorColumn()
Gets the cursor's column number.
|
int |
getCursorPos()
Gets the cursor position.
|
int |
getCursorRow()
Gets the cursor's row number.
|
double |
getFontScale()
Gets the font scaling factor.
|
int |
getHorizontalAlignment()
Gets the horizontal alignment.
|
MTextDocument.Portion |
getLine(int i)
Gets a line.
|
int |
getLineCount()
Gets the number of lines.
|
double |
getMinimumHeight()
Gets the minimum height of the text.
|
String |
getPreBreakingChars()
Gets the breaking characters before that the text in the text
box can be broken if it doesn't fit into the text box.
|
int |
getPreviousNormalTextSectionIndex()
Gets the index of the last `normal' text section before the
current subscript/superscript section.
|
String |
getSelectedString()
Gets the selected substring.
|
int |
getSelectionEndColumn()
Gets the selection's end column number.
|
int |
getSelectionEndPos()
Gets the selection's end position.
|
int |
getSelectionEndRow()
Gets the selection's end row number.
|
int |
getSelectionStartColumn()
Gets the selection's start column number.
|
int |
getSelectionStartPos()
Gets the selection's start position.
|
int |
getSelectionStartRow()
Gets the selection's start row number.
|
String |
getText()
Gets the text stored.
|
MTextAttributes |
getTextAttributesAtCursor()
Gets the common attributes of the text on the cursor.
|
MTextDocument |
getTextDocument()
Gets the text document.
|
int |
getVerticalAlignment()
Gets the vertical alignment.
|
boolean |
hasBackground()
A text box has a background always.
|
boolean |
hasColor()
A text box has a text color.
|
boolean |
hasFace()
Is it 2 dimensional?
|
boolean |
hasRichText()
Tests whether the document is rich text.
|
boolean |
hasSelection()
Checks the existence of the selection.
|
boolean |
isAutoHeight()
Gets if it is autoHeight.
|
boolean |
isAutoSize() |
boolean |
isCurrentFontDefault()
Tests whether the default font is used.
|
boolean |
isCurrentFontRegular()
Tests whether the current font is regular.
|
boolean |
isEditable()
Determines if this text box's content can be edited by the user.
|
boolean |
isEmpty()
A text box is empty if the string contains only whitespace.
|
boolean |
isMinimumHeightSet()
Gets if it is minimumHeightSet.
|
void |
setActionMap(ActionMap map)
Sets the ActionMap to map.
|
void |
setAttribute(String s,
String v)
Sets the value of an attribute.
|
void |
setAutoHeight(boolean v)
Turns on/off automatic height calculation.
|
void |
setAutoSize(boolean v)
Turns on/off automatic size calculation.
|
void |
setBaseFontFamily(String name)
Sets the base font family.
|
void |
setBaseFontStyle(int style)
Sets the base font style.
|
void |
setCurrentDefaultFontMetrics(FontMetrics fm)
Sets the current height of the text..
|
void |
setCurrentFont(MFont ft,
int setflags)
Sets font for selected text or the next character to be typed.
|
void |
setCurrentForeground(Color c)
Sets color for selected text or the next character to be typed.
|
void |
setCurrentHeight(double h)
Sets the current height of the text..
|
void |
setCurrentTextAttributes(MTextAttributes attr)
Sets the attributes for the selected text or the next character
to be typed.
|
void |
setCurrentWidth(double w)
Sets the current height of the text..
|
void |
setCursorPos(int i,
boolean select)
Sets the cursor position.
|
void |
setCursorRow(int i)
Sets the cursor row number.
|
void |
setFontScale(double scale)
Sets the font scaling factor.
|
void |
setHorizontalAlignment(int align)
Sets the horizontal alignment.
|
void |
setMinimumHeight(double h)
Sets the minimum height of the text..
|
void |
setMinimumHeightSet(boolean v)
Turns on/off minimum height calculation.
|
void |
setPoints(MPoint[] p)
Sets the points.
|
void |
setRowAndColumn0(int i) |
void |
setSelected(boolean v)
Selects or unselects the text box.
|
void |
setText(String s)
Sets the text.
|
void |
setVerticalAlignment(int align)
Sets the vertical alignment.
|
void |
transform(CTransform3D t,
int opts,
CTransform3D trot)
Transforms all points and scales the font size.
|
void |
unselectContents()
Unselects text.
|
calcCenter, convertTransform, distanceFrom, fixClonedPoints, fixRectanglePointClones, getClip, getPointRef, getPointRefCount, getTCenter, getTOption, removeChild, setCorners, setTCenter, setTOption, transformTo2D
checkValidity, containsAtom, copyProperties, finishCloning, fixMidPointClones, getArcAngle, getArcCenter, getArcRadius, getArcRadius, getArrowFlags, getArrowLength, getArrowWidth, getFlags, getLineMiddlePoint, getMidPointLocation, getMirroredArrowFlags, getPoint, getPointCount, getPoints, getSkip, getThickness, hasLineColor, hasOutline, isArrow, isThicknessSet, removeNotify, replaceAtom, reverse, rotate, setArcAngle, setArrow, setArrowFlags, setArrowLength, setArrowWidth, setFlags, setSkip, setThickness, updateBoundingRect
addNotify, addNotify, connectToSgroupOfAtom, containsPoint, distanceFrom, getBackground, getColor, getLineColor, isChildOf, isInternalSelectable, isReactionArrow, isSelectableNow, isSelected, isTransformable, makeColor, removeAtom, removeNotify, setBackground, setColor, setLineColor, toString
public static final int FONT_DEFAULT_SCALE
public static final int ALIGN_LEFT
public static final int ALIGN_CENTER
public static final int ALIGN_RIGHT
public static final int ALIGN_TOP
public static final int ALIGN_BOTTOM
public MTextBox()
protected MTextBox(MTextBox t)
t
- the original text boxpublic MTextBox clone()
MObject
clone
in class MRectangle
public ActionMap getActionMap()
public void setActionMap(ActionMap map)
map
- the new ActionMappublic MTextDocument getTextDocument()
public String getText()
public void setText(String s)
s
- the textpublic boolean isEditable()
public final MFont getBaseFont()
public final String getBaseFontFamily()
public final void setBaseFontFamily(String name)
name
- the font family namepublic final int getBaseFontStyle()
public final void setBaseFontStyle(int style)
style
- the font stylepublic final double getFontScale()
public final void setFontScale(double scale)
scale
- the font scalepublic final int getHorizontalAlignment()
ALIGN_LEFT
,
ALIGN_RIGHT
,
ALIGN_CENTER
public final void setHorizontalAlignment(int align)
align
- the horizontal alignmentALIGN_LEFT
,
ALIGN_RIGHT
,
ALIGN_CENTER
public final int getVerticalAlignment()
ALIGN_TOP
,
ALIGN_BOTTOM
,
ALIGN_CENTER
public final void setVerticalAlignment(int align)
align
- the vertical alignmentALIGN_TOP
,
ALIGN_BOTTOM
,
ALIGN_CENTER
public int getLineCount()
public MTextDocument.Portion getLine(int i)
i
- line indexpublic void clearLines()
public void setAutoSize(boolean v)
v
- turn on (true) or off (false)public boolean isAutoSize()
public boolean isEmpty()
public boolean hasRichText()
public void addAttributeKeys(List<String> l)
addAttributeKeys
in class MRectangle
l
- the listpublic void addCdataAttributeKeys(List<String> l)
addCdataAttributeKeys
in class MObject
l
- the listpublic String getAttribute(String s)
getAttribute
in class MRectangle
s
- the attribute namepublic void setAttribute(String s, String v)
setAttribute
in class MRectangle
s
- the attribute namev
- the attribute valuepublic boolean hasSelection()
public String getSelectedString()
public void deleteCharBackward()
public void deleteChar()
public void addChar(char c)
c
- the characterpublic void addString(String s)
s
- the stringpublic int getCursorPos()
public void setCursorPos(int i, boolean select)
i
- the new positionselect
- select text while moving the cursorpublic final int getPreviousNormalTextSectionIndex()
public final int getCurrentSubLevel()
public final int getCurrentScriptCount(int subl)
subl
- the script level to query,
+1 (superscript) or -1 (subscript)public final MTextAttributes getCurrentTextAttributes(int set0)
set0
- the set of attributes that are supposed to be set
even if their values are "default"MTextAttributes.A_SUBLEVEL
,
MTextAttributes.A_FOREGROUND
,
MTextAttributes.A_FONT
,
MTextAttributes.A_FONTFAMILY
,
MTextAttributes.A_FONTSIZE
,
MTextAttributes.A_BOLD
,
MTextAttributes.A_ITALIC
,
MTextAttributes.A_SCALE
,
MTextAttributes.A_DX
,
MTextAttributes.A_DY
public final MTextAttributes getTextAttributesAtCursor()
public void setCurrentTextAttributes(MTextAttributes attr)
attr
- the text attributesMTextAttributes.A_SUBLEVEL
,
MTextAttributes.A_FOREGROUND
,
MTextAttributes.A_FONT
,
MTextAttributes.A_FONTFAMILY
,
MTextAttributes.A_FONTSIZE
,
MTextAttributes.A_BOLD
,
MTextAttributes.A_ITALIC
,
MTextAttributes.A_SCALE
,
MTextAttributes.A_DX
,
MTextAttributes.A_DX
,
MTextAttributes.A_DY
public final boolean isCurrentFontDefault()
public final boolean isCurrentFontRegular()
public final Color getCurrentForeground()
public final void setCurrentForeground(Color c)
c
- the colorpublic final void setCurrentFont(MFont ft, int setflags)
ft
- the font or nullsetflags
- font attributes to setMTextAttributes.A_FONT
,
MTextAttributes.A_FONTFAMILY
,
MTextAttributes.A_FONTSIZE
,
MTextAttributes.A_BOLD
,
MTextAttributes.A_ITALIC
public void cursorUp(boolean select)
select
- select text while moving the cursorpublic void cursorDown(boolean select)
select
- select text while moving the cursorpublic void cursorToRowStart(boolean select)
public void cursorToRowEnd(boolean select)
public int getSelectionStartPos()
public int getSelectionEndPos()
public int getSelectionStartRow()
public int getSelectionEndRow()
public int getSelectionStartColumn()
public int getSelectionEndColumn()
public void setCursorRow(int i)
i
- the row numberpublic int getCursorRow()
public int getCursorColumn()
public void setCurrentWidth(double w)
w
- the widthpublic double getCurrentWidth()
public void setCurrentHeight(double h)
h
- the heightpublic double getCurrentHeight()
public void setAutoHeight(boolean v)
v
- turn on (true) or off (false)public boolean isAutoHeight()
public void setMinimumHeight(double h)
h
- the heightpublic double getMinimumHeight()
public void setMinimumHeightSet(boolean v)
v
- turn on (true) or off (false)public boolean isMinimumHeightSet()
public void setCurrentDefaultFontMetrics(FontMetrics fm)
fm
- the fontMetricspublic FontMetrics getCurrentDefaultFontMetrics()
public void setPoints(MPoint[] p)
public boolean hasColor()
public boolean hasBackground()
hasBackground
in class MPolyline
public boolean hasFace()
public void transform(CTransform3D t, int opts, CTransform3D trot)
transform
in class MRectangle
t
- the transformation matrixopts
- transform options or 0trot
- the viewing transformation or nullMObject.TRANSFORM_DISTORT
public void setSelected(boolean v)
setSelected
in class MObject
v
- true to select, false to unselectpublic void unselectContents()
unselectContents
in class MPolyline
public void setRowAndColumn0(int i)
public void addLine(MTextDocument.Portion s)
public int determinePosition(DPoint3 p, boolean allowExternalPoints)
public String getPreBreakingChars()
public String getBreakingChars()