Diff for /capa/capa51/JavaTools/GLabel.java between versions 1.1 and 1.4

version 1.1, 1999/11/29 19:44:21 version 1.4, 2000/07/07 16:57:17
Line 1 Line 1
   
 /* ====================================================  /* ====================================================
    created by Isaac Tsai, 1997     created by Isaac Tsai, 1997
    Copyrighted 1999, 2000 Isaac Tsai     randomized labeling of a figure applet
      Copyright (C) 1992-2000 Michigan State University
   
      The CAPA system is free software; you can redistribute it and/or
      modify it under the terms of the GNU Library General Public License as
      published by the Free Software Foundation; either version 2 of the
      License, or (at your option) any later version.
   
      The CAPA system is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Library General Public License for more details.
   
      You should have received a copy of the GNU Library General Public
      License along with the CAPA system; see the file COPYING.  If not,
      write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      Boston, MA 02111-1307, USA.
   
      As a special exception, you have permission to link this program
      with the TtH/TtM library and distribute executables, as long as you
      follow the requirements of the GNU GPL in regard to all of the
      software in the executable aside from TtH/TtM.
   */
   
 <CENTER>  <CENTER>
   
 <APPLET CODE=GLabel.class CODEBASE=JAVA/Class width=550 height=304>  <APPLET CODE=GLabel.class CODEBASE=JAVA/Class width=550 height=304>
 <PARAM NAME="BGIMG" VALUE="path/to/D.gif">  <PARAM NAME="BGIMG" VALUE="path/to/background.gif">
 <PARAM NAME="GRID"  VALUE="10">  <PARAM NAME="GRID"  VALUE="10">
 <PARAM NAME="COUNT" VALUE="7">  <PARAM NAME="COUNT" VALUE="7">
 <PARAM NAME="LB0" VALUE="X">  <PARAM NAME="LB0" VALUE="X">
Line 29 Line 52
 <PARAM NAME="LB6" VALUE="7">  <PARAM NAME="LB6" VALUE="7">
 <PARAM NAME="X6" VALUE="49">  <PARAM NAME="X6" VALUE="49">
 <PARAM NAME="Y6" VALUE="106">  <PARAM NAME="Y6" VALUE="106">
   <PARAM NAME="ICOUNT" VALUE="2">
   <PARAM NAME="IMG0" VALUE="path/to/image0.gif">
   <PARAM NAME="IX0" VALUE="106">
   <PARAM NAME="IY0" VALUE="106">
   <PARAM NAME="IMG1" VALUE="path/to/image1.gif">
   <PARAM NAME="IX1" VALUE="106">
   <PARAM NAME="IY1" VALUE="106">
 </APPLET>  </APPLET>
   
 </CENTER>  </CENTER>
Line 63  public class GLabel extends Applet imple Line 93  public class GLabel extends Applet imple
  public int     Xcord[];   public int     Xcord[];
  public int     Ycord[];   public int     Ycord[];
  public String  sLabel[];   public String  sLabel[];
    public Image   iImg[];
    public int     iX[];
    public int     iY[];
    
  public int     label_cnt;   public int     label_cnt;
    public int     img_cnt;
  public int     fsize;   public int     fsize;
  public int     show_grid;   public int     show_grid;
  public int     grid_ww;   public int     grid_ww;
Line 78  public void init() Line 113  public void init()
         
    Xcord = new int[64]; Ycord = new int[64];     Xcord = new int[64]; Ycord = new int[64];
    sLabel = new String[64];     sLabel = new String[64];
      iImg = new Image[64];
      iX = new int[64]; iY = new int[64];
      
    show_grid = 0;     show_grid = 0;
    f16 = new Font("TimesRoman",Font.PLAIN,16);     f16 = new Font("TimesRoman",Font.PLAIN,16);
         
Line 95  public void init() Line 133  public void init()
      Ycord[idx]=(p==null)?30:Integer.valueOf(p).intValue();       Ycord[idx]=(p==null)?30:Integer.valueOf(p).intValue();
      // System.out.println("X= "+Xcord[idx]+" Y= "+Ycord[idx]+" L= "+sLabel[idx]);       // System.out.println("X= "+Xcord[idx]+" Y= "+Ycord[idx]+" L= "+sLabel[idx]);
    }     }
      
      p=getParameter("ICOUNT");
      img_cnt=(p==null)?0:Integer.valueOf(p).intValue();
      for(idx=0;idx<img_cnt;idx++){
        q = "IMG" + idx;
        p = getParameter(q);
        if(p != null) {
        try {
             System.out.print("URL=" + p + "\n");
             f_url = new URL(p);
        } 
        catch (MalformedURLException exc) {
             System.out.print("Malformed URL=" + p + "\n");
          }
          iImg[idx] = getImage(f_url);
        }
        q = "IX" + idx;
        p = getParameter(q);
        iX[idx]=(p==null)?20:Integer.valueOf(p).intValue();
        q = "IY" + idx;
        p = getParameter(q);
        iY[idx]=(p==null)?30:Integer.valueOf(p).intValue();
        // System.out.println("X= "+Xcord[idx]+" Y= "+Ycord[idx]+" L= "+sLabel[idx]);
      }
      
      
      
    p=getParameter("BGIMG");     p=getParameter("BGIMG");
    if(p != null) {     if(p != null) {
      try {       try {
Line 119  public void init() Line 184  public void init()
 public void paint(Graphics g)  public void paint(Graphics g)
  {   {
    int        idx;      int        idx; 
    Dimension  d = size();     Dimension  d = getSize();
    int        appw = d.width;     int        appw = d.width;
    int        apph = d.height;     int        apph = d.height;
    int        x1,y1,x2,y2;     int        x1,y1,x2,y2;
Line 131  public void paint(Graphics g) Line 196  public void paint(Graphics g)
        g.setColor(Color.white);         g.setColor(Color.white);
        g.fillRect(0, 0, appw, apph);         g.fillRect(0, 0, appw, apph);
     }      }
       
       for(idx=0;idx<img_cnt;idx++){
         if( iImg[idx] != null ) {
           g.drawImage(iImg[idx], iX[idx],iY[idx], this);
         } else {
           g.setColor(Color.white);
           g.fillRect(iX[idx], iY[idx], appw, apph);
         }
       }
       
       
       
     g.setColor(Color.black);      g.setColor(Color.black);
     for(idx=0;idx<label_cnt;idx++){      for(idx=0;idx<label_cnt;idx++){
       g.drawString(sLabel[idx],Xcord[idx],Ycord[idx]);        g.drawString(sLabel[idx],Xcord[idx],Ycord[idx]);

Removed from v.1.1  
changed lines
  Added in v.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>