package NET.worlds.scape; import java.awt.Color; import java.io.IOException; public class StringTexture extends Texture implements Persister { private String _text; private String _font; private int _size; private Color _fore; private Color _back; private char[] _array; private int _length; private static Object classCookie = new Object(); static { nativeInit(); } public StringTexture(String text, String font, int size, Color fore, Color back) { this._text = text; this._font = font; this._size = size; this._fore = fore; this._back = back; this._array = text.toCharArray(); this._length = text.length(); this.makeStringTexture(); } protected StringTexture() { } public static native void nativeInit(); private native void makeStringTexture(); @Override public void saveState(Saver s) throws IOException { s.saveVersion(0, classCookie); super.saveState(s); s.saveString(this._text); s.saveString(this._font); s.saveInt(this._size); s.saveInt(this._fore.getRGB()); s.saveInt(this._back.getRGB()); } @Override public void restoreState(Restorer r) throws IOException, TooNewException { switch (r.restoreVersion(classCookie)) { case 0: super.restoreState(r); this._text = r.restoreString(); this._array = this._text.toCharArray(); this._length = this._text.length(); this._font = r.restoreString(); this._size = r.restoreInt(); this._fore = new Color(r.restoreInt()); this._back = new Color(r.restoreInt()); this.makeStringTexture(); return; default: throw new TooNewException(); } } public String getText() { return this._text; } public String getFont() { return this._font; } public int getSize() { return this._size; } public Color getForegroundColor() { return this._fore; } public Color getBackgroundColor() { return this._back; } @Override public String toString() { return super.toString() + "[" + this._text + ", Font " + this._font + ", Size " + this._size + ", Forground " + this._fore + ", Background " + this._back + "]"; } }