Package chemaxon.struc.graphics
Class MTextBox
java.lang.Object
chemaxon.struc.MObject
chemaxon.struc.graphics.MPolyline
chemaxon.struc.graphics.MRectangle
chemaxon.struc.graphics.MTextBox
- All Implemented Interfaces:
- Serializable,- Cloneable
- Direct Known Subclasses:
- MAnalysisBox,- MNameTextBox,- MReactionSign
Text box object.
- Since:
- Marvin 3.3, 10/20/2003
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intAlign text to bottom of box.static final intAlign text to center of box.static final intAlign text to left edge of box.static final intAlign text to right edge of box.static final intAlign text to top of box.static final intFields inherited from class chemaxon.struc.graphics.MRectangleP_CENTER, P_E, P_N, P_NE, P_NW, P_S, P_SE, P_SW, P_W, T_NOROTFields inherited from class chemaxon.struc.graphics.MPolylineARROW_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_FLAGFields inherited from class chemaxon.struc.MObjectTRANSFORM_DISTORT
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds the attribute names to the specified list.voidAdds attribute names to the specified list.voidaddChar(char c) Adds a character to the text.voidvoidAdds a string to the text.voidClears all lines.clone()Creates a clone.voidcursorDown(boolean select) Move the cursor down.voidcursorLeft(boolean select) voidcursorRight(boolean select) voidcursorToRowEnd(boolean select) voidcursorToRowStart(boolean select) voidcursorUp(boolean select) Moves the cursor up.voidRemoves the character under the cursor.voidRemoves the character before the cursor (backspace).intdeterminePosition(DPoint3 p, boolean allowExternalPoints) Deprecated, for removal: This API element is subject to removal in a future version.intdeterminePosition(Graphics g, DPoint3 p, boolean allowExternalPoints) Determines the character index based on the passed view coordinate.Returns the ActionMap used to determine what Action to fire for particular KeyStroke binding.Gets the value of an attribute.final MFontGets the base font.final StringGets the base font family.final intGets the base font style.Gets the breaking characters after that the text in the text box can be broken if it doesn't fit into the text box.Gets the current default FontMetrics.final ColorGets the current color.doubleGets the current height of the text.final intgetCurrentScriptCount(int subl) Gets the number of subscripts or superscripts on the last normal character.final intGets the current subscript/superscript level.final MTextAttributesgetCurrentTextAttributes(int set0) Gets the common attributes of the selected text or attributes for the next character to be typed.doubleGets the current width of the text.intGets the cursor's column number.intGets the cursor position.intGets the cursor's row number.final doubleGets the font scaling factor.final intGets the horizontal alignment.getLine(int i) Gets a line.intGets the number of lines.doubleGets the minimum height of the text.Gets the breaking characters before that the text in the text box can be broken if it doesn't fit into the text box.final intGets the index of the last `normal' text section before the current subscript/superscript section.Gets the selected substring.intGets the selection's end column number.intGets the selection's end position.intGets the selection's end row number.intGets the selection's start column number.intGets the selection's start position.intGets the selection's start row number.getText()Gets the text stored.final MTextAttributesGets the common attributes of the text on the cursor.Gets the text document.final intGets the vertical alignment.booleanA text box has a background always.booleanhasColor()A text box has a text color.booleanhasFace()Is it 2 dimensional?booleanTests whether the document is rich text.booleanChecks the existence of the selection.voidinsertDocument(MTextDocument document) Inserts document at the current cursor position.booleanGets if it is autoHeight.booleanfinal booleanDeprecated, for removal: This API element is subject to removal in a future version.final booleanDeprecated, for removal: This API element is subject to removal in a future version.booleanDetermines if this text box's content can be edited by the user.booleanisEmpty()A text box is empty if the string contains only whitespace.booleanGets if it is minimumHeightSet.voidsetActionMap(ActionMap map) Sets the ActionMap to map.voidsetAttribute(String s, String v) Sets the value of an attribute.voidsetAutoHeight(boolean v) Turns on/off automatic height calculation.voidsetAutoSize(boolean v) Turns on/off automatic size calculation.final voidsetBaseFontFamily(String name) Sets the base font family.final voidsetBaseFontStyle(int style) Sets the base font style.voidSets the current height of the text..final voidsetCurrentFont(MFont ft, int setflags) Sets font for selected text or the next character to be typed.final voidSets color for selected text or the next character to be typed.voidsetCurrentHeight(double h) Sets the current height of the text..voidSets the attributes for the selected text or the next character to be typed.voidsetCurrentWidth(double w) Sets the current height of the text..voidsetCursorPos(int i, boolean select) Sets the cursor position.voidsetCursorRow(int i) Sets the cursor row number.voidfinal voidsetFontScale(double scale) Sets the font scaling factor.final voidsetHorizontalAlignment(int align) Sets the horizontal alignment.voidsetMinimumHeight(double h) Sets the minimum height of the text..voidsetMinimumHeightSet(boolean v) Turns on/off minimum height calculation.voidSets the points.voidsetRowAndColumn0(int i) voidsetSelected(boolean v) Selects or unselects the text box.voidSets the text.final voidsetVerticalAlignment(int align) Sets the vertical alignment.voidtransform(CTransform3D t, int opts, CTransform3D trot) Transforms all points and scales the font size.voidUnselects text.voidwrapTextAndSetActualPoints(CTransform3D transform, double scale) Methods inherited from class chemaxon.struc.graphics.MRectanglecalcCenter, convertTransform, distanceFrom, fixClonedPoints, fixRectanglePointClones, getClip, getPointRef, getPointRefCount, getTCenter, getTOption, removeChild, setCorners, setTCenter, setTOption, transformTo2DMethods inherited from class chemaxon.struc.graphics.MPolylinecheckValidity, 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, updateBoundingRectMethods inherited from class chemaxon.struc.MObjectaddNotify, clearProperties, connectToSgroupOfAtom, containsPoint, containsPropertyKey, distanceFrom, getBackground, getColor, getContainerMObject, getLineColor, getProperty, isChildOf, isInternalSelectable, isReactionArrow, isSelectableNow, isSelected, isTransformable, makeColor, propertyCount, propertyKeySet, propertySet, putProperty, removeAtom, removeProperty, setBackground, setColor, setLineColor, toString, updateBoundingRect
- 
Field Details- 
FONT_DEFAULT_SCALEpublic static final int FONT_DEFAULT_SCALE- See Also:
 
- 
ALIGN_LEFTpublic static final int ALIGN_LEFTAlign text to left edge of box.- Since:
- Marvin 5.0, 02/13/2007
- See Also:
 
- 
ALIGN_CENTERpublic static final int ALIGN_CENTERAlign text to center of box.- Since:
- Marvin 5.0, 02/13/2007
- See Also:
 
- 
ALIGN_RIGHTpublic static final int ALIGN_RIGHTAlign text to right edge of box.- Since:
- Marvin 5.0, 02/13/2007
- See Also:
 
- 
ALIGN_TOPpublic static final int ALIGN_TOPAlign text to top of box.- Since:
- Marvin 5.0, 02/13/2007
- See Also:
 
- 
ALIGN_BOTTOMpublic static final int ALIGN_BOTTOMAlign text to bottom of box.- Since:
- Marvin 5.0, 02/13/2007
- See Also:
 
 
- 
- 
Constructor Details- 
MTextBoxpublic MTextBox()Contructs an empty text box.
- 
MTextBoxCopy constructor.- Parameters:
- t- the original text box
 
 
- 
- 
Method Details- 
cloneDescription copied from class:MObjectCreates a clone.- Overrides:
- clonein class- MRectangle
- Returns:
- the clone
 
- 
getActionMapReturns the ActionMap used to determine what Action to fire for particular KeyStroke binding. The returned ActionMap, unless otherwise set, will be null.- Returns:
- the ActionMap containing the key/action bindings
- Since:
- Marvin 5.0.2
 
- 
setActionMapSets the ActionMap to map. This does not set the parent of the map, it is up to the caller to have done this.- Parameters:
- map- the new ActionMap
- Since:
- Marvin 5.0.2
 
- 
getTextDocumentGets the text document.- Returns:
- the text
- Since:
- Marvin 4.1, 09/30/2005
 
- 
getTextGets the text stored.- Returns:
- the text
 
- 
setTextSets the text.- Parameters:
- s- the text
- Since:
- Marvin 3.5, 07/14/2004
 
- 
setDocument
- 
isEditablepublic boolean isEditable()Determines if this text box's content can be edited by the user.- Returns:
- true if the content can be edited, false otherwise
- Since:
- Marvin 5.3
 
- 
getBaseFontGets the base font.- Returns:
- the base font
- Since:
- Marvin 4.1, 11/11/2005
 
- 
getBaseFontFamilyGets the base font family.- Returns:
- the font family name
- Since:
- Marvin 4.1, 11/11/2005
 
- 
setBaseFontFamilySets the base font family.- Parameters:
- name- the font family name
- Since:
- Marvin 4.1, 11/11/2005
 
- 
getBaseFontStylepublic final int getBaseFontStyle()Gets the base font style.- Returns:
- the font style
- Since:
- Marvin 4.1, 11/11/2005
 
- 
setBaseFontStylepublic final void setBaseFontStyle(int style) Sets the base font style.- Parameters:
- style- the font style
- Since:
- Marvin 4.1, 11/11/2005
 
- 
getFontScalepublic final double getFontScale()Gets the font scaling factor.- Returns:
- the font scale
- Since:
- Marvin 4.1, 11/11/2005
 
- 
setFontScalepublic final void setFontScale(double scale) Sets the font scaling factor.- Parameters:
- scale- the font scale
- Since:
- Marvin 4.1, 11/11/2005
 
- 
getHorizontalAlignmentpublic final int getHorizontalAlignment()Gets the horizontal alignment. (The "halign" property.)- Returns:
- the horizontal alignment
- Since:
- Marvin 5.0, 02/13/2007
- See Also:
 
- 
setHorizontalAlignmentpublic final void setHorizontalAlignment(int align) Sets the horizontal alignment. (The "halign" property.)- Parameters:
- align- the horizontal alignment
- Since:
- Marvin 5.0, 02/13/2007
- See Also:
 
- 
getVerticalAlignmentpublic final int getVerticalAlignment()Gets the vertical alignment. (The "valign" property.)- Returns:
- the vertical alignment
- Since:
- Marvin 5.0, 02/13/2007
- See Also:
 
- 
setVerticalAlignmentpublic final void setVerticalAlignment(int align) Sets the vertical alignment. (The "valign" property.)- Parameters:
- align- the vertical alignment
- Since:
- Marvin 5.0, 02/13/2007
- See Also:
 
- 
getLineCountpublic int getLineCount()Gets the number of lines. This method can only be called after the text is wrapped.- Returns:
- wrapped number of lines
 
- 
getLineGets a line. This method can only be called after the text is wrapped.- Parameters:
- i- line index
- Returns:
- selected line
 
- 
clearLinespublic void clearLines()Clears all lines.
- 
setAutoSizepublic void setAutoSize(boolean v) Turns on/off automatic size calculation.- Parameters:
- v- turn on (true) or off (false)
 
- 
isAutoSizepublic boolean isAutoSize()
- 
isEmptypublic boolean isEmpty()A text box is empty if the string contains only whitespace.
- 
hasRichTextpublic boolean hasRichText()Tests whether the document is rich text.- Returns:
- true if the text is rich, false otherwise
- Since:
- Marvin 4.1, 11/11/2005
 
- 
addAttributeKeysAdds the attribute names to the specified list. CDATA attributes are not added.- Overrides:
- addAttributeKeysin class- MRectangle
- Parameters:
- l- the list
 
- 
addCdataAttributeKeysAdds attribute names to the specified list. Only CDATA attributes are added.- Overrides:
- addCdataAttributeKeysin class- MObject
- Parameters:
- l- the list
 
- 
getAttributeGets the value of an attribute.
 Supported attributes:- cursorPosition: the position of the cursor in the text box
- text: the content of the text box
 - Overrides:
- getAttributein class- MRectangle
- Parameters:
- s- the attribute name
- Returns:
- the value or null
 
- 
setAttributeSets the value of an attribute.
 Supported attributes:- cursorPosition: the position of the cursor in the text box
- text: the content of the text box
 - Overrides:
- setAttributein class- MRectangle
- Parameters:
- s- the attribute name
- v- the attribute value
 
- 
hasSelectionpublic boolean hasSelection()Checks the existence of the selection.- Returns:
- true if selection exists, false otherwise
 
- 
getSelectedStringGets the selected substring.- Returns:
- the selection if it exists, null otherwise
 
- 
getSelectedDocument
- 
deleteCharBackwardpublic void deleteCharBackward()Removes the character before the cursor (backspace).
- 
deleteCharpublic void deleteChar()Removes the character under the cursor.
- 
addCharpublic void addChar(char c) Adds a character to the text.- Parameters:
- c- the character
 
- 
addStringAdds a string to the text.- Parameters:
- s- the string
 
- 
insertDocumentInserts document at the current cursor position. Style of the source is preserved.
- 
getCursorPospublic int getCursorPos()Gets the cursor position.- Returns:
- the position
 
- 
setCursorPospublic void setCursorPos(int i, boolean select) Sets the cursor position.- Parameters:
- i- the new position
- select- select text while moving the cursor
 
- 
getPreviousNormalTextSectionIndexpublic final int getPreviousNormalTextSectionIndex()Gets the index of the last `normal' text section before the current subscript/superscript section. `Normal' means that the absolute value of the subscript/superscript level must be smaller than in the current cursor position.- Returns:
- the section index or -1
- Since:
- Marvin 4.1, 10/08/2005
 
