📄 asciidraw.java
字号:
//-----------------------------------------------------------------------// AsciiDraw.java |// By: Joe Heitzeberg = intellectual property right owner :-) |
//
// I wrote this nifty little java program over a weekend because I needed
// a way to send pictures over regular email. At the time I was working
// for Fujitsu Research Labs in Kawasaki Japan programming Java systems.
// Now I'm out at Starwave in Seattle WA.... Whatever you do, don't take
// this code to be representative of 'me at my best' because it is quick
// and dirty code and nothing more.
//
// My "permanent email" joeh@goldbay.com
// By the way, please check out my on-the-side import business: www.goldbay.com
//----------------------------------------------------------------------- // (Computer industry humor) /// TO DO maybe... // (5) Add undo class that remembers a list of locations and previous colors and // a graphic object before an operation so I can undo anyoperation and do it quickly. // (6) Refine the color palette to be more like the usual kind... // (7) Add a rectangle tool, selection tool for moving and deleting, eraser tool and // a dropper tool (for selecting color) --> hey YOU, yes YOU could do that!!! :-) // (99) Add "tip of the day" feature and somehow tack on 24 extra megs and a Wizard or two; // eventually write a book called "the road back"
package joeh.asciidraw;import java.awt.*;import java.applet.*;import java.util.*;import java.io.*;//From here = code I wrotepublic class AsciiDraw extends Applet { Choice c; // a choice of start sizes public String getAppletInfo() { return "AsciiDraw - by Joe Heitzeberg"; } //this app doesn't take parameters so why did I put this in? To confuse you? //Actually, if any browsers implemented a get applet parameter info //feature, its in the Java specs to call this function at that time. public String[][] getParameterInfo() { String[][] info = { {"param1", "type1", "description 1"}, {"param2", "type2", "description 2"}, }; return info; } public void init() { //this is called when it is an applet add(new Button("Start AsciiDraw")); c = new Choice(); c.addItem("10 X 10"); c.addItem("20 X 20"); c.addItem("30 X 30"); c.addItem("40 X 40"); c.addItem("50 X 50"); c.addItem("60 X 60"); c.addItem("70 X 70"); c.addItem("80 X 80"); c.select(6); add(c); } public void beginAll() { int sqrsize = (c.getSelectedIndex() +1)*10; System.out.println(sqrsize + " by " + sqrsize); AsciiDrawFrame f1 = new AsciiDrawFrame(330,540,sqrsize); f1.setResizable(true); f1.setBackground(Color.white); f1.show(); f1.initializeUI(); PreviewFrame pf = new PreviewFrame(550,450, announceStart()); pf.show(); //about message
f1.resize(330,540); }
public AsciiDraw() { announceStart(); } public static void main(String args[]) { //this is called when run directly announceStart(); AppletFrame.startApplet("AsciiDraw", "AsciiDraw",args); // AsciiDraw applet = new AsciiDraw(); } //Here is one of two places where this program helped make itself! public static String announceStart() { System.out.println(" Intellectual property rights held exclusively by the creator."); String aboutmssg = ""; aboutmssg += " \n"; aboutmssg += " Welcome to \n"; aboutmssg += " \n"; aboutmssg += " %% \n"; aboutmssg += " %%% %%%%%% %% %% \n"; aboutmssg += " %% % % %%%%% %% %% \n"; aboutmssg += " %% %% %% %%% %% %% \n"; aboutmssg += " %% %% %%%% %% %% %% \n"; aboutmssg += " %%%%%%% %%% %% %% %% \n"; aboutmssg += " % % % %%% %% %% \n"; aboutmssg += " % %%%%% %%%%% %% %% \n"; aboutmssg += " %% \n"; aboutmssg += " by \n"; aboutmssg += " Joe Heitzeberg [joeh@goldbay.com] \n"; aboutmssg += " http://www.goldbay.com/joeh/ \n"; aboutmssg += " \n"; aboutmssg += " %%%% \n"; aboutmssg += " %%%%% %%%%% % \n"; aboutmssg += " %% %% %%%%%% %%% %% %% \n"; aboutmssg += " %% % %% %% % %% %% %% \n"; aboutmssg += " %% % %% %% %% %% %% %% \n"; aboutmssg += " %% % %%%%% %% % %% % %% \n"; aboutmssg += " %% %% %%%% %%%%%% %%%%% % \n"; aboutmssg += " %% %% %% %% % % %% %% \n"; aboutmssg += " %%%% %% %% % % %% %% \n"; aboutmssg += " \n"; aboutmssg += "Note: Please view your output in a MONOSPACE font \n"; return aboutmssg; } //On the web-page there will be a button. When the person //pushes the button, creates the frame which displays the images. //You can keep the frame floating around even while you surf //to other pages. I think thats the best way... public boolean handleEvent(Event evt) { switch(evt.id) { case Event.ACTION_EVENT: { if (evt.target instanceof Button) if ("Start AsciiDraw".equals(evt.arg)) { beginAll(); //create and show a time frame } } } return true; } }////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -