MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / TextBox

Class TextBox

src/org/opensourcephysics/display/TextBox.java:15–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13import java.awt.Graphics2D;
14
15public class TextBox implements Drawable {
16 public static final int COORDINATE_PLACEMENT = 0;
17 public static final int PIXEL_PLACEMENT = 1;
18 public static final int RELATIVE_PLACEMENT = 2;
19 public static final int BOTTOM_LEFT_PLACEMENT = 3;
20 public static final int TOP_LEFT_PLACEMENT = 4;
21 public static final int BOTTOM_RIGHT_PLACEMENT = 5;
22 public static final int TOP_RIGHT_PLACEMENT = 6;
23 public static final int BOTTOM_LEFT_GUTTER_PLACEMENT = 7;
24 public static final int TOP_LEFT_GUTTER_PLACEMENT = 8;
25 public static final int BOTTOM_RIGHT_GUTTER_PLACEMENT = 9;
26 public static final int TOP_RIGHT_GUTTER_PLACEMENT = 10;
27 public static final int TOP_RIGHT_ALIGNMENT = 0;
28 public static final int TOP_CENTER_ALIGNMENT = 1;
29 public int placement_mode = COORDINATE_PLACEMENT;
30 public int alignment_mode = TOP_RIGHT_ALIGNMENT;
31 public int xoffset = 0, yoffset = 0;
32 protected String text = null;
33 protected Font font;
34 protected String fontname = "TimesRoman"; // The logical name of the font to use //$NON-NLS-1$
35 protected int fontsize = 14; // The font size
36 protected int fontstyle = Font.PLAIN; // The font style
37 protected Color color = Color.black;
38 protected double x, y;
39 protected int xpix = 0, ypix = 0;
40 protected int boxHeight = 0, boxWidth = 0; // the box width and height
41
42 /**
43 * Constructor TextBox
44 */
45 public TextBox() {
46 font = new Font(fontname, fontstyle, fontsize);
47 }
48
49 /**
50 * Constructor TextBox
51 * @param str
52 */
53 public TextBox(String str) {
54 this();
55 text = TeXParser.parseTeX(str);
56 }
57
58 public void setXY(double _x, double _y) {
59 x = _x;
60 y = _y;
61 }
62
63 public void setText(String _text) {
64 text = TeXParser.parseTeX(_text);
65 }
66
67 public void setText(String _text, double _x, double _y) {
68 x = _x;
69 y = _y;
70 text = TeXParser.parseTeX(_text);
71 }
72

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected