31 |
import org.nongnu.libvob.impl.gl.*; |
import org.nongnu.libvob.impl.gl.*; |
32 |
import org.nongnu.libvob.linebreaking.*; |
import org.nongnu.libvob.linebreaking.*; |
33 |
import org.nongnu.libvob.gl.*; |
import org.nongnu.libvob.gl.*; |
34 |
|
import org.nongnu.libvob.util.*; |
35 |
import java.awt.Rectangle; |
import java.awt.Rectangle; |
36 |
import java.awt.Shape; |
import java.awt.Shape; |
37 |
|
import java.awt.Color; |
38 |
|
|
39 |
/** A single contiguous text string as a Vob. |
/** A single contiguous text string as a Vob. |
40 |
* This vob implements the HBox interface so it is |
* This vob implements the HBox interface so it is |
61 |
protected final TextStyle style; |
protected final TextStyle style; |
62 |
protected final String text; |
protected final String text; |
63 |
protected final boolean baselined; |
protected final boolean baselined; |
64 |
protected String textColor = null; |
protected Color color = null; |
65 |
|
protected String colorString = null; |
66 |
|
|
67 |
protected Object key; |
protected Object key; |
68 |
|
|
75 |
* If false, the text will be comfortably within the box. |
* If false, the text will be comfortably within the box. |
76 |
*/ |
*/ |
77 |
public TextVob(TextStyle style, String text, boolean baselined) { |
public TextVob(TextStyle style, String text, boolean baselined) { |
78 |
this(style, text, baselined, null); |
this(style, text, baselined, (String)null); |
79 |
} |
} |
80 |
|
|
81 |
/** Same as another constructor but in GL side you can give the color |
/** Same as another constructor but in GL side you can give the color |
82 |
* with string like "Color 1 0.5 0.5" |
* with string like "Color 1 0.5 0.5" |
83 |
* @param color OpenGL Color used to draw the text. |
* @param color OpenGL Color used to draw the text. |
84 |
*/ |
*/ |
85 |
|
public TextVob(TextStyle style, String text, boolean baselined, Color color) { |
86 |
|
super(); |
87 |
|
this.style = style; |
88 |
|
this.baselined = baselined; |
89 |
|
this.text = text; |
90 |
|
|
91 |
|
this.color = color; |
92 |
|
if (color != null) |
93 |
|
this.colorString ="Color "+ ColorUtil.colorGLString(color); |
94 |
|
} |
95 |
|
|
96 |
public TextVob(TextStyle style, String text, boolean baselined, String color) { |
public TextVob(TextStyle style, String text, boolean baselined, String color) { |
97 |
super(); |
super(); |
98 |
this.style = style; |
this.style = style; |
99 |
this.baselined = baselined; |
this.baselined = baselined; |
100 |
this.text = text; |
this.text = text; |
101 |
|
|
102 |
this.textColor = color; |
this.colorString = color; |
103 |
} |
} |
104 |
|
|
105 |
|
|
110 |
} |
} |
111 |
|
|
112 |
public TextVob(TextStyle style, String text, boolean baselined, Object key) { |
public TextVob(TextStyle style, String text, boolean baselined, Object key) { |
113 |
this(style, text, baselined, null); |
this(style, text, baselined, (String)null); |
114 |
|
} |
115 |
|
public TextVob(TextStyle style, String text, boolean baselined, Object key, Color color) { |
116 |
|
this(style, text, baselined, color); |
117 |
|
this.color = color; |
118 |
} |
} |
119 |
public TextVob(TextStyle style, String text, boolean baselined, Object key, String color) { |
public TextVob(TextStyle style, String text, boolean baselined, Object key, String color) { |
120 |
this(style, text, baselined, color); |
this(style, text, baselined, color); |
223 |
|
|
224 |
private Vob setColor() { |
private Vob setColor() { |
225 |
if(setColor == null) { |
if(setColor == null) { |
226 |
setColor = GLCache.getCallList(this.textColor == null ? "" : this.textColor); |
setColor = GLCache.getCallList(this.colorString == null ? "" : this.colorString); |
227 |
} |
} |
228 |
return setColor; |
return setColor; |
229 |
} |
} |