Beispiel #1
0
  public void draw(GraphicsWrapper gw) {
    // draw border
    gw.setColor(0, 0, 0);
    gw.drawRect(x0, y0, width, height);

    for (PaletteButton b : buttons) {
      b.draw(x0, y0, gw);
    }
  }
Beispiel #2
0
 public void draw(
     int palette_x,
     int palette_y, // upper left corner of the palette that contains us, in pixels
     GraphicsWrapper gw) {
   // draw background
   if (isPressed) {
     gw.setColor(0, 0, 0, Palette.alpha);
     gw.fillRect(palette_x + x0, palette_y + y0, width, height);
     // set the foreground color in preparation for drawing the label
     gw.setColor(1, 1, 1);
   } else {
     gw.setColor(1, 1, 1, Palette.alpha);
     gw.fillRect(palette_x + x0, palette_y + y0, width, height);
     // draw border
     gw.setColor(0, 0, 0);
     gw.drawRect(palette_x + x0, palette_y + y0, width, height);
   }
   // draw text label
   int stringWidth = Math.round(gw.stringWidth(label));
   gw.drawString(
       palette_x + x0 + (width - stringWidth) / 2,
       palette_y + y0 + height / 2 + Constant.TEXT_HEIGHT / 2,
       label);
 }