Beispiel #1
0
  public static synchronized void drawWhiteTextRect(
      MenuItem item, float x, float y, float w, float h) {
    Graphics2D g2 = item.menu.buff.g2;

    roundRect.setRoundRect(x, y, w, h, h / 3, h / 3);
    if (!item.isEnabled()) g2.setPaint(item.getStyle().getC("c.disabled"));
    else g2.setPaint(Color.white);
    g2.fill(roundRect);
    g2.setPaint(Color.black);
    g2.setStroke(new BasicStroke(item.getStyle().getF("f.strokeWeight")));
    g2.draw(roundRect);
  }
Beispiel #2
0
  public static void drawText(
      MenuItem item,
      String s,
      boolean centerH,
      boolean centerV,
      float x,
      float y,
      float width,
      float height) {

    try {
      Graphics2D g2 = (Graphics2D) item.menu.buff.g2;

      float descent = getTextDescent(item);

      float xOffset = 0, yOffset = 0;
      if (centerH) {
        float tWidth = getTextWidth(item, s);
        xOffset = (width - tWidth) / 2f;
      }
      if (centerV) {
        float tHeight = getTextHeight(item, s);
        yOffset = (height - tHeight) / 2f + descent;
      } else yOffset = height - descent;

      MenuStyle style = item.getStyle();
      PFont font = style.getFont("font");
      float fs = style.getF("f.fontSize");

      g2.setFont(font.getFont().deriveFont(fs));
      if (!item.isEnabled()) g2.setPaint(style.getC("c.foreground").brighter(120));
      else g2.setPaint(style.getC("c.foreground"));
      g2.setStroke(new BasicStroke(style.getF("f.strokeWeight")));
      g2.drawString(s, x + xOffset, y + yOffset);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 @Override
 public boolean isEnabled() {
   return ITEM.isEnabled();
 }