Annotation of capa/capa51/GLabelImg.java, revision 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=GLabelImg.class CODEBASE=JAVA/Class width=550 height=304>
! 8: <PARAM NAME="BGIMG" VALUE="path/to/background.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: <PARAM NAME="ICOUNT" VALUE="2">
! 33: <PARAM NAME="IMG0" VALUE="path/to/image0.gif">
! 34: <PARAM NAME="IX0" VALUE="106">
! 35: <PARAM NAME="IY0" VALUE="106">
! 36: <PARAM NAME="IMG1" VALUE="path/to/image1.gif">
! 37: <PARAM NAME="IX1" VALUE="106">
! 38: <PARAM NAME="IY1" VALUE="106">
! 39: </APPLET>
! 40:
! 41: </CENTER>
! 42: < APPLET
! 43: [CODEBASE = codebaseURL]
! 44: CODE = appletFile
! 45: [ALT = alternateText]
! 46: [NAME = appletInstanceName]
! 47: WIDTH = pixels
! 48: HEIGHT = pixels
! 49: [ALIGN = alignment]
! 50: [VSPACE = pixels]
! 51: [HSPACE = pixels]
! 52: >
! 53: [< PARAM NAME = appletParameter1 VALUE = value >]
! 54: [< PARAM NAME = appletParameter2 VALUE = value >]
! 55: . . .
! 56: [alternateHTML]
! 57: </APPLET>
! 58:
! 59: */
! 60:
! 61: import java.applet.*;
! 62: import java.awt.*;
! 63: import java.lang.*;
! 64: import java.util.*;
! 65: import java.net.*;
! 66:
! 67: public class GLabelImg extends Applet implements Runnable
! 68: {
! 69:
! 70: public int Xcord[];
! 71: public int Ycord[];
! 72: public String sLabel[];
! 73: public Image iImg[];
! 74: public int iX[];
! 75: public int iY[];
! 76:
! 77: public int label_cnt;
! 78: public int img_cnt;
! 79: public int fsize;
! 80: public int show_grid;
! 81: public int grid_ww;
! 82: public Image img;
! 83: public Font f16;
! 84:
! 85: public void init()
! 86: {
! 87: int count, idx;
! 88: String p, q;
! 89: URL f_url=null;
! 90:
! 91: Xcord = new int[64]; Ycord = new int[64];
! 92: sLabel = new String[64];
! 93: iImg = new Image[64];
! 94: iX = new int[64]; iY = new int[64];
! 95:
! 96: show_grid = 0;
! 97: f16 = new Font("TimesRoman",Font.PLAIN,16);
! 98:
! 99: p=getParameter("COUNT");
! 100: label_cnt=(p==null)?1:Integer.valueOf(p).intValue();
! 101:
! 102: for(idx=0;idx<label_cnt;idx++){
! 103: q = "LB" + idx;
! 104: sLabel[idx] = getParameter(q);
! 105: q = "X" + idx;
! 106: p = getParameter(q);
! 107: Xcord[idx]=(p==null)?20:Integer.valueOf(p).intValue();
! 108: q = "Y" + idx;
! 109: p = getParameter(q);
! 110: Ycord[idx]=(p==null)?30:Integer.valueOf(p).intValue();
! 111: // System.out.println("X= "+Xcord[idx]+" Y= "+Ycord[idx]+" L= "+sLabel[idx]);
! 112: }
! 113:
! 114: p=getParameter("ICOUNT");
! 115: img_cnt=(p==null)?1:Integer.valueOf(p).intValue();
! 116: for(idx=0;idx<img_cnt;idx++){
! 117: q = "IMG" + idx;
! 118: p = getParameter(q);
! 119: if(p != null) {
! 120: try {
! 121: System.out.print("URL=" + p + "\n");
! 122: f_url = new URL(p);
! 123: }
! 124: catch (MalformedURLException exc) {
! 125: System.out.print("Malformed URL=" + p + "\n");
! 126: }
! 127: iImg[idx] = getImage(f_url);
! 128: }
! 129: q = "IX" + idx;
! 130: p = getParameter(q);
! 131: iX[idx]=(p==null)?20:Integer.valueOf(p).intValue();
! 132: q = "IY" + idx;
! 133: p = getParameter(q);
! 134: iY[idx]=(p==null)?30:Integer.valueOf(p).intValue();
! 135: // System.out.println("X= "+Xcord[idx]+" Y= "+Ycord[idx]+" L= "+sLabel[idx]);
! 136: }
! 137:
! 138:
! 139:
! 140: p=getParameter("BGIMG");
! 141: if(p != null) {
! 142: try {
! 143: System.out.print("URL=" + p + "\n");
! 144: f_url = new URL(p);
! 145: }
! 146: catch (MalformedURLException exc) {
! 147: System.out.print("Malformed URL=" + p + "\n");
! 148: }
! 149: img = getImage(f_url);
! 150: }
! 151: p=getParameter("FSIZE");
! 152: fsize=(p==null)?16:Integer.valueOf(p).intValue();
! 153: p=getParameter("GRID");
! 154: if(p != null) {
! 155: grid_ww=Integer.valueOf(p).intValue();
! 156: show_grid = 1;
! 157: }
! 158: f16 = new Font("TimesRoman",Font.BOLD,fsize);
! 159: }
! 160:
! 161: public void paint(Graphics g)
! 162: {
! 163: int idx;
! 164: Dimension d = getSize();
! 165: int appw = d.width;
! 166: int apph = d.height;
! 167: int x1,y1,x2,y2;
! 168:
! 169: g.setFont(f16);
! 170: if( img != null ) {
! 171: g.drawImage(img, 0, 0, this);
! 172: } else {
! 173: g.setColor(Color.white);
! 174: g.fillRect(0, 0, appw, apph);
! 175: }
! 176:
! 177: for(idx=0;idx<img_cnt;idx++){
! 178: if( iImg[idx] != null ) {
! 179: g.drawImage(iImg[idx], iX[idx],iY[idx], this);
! 180: } else {
! 181: g.setColor(Color.white);
! 182: g.fillRect(iX[idx], iY[idx], appw, apph);
! 183: }
! 184: }
! 185:
! 186:
! 187:
! 188: g.setColor(Color.black);
! 189: for(idx=0;idx<label_cnt;idx++){
! 190: g.drawString(sLabel[idx],Xcord[idx],Ycord[idx]);
! 191: }
! 192: if((show_grid == 1) && (grid_ww>1)) {
! 193: for(x1=0,y1=0,y2=apph;x1<=appw;x1=x1+grid_ww) {
! 194: x2=x1;
! 195: g.drawLine(x1,y1,x2,y2);
! 196: }
! 197: for(x1=0,y1=0,x2=appw;y1<=apph;y1=y1+grid_ww) {
! 198: y2=y1;
! 199: g.drawLine(x1,y1,x2,y2);
! 200: }
! 201: }
! 202: }
! 203: public void run() { }
! 204: public void start() { }
! 205: public void stop() { }
! 206:
! 207: }
! 208:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>