- 
getCurrentSubLevelpublic final int getCurrentSubLevel()Gets the current subscript/superscript level.- Returns:
- the attributes
- Since:
- Marvin 4.1, 10/08/2005
 
- 
getCurrentScriptCountpublic final int getCurrentScriptCount(int subl) Gets the number of subscripts or superscripts on the last normal character.- Parameters:
- subl- the script level to query, +1 (superscript) or -1 (subscript)
- Returns:
- the number of subscripts or superscripts
- Since:
- Marvin 4.1, 02/25/2006
 
- 
getCurrentTextAttributesGets the common attributes of the selected text or attributes for the next character to be typed.- Parameters:
- set0- the set of attributes that are supposed to be set even if their values are "default"
- Returns:
- the attributes
- Since:
- Marvin 4.1, 10/06/2005
- See Also:
 
- 
getTextAttributesAtCursorGets the common attributes of the text on the cursor.- Returns:
- the attributes
 
- 
setCurrentTextAttributesSets the attributes for the selected text or the next character to be typed.- Parameters:
- attr- the text attributes
- Since:
- Marvin 4.1, 10/06/2005
- See Also:
 
- 
isCurrentFontDefault@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public final boolean isCurrentFontDefault()Deprecated, for removal: This API element is subject to removal in a future version.Tests whether the default font is used.- Returns:
- true if only the default font is used, false otherwise
- Since:
- Marvin 4.1, 01/11/2006
 
