Package codedraw
Class TextFormat
java.lang.Object
codedraw.TextFormat
TextFormat is used to specify how CodeDraw formats, places and styles its drawn text.
See also
Image.drawText(double, double, String)
and Image.drawText(double, double, String)
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
static String[]
Creates a list of available fonts on the current system.Defines the font of the drawn text.int
Defines the font size of the drawn text.Defines the origin of the drawn text relative to the position specified in theImage.drawText(double, double, String)
method.Defines the underline styling of the drawn text.int
hashCode()
boolean
isBold()
Defines whether the drawn text is bold.static boolean
isFontNameAvailable
(String fontName) Tests whether the font is available on the current system.boolean
isItalic()
Defines whether the drawn text is italic.boolean
Defines whether the drawn text is strikethrough.setBold
(boolean isBold) Defines whether the drawn text is bold.setFontName
(String fontName, String... fallbackFontNames) Defines the font of the drawn text.Sets the font-name property to its default valueFont.DIALOG
.setFontSize
(int fontSize) Defines the font size of the drawn text.setItalic
(boolean isItalic) Defines whether the drawn text is italic.setStrikethrough
(boolean isStrikethrough) Defines whether the drawn text is strikethrough.setTextOrigin
(TextOrigin textOrigin) Defines the origin of the drawn text relative to the position specified in theImage.drawText(double, double, String)
method.setUnderlined
(Underline underline) Defines the underline styling of the drawn text.toString()
-
Constructor Details
-
TextFormat
public TextFormat()
-
-
Method Details
-
getTextOrigin
Defines the origin of the drawn text relative to the position specified in theImage.drawText(double, double, String)
method. The default isTextOrigin.TOP_LEFT
. SeeTextOrigin
for a more detailed explanation.- Returns:
- the text origin
-
setTextOrigin
Defines the origin of the drawn text relative to the position specified in theImage.drawText(double, double, String)
method. The default isTextOrigin.TOP_LEFT
. SeeTextOrigin
for a more detailed explanation.- Parameters:
textOrigin
- Sets the text origin.
-
getFontSize
public int getFontSize()Defines the font size of the drawn text. The default is 16.- Returns:
- the font size.
-
setFontSize
Defines the font size of the drawn text. The default is 16.- Parameters:
fontSize
- Sets the font size.
-
getFontName
Defines the font of the drawn text. The default font isFont.DIALOG
.- Returns:
- the font name.
-
setFontName
Defines the font of the drawn text. If a given font is not available the next fallbackFontName will be used. If none of the fallbackFontNames are available theFont.DIALOG
will be used. The default font isFont.DIALOG
. To check which fonts are available you can call the static methodsgetAllAvailableFontNames()
andisFontNameAvailable(String)
. The font chosen by this method can be found by callinggetFontName()
after setting one or several fonts.- Parameters:
fontName
- Sets the font name.fallbackFontNames
- Defines alternative font names which are used in case fontName is not available.
-
setFontNameToDefault
Sets the font-name property to its default valueFont.DIALOG
. -
isBold
public boolean isBold()Defines whether the drawn text is bold. The default is false (not bold).- Returns:
- whether the drawn text is bold.
-
setBold
Defines whether the drawn text is bold. The default is false (not bold).- Parameters:
isBold
- Sets whether the drawn text is bold.
-
isItalic
public boolean isItalic()Defines whether the drawn text is italic. The default is false (not italic).- Returns:
- whether the drawn text is italic.
-
setItalic
Defines whether the drawn text is italic. The default is false (not italic).- Parameters:
isItalic
- Sets whether the drawn text is italic.
-
getUnderline
Defines the underline styling of the drawn text. The default isUnderline.NONE
.- Returns:
- the underline styling.
-
setUnderlined
Defines the underline styling of the drawn text. The default isUnderline.NONE
.- Parameters:
underline
- Sets the underline styling.
-
isStrikethrough
public boolean isStrikethrough()Defines whether the drawn text is strikethrough. The default is false (no strikethrough).- Returns:
- whether the drawn text is strikethrough.
-
setStrikethrough
Defines whether the drawn text is strikethrough. The default is false (no strikethrough).- Parameters:
isStrikethrough
- Sets whether the drawn text is strikethrough.
-
getAllAvailableFontNames
Creates a list of available fonts on the current system.- Returns:
- an array of all available fonts.
-
isFontNameAvailable
Tests whether the font is available on the current system. If this method returns for a given font,setFontName(String, String...)
will not use the fallback fonts.- Parameters:
fontName
- any font name.- Returns:
- whether the font is available.
-
equals
-
hashCode
-
toString
-