mirror of
https://github.com/jneug/zeichenmaschine.git
synced 2026-04-14 06:33:34 +02:00
Verwendung der neuen FontLoader KLasse
This commit is contained in:
@@ -2,6 +2,7 @@ package schule.ngb.zm.shapes;
|
||||
|
||||
import schule.ngb.zm.Color;
|
||||
import schule.ngb.zm.Options;
|
||||
import schule.ngb.zm.util.FontLoader;
|
||||
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Font;
|
||||
@@ -23,6 +24,19 @@ public class Text extends Shape {
|
||||
public Text( double x, double y, String text ) {
|
||||
this(x, y, text, new Font(Font.SANS_SERIF, Font.PLAIN, STD_FONTSIZE));
|
||||
}
|
||||
public Text( double x, double y, String text, String fontname ) {
|
||||
super(x, y);
|
||||
Font userfont = FontLoader.loadFont(fontname);
|
||||
if( userfont != null ) {
|
||||
font = userfont;
|
||||
} else {
|
||||
font = new Font(Font.SANS_SERIF, Font.PLAIN, STD_FONTSIZE);
|
||||
}
|
||||
setText(text);
|
||||
fillColor = null;
|
||||
strokeColor = null;
|
||||
anchor = Options.Direction.CENTER;
|
||||
}
|
||||
|
||||
public Text( double x, double y, String text, Font font ) {
|
||||
super(x, y);
|
||||
@@ -46,6 +60,18 @@ public class Text extends Shape {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setFont( String fontname ) {
|
||||
Font newFont = FontLoader.loadFont(fontname);
|
||||
if( newFont != null ) {
|
||||
setFont(newFont);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFont( Font newFont ) {
|
||||
font = newFont.deriveFont(font.getSize2D());
|
||||
calculateBounds();
|
||||
}
|
||||
|
||||
public Font getFont() {
|
||||
return font;
|
||||
}
|
||||
@@ -55,6 +81,10 @@ public class Text extends Shape {
|
||||
calculateBounds();
|
||||
}
|
||||
|
||||
public double getFontsize() {
|
||||
return font.getSize2D();
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user