private List createTwoPercentValueResponse( float percent1, float percent2, boolean important, int origin) { PropertyValue value1 = new PropertyValue( CSSPrimitiveValue.CSS_PERCENTAGE, percent1, percent1 + "%"); PropertyValue value2 = new PropertyValue( CSSPrimitiveValue.CSS_PERCENTAGE, percent2, percent2 + "%"); List values = new ArrayList(2); values.add(value1); values.add(value2); PropertyDeclaration result = new PropertyDeclaration( CSSName.BACKGROUND_POSITION, new PropertyValue(values), important, origin); return Collections.singletonList(result); }
private static List createTwoValueResponse(CSSName cssName, CSSPrimitiveValue value1, CSSPrimitiveValue value2, int origin, boolean important) { List values = new ArrayList(2); values.add(value1); values.add(value2); PropertyDeclaration result = new PropertyDeclaration( cssName, new PropertyValue(values), important, origin); return Collections.singletonList(result); }
private PropertyValue createValueForIdent(IdentValue ident) { float percent = getPercentForIdent(ident); return new PropertyValue( CSSPrimitiveValue.CSS_PERCENTAGE, percent, percent + "%"); }
/** * Creates a <code>PropertyDeclaration</code> suitable for passing to * {@link #createLayoutStyle(PropertyDeclaration[])} or * {@link #createLayoutStyle(CascadedStyle, PropertyDeclaration[])} */ public static PropertyDeclaration createLayoutPropertyDeclaration( CSSName cssName, IdentValue display) { CSSPrimitiveValue val = new PropertyValue(display); // Urk... kind of ugly, but we really want this value to be used return new PropertyDeclaration(cssName, val, true, StylesheetInfo.USER); }
/** * Creates a <code>CascadedStyle</code>, setting the display property to * to the value of the <code>display</code> parameter. */ public static CascadedStyle createAnonymousStyle(IdentValue display) { CSSPrimitiveValue val = new PropertyValue(display); List<PropertyDeclaration> props = Collections.singletonList( new PropertyDeclaration(CSSName.DISPLAY, val, true, StylesheetInfo.USER)); return new CascadedStyle(props.iterator()); }
all.add(new PropertyDeclaration( CSSName.VERTICAL_ALIGN, new PropertyValue(marginBox.getInitialVerticalAlign()), false, StylesheetInfo.USER_AGENT)); all.add(new PropertyDeclaration( CSSName.TEXT_ALIGN, new PropertyValue(marginBox.getInitialTextAlign()), false, StylesheetInfo.USER_AGENT));
@Override public List buildDeclarations(CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue) values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() == CSSPrimitiveValue.CSS_INHERIT) { return Collections.singletonList(new PropertyDeclaration(cssName, value, important, origin)); } if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { IdentValue ident = checkIdent(cssName, value); checkValidity(cssName, ALLOWED, ident); if (ident == IdentValue.LEFT) { return Collections.singletonList(new PropertyDeclaration(cssName, new PropertyValue(CSSPrimitiveValue.CSS_PERCENTAGE, 0f, "0%"), important, origin)); } else if (ident == IdentValue.CENTER) { return Collections.singletonList(new PropertyDeclaration(cssName, new PropertyValue(CSSPrimitiveValue.CSS_PERCENTAGE, 50f, "50%"), important, origin)); } else { // if (ident == IdentValue.RIGHT) return Collections.singletonList(new PropertyDeclaration(cssName, new PropertyValue(CSSPrimitiveValue.CSS_PERCENTAGE, 100f, "100%"), important, origin)); } } else { checkLengthOrPercentType(cssName, value); return Collections.singletonList(new PropertyDeclaration(cssName, value, important, origin)); } } }
@Override public List buildDeclarations(CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue) values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() == CSSPrimitiveValue.CSS_INHERIT) { return Collections.singletonList(new PropertyDeclaration(cssName, value, important, origin)); } if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { IdentValue ident = checkIdent(cssName, value); checkValidity(cssName, ALLOWED, ident); if (ident == IdentValue.TOP) { return Collections.singletonList(new PropertyDeclaration(cssName, new PropertyValue(CSSPrimitiveValue.CSS_PERCENTAGE, 0f, "0%"), important, origin)); } else if (ident == IdentValue.CENTER) { return Collections.singletonList(new PropertyDeclaration(cssName, new PropertyValue(CSSPrimitiveValue.CSS_PERCENTAGE, 50f, "50%"), important, origin)); } else { // if (ident == IdentValue.BOTTOM) return Collections.singletonList(new PropertyDeclaration(cssName, new PropertyValue(CSSPrimitiveValue.CSS_PERCENTAGE, 100f, "100%"), important, origin)); } } else { checkLengthOrPercentType(cssName, value); return Collections.singletonList(new PropertyDeclaration(cssName, value, important, origin)); } } }
public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentOrString(cssName, value); if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { // Convert to string return Collections.singletonList( new PropertyDeclaration( cssName, new PropertyValue( CSSPrimitiveValue.CSS_STRING, value.getStringValue(), value.getCssText()), important, origin)); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); } }
public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentType(cssName, value); if (! value.getStringValue().equals("auto")) { // Treat as string since it won't be a proper IdentValue value = new PropertyValue( CSSPrimitiveValue.CSS_STRING, value.getStringValue(), value.getCssText()); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); } }
new PropertyDeclaration(cssName, new PropertyValue(values), important, origin));
new PropertyDeclaration(cssName, new PropertyValue( Collections.singletonList(data)), important, origin)); new PropertyDeclaration(cssName, new PropertyValue(result), important, origin));
public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentOrColorType(cssName, value); if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { FSRGBColor color = Conversions.getColor(value.getStringValue()); if (color != null) { return Collections.singletonList( new PropertyDeclaration( cssName, new PropertyValue(color), important, origin)); } IdentValue ident = checkIdent(cssName, value); checkValidity(cssName, ALLOWED, ident); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); } }
private PropertyValue hexcolor() throws IOException { //System.out.println("hexcolor()"); PropertyValue result = null; Token t = next(); if (t == Token.TK_HASH) { String s = getTokenValue(t); if ((s.length() != 3 && s.length() != 6) || ! isHexString(s)) { push(t); throw new CSSParseException('#' + s + " is not a valid color definition", getCurrentLine()); } FSRGBColor color = null; if (s.length() == 3) { color = new FSRGBColor( convertToInteger(s.charAt(0), s.charAt(0)), convertToInteger(s.charAt(1), s.charAt(1)), convertToInteger(s.charAt(2), s.charAt(2))); } else { /* s.length == 6 */ color = new FSRGBColor( convertToInteger(s.charAt(0), s.charAt(1)), convertToInteger(s.charAt(2), s.charAt(3)), convertToInteger(s.charAt(4), s.charAt(5))); } result = new PropertyValue(color); skip_whitespace(); } else { push(t); throw new CSSParseException(t, Token.TK_HASH, getCurrentLine()); } return result; }
new PropertyDeclaration(CSSName.CONTENT, new PropertyValue(resultValues), important, origin)); } else { return Collections.EMPTY_LIST;
new PropertyDeclaration(CSSName.QUOTES, new PropertyValue(resultValues), important, origin)); } else { return Collections.EMPTY_LIST;
private CSSPrimitiveValue convertToBorderColor(CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_IDENT && type != CSSPrimitiveValue.CSS_RGBCOLOR) { return null; } if (type == CSSPrimitiveValue.CSS_RGBCOLOR) { return value; } else { FSRGBColor color = Conversions.getColor(value.getStringValue()); if (color != null) { return new PropertyValue(color); } IdentValue ident = IdentValue.valueOf(value.getCssText()); if (ident == null || ident != IdentValue.TRANSPARENT) { return null; } return value; } } }
result = new PropertyValue(createRGBColorFromFunction(params)); } else if (f.equals("cmyk(")) { if (! isSupportCMYKColors()) { result = new PropertyValue(createCMYKColorFromFunction(params)); } else { result = new PropertyValue(new FSFunction(f.substring(0, f.length()-1), params));
public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); PropertyValue value = (PropertyValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentOrNumberType(cssName, value); short type = value.getPrimitiveType(); if (type == CSSPrimitiveValue.CSS_IDENT) { checkIdentType(cssName, value); IdentValue ident = checkIdent(cssName, value); checkValidity(cssName, getAllowed(), ident); } else if (type == CSSPrimitiveValue.CSS_NUMBER) { IdentValue weight = Conversions.getNumericFontWeight(value.getFloatValue()); if (weight == null) { throw new CSSParseException(value + " is not a valid font weight", -1); } PropertyValue replacement = new PropertyValue( CSSPrimitiveValue.CSS_IDENT, weight.toString(), weight.toString()); replacement.setIdentValue(weight); return Collections.singletonList( new PropertyDeclaration(cssName, replacement, important, origin)); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); }
return createTwoValueResponse(CSSName.BACKGROUND_SIZE, first, new PropertyValue(IdentValue.AUTO), origin, important);