Package snap.text
Class StringBox
java.lang.Object
snap.geom.Shape
snap.geom.RectBase
snap.geom.RoundRect
snap.text.StringBox
- All Implemented Interfaces:
Cloneable
This class manages a string and a bounding rect.
-
Field Summary
Fields inherited from class snap.geom.Shape
_bounds, WIND_EVEN_ODD, WIND_NON_ZERO
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Standard clone implementation.void
Draws the string.void
drawString
(Painter aPntr) Draws the string.getAlign()
Returns how the string is positioned in the box if larger than String width/height (default is Top-Left).double
Returns the ascent.Returns the border.double
Returns the descent.getFont()
Returns the font.static StringBox
getForStringAndAttributes
(String aStr, Object... theAttrs) Returns a StringBox for string and attributes.Returns the total insets due to border and/or padding.Returns the padding.double
Returns the preferred height of box.double
Returns the preferred width of box.int
Returns the run's scripting.double
Returns the height of the current string/font (aka the 'line height').double
Returns the width of the string (aka the 'advance').double
Returns the string X point.double
Returns the string Y point.Returns the string.Returns the color for string text.Returns the TextStyle.boolean
Returns whether to size to font (looser) instead of glyphs (tighter).boolean
Returns whether this run has a hyphen at the end.boolean
Returns whether this run is underlined.int
length()
Returns the length of the string.void
Paints the string box.void
resize()
Resizes bounds to fit string.void
Sets how the string is positioned in the box if larger than String width/height (default is Top-Left).void
Sets the border.void
Sets the border for given color and stroke width.void
setCenteredXY
(double aX, double aY) Override to size.void
Sets the font.void
setFontSizing
(boolean aValue) Sets whether to size to font (looser) instead of glyphs (tighter).void
setHyphenated
(boolean aFlag) Sets whether this run has a hyphen at the end.void
setPadding
(double aTop, double aRgt, double aBtm, double aLft) Sets the padding to given insets.void
setPadding
(Insets theInsets) Sets the padding.void
Sets the string.void
setStringXY
(double aX, double aY) Sets the string X/Y.void
setTextColor
(Color aColor) Sets the color for string text.void
setTextStyle
(TextStyle textStyle) Sets the TextStyle.void
setUnderlined
(boolean aValue) Sets whether this run is underlined.void
setWidth
(double aValue) Override to mark sized.toString()
Standard toString implementation.Methods inherited from class snap.geom.RoundRect
copyForCorners, copyForPosition, copyForRadius, equals, getPathIter, getRadius, hashCode, setRadius
Methods inherited from class snap.geom.RectBase
copyFor, copyFor, equals, getBoundsImpl, getHeight, getMaxX, getMaxY, getMidX, getMidY, getMinX, getMinY, getSize, getWidth, getX, getXY, getY, inset, inset, inset, isEmpty, offset, setHeight, setRect, setRect, setSize, setX, setXY, setY
Methods inherited from class snap.geom.Shape
addShapes, contains, contains, contains, contains, containsSeg, copyForBounds, crossesSeg, getArcLength, getBounds, getCrossings, getDistance, getFlattenedShape, getFlattenedShape, getNotSelfIntersectingShape, intersectShapes, intersectsSeg, intersectsShape, intersectsShape, intersectsXY, isClosed, isFlat, isMultiCycle, isSelfIntersecting, isSingleCycle, shapeChanged, subtractShapes
-
Constructor Details
-
StringBox
public StringBox()Constructor. -
StringBox
Constructor.
-
-
Method Details
-
getSvgString
Returns the string.- Overrides:
getSvgString
in classRectBase
-
length
public int length()Returns the length of the string. -
setString
Sets the string. -
getTextStyle
Returns the TextStyle. -
setTextStyle
Sets the TextStyle. -
getFont
Returns the font. -
setFont
Sets the font. -
getTextColor
Returns the color for string text. -
setTextColor
Sets the color for string text. -
isUnderlined
public boolean isUnderlined()Returns whether this run is underlined. -
setUnderlined
public void setUnderlined(boolean aValue) Sets whether this run is underlined. -
getScripting
public int getScripting()Returns the run's scripting. -
getBorder
Returns the border. -
setBorder
Sets the border. -
setBorder
Sets the border for given color and stroke width. -
getPadding
Returns the padding. -
setPadding
Sets the padding. -
setPadding
public void setPadding(double aTop, double aRgt, double aBtm, double aLft) Sets the padding to given insets. -
getAlign
Returns how the string is positioned in the box if larger than String width/height (default is Top-Left). -
setAlign
Sets how the string is positioned in the box if larger than String width/height (default is Top-Left). -
isFontSizing
public boolean isFontSizing()Returns whether to size to font (looser) instead of glyphs (tighter). -
setFontSizing
public void setFontSizing(boolean aValue) Sets whether to size to font (looser) instead of glyphs (tighter). -
isHyphenated
public boolean isHyphenated()Returns whether this run has a hyphen at the end. -
setHyphenated
public void setHyphenated(boolean aFlag) Sets whether this run has a hyphen at the end. -
getInsetsAll
Returns the total insets due to border and/or padding. -
resize
public void resize()Resizes bounds to fit string. -
getStringWidth
public double getStringWidth()Returns the width of the string (aka the 'advance'). -
getStringHeight
public double getStringHeight()Returns the height of the current string/font (aka the 'line height'). -
getAscent
public double getAscent()Returns the ascent. -
getDescent
public double getDescent()Returns the descent. -
getPrefWidth
public double getPrefWidth()Returns the preferred width of box. -
getPrefHeight
public double getPrefHeight()Returns the preferred height of box. -
getStringX
public double getStringX()Returns the string X point. -
getStringY
public double getStringY()Returns the string Y point. -
setStringXY
public void setStringXY(double aX, double aY) Sets the string X/Y. -
drawString
Draws the string. -
drawRect
Draws the string. -
paint
Paints the string box. -
setWidth
public void setWidth(double aValue) Override to mark sized. -
setCenteredXY
public void setCenteredXY(double aX, double aY) Override to size.- Overrides:
setCenteredXY
in classRectBase
-
clone
Standard clone implementation. -
toString
Standard toString implementation. -
getForStringAndAttributes
Returns a StringBox for string and attributes.
-