Exemplo n.º 1
0
  public ICSSFont createFont(ICSSStyle style) {
    String fontfamily = (String) style.getStyleProperty(ICSSPropertyID.ATTR_FONT_FAMILY);
    Object fontsizeobj = style.getStyleProperty(ICSSPropertyID.ATTR_FONT_SIZE);
    int fontsize;
    fontsize = getFontSize(style, fontsizeobj);
    int fontstyle = getFontStyle(style);
    int fontweight = ((Integer) style.getStyleProperty(ICSSPropertyID.ATTR_FONT_WEIGHT)).intValue();

    return new CSSFont(fontfamily, fontsize, fontstyle, fontweight, resolveFontStyleString(style));
  }
Exemplo n.º 2
0
 private String resolveFontStyleString(ICSSStyle style) {
   StringBuffer sb = new StringBuffer();
   sb.append(ICSSPropertyID.ATTR_FONT_FAMILY).append(":"); // $NON-NLS-1$
   sb.append("'")
       .append( //$NON-NLS-1$
           (String) style.getStyleProperty(ICSSPropertyID.ATTR_FONT_FAMILY))
       .append("'"); // $NON-NLS-1$
   sb.append(";"); // $NON-NLS-1$
   sb.append(ICSSPropertyID.ATTR_FONT_STYLE).append(":"); // $NON-NLS-1$
   sb.append((String) style.getStyleProperty(ICSSPropertyID.ATTR_FONT_STYLE))
       .append(";"); // $NON-NLS-1$
   sb.append(ICSSPropertyID.ATTR_FONT_WEIGHT).append(":"); // $NON-NLS-1$
   sb.append(((Integer) style.getStyleProperty(ICSSPropertyID.ATTR_FONT_WEIGHT)).toString())
       .append(";"); // $NON-NLS-1$
   sb.append(ICSSPropertyID.ATTR_FONT_SIZE).append(":"); // $NON-NLS-1$
   int fontSize = getFontSize(style, style.getStyleProperty(ICSSPropertyID.ATTR_FONT_SIZE));
   sb.append(Integer.toString(fontSize));
   return sb.toString();
 }
Exemplo n.º 3
0
 /** @param style */
 private int getFontStyle(ICSSStyle style) {
   int fontstyle;
   String fontstylestr = (String) style.getStyleProperty(ICSSPropertyID.ATTR_FONT_STYLE);
   if (ICSSPropertyID.VAL_ITALIC.equals(fontstylestr)
       || ICSSPropertyID.VAL_OBLIQUE.equals(fontstylestr)) {
     fontstyle = SWT.ITALIC;
   } else {
     fontstyle = SWT.NORMAL;
   }
   return fontstyle;
 }
Exemplo n.º 4
0
  /**
   * @param info
   * @param tableHeight
   */
  public void calculateHeight(TableInfo info, int tableHeight) {
    ICSSStyle style = this.getFigure().getCSSStyle();
    if (style == null) {
      this._rowHeight = -1;
    } else {
      Object height = style.getStyleProperty(ICSSPropertyID.ATTR_HEIGHT);
      Length recommendedHeight = (height instanceof Length) ? (Length) height : null;

      int rh = 0;
      if (recommendedHeight == null || recommendedHeight.getValue() <= 0) {
        rh = 0;
      } else {
        if (recommendedHeight.isPercentage()) {
          // not supported.
        } else {
          rh = recommendedHeight.getValue();
        }
        if (rh > 0 && !style.isSizeIncludeBorderPadding()) {
          rh += style.getBorderInsets().getHeight() + style.getPaddingInsets().getHeight();
        }
      }
      this._rowHeight = rh;
    }
  }