- 
isCurrentFontRegular@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public final boolean isCurrentFontRegular()Deprecated, for removal: This API element is subject to removal in a future version.Tests whether the current font is regular.- Returns:
- true if the font is regular, false otherwise
- Since:
- Marvin 4.1, 01/11/2006
 
- 
getCurrentForegroundGets the current color.- Returns:
- the color
- Since:
- Marvin 4.1, 01/18/2006
 
- 
setCurrentForegroundSets color for selected text or the next character to be typed.- Parameters:
- c- the color
- Since:
- Marvin 4.1, 10/08/2005
 
- 
setCurrentFontSets font for selected text or the next character to be typed.- Parameters:
- ft- the font or null
- setflags- font attributes to set
- Since:
- Marvin 4.1, 10/08/2005
- See Also:
 
- 
cursorUppublic void cursorUp(boolean select) Moves the cursor up.- Parameters:
- select- select text while moving the cursor
 
- 
cursorDownpublic void cursorDown(boolean select) Move the cursor down.- Parameters:
- select- select text while moving the cursor
 
- 
cursorRightpublic void cursorRight(boolean select) 
- 
cursorLeftpublic void cursorLeft(boolean select) 
- 
cursorToRowStartpublic void cursorToRowStart(boolean select) 
- 
cursorToRowEndpublic void cursorToRowEnd(boolean select) 
- 
getSelectionStartPospublic int getSelectionStartPos()Gets the selection's start position.- Returns:
- the start index
 
