protected static Integer getLengthValue(CalculatedStyle style, CSSName cssName) { FSDerivedValue widthValue = style.valueByName(cssName); if (widthValue instanceof LengthValue) { return new Integer((int)widthValue.asFloat()); } return null; } }
public float asFloat(CSSName cssName) { return valueByName(cssName).asFloat(); }
public float asFloat(CSSName cssName) { return valueByName(cssName).asFloat(); }
public float getLineHeight(CssContext ctx) { if (! _lineHeightResolved) { if (isIdent(CSSName.LINE_HEIGHT, IdentValue.NORMAL)) { float lineHeight1 = getFont(ctx).size * 1.1f; // Make sure rasterized characters will (probably) fit inside // the line box FSFontMetrics metrics = getFSFontMetrics(ctx); float lineHeight2 = (float)Math.ceil(metrics.getDescent() + Math.round(metrics.getAscent())); _lineHeight = Math.max(lineHeight1, lineHeight2); } else if (isLength(CSSName.LINE_HEIGHT)) { //could be more elegant, I suppose _lineHeight = getFloatPropertyProportionalHeight(CSSName.LINE_HEIGHT, 0, ctx); } else { //must be a number _lineHeight = getFont(ctx).size * valueByName(CSSName.LINE_HEIGHT).asFloat(); } _lineHeightResolved = true; } return _lineHeight; }
public float getLineHeight(CssContext ctx) { if (! _lineHeightResolved) { if (isIdent(CSSName.LINE_HEIGHT, IdentValue.NORMAL)) { float lineHeight1 = getFont(ctx).size * 1.1f; // Make sure rasterized characters will (probably) fit inside // the line box FSFontMetrics metrics = getFSFontMetrics(ctx); float lineHeight2 = (float)Math.ceil(metrics.getDescent() + Math.round(metrics.getAscent())); _lineHeight = Math.max(lineHeight1, lineHeight2); } else if (isLength(CSSName.LINE_HEIGHT)) { //could be more elegant, I suppose _lineHeight = getFloatPropertyProportionalHeight(CSSName.LINE_HEIGHT, 0, ctx); } else { //must be a number _lineHeight = getFont(ctx).size * valueByName(CSSName.LINE_HEIGHT).asFloat(); } _lineHeightResolved = true; } return _lineHeight; }
public Length asLength(CssContext c, CSSName cssName) { Length result = new Length(); FSDerivedValue value = valueByName(cssName); if (value instanceof LengthValue || value instanceof NumberValue) { if (value.hasAbsoluteUnit()) { result.setValue((int) value.getFloatProportionalTo(cssName, 0, c)); result.setType(Length.FIXED); } else { result.setValue((int) value.asFloat()); result.setType(Length.PERCENT); } } return result; }
public Length asLength(CssContext c, CSSName cssName) { Length result = new Length(); FSDerivedValue value = valueByName(cssName); if (value instanceof LengthValue || value instanceof NumberValue) { if (value.hasAbsoluteUnit()) { result.setValue((int) value.getFloatProportionalTo(cssName, 0, c)); result.setType(Length.FIXED); } else { result.setValue((int) value.asFloat()); result.setType(Length.PERCENT); } } return result; }