public class Label extends Entity
Modifier and Type | Field and Description |
---|---|
java.lang.String |
alignment
text alignment ("LEFT", "CENTER", "RIGHT") with respect to anchor point (x,y)
|
javafx.scene.paint.Color |
borderColor
color used to draw font border
|
boolean |
borderDraw
determines if font border will be drawn
|
int |
borderSize
size of font border
|
(package private) javafx.scene.text.Font |
font
Automatically set by load methods.
|
javafx.scene.paint.Color |
fontColor
color used to draw font
|
(package private) java.lang.String |
fontName
Name of the current font.
|
(package private) int |
fontSize
Size of the current font.
|
java.lang.String |
text
text to display in label
|
boolean |
visible
determines if label will be visible
|
double |
x
x-coordinate of anchor of label; see
setPosition(double, double) |
double |
y
y-coordinate of anchor of label; see
setPosition(double, double) |
Constructor and Description |
---|
Label()
Initialize label to default settings.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(javafx.scene.canvas.GraphicsContext context)
Render this text to a canvas used specified parameters.
|
void |
loadFontFromFile(java.lang.String fontFileName,
int fontSize)
Configure this label to use a font from a specified file.
|
void |
loadFontFromSystem(java.lang.String fontName,
int fontSize)
Configure this label to use a font already installed on this system.
|
void |
setPosition(double x,
double y)
Set the coordinates of the anchor position of this label;
this may be to the left, center, or right of the text
according to the value of
alignment . |
java.lang.String fontName
loadFontFromSystem(String, int)
or set by file in loadFontFromFile(String, int)
.int fontSize
loadFontFromSystem(String, int)
or loadFontFromFile(String, int)
.javafx.scene.text.Font font
public javafx.scene.paint.Color fontColor
public java.lang.String text
public double x
setPosition(double, double)
public double y
setPosition(double, double)
public java.lang.String alignment
public boolean borderDraw
public int borderSize
public javafx.scene.paint.Color borderColor
public boolean visible
public void loadFontFromSystem(java.lang.String fontName, int fontSize)
fontName
- name of font (e.g. "Arial", "Times New Roman", "Courier New"); must be installed on systemfontSize
- size of fontpublic void loadFontFromFile(java.lang.String fontFileName, int fontSize)
fontFileName
- name of font filefontSize
- size of fontpublic void setPosition(double x, double y)
alignment
.x
- x-coordinate of anchor of labely
- y-coordinate of anchor of label