java-org.hwo/src/org/hwo/layout/TextLayouter.java

74 lines
1.3 KiB
Java

package org.hwo.layout;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.font.GlyphVector;
import java.awt.image.BufferedImage;
import java.util.LinkedList;
public class TextLayouter {
private Font font;
private FontMetrics metrics;
private char[] characters;
private GlyphVector[] glyphs;
private int position;
public TextLayouter(String text)
{
this.setFont(new Font("Arial", 0, 50));
this.characters = text.toCharArray();
}
public TextLayouter(String text,Font font)
{
this.characters = text.toCharArray();
this.setFont(font);
}
public int getPosition() {
return position;
}
public void setPosition(int position) {
this.position = position;
}
public String getLine(float width)
{
LinkedList<Character> lineCharacters = new LinkedList<Character>();
float x = 0;
while ( position < characters.length )
{
}
//return String.valueOf(lineCharacters.toArray(new char[0]));
return "";
}
public Font getFont() {
return font;
}
public void setFont(Font font) {
this.font = font;
BufferedImage img = new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = img.createGraphics();
g2d.setFont(font);
this.metrics = g2d.getFontMetrics();
}
}