/* */ package NET.worlds.console; /* */ /* */ import java.awt.Color; /* */ import java.awt.Dimension; /* */ import java.awt.Font; /* */ import java.awt.FontMetrics; /* */ import java.awt.Graphics; /* */ import java.awt.Toolkit; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ class TextImageButtons /* */ extends ImageButtons /* */ { /* */ private static final long serialVersionUID = -3744924750348174006L; /* */ private int buttonCount; /* */ private int[] xText; /* */ private String[] texts; /* */ private int[] buttonBottoms; /* */ private Font font; /* 60 */ private static Font defFont = new Font(Console.message("ButtonFont"), /* 61 */ 0, 9); /* */ /* */ private static final int yBaseline = 4; /* */ /* */ /* */ public static Dimension measure(String text, Font f) /* */ { /* 68 */ Dimension sz = new Dimension(); /* 69 */ FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(f); /* 70 */ sz.width = fm.stringWidth(text); /* 71 */ sz.height = fm.getHeight(); /* 72 */ return sz; /* */ } /* */ /* */ /* */ /* */ public TextImageButtons(String imageName, int buttonWidth, int[] buttonHeights, int[] textLefts, String[] texts, ImageButtonsCallback handler) /* */ { /* 79 */ this(imageName, buttonWidth, buttonHeights, textLefts, texts, handler, defFont); /* */ } /* */ /* */ /* */ public TextImageButtons(String imageName, int buttonWidth, int[] buttonHeights, int[] textLefts, String[] texts, ImageButtonsCallback handler, Font f) /* */ { /* 85 */ super(imageName, buttonWidth, buttonHeights, handler); /* 86 */ this.xText = textLefts; /* 87 */ this.texts = texts; /* 88 */ this.buttonCount = buttonHeights.length; /* 89 */ this.font = f; /* */ /* 91 */ this.buttonBottoms = new int[this.buttonCount]; /* 92 */ int lastBottom = 0; /* 93 */ for (int i = 0; i < this.buttonCount; i++) { /* 94 */ lastBottom += buttonHeights[i]; /* 95 */ this.buttonBottoms[i] = lastBottom; /* */ } /* */ } /* */ /* */ public void setTexts(String[] newTexts) { /* 100 */ assert (newTexts.length == this.texts.length); /* 101 */ this.texts = newTexts; /* 102 */ repaint(); /* */ } /* */ /* */ public String getText(int i) { /* 106 */ return this.texts[i]; /* */ } /* */ /* */ protected Graphics drawButton(Graphics g, int button, int state) /* */ { /* 111 */ return drawButton(g, button, state, Color.white); /* */ } /* */ /* */ protected Graphics drawButton(Graphics g, int button, int state, Color c) /* */ { /* 116 */ if ((button >= 0) && (button < this.buttonCount) && (this.texts[button] != null)) { /* 117 */ g = super.drawButton(g, button, state); /* */ /* 119 */ if ((g != null) || ((g = getGraphics()) != null)) { /* 120 */ g.setColor(c); /* */ /* 122 */ g.setFont(this.font); /* 123 */ g.drawString(this.texts[button], this.xText[button], /* 124 */ this.buttonBottoms[button] - 4); /* */ } /* */ } else { /* 127 */ g = super.drawButton(g, button, 0); /* */ } /* 129 */ return g; /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\TextImageButtons.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */