Beispiel #1
0
  /**
   * 绘制选单
   *
   * @param g
   * @param color1
   * @param color2
   */
  public void drawChoice(LGraphics g) {
    if (!visible) {
      return;
    }
    int x1 = this.getX() - 5;
    int y1 = this.getY();
    int x2 = this.getWidth() + 20;
    int y2 = this.getAllHeight() + 10;
    int w = x2 + 15;
    int h = y2 + 10;
    if (dialogImage == null) {
      dialogImage = createDefaultDialog(w, h);
    }

    Font font = g.getFont();
    try {
      g.setFont(defFont);
      // 选中项
      int i = getDrawContent();

      g.drawImage(dialogImage, x1, y1 - 5);
      if (i >= 0 && i < maxSize) {
        LGradation.getInstance(Color.white, Color.black, getWidth() + 6, getSpace())
            .drawHeight(g, x1 + 14, y1 + getSpace() * getDrawContent() + 2);
        g.setColor(Color.darkGray);
        g.drawRect(x1 + 14, y1 + getSpace() * getDrawContent() + 2, getWidth() + 6, getSpace());
      }

      int index = 0;
      // 遍历文字与颜色信息
      for (; ; ) {
        if (index >= maxSize) {
          break;
        }
        int viewIndex = index + view;
        if (viewIndex >= choice.length) {
          break;
        }
        Color nColor;
        if (colors[viewIndex] != null) {
          nColor = colors[viewIndex];
        } else {
          nColor = Color.white;
        }
        int i1 = 0;
        for (int j1 = 0; j1 < choice[viewIndex].length; j1++) {
          g.drawStyleString(
              choice[viewIndex][j1],
              posX + i1 + 14,
              posY + index * getSpace() + getHeight(),
              Color.darkGray,
              nColor);
          i1 += mesList[j1] + tab;
        }
        index++;
      }
    } finally {
      g.setFont(font);
    }
  }
 /**
  * 创建默认的选择器背景图片
  *
  * @param w
  * @param h
  * @return
  */
 private LImage createDefaultDialog(int w, int h) {
   if (lazyDialog == null) {
     lazyDialog = new HashMap<String, LImage>(10);
   }
   int hash = 1;
   hash = LSystem.unite(hash, w);
   hash = LSystem.unite(hash, h);
   String key = String.valueOf(hash);
   LImage o = (LImage) lazyDialog.get(key);
   if (o == null) {
     o = LImage.createImage(w, h, true);
     LGraphics g = o.getLGraphics();
     LGradation.getInstance(Color.white, Color.black, w, h).drawHeight(g, 0, 0);
     g.setColor(Color.black);
     g.drawRect(0, 0, w - 1, h - 1);
     g.dispose();
     lazyDialog.put(key, o);
   }
   return o;
 }
Beispiel #3
0
 public void draw(LGraphics g, int x, int y, int w, int h) {
   switch (style) {
     case 0:
       Color oldColor = g.getColor();
       g.setAntiAlias(true);
       g.setColor(color);
       float alpha = 0.0f;
       int nx = x + w / 2 - (int) r * 4, ny = y + h / 2 - (int) r * 4;
       g.translate(nx, ny);
       for (Iterator it = list.iterator(); it.hasNext(); ) {
         Shape s = (Shape) it.next();
         alpha = isRunning ? alpha + 0.1f : 0.5f;
         g.setAlpha(alpha);
         g.fill(s);
       }
       g.setAntiAlias(false);
       g.setAlpha(1.0F);
       g.translate(-nx, -ny);
       g.setColor(oldColor);
       break;
     case 1:
       g.translate(x, y);
       g.setAntialiasAll(true);
       g.setColor(fill);
       g.drawRect(0, 0, width, height);
       g.setStroke(stroke);
       int sa = angle % 360;
       g.setPaint(border);
       g.drawArc(
           x + (width - paintWidth) / 2,
           y + (height - paintHeight) / 2,
           paintWidth,
           paintHeight,
           sa,
           sa + ANGLE_STEP);
       g.setAntialiasAll(false);
       g.translate(-x, -y);
       break;
   }
 }