Java 类org.w3c.dom.css.CSSPrimitiveValue 实例源码
项目:icetone
文件:Element.java
@Override
public BaseElement setTextPadding(float left, float right, float top, float bottom) {
PropertyDeclaration declLeft = new PropertyDeclaration(CSSName.PADDING_LEFT,
new PropertyValue(CSSPrimitiveValue.CSS_PX, left, String.format("%fpx", left)), false,
StylesheetInfo.USER);
PropertyDeclaration declRight = new PropertyDeclaration(CSSName.PADDING_RIGHT,
new PropertyValue(CSSPrimitiveValue.CSS_PX, right, String.format("%fpx", right)), false,
StylesheetInfo.USER);
PropertyDeclaration declBottom = new PropertyDeclaration(CSSName.PADDING_BOTTOM,
new PropertyValue(CSSPrimitiveValue.CSS_PX, bottom, String.format("%fpx", bottom)), false,
StylesheetInfo.USER);
PropertyDeclaration declTop = new PropertyDeclaration(CSSName.PADDING_TOP,
new PropertyValue(CSSPrimitiveValue.CSS_PX, top, String.format("%fpx", top)), false,
StylesheetInfo.USER);
cssState.addAllCssDeclaration(declLeft);
applyCssPadding(declLeft);
cssState.addAllCssDeclaration(declRight);
applyCssPadding(declRight);
cssState.addAllCssDeclaration(declTop);
applyCssPadding(declTop);
cssState.addAllCssDeclaration(declBottom);
applyCssPadding(declBottom);
layoutChildren();
return this;
}
项目:icetone
文件:Element.java
protected void setCssSize(CSSName size, Size dim) {
PropertyDeclaration decl = dim == null
? CssExtensions.createValues(size, StylesheetInfo.USER, false, new PropertyValue(IdentValue.AUTO),
new PropertyValue(IdentValue.AUTO))
: CssExtensions.createValues(size, StylesheetInfo.USER, false,
dim.xUnit == Unit.AUTO ? new PropertyValue(IdentValue.AUTO)
: new PropertyValue(
dim.xUnit == Unit.PX ? CSSPrimitiveValue.CSS_PX
: CSSPrimitiveValue.CSS_PERCENTAGE,
dim.x, String.format("%f%s", dim.x, dim.xUnit == Unit.PX ? "px" : "%")),
dim.yUnit == Unit.AUTO ? new PropertyValue(IdentValue.AUTO)
: new PropertyValue(
dim.yUnit == Unit.PX ? CSSPrimitiveValue.CSS_PX
: CSSPrimitiveValue.CSS_PERCENTAGE,
dim.y, String.format("%f%s", dim.y, dim.yUnit == Unit.PX ? "px" : "%")));
cssState.addAllCssDeclaration(decl);
applyCss(decl);
layoutChildren();
}
项目:icetone
文件:Element.java
@Override
public BaseElement setHandlePosition(Vector4f borderHandles) {
PropertyDeclaration declLeft = new PropertyDeclaration(CssExtensions.HANDLE_POSITION_LEFT,
new PropertyValue(CSSPrimitiveValue.CSS_PX, borderHandles.w, String.format("%fpx", borderHandles.w)),
false, StylesheetInfo.USER);
PropertyDeclaration declRight = new PropertyDeclaration(CssExtensions.HANDLE_POSITION_RIGHT,
new PropertyValue(CSSPrimitiveValue.CSS_PX, borderHandles.y, String.format("%fpx", borderHandles.y)),
false, StylesheetInfo.USER);
PropertyDeclaration declBottom = new PropertyDeclaration(CssExtensions.HANDLE_POSITION_BOTTOM,
new PropertyValue(CSSPrimitiveValue.CSS_PX, borderHandles.z, String.format("%fpx", borderHandles.z)),
false, StylesheetInfo.USER);
PropertyDeclaration declTop = new PropertyDeclaration(CssExtensions.HANDLE_POSITION_TOP,
new PropertyValue(CSSPrimitiveValue.CSS_PX, borderHandles.x, String.format("%fpx", borderHandles.x)),
false, StylesheetInfo.USER);
cssState.addAllCssDeclaration(declLeft);
applyCss(declLeft);
cssState.addAllCssDeclaration(declRight);
applyCss(declRight);
cssState.addAllCssDeclaration(declTop);
applyCss(declTop);
cssState.addAllCssDeclaration(declBottom);
applyCss(declBottom);
layoutChildren();
return this;
}
项目:Push2Display
文件:ClipPathManager.java
/**
* Implements {@link
* ValueManager#createStringValue(short,String,CSSEngine)}.
*/
public Value createStringValue(short type, String value, CSSEngine engine)
throws DOMException {
switch (type) {
case CSSPrimitiveValue.CSS_IDENT:
if (value.equalsIgnoreCase(CSSConstants.CSS_NONE_VALUE)) {
return ValueConstants.NONE_VALUE;
}
break;
case CSSPrimitiveValue.CSS_URI:
return new URIValue(value,
resolveURI(engine.getCSSBaseURI(), value));
}
throw createInvalidStringTypeDOMException(type);
}
项目:Push2Display
文件:MaskManager.java
/**
* Implements {@link
* ValueManager#createStringValue(short,String,CSSEngine)}.
*/
public Value createStringValue(short type, String value, CSSEngine engine)
throws DOMException {
switch (type) {
case CSSPrimitiveValue.CSS_IDENT:
if (value.equalsIgnoreCase(CSSConstants.CSS_NONE_VALUE)) {
return ValueConstants.NONE_VALUE;
}
break;
case CSSPrimitiveValue.CSS_URI:
return new URIValue(value,
resolveURI(engine.getCSSBaseURI(), value));
}
throw createInvalidStringTypeDOMException(type);
}
项目:Push2Display
文件:StrokeMiterlimitManager.java
/**
* Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
*/
public Value createValue(LexicalUnit lu, CSSEngine engine)
throws DOMException {
switch (lu.getLexicalUnitType()) {
case LexicalUnit.SAC_INHERIT:
return SVGValueConstants.INHERIT_VALUE;
case LexicalUnit.SAC_INTEGER:
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
lu.getIntegerValue());
case LexicalUnit.SAC_REAL:
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
lu.getFloatValue());
default:
throw createInvalidLexicalUnitDOMException
(lu.getLexicalUnitType());
}
}
项目:icetone
文件:Element.java
protected void applyCssBgMap(PropertyDeclaration decl) {
CSSPrimitiveValue v = decl.getValue();
CSSName cssName = decl.getCSSName();
if (cssName == CssExtensions.BGMAP_COLOR) {
super.setBgMapColor(CssUtil.toColor(v.getCssText()));
} else if (cssName == CssExtensions.BGMAP_IMAGE) {
if (decl.getValue().getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
IdentValue ident = decl.asIdentValue();
if (ident == IdentValue.NONE || ident == IdentValue.AUTO) {
super.setBgMap(null);
} else
throw new UnsupportedOperationException(String.format("Invalid animation image type %s.", ident));
} else if (decl.getValue().getPrimitiveType() == CSSPrimitiveValue.CSS_URI) {
super.setBgMap(v.getStringValue());
} else
throw new UnsupportedOperationException(
String.format("Invalid animation image type %d", decl.getValue().getPrimitiveType()));
}
}
项目:Push2Display
文件:ColorProfileManager.java
/**
* Implements {@link
* ValueManager#createStringValue(short,String,CSSEngine)}.
*/
public Value createStringValue(short type, String value, CSSEngine engine)
throws DOMException {
switch (type) {
case CSSPrimitiveValue.CSS_IDENT:
String s = value.toLowerCase();
if (s.equals(CSSConstants.CSS_AUTO_VALUE)) {
return SVGValueConstants.AUTO_VALUE;
}
if (s.equals(CSSConstants.CSS_SRGB_VALUE)) {
return SVGValueConstants.SRGB_VALUE;
}
return new StringValue(CSSPrimitiveValue.CSS_IDENT, s);
case CSSPrimitiveValue.CSS_URI:
return new URIValue(value,
resolveURI(engine.getCSSBaseURI(), value));
}
throw createInvalidStringTypeDOMException(type);
}
项目:Push2Display
文件:OpacityManager.java
/**
* Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
*/
public Value createValue(LexicalUnit lu, CSSEngine engine)
throws DOMException {
switch (lu.getLexicalUnitType()) {
case LexicalUnit.SAC_INHERIT:
return SVGValueConstants.INHERIT_VALUE;
case LexicalUnit.SAC_INTEGER:
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
lu.getIntegerValue());
case LexicalUnit.SAC_REAL:
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
lu.getFloatValue());
}
throw createInvalidLexicalUnitDOMException(lu.getLexicalUnitType());
}
项目:icetone
文件:Element.java
@Override
public BaseElement setAtlas(Vector4f atlas) {
PropertyDeclaration declX = new PropertyDeclaration(CssExtensions.ATLAS_X,
new PropertyValue(CSSPrimitiveValue.CSS_PX, atlas.x, String.format("%fpx", atlas.x)), false,
StylesheetInfo.USER);
PropertyDeclaration declY = new PropertyDeclaration(CssExtensions.ATLAS_Y,
new PropertyValue(CSSPrimitiveValue.CSS_PX, atlas.y, String.format("%fpx", atlas.y)), false,
StylesheetInfo.USER);
PropertyDeclaration declW = new PropertyDeclaration(CssExtensions.ATLAS_WIDTH,
new PropertyValue(CSSPrimitiveValue.CSS_PX, atlas.z, String.format("%fpx", atlas.z)), false,
StylesheetInfo.USER);
PropertyDeclaration declH = new PropertyDeclaration(CssExtensions.ATLAS_HEIGHT,
new PropertyValue(CSSPrimitiveValue.CSS_PX, atlas.w, String.format("%fpx", atlas.w)), false,
StylesheetInfo.USER);
cssState.addAllCssDeclaration(declX);
applyCss(declX);
cssState.addAllCssDeclaration(declY);
applyCss(declY);
cssState.addAllCssDeclaration(declH);
applyCss(declH);
cssState.addAllCssDeclaration(declW);
applyCss(declW);
layoutChildren();
return this;
}
项目:icetone
文件:Element.java
@Override
public BaseElement setMargin(float left, float right, float top, float bottom) {
PropertyDeclaration declLeft = new PropertyDeclaration(CSSName.MARGIN_LEFT,
new PropertyValue(CSSPrimitiveValue.CSS_PX, left, String.format("%fpx", left)), false,
StylesheetInfo.USER);
PropertyDeclaration declRight = new PropertyDeclaration(CSSName.MARGIN_RIGHT,
new PropertyValue(CSSPrimitiveValue.CSS_PX, right, String.format("%fpx", right)), false,
StylesheetInfo.USER);
PropertyDeclaration declBottom = new PropertyDeclaration(CSSName.MARGIN_BOTTOM,
new PropertyValue(CSSPrimitiveValue.CSS_PX, bottom, String.format("%fpx", bottom)), false,
StylesheetInfo.USER);
PropertyDeclaration declTop = new PropertyDeclaration(CSSName.MARGIN_TOP,
new PropertyValue(CSSPrimitiveValue.CSS_PX, top, String.format("%fpx", top)), false,
StylesheetInfo.USER);
cssState.addAllCssDeclaration(declLeft);
applyCssMargin(declLeft);
cssState.addAllCssDeclaration(declRight);
applyCssMargin(declRight);
cssState.addAllCssDeclaration(declTop);
applyCssMargin(declTop);
cssState.addAllCssDeclaration(declBottom);
applyCssMargin(declBottom);
layoutChildren();
return this;
}
项目:Push2Display
文件:AbstractColorManager.java
/**
* Creates a color component from a lexical unit.
*/
protected Value createColorComponent(LexicalUnit lu) throws DOMException {
switch (lu.getLexicalUnitType()) {
case LexicalUnit.SAC_INTEGER:
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
lu.getIntegerValue());
case LexicalUnit.SAC_REAL:
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
lu.getFloatValue());
case LexicalUnit.SAC_PERCENTAGE:
return new FloatValue(CSSPrimitiveValue.CSS_PERCENTAGE,
lu.getFloatValue());
}
throw createInvalidRGBComponentUnitDOMException
(lu.getLexicalUnitType());
}
项目:Push2Display
文件:AbstractValueManager.java
/**
* Implements {@link
* ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}.
*/
public Value computeValue(CSSStylableElement elt,
String pseudo,
CSSEngine engine,
int idx,
StyleMap sm,
Value value) {
if ((value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) &&
(value.getPrimitiveType() == CSSPrimitiveValue.CSS_URI)) {
// Reveal the absolute value as the cssText now.
return new URIValue(value.getStringValue(),
value.getStringValue());
}
return value;
}
项目:Push2Display
文件:CursorManager.java
/**
* Implements {@link
* ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}.
*/
public Value computeValue(CSSStylableElement elt,
String pseudo,
CSSEngine engine,
int idx,
StyleMap sm,
Value value) {
if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
ListValue lv = (ListValue)value;
int len = lv.getLength();
ListValue result = new ListValue(' ');
for (int i=0; i<len; i++) {
Value v = lv.item(0);
if (v.getPrimitiveType() == CSSPrimitiveValue.CSS_URI) {
// Reveal the absolute value as the cssText now.
result.append(new URIValue(v.getStringValue(),
v.getStringValue()));
} else {
result.append(v);
}
}
return result;
}
return super.computeValue(elt, pseudo, engine, idx, sm, value);
}
项目:Push2Display
文件:FontSizeAdjustManager.java
/**
* Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}.
*/
public Value createValue(LexicalUnit lu, CSSEngine engine)
throws DOMException {
switch (lu.getLexicalUnitType()) {
case LexicalUnit.SAC_INHERIT:
return ValueConstants.INHERIT_VALUE;
case LexicalUnit.SAC_INTEGER:
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
lu.getIntegerValue());
case LexicalUnit.SAC_REAL:
return new FloatValue(CSSPrimitiveValue.CSS_NUMBER,
lu.getFloatValue());
case LexicalUnit.SAC_IDENT:
if (lu.getStringValue().equalsIgnoreCase
(CSSConstants.CSS_NONE_VALUE)) {
return ValueConstants.NONE_VALUE;
}
throw createInvalidIdentifierDOMException(lu.getStringValue());
}
throw createInvalidLexicalUnitDOMException(lu.getLexicalUnitType());
}
项目:Push2Display
文件:CSSOMValue.java
/**
* Converts the current value into inches.
*/
protected static float toInches(Value value) {
switch (value.getPrimitiveType()) {
case CSSPrimitiveValue.CSS_CM:
return (value.getFloatValue() / 2.54f);
case CSSPrimitiveValue.CSS_MM:
return (value.getFloatValue() / 25.4f);
case CSSPrimitiveValue.CSS_IN:
return value.getFloatValue();
case CSSPrimitiveValue.CSS_PT:
return (value.getFloatValue() / 72);
case CSSPrimitiveValue.CSS_PC:
return (value.getFloatValue() / 6);
default:
throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
}
}
项目:Push2Display
文件:CSSOMValue.java
/**
* Converts the current value into millimeters.
*/
protected static float toMillimeters(Value value) {
switch (value.getPrimitiveType()) {
case CSSPrimitiveValue.CSS_CM:
return (value.getFloatValue() * 10);
case CSSPrimitiveValue.CSS_MM:
return value.getFloatValue();
case CSSPrimitiveValue.CSS_IN:
return (value.getFloatValue() * 25.4f);
case CSSPrimitiveValue.CSS_PT:
return (value.getFloatValue() * 25.4f / 72);
case CSSPrimitiveValue.CSS_PC:
return (value.getFloatValue() * 25.4f / 6);
default:
throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
}
}
项目:Push2Display
文件:CSSOMValue.java
/**
* Converts the current value into points.
*/
protected static float toPoints(Value value) {
switch (value.getPrimitiveType()) {
case CSSPrimitiveValue.CSS_CM:
return (value.getFloatValue() * 72 / 2.54f);
case CSSPrimitiveValue.CSS_MM:
return (value.getFloatValue() * 72 / 25.4f);
case CSSPrimitiveValue.CSS_IN:
return (value.getFloatValue() * 72);
case CSSPrimitiveValue.CSS_PT:
return value.getFloatValue();
case CSSPrimitiveValue.CSS_PC:
return (value.getFloatValue() * 12);
default:
throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
}
}
项目:Push2Display
文件:CSSOMValue.java
/**
* Converts the current value into picas.
*/
protected static float toPicas(Value value) {
switch (value.getPrimitiveType()) {
case CSSPrimitiveValue.CSS_CM:
return (value.getFloatValue() * 6 / 2.54f);
case CSSPrimitiveValue.CSS_MM:
return (value.getFloatValue() * 6 / 25.4f);
case CSSPrimitiveValue.CSS_IN:
return (value.getFloatValue() * 6);
case CSSPrimitiveValue.CSS_PT:
return (value.getFloatValue() / 12);
case CSSPrimitiveValue.CSS_PC:
return value.getFloatValue();
default:
throw new DOMException(DOMException.INVALID_ACCESS_ERR, "");
}
}
项目:icetone
文件:Element.java
protected void setCssPosition(CSSName size, Measurement dim) {
PropertyDeclaration decl = dim == null
? CssExtensions.createValues(size, StylesheetInfo.USER, false, new PropertyValue(IdentValue.AUTO),
new PropertyValue(IdentValue.AUTO))
: CssExtensions.createValues(size, StylesheetInfo.USER, false,
dim.xUnit == Unit.AUTO ? new PropertyValue(IdentValue.AUTO)
: new PropertyValue(
dim.yUnit == Unit.PX ? CSSPrimitiveValue.CSS_PX
: CSSPrimitiveValue.CSS_PERCENTAGE,
dim.x, String.format("%fpx", dim.x)),
dim.yUnit == Unit.AUTO ? new PropertyValue(IdentValue.AUTO)
: new PropertyValue(
dim.yUnit == Unit.PX ? CSSPrimitiveValue.CSS_PX
: CSSPrimitiveValue.CSS_PERCENTAGE,
dim.y, String.format("%fpx", dim.y)));
cssState.addAllCssDeclaration(decl);
applyCss(decl);
layoutChildren();
}
项目:icetone
文件:GenericColor.java
@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() != CSSValue.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));
}
项目:icetone
文件:Element.java
/**
* Set the north, west, east and south borders in number of pixels
*
* @param nBorder
* float
* @param wBorder
* float
* @param eBorder
* float
* @param sBorder
* float
*/
@Override
public BaseElement setResizeBorders(float nBorder, float wBorder, float eBorder, float sBorder) {
PropertyDeclaration declW = new PropertyDeclaration(CSSName.BORDER_LEFT_WIDTH,
new PropertyValue(CSSPrimitiveValue.CSS_PX, eBorder, String.format("%fpx", eBorder)), false,
StylesheetInfo.USER);
PropertyDeclaration declE = new PropertyDeclaration(CSSName.BORDER_RIGHT_WIDTH,
new PropertyValue(CSSPrimitiveValue.CSS_PX, wBorder, String.format("%fpx", wBorder)), false,
StylesheetInfo.USER);
PropertyDeclaration declN = new PropertyDeclaration(CSSName.BORDER_TOP_WIDTH,
new PropertyValue(CSSPrimitiveValue.CSS_PX, nBorder, String.format("%fpx", nBorder)), false,
StylesheetInfo.USER);
PropertyDeclaration declS = new PropertyDeclaration(CSSName.BORDER_BOTTOM_WIDTH,
new PropertyValue(CSSPrimitiveValue.CSS_PX, sBorder, String.format("%fpx", sBorder)), false,
StylesheetInfo.USER);
cssState.addAllCssDeclaration(declW);
cssState.addAllCssDeclaration(declE);
cssState.addAllCssDeclaration(declN);
cssState.addAllCssDeclaration(declS);
applyCss(declW);
applyCss(declE);
applyCss(declN);
applyCss(declS);
layoutChildren();
return this;
}
项目:Push2Display
文件:CSSOMSVGColor.java
/**
* <b>DOM</b>: Implements {@link
* org.w3c.dom.svg.SVGColor#getColorType()}.
*/
public short getColorType() {
Value value = valueProvider.getValue();
int cssValueType = value.getCssValueType();
switch ( cssValueType ) {
case CSSValue.CSS_PRIMITIVE_VALUE:
int primitiveType = value.getPrimitiveType();
switch ( primitiveType ) {
case CSSPrimitiveValue.CSS_IDENT: {
if (value.getStringValue().equalsIgnoreCase
(CSSConstants.CSS_CURRENTCOLOR_VALUE))
return SVG_COLORTYPE_CURRENTCOLOR;
return SVG_COLORTYPE_RGBCOLOR;
}
case CSSPrimitiveValue.CSS_RGBCOLOR:
return SVG_COLORTYPE_RGBCOLOR;
}
// there was no case for this primitiveType, prevent throwing the other exception
throw new IllegalStateException("Found unexpected PrimitiveType:" + primitiveType );
case CSSValue.CSS_VALUE_LIST:
return SVG_COLORTYPE_RGBCOLOR_ICCCOLOR;
}
// should not happen
throw new IllegalStateException("Found unexpected CssValueType:" + cssValueType );
}
项目:Push2Display
文件:SVGAnimationEngine.java
protected AnimatableValue createAnimatableValue(AnimationTarget target,
String pn, Value v) {
FloatValue fv = (FloatValue) v;
short unit;
switch (fv.getPrimitiveType()) {
case CSSPrimitiveValue.CSS_NUMBER:
case CSSPrimitiveValue.CSS_DEG:
unit = SVGAngle.SVG_ANGLETYPE_DEG;
break;
case CSSPrimitiveValue.CSS_RAD:
unit = SVGAngle.SVG_ANGLETYPE_RAD;
break;
case CSSPrimitiveValue.CSS_GRAD:
unit = SVGAngle.SVG_ANGLETYPE_GRAD;
break;
default:
// XXX Do something better than returning null.
return null;
}
return new AnimatableAngleValue(target, fv.getFloatValue(), unit);
}
项目:Push2Display
文件:SVGAnimationEngine.java
protected AnimatableValue createAnimatableValue(AnimationTarget target,
String pn, Value v) {
if (v instanceof StringValue) {
return new AnimatableAngleOrIdentValue(target,
v.getStringValue());
}
FloatValue fv = (FloatValue) v;
short unit;
switch (fv.getPrimitiveType()) {
case CSSPrimitiveValue.CSS_NUMBER:
case CSSPrimitiveValue.CSS_DEG:
unit = SVGAngle.SVG_ANGLETYPE_DEG;
break;
case CSSPrimitiveValue.CSS_RAD:
unit = SVGAngle.SVG_ANGLETYPE_RAD;
break;
case CSSPrimitiveValue.CSS_GRAD:
unit = SVGAngle.SVG_ANGLETYPE_GRAD;
break;
default:
// XXX Do something better than returning null.
return null;
}
return new AnimatableAngleOrIdentValue(target, fv.getFloatValue(),
unit);
}
项目:Push2Display
文件:CSSUtilities.java
/**
* Returns an array of floating offsets representing the 'clip'
* property or null if 'auto'. The offsets are specified in the
* order top, right, bottom, left.
*
* @param e the element with the 'clip' property
*/
public static float[] convertClip(Element e) {
Value v = getComputedStyle(e, SVGCSSEngine.CLIP_INDEX);
int primitiveType = v.getPrimitiveType();
switch ( primitiveType ) {
case CSSPrimitiveValue.CSS_RECT:
float [] off = new float[4];
off[0] = v.getTop().getFloatValue();
off[1] = v.getRight().getFloatValue();
off[2] = v.getBottom().getFloatValue();
off[3] = v.getLeft().getFloatValue();
return off;
case CSSPrimitiveValue.CSS_IDENT:
return null; // 'auto' means no offsets
default:
// can't be reached
throw new IllegalStateException("Unexpected primitiveType:" + primitiveType );
}
}
项目:icetone
文件:Element.java
/**
* Sets the text of the element.
*
* @param text
* String The text to display.
*/
@Override
public BaseElement setText(String text) {
if (!Objects.equals(text, getText())) {
if (text == null) {
cssState.removeAllCssDeclaration(CSSName.CONTENT.toString());
} else {
PropertyDeclaration decl = new PropertyDeclaration(CSSName.CONTENT,
new PropertyValue(CSSPrimitiveValue.CSS_STRING, text, text), false, StylesheetInfo.USER);
cssState.addAllCssDeclaration(decl);
try {
applyCss(decl);
} catch (IndexOutOfBoundsException iiobe) {
System.err.println("**BUG** Text for " + toString() + " is '" + text + "'");
iiobe.printStackTrace();
}
}
layoutChildren();
}
return this;
}
项目:Push2Display
文件:PaintServer.java
/**
* Returns the value of one color component (0 <= result <= 255).
* @param v the value that defines the color component
*/
public static int resolveColorComponent(Value v) {
float f;
switch(v.getPrimitiveType()) {
case CSSPrimitiveValue.CSS_PERCENTAGE:
f = v.getFloatValue();
f = (f > 100f) ? 100f : (f < 0f) ? 0f : f;
return Math.round(255f * f / 100f);
case CSSPrimitiveValue.CSS_NUMBER:
f = v.getFloatValue();
f = (f > 255f) ? 255f : (f < 0f) ? 0f : f;
return Math.round(f);
default:
throw new IllegalArgumentException
("Color component argument is not an appropriate CSS value");
}
}
项目:icetone
文件:Element.java
protected void applyCssBorder(PropertyDeclaration decl) {
CSSName cssName = decl.getCSSName();
CSSPrimitiveValue v = decl.getValue();
if (cssName == CSSName.BORDER_LEFT_WIDTH) {
borders.x = v.getFloatValue(CSSPrimitiveValue.CSS_PX);
dirtyLayout(false, LayoutType.boundsChange());
} else if (cssName == CSSName.BORDER_RIGHT_WIDTH) {
borders.y = v.getFloatValue(CSSPrimitiveValue.CSS_PX);
dirtyLayout(false, LayoutType.boundsChange());
} else if (cssName == CSSName.BORDER_TOP_WIDTH) {
borders.z = v.getFloatValue(CSSPrimitiveValue.CSS_PX);
dirtyLayout(false, LayoutType.boundsChange());
} else if (cssName == CSSName.BORDER_BOTTOM_WIDTH) {
borders.w = v.getFloatValue(CSSPrimitiveValue.CSS_PX);
dirtyLayout(false, LayoutType.boundsChange());
}
}
项目:icetone
文件:GenericURIWithNone.java
@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() != CSSValue.CSS_INHERIT) {
checkIdentOrURIType(cssName, value);
if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
IdentValue ident = checkIdent(cssName, value);
checkValidity(cssName, ALLOWED, ident);
}
}
return Collections.singletonList(new PropertyDeclaration(cssName, value, important, origin));
}
项目:icetone
文件:AnimationIterationCount.java
@Override
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() != CSSValue.CSS_INHERIT) {
checkIdentNumberType(cssName, value);
if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
IdentValue ident = checkIdent(cssName, value);
checkValidity(cssName, allowed, ident);
} else if (value.getFloatValue() < 0.0f) {
throw new CSSParseException(cssName + " may not be negative", -1);
}
}
return Collections.singletonList(new PropertyDeclaration(cssName, value, important, origin));
}
项目:icetone
文件:SingleIdent.java
@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() != CSSValue.CSS_INHERIT) {
checkIdentType(cssName, value);
IdentValue ident = checkIdent(cssName, value);
checkValidity(cssName, getAllowed(), ident);
}
return Collections.singletonList(new PropertyDeclaration(cssName, value, important, origin));
}
项目:icetone
文件:Opacity.java
@Override
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() != CSSValue.CSS_INHERIT) {
checkIdentNumberOrPercentType(cssName, value);
if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
IdentValue ident = checkIdent(cssName, value);
checkValidity(cssName, allowed, ident);
} else if (value.getFloatValue() < 0.0f) {
throw new CSSParseException(cssName + " may not be negative", -1);
}
}
return Collections.singletonList(new PropertyDeclaration(cssName, value, important, origin));
}
项目:VISNode
文件:StylerValueConverter.java
/**
* Converts a value to a color
*
* @param value
* @return Color
*/
public static Color color(CSSValue value) {
RGBColor rgbColorValue = ((CSSPrimitiveValue)value).getRGBColorValue();
int r = (int)rgbColorValue.getRed().getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
int g = (int)rgbColorValue.getGreen().getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
int b = (int)rgbColorValue.getBlue().getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
return new Color(r, g, b);
}
项目:tm4e
文件:CSSDocumentHandler.java
private RGB createRGB(LexicalUnit value) {
RGBColor rgbColor = new RGBColorImpl(value);
int green = ((int) rgbColor.getGreen().getFloatValue(CSSPrimitiveValue.CSS_NUMBER));
int red = ((int) rgbColor.getRed().getFloatValue(CSSPrimitiveValue.CSS_NUMBER));
int blue = ((int) rgbColor.getBlue().getFloatValue(CSSPrimitiveValue.CSS_NUMBER));
return new RGB(red, green, blue);
}
项目:icetone
文件:Element.java
protected void setCssBounds(CSSName size, Vector4f dim) {
PropertyDeclaration decl = dim == null
? CssExtensions.createValues(size, StylesheetInfo.USER, false, new PropertyValue(IdentValue.AUTO),
new PropertyValue(IdentValue.AUTO))
: CssExtensions.createValues(size, StylesheetInfo.USER, false,
new PropertyValue(CSSPrimitiveValue.CSS_PX, dim.x, String.format("%fpx", dim.x)),
new PropertyValue(CSSPrimitiveValue.CSS_PX, dim.y, String.format("%fpx", dim.y)),
new PropertyValue(CSSPrimitiveValue.CSS_PX, dim.z, String.format("%fpx", dim.z)),
new PropertyValue(CSSPrimitiveValue.CSS_PX, dim.w, String.format("%fpx", dim.w)));
cssState.addAllCssDeclaration(decl);
applyCss(decl);
layoutChildren();
}
项目:icetone
文件:Button.java
public BaseElement setHoverVolume(float volume) {
PropertyDeclaration decl = new PropertyDeclaration(CssExtensions.VOLUME,
new PropertyValue(CSSPrimitiveValue.CSS_PERCENTAGE, (int) (volume * 100f),
String.valueOf((int) (volume * 100))),
false, StylesheetInfo.USER);
getCssState().addCssDeclaration(decl, PseudoStyle.hover);
applyCss(decl);
return this;
}
项目:icetone
文件:CssUtil.java
public static ColorRGBA toFontColor(PropertyDeclaration pd, StyledNode<?, ?> element) {
if (pd.getValue().getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) {
IdentValue iv = pd.asIdentValue();
if (iv == IdentValue.INHERIT)
return null;
} else if (pd != null && pd.getValue() instanceof PropertyValue) {
PropertyValue pv = (PropertyValue) pd.getValue();
return CssUtil.toColor(pv.getFSColor());
} else if (pd != null)
return CssUtil.toColor(pd.getValue().getCssText());
return null;
}
项目:Push2Display
文件:RectManager.java
/**
* Implements {@link
* ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}.
*/
public Value computeValue(CSSStylableElement elt,
String pseudo,
CSSEngine engine,
int idx,
StyleMap sm,
Value value) {
if (value.getCssValueType() != CSSValue.CSS_PRIMITIVE_VALUE) {
return value;
}
if (value.getPrimitiveType() != CSSPrimitiveValue.CSS_RECT) {
return value;
}
RectValue rect = (RectValue)value;
orientation = VERTICAL_ORIENTATION;
Value top = super.computeValue(elt, pseudo, engine, idx, sm,
rect.getTop());
Value bottom = super.computeValue(elt, pseudo, engine, idx, sm,
rect.getBottom());
orientation = HORIZONTAL_ORIENTATION;
Value left = super.computeValue(elt, pseudo, engine, idx, sm,
rect.getLeft());
Value right = super.computeValue(elt, pseudo, engine, idx, sm,
rect.getRight());
if (top != rect.getTop() ||
right != rect.getRight() ||
bottom != rect.getBottom() ||
left != rect.getLeft()) {
return new RectValue(top, right, bottom, left);
} else {
return value;
}
}
项目:Push2Display
文件:EnableBackgroundManager.java
/**
* Implements {@link
* ValueManager#createStringValue(short,String,CSSEngine)}.
*/
public Value createStringValue(short type, String value,
CSSEngine engine) {
if (type != CSSPrimitiveValue.CSS_IDENT) {
throw createInvalidStringTypeDOMException(type);
}
if (!value.equalsIgnoreCase(CSSConstants.CSS_ACCUMULATE_VALUE)) {
throw createInvalidIdentifierDOMException(value);
}
return SVGValueConstants.ACCUMULATE_VALUE;
}