- 
getSelectionEndPospublic int getSelectionEndPos()Gets the selection's end position.- Returns:
- the end index
 
- 
getSelectionStartRowpublic int getSelectionStartRow()Gets the selection's start row number.- Returns:
- the start index
 
- 
getSelectionEndRowpublic int getSelectionEndRow()Gets the selection's end row number.- Returns:
- the end index
 
- 
getSelectionStartColumnpublic int getSelectionStartColumn()Gets the selection's start column number.- Returns:
- the start index
 
- 
getSelectionEndColumnpublic int getSelectionEndColumn()Gets the selection's end column number.- Returns:
- the end index
 
- 
setCursorRowpublic void setCursorRow(int i) Sets the cursor row number.- Parameters:
- i- the row number
 
- 
getCursorRowpublic int getCursorRow()Gets the cursor's row number.- Returns:
- the row number
 
- 
getCursorColumnpublic int getCursorColumn()Gets the cursor's column number.- Returns:
- the start index
 
- 
setCurrentWidthpublic void setCurrentWidth(double w) Sets the current height of the text..- Parameters:
- w- the width
 
- 
getCurrentWidthpublic double getCurrentWidth()Gets the current width of the text.- Returns:
- the width
 
- 
setCurrentHeightpublic void setCurrentHeight(double h) Sets the current height of the text..- Parameters:
- h- the height
 
