コード例 #1
0
  private void createLabel(Composite c, int span, String content, Image image, LabelAttributes la) {
    if (content == null && image == null) return;

    Label l = new Label(c, la.getFontStyle());
    GridData gd = new GridData();
    gd.verticalSpan = span;
    gd.horizontalIndent = 5;
    if (content != null) l.setText(content);

    if (image != null) l.setImage(image);
    if (la.getForegroundColor() != null)
      l.setForeground(new Color(DisplayManager.getDefaultDisplay(), la.getForegroundColor()));

    Font initialFont = l.getFont();
    FontData[] fontData = initialFont.getFontData();
    for (int i = 0; i < fontData.length; i++) {
      fontData[i].setHeight(la.getFontSize());
      fontData[i].setStyle(la.getFontStyle());
    }
    Font newFont = new Font(DisplayManager.getDefaultDisplay(), fontData[0]);
    l.setFont(newFont);
    l.pack();

    l.setBackground(c.getBackground());
    l.setLayoutData(gd);
  }
コード例 #2
0
  private LabelAttributes getLabelAttributes(String c) {
    if (c == null) return new LabelAttributes();
    c = c.trim();
    if (!c.startsWith("%")) return new LabelAttributes();
    LabelAttributes la = new LabelAttributes();

    la.setForegroundColor(this.getColor(c));
    la.setFontSize(getFontSize(c));
    la.setFontStyle(getFontStyle(c));

    return la;
  }