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)
10 * $Id: CharDisplayTest.java,v 1.1.1.1 1997/03/05 13:35:16 leo Exp $
11 * $timestamp: Mon Feb 17 20:11:20 1997 by Matthias L. Jugel :$
13 * This file is part of "The Java Telnet Applet".
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)
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.
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.
31 import java.applet.Applet;
32 import java.awt.Button;
33 import java.awt.Panel;
34 import java.awt.Event;
35 import java.awt.FlowLayout;
36 import java.awt.BorderLayout;
37 import java.awt.Choice;
38 import java.awt.TextField;
41 import de.mud.telnet.display.CharDisplay;
44 * CharDisplayTest -- a test applet to show the display/CharDisplay features
46 * @version $Id: CharDisplayTest.java,v 1.1.1.1 1997/03/05 13:35:16 leo Exp $
47 * @author Matthias L. Jugel, Marcus Meißner
49 public class CharDisplayTest extends Applet
51 CharDisplay display = new CharDisplay(80, 24, "Courier", 14);
53 Panel buttons = new Panel();
54 Button info = new Button("Information");
55 Button chars = new Button("Character Table");
56 Button attr = new Button("Attributes");
57 Choice fonts = new Choice();
58 TextField from = new TextField("0", 4);
62 setLayout(new BorderLayout());
63 fonts.addItem("Helvetica");
64 fonts.addItem("TimesRoman");
65 fonts.addItem("Courier");
66 fonts.addItem("Dialog");
67 fonts.addItem("DialogInput");
68 fonts.addItem("ZapfDingBats");
69 fonts.addItem("default");
75 add("North", buttons);
76 display.setResizeStrategy(CharDisplay.RESIZE_FONT);
77 add("Center", display);
81 public boolean handleEvent(Event evt)
83 if(evt.target == info) { Info(); return true; }
84 if(evt.target == chars) { CharacterTable(); return true; }
85 if(evt.target == attr) { Attributes(); return true; }
86 if(evt.id == Event.ACTION_EVENT &&
87 (evt.target == fonts || evt.target == from))
90 display = new CharDisplay(80, 24, fonts.getSelectedItem(), 12);
91 add("Center", display);
101 display.deleteArea(0, 0, 80, 24);
107 display.putString(4, 1, "CharDisplay.class Information", CharDisplay.INVERT);
108 display.putString(4, 3, "Version: "+display.version, CharDisplay.BOLD);
109 display.putString(4, 5, "This class implements several hardware features needed to implement");
110 display.putString(4, 6, "a video terminal.");
111 display.putString(4, 7, "This includes simple operations, such as putting and inserting single");
112 display.putString(4, 8, "characters or strings on the screen, character attributes and colors.");
113 display.putString(4, 9, "Special features like inserting lines, scrolling text up or down and");
114 display.putString(4,10, "defining scrollareas help implementing terminal emulations.");
118 private void CharacterTable()
120 int ch = (new Integer(from.getText())).intValue();
123 display.putString( 4, 1, "Character Table", CharDisplay.INVERT);
124 for(int c = 1; c < 80; c += 6)
125 for(int l = 3; l < 23; l++)
127 display.putString(c, l, ""+ch, CharDisplay.INVERT);
128 display.putChar(c+4, l, (char)ch++);
130 display.markLine(3, 20);
134 private void Attributes()
139 display.putString( 4, 1, "Character attributes", CharDisplay.INVERT);
140 display.putString( 4, 3, "Normal", CharDisplay.NORMAL);
141 display.putString(22, 3, "Bold", CharDisplay.BOLD);
142 display.putString(40, 3, "Underline", CharDisplay.UNDERLINE);
143 display.putString(58, 3, "Invert", CharDisplay.INVERT);
145 display.putString( 4, 5, "Black", 1 << 3 | 8 << 7);
146 display.putString(13, 5, "Red", 2 << 3);
147 display.putString(22, 5, "Green", 3 << 3);
148 display.putString(31, 5, "Yellow", 4 << 3);
149 display.putString(40, 5, "Blue", 5 << 3);
150 display.putString(49, 5, "Magenta", 6 << 3);
151 display.putString(58, 5, "Cyan", 7 << 3);
152 display.putString(67, 5, "LightGray", 8 << 3);
154 for(int bg = 1; bg <= 8; bg++)
156 for(int fg = 1; fg <= 8; fg++)
158 for(int a = 0; a <= 7; a++)
160 display.putChar(c++, l, '@', (fg << 3) | (bg << 7) | a);