- 
getCurrentHeightpublic double getCurrentHeight()Gets the current height of the text.- Returns:
- the height
 
- 
setAutoHeightpublic void setAutoHeight(boolean v) Turns on/off automatic height calculation.- Parameters:
- v- turn on (true) or off (false)
 
- 
isAutoHeightpublic boolean isAutoHeight()Gets if it is autoHeight.- Returns:
- true if aoutoHeight
 
- 
setMinimumHeightpublic void setMinimumHeight(double h) Sets the minimum height of the text..- Parameters:
- h- the height
 
- 
getMinimumHeightpublic double getMinimumHeight()Gets the minimum height of the text.- Returns:
- the height
 
- 
setMinimumHeightSetpublic void setMinimumHeightSet(boolean v) Turns on/off minimum height calculation.- Parameters:
- v- turn on (true) or off (false)
 
- 
isMinimumHeightSetpublic boolean isMinimumHeightSet()Gets if it is minimumHeightSet.- Returns:
- true if minimumHeightSet
 
- 
setCurrentDefaultFontMetricsSets the current height of the text..- Parameters:
- fm- the fontMetrics
 
- 
getCurrentDefaultFontMetricsGets the current default FontMetrics.- Returns:
- the fontMetrics
 
- 
setPointsSets the points.
- 
hasColorpublic boolean hasColor()A text box has a text color.
- 
hasBackgroundpublic boolean hasBackground()A text box has a background always.- Overrides:
- hasBackgroundin class- MPolyline
- Returns:
- true if closed
 
- 
hasFacepublic boolean hasFace()Is it 2 dimensional?
- 
transformTransforms all points and scales the font size.- Overrides:
- transformin class- MRectangle
- Parameters:
- t- the transformation matrix
- opts- transform options or 0
- trot- the viewing transformation or null
- Since:
- Marvin 4.1, 04/28/2006
- See Also:
 
- 
wrapTextAndSetActualPoints
- 
setSelectedpublic void setSelected(boolean v) Selects or unselects the text box.- Overrides:
- setSelectedin class- MObject
- Parameters:
- v- true to select, false to unselect
 
- 
unselectContentspublic void unselectContents()Unselects text.- Overrides:
- unselectContentsin class- MPolyline
 
- 
setRowAndColumn0public void setRowAndColumn0(int i) 
- 
addLine
- 
determinePosition@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public int determinePosition(DPoint3 p, boolean allowExternalPoints) Deprecated, for removal: This API element is subject to removal in a future version.usedeterminePosition(Graphics, DPoint3, boolean)in case you have a special graphics context to be used for font calculations.Determines the character index based on the passed view coordinate.- Parameters:
- p- view coordinate
- allowExternalPoints- is set to true to allow external points (outside of this text box) to be checked.
- Returns:
- character index
 
- 
determinePositionDetermines the character index based on the passed view coordinate. This method also takes the passed graphics context into account.- Parameters:
- p- view coordinate
- allowExternalPoints- is set to true to allow external points (outside of this text box) to be checked.
- Returns:
- character index
 
- 
getPreBreakingCharsGets the breaking characters before that the text in the text box can be broken if it doesn't fit into the text box.- Returns:
- the string that contains the breaking characters.
 
- 
getBreakingCharsGets the breaking characters after that the text in the text box can be broken if it doesn't fit into the text box.- Returns:
- the string that contains the breaking characters.
 
 
- 
determinePosition(Graphics, DPoint3, boolean)in case you have a special graphics context to be used for font calculations.