Annotation of capa/capa51/GLabel.java, revision 1.1.1.1
1.1 albertel 1:
2: /* ====================================================
3: created by Isaac Tsai, 1997
4: Copyrighted 1999, 2000 Isaac Tsai
5: <CENTER>
6:
7: <APPLET CODE=GLabel.class CODEBASE=JAVA/Class width=550 height=304>
8: <PARAM NAME="BGIMG" VALUE="path/to/D.gif">
9: <PARAM NAME="GRID" VALUE="10">
10: <PARAM NAME="COUNT" VALUE="7">
11: <PARAM NAME="LB0" VALUE="X">
12: <PARAM NAME="X0" VALUE="16">
13: <PARAM NAME="Y0" VALUE="242">
14: <PARAM NAME="LB1" VALUE="Y">
15: <PARAM NAME="X1" VALUE="144">
16: <PARAM NAME="Y1" VALUE="288">
17: <PARAM NAME="LB2" VALUE="3">
18: <PARAM NAME="X2" VALUE="317">
19: <PARAM NAME="Y2" VALUE="193">
20: <PARAM NAME="LB3" VALUE="4">
21: <PARAM NAME="X3" VALUE="524">
22: <PARAM NAME="Y3" VALUE="154">
23: <PARAM NAME="LB4" VALUE="5">
24: <PARAM NAME="X4" VALUE="309">
25: <PARAM NAME="Y4" VALUE="30">
26: <PARAM NAME="LB5" VALUE="6">
27: <PARAM NAME="X5" VALUE="224">
28: <PARAM NAME="Y5" VALUE="45">
29: <PARAM NAME="LB6" VALUE="7">
30: <PARAM NAME="X6" VALUE="49">
31: <PARAM NAME="Y6" VALUE="106">
32: </APPLET>
33:
34: </CENTER>
35: < APPLET
36: [CODEBASE = codebaseURL]
37: CODE = appletFile
38: [ALT = alternateText]
39: [NAME = appletInstanceName]
40: WIDTH = pixels
41: HEIGHT = pixels
42: [ALIGN = alignment]
43: [VSPACE = pixels]
44: [HSPACE = pixels]
45: >
46: [< PARAM NAME = appletParameter1 VALUE = value >]
47: [< PARAM NAME = appletParameter2 VALUE = value >]
48: . . .
49: [alternateHTML]
50: </APPLET>
51:
52: */
53:
54: import java.applet.*;
55: import java.awt.*;
56: import java.lang.*;
57: import java.util.*;
58: import java.net.*;
59:
60: public class GLabel extends Applet implements Runnable
61: {
62:
63: public int Xcord[];
64: public int Ycord[];
65: public String sLabel[];
66: public int label_cnt;
67: public int fsize;
68: public int show_grid;
69: public int grid_ww;
70: public Image img;
71: public Font f16;
72:
73: public void init()
74: {
75: int count, idx;
76: String p, q;
77: URL f_url=null;
78:
79: Xcord = new int[64]; Ycord = new int[64];
80: sLabel = new String[64];
81: show_grid = 0;
82: f16 = new Font("TimesRoman",Font.PLAIN,16);
83:
84: p=getParameter("COUNT");
85: label_cnt=(p==null)?1:Integer.valueOf(p).intValue();
86:
87: for(idx=0;idx<label_cnt;idx++){
88: q = "LB" + idx;
89: sLabel[idx] = getParameter(q);
90: q = "X" + idx;
91: p = getParameter(q);
92: Xcord[idx]=(p==null)?20:Integer.valueOf(p).intValue();
93: q = "Y" + idx;
94: p = getParameter(q);
95: Ycord[idx]=(p==null)?30:Integer.valueOf(p).intValue();
96: // System.out.println("X= "+Xcord[idx]+" Y= "+Ycord[idx]+" L= "+sLabel[idx]);
97: }
98: p=getParameter("BGIMG");
99: if(p != null) {
100: try {
101: System.out.print("URL=" + p + "\n");
102: f_url = new URL(p);
103: }
104: catch (MalformedURLException exc) {
105: System.out.print("Malformed URL=" + p + "\n");
106: }
107: img = getImage(f_url);
108: }
109: p=getParameter("FSIZE");
110: fsize=(p==null)?16:Integer.valueOf(p).intValue();
111: p=getParameter("GRID");
112: if(p != null) {
113: grid_ww=Integer.valueOf(p).intValue();
114: show_grid = 1;
115: }
116: f16 = new Font("TimesRoman",Font.BOLD,fsize);
117: }
118:
119: public void paint(Graphics g)
120: {
121: int idx;
122: Dimension d = size();
123: int appw = d.width;
124: int apph = d.height;
125: int x1,y1,x2,y2;
126:
127: g.setFont(f16);
128: if( img != null ) {
129: g.drawImage(img, 0, 0, this);
130: } else {
131: g.setColor(Color.white);
132: g.fillRect(0, 0, appw, apph);
133: }
134: g.setColor(Color.black);
135: for(idx=0;idx<label_cnt;idx++){
136: g.drawString(sLabel[idx],Xcord[idx],Ycord[idx]);
137: }
138: if((show_grid == 1) && (grid_ww>1)) {
139: for(x1=0,y1=0,y2=apph;x1<=appw;x1=x1+grid_ww) {
140: x2=x1;
141: g.drawLine(x1,y1,x2,y2);
142: }
143: for(x1=0,y1=0,x2=appw;y1<=apph;y1=y1+grid_ww) {
144: y2=y1;
145: g.drawLine(x1,y1,x2,y2);
146: }
147: }
148: }
149: public void run() { }
150: public void start() { }
151: public void stop() { }
152:
153: }
154:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>