Exemplo n.º 1
0
 public Dimension getCellContentSize(Object value) {
   if (value == null) {
     return null;
   }
   String s = value.toString();
   return new Dimension(font.stringWidth(s), font.getHeight());
 }
Exemplo n.º 2
0
 public void set(
     String[] mes,
     int languageIndex,
     LFont font,
     int x,
     int y,
     int w,
     int h,
     int offsetLeft,
     int offsetTop,
     boolean isLeft) {
   this.max = mes.length;
   this.message = new SRPGMessage[max];
   boolean isEnglish = (languageIndex == 3);
   for (int i = 0; i < max; i++) {
     message[i] = new SRPGMessage(mes[i], font, x, y, w, h);
     message[i].setEnglish(isEnglish);
     message[i].setDelay(180);
     if (isEnglish) {
       message[i].setMessageLength(font.stringWidth(mes[i]) / mes[i].length() * 4);
     } else if (languageIndex == 0 || languageIndex == 1) {
       message[i].setMessageLength(font.stringWidth(mes[i]) / mes[i].length());
     } else {
       message[i].setMessageLength(font.stringWidth(mes[i]) / mes[i].length() * 2 - 2);
       message[i].setLeftOffset(-20);
     }
     message[i].setTopOffset(15);
     if (isLeft) {
       message[i].left();
       if (!isEnglish) {
         if (languageIndex == 0 || languageIndex == 1) {
           message[i].setMessageLength(message[i].getMessageLength() - 1);
         } else {
           message[i].setMessageLength(font.stringWidth(mes[i]) / mes[i].length() - 1);
           message[i].setLeftOffset(10);
         }
       }
     }
     if (offsetLeft != 0) {
       message[i].setLeftOffset(offsetLeft);
     }
     if (offsetTop != 0) {
       message[i].setTopOffset(offsetTop);
     }
   }
   this.reset();
 }
Exemplo n.º 3
0
public class TextCellRenderer implements ICellRenderer {
  private LFont font = LFont.getDefaultFont();
  private LColor textColor = LColor.white;
  private Alignment alignment = Alignment.LEFT;

  public void paint(GLEx g, Object value, int x, int y, int width, int height) {
    if (value instanceof BindIcon) {
      int size = font.getHeight() - 4;
      BindIcon icon = (BindIcon) value;
      String s = icon.name;
      s = font.confineLength(s, width - size - 4);
      int entryOffset = 4 + alignment.alignX(width - 4, font.stringWidth(s));
      g.setFont(font);
      g.setColor(textColor);
      if (icon.texture != null) {
        g.drawTexture(icon.texture, x + 4, y + (font.getHeight() - size) / 2, size, size);
        g.drawString(s, x + size + entryOffset + 4, y + font.getHeight() - 4);
      } else {
        g.drawString(s, x + entryOffset, y + font.getHeight() - 4);
      }
    } else {
      String s = value.toString();
      s = font.confineLength(s, width - 4);
      int entryOffset = 4 + alignment.alignX(width - 4, font.stringWidth(s));
      g.setFont(font);
      g.setColor(textColor);
      g.drawString(s, x + entryOffset, y + font.getHeight() - 4);
    }
  }

  public void setFont(LFont font) {
    this.font = font;
  }

  public void setTextColor(LColor textColor) {
    this.textColor = textColor;
  }

  public Dimension getCellContentSize(Object value) {
    if (value == null) {
      return null;
    }
    String s = value.toString();
    return new Dimension(font.stringWidth(s), font.getHeight());
  }
}
Exemplo n.º 4
0
 public void paint(GLEx g, Object value, int x, int y, int width, int height) {
   if (value instanceof BindIcon) {
     int size = font.getHeight() - 4;
     BindIcon icon = (BindIcon) value;
     String s = icon.name;
     s = font.confineLength(s, width - size - 4);
     int entryOffset = 4 + alignment.alignX(width - 4, font.stringWidth(s));
     g.setFont(font);
     g.setColor(textColor);
     if (icon.texture != null) {
       g.drawTexture(icon.texture, x + 4, y + (font.getHeight() - size) / 2, size, size);
       g.drawString(s, x + size + entryOffset + 4, y + font.getHeight() - 4);
     } else {
       g.drawString(s, x + entryOffset, y + font.getHeight() - 4);
     }
   } else {
     String s = value.toString();
     s = font.confineLength(s, width - 4);
     int entryOffset = 4 + alignment.alignX(width - 4, font.stringWidth(s));
     g.setFont(font);
     g.setColor(textColor);
     g.drawString(s, x + entryOffset, y + font.getHeight() - 4);
   }
 }