-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenuString.java
114 lines (99 loc) · 2.88 KB
/
MenuString.java
1
import java.awt.*;import java.awt.image.*;import java.applet.*;import java.util.*;public class MenuString extends Object{ public String text; private int width; private MediaTracker tracker; private static int height; private static FontMetrics fm; private static Image apple,applei,temp; private static Graphics tempGC; private static Font helvFont = new Font("Helvetica", Font.BOLD, 12); private static Desktop theDesktop; private static final byte pixels2[] = { 0,0,0,0,0,0,0,1,1,0,0, 0,0,0,0,0,0,1,1,0,0,0, 0,0,0,0,0,0,1,0,0,0,0, 0,0,1,1,1,0,0,1,1,1,0, 0,1,1,1,1,1,1,1,1,1,1, 2,2,2,2,2,2,2,2,2,0,0, 2,2,2,2,2,2,2,2,2,0,0, 3,3,3,3,3,3,3,3,3,0,0, 3,3,3,3,3,3,3,3,3,3,0, 4,4,4,4,4,4,4,4,4,4,4, 0,5,5,5,5,5,5,5,5,5,5, 0,5,5,5,5,5,5,5,5,5,5, 0,0,6,6,6,6,6,6,6,6,0, 0,0,0,6,6,0,0,6,6,0,0, }; private static final byte pixels2i[] = { 7,7,7,7,7,7,7,1,1,7,7, 7,7,7,7,7,7,1,1,7,7,7, 7,7,7,7,7,7,1,7,7,7,7, 7,7,1,1,1,7,7,1,1,1,7, 7,1,1,1,1,1,1,1,1,1,1, 2,2,2,2,2,2,2,2,2,7,7, 2,2,2,2,2,2,2,2,2,7,7, 3,3,3,3,3,3,3,3,3,7,7, 3,3,3,3,3,3,3,3,3,3,7, 4,4,4,4,4,4,4,4,4,4,4, 7,5,5,5,5,5,5,5,5,5,5, 7,5,5,5,5,5,5,5,5,5,5, 7,7,6,6,6,6,6,6,6,6,7, 7,7,7,6,6,7,7,6,6,7,7, }; private static final byte rbmap[] = {(byte)255,(byte)000,(byte)255,(byte)255,(byte)0xDC,(byte)0xFF,(byte)0x00,(byte)0x00}; private static final byte gbmap[] = {(byte)255,(byte)203,(byte)255,(byte)102,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00}; private static final byte bbmap[] = {(byte)255,(byte)000,(byte)000,(byte)000,(byte)0x00,(byte)0x99,(byte)0x66,(byte)0x00}; MenuString(String theString,Desktop back) { if (theDesktop == null) { theDesktop = back; IndexColorModel model = new IndexColorModel(4,8,rbmap,gbmap,bbmap,9); apple = theDesktop.theApplet.createImage(new MemoryImageSource (11, 14, model, pixels2, 0, 11)); applei = theDesktop.theApplet.createImage(new MemoryImageSource (11, 14, model, pixels2i, 0, 11)); temp = theDesktop.theApplet.createImage(11, 14); tempGC = temp.getGraphics(); tempGC.setFont(helvFont); fm = tempGC.getFontMetrics(tempGC.getFont()); height = fm.getMaxAscent()+fm.getMaxDescent(); } width = fm.stringWidth(theString); if (theString.equals("@")) this.width = 11; text = theString; } public int Width() { return this.width; } public void Draw(int x, int y, Graphics g, boolean Disabled) { g.setFont(helvFont); if (Disabled) g.setColor(Color.gray); else g.setColor(Color.black); if (text.equals("@")) { g.drawImage(apple,x,3,null); } else g.drawString(text,x,y); g.setColor(Color.black); } public void DrawApple(int x, Graphics g) { g.setColor(Color.white); g.fillRect(x,2,x+this.width+11,18); g.drawImage(apple,x+8,3,null); } public void DrawAppleInv(int x, Graphics g) { g.setColor(Color.black); g.fillRect(x,2,x+this.width+11,18); g.drawImage(applei,x+8,3,null); }}