added support for copying moves
[fleet.git] / src / de / mud / telnet / modules / TextLabel.java
1 package de.mud.telnet.modules;
2 /* "In case you would like to use the packages as libraries please
3  *  apply the GNU Library General Public License as documented in the
4  *  file COPYING.LIB." (from Telnet/Documentation/index.html)
5  */
6
7 /**
8  * TextLabel -- A module to display a Label on the applet.
9  * --
10  * $Id: TextLabel.java,v 1.1 1997/07/09 20:12:05 leo Exp $
11  * $timestamp: Wed Jul  9 17:37:28 1997 by Matthias L. Jugel :$
12  *
13  * This file is part of "The Java Telnet Applet".
14  *
15  * This is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2, or (at your option)
18  * any later version.
19  *
20  * "The Java Telnet Applet" is distributed in the hope that it will be 
21  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  * 
25  * You should have received a copy of the GNU General Public License
26  * along with this software; see the file COPYING.  If not, write to the
27  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28  * Boston, MA 02111-1307, USA.
29  */
30
31 import de.mud.telnet.*;
32 import java.awt.Panel;
33 import java.awt.Label;
34 import java.awt.GridLayout;
35 import java.awt.Font;
36
37 /**
38  * This small module lets you display text somewhere in the applets area.
39  *
40  * <DL>
41  *  <DT><B>Label:</B>
42  *   <DD><PRE>&lt;PARAM NAME=labelRows    VALUE=&quot;<B><I>rows</B></I>&quot;&gt;</PRE>
43  *   <DD>Defines the how many rows the label will have.
44  *   <DD><PRE>&lt;PARAM NAME=labelCols    VALUE=&quot;<B><I>cols</B></I>&quot;&gt;</PRE>
45  *   <DD>Defines the how many columns the label will have.
46  *   <DD><PRE>&lt;PARAM NAME=labelFont    VALUE=&quot;<B><I>font[,size]</B></I>&quot;&gt;</PRE>
47  *   <DD>The font for displaying the label text. If the <I>size</I> is left out
48  *       a standard size of 14 points is assumed.
49  *   <DD><PRE>&lt;PARAM NAME=label#<I>number</I> VALUE=&quot;<B><I>text</I></B>&quot;&gt;</PRE>
50  *   <DT>The labels are enumerated and displayed in rows and columns.
51  * </DL>
52  * @version $Id: TextLabel.java,v 1.1 1997/07/09 20:12:05 leo Exp $
53  * @author  Matthias L. Jugel, Marcus Meißner
54  * @see modules.Module
55  */
56 public class TextLabel extends Panel implements Module
57 {
58   telnet applet;
59   
60         /**
61          * Set the applet as module loader and configure.
62          * @param o the object that is the applet (must be an Applet)
63          * @see module.Module
64          * @see java.applet.Applet
65          */
66         public void setLoader(Object o) { 
67     applet = (telnet)o;
68
69     int rows = 1, cols = 1;
70     
71     String tmp = applet.getParameter("labelRows");
72     if(tmp != null) rows = Integer.parseInt(tmp);
73     if((tmp = applet.getParameter("labelCols")) != null)
74       cols = Integer.parseInt(tmp);
75
76     setLayout(new GridLayout(rows, cols));
77
78     Font labelFont = null;
79     if((tmp = applet.getParameter("labelFont")) != null) {
80       int idx = tmp.indexOf(",");
81       int size = 14;
82       if(idx != -1) size = Integer.parseInt(tmp.substring(idx+1));
83       labelFont = new Font(tmp, Font.PLAIN, size);
84     }
85     
86     int no = 1;
87     while((tmp = applet.getParameter("label#"+no++)) != null) {
88       Label text = new Label(tmp);
89       if(labelFont != null) text.setFont(labelFont);
90       add(text);
91     }
92   }
93         
94         /**
95          * Do nothing upon connect.
96          * @param host remote hostaddress - not used
97          * @param port remote port - not used
98          */
99         public void connect(String host, int port) {}
100   
101         /**
102          * Do nothing upon disconnecton.
103          */
104         public void disconnect() {}
105         
106         /**
107    * Do nothing when receiving text. Be removed upon first call.
108          * @param s The string received.
109          * @see peer.InputPeer
110          */
111         public String receive(String s) { return null; }
112 }
113