protected TermLengthOrPercent getLengthOrPercentArg(Term<?> term) { if (term instanceof TermLengthOrPercent) return (TermLengthOrPercent) term; else if (isNumberArg(term) && getNumberArg(term) == 0) return CSSFactory.getTermFactory().createLength(0.0f); else return null; }
protected TermLength getLengthArg(Term<?> term) { if (term instanceof TermLength) return (TermLength) term; else if (isNumberArg(term) && getNumberArg(term) == 0) return CSSFactory.getTermFactory().createLength(0.0f); else return null; }
@Override public TermList setValue(List<Term<?>> value) { super.setValue(value); List<Term<?>> args = getSeparatedValues(DEFAULT_ARG_SEP, false); if (args.size() == 2 && (translateX = getLengthOrPercentArg(args.get(0))) != null && (translateY = getLengthOrPercentArg(args.get(1))) != null) { setValid(true); } else if (size() == 1 && (translateX = getLengthOrPercentArg(args.get(0))) != null) { translateY = CSSFactory.getTermFactory().createLength(0.0f); setValid(true); } return this; } }
private Term<?> stripSlash(Term<?> src) { if (src.getOperator() == Operator.SLASH) { if (src instanceof TermLength) return tf.createLength((Float) src.getValue(), ((TermLength) src).getUnit()); else if (src instanceof TermPercent) return tf.createPercent((Float) src.getValue()); else return src; } else return src; }
private Term<?> stripSlash(Term<?> src) { if (src.getOperator() == Operator.SLASH) { if (src instanceof TermLength) return tf.createLength((Float) src.getValue(), ((TermLength) src).getUnit()); else if (src instanceof TermPercent) return tf.createPercent((Float) src.getValue()); else return src; } else return src; }
private Term<?> stripSlash(Term<?> src) { if (src.getOperator() == Operator.SLASH) { if (src instanceof TermLength) return tf.createLength((Float) src.getValue(), ((TermLength) src).getUnit()); else if (src instanceof TermPercent) return tf.createPercent((Float) src.getValue()); else return src; } else return src; }
private Term<?> stripSlash(Term<?> src) { if (src.getOperator() == Operator.SLASH) { if (src instanceof TermLength) return tf.createLength((Float) src.getValue(), ((TermLength) src).getUnit()); else if (src instanceof TermPercent) return tf.createPercent((Float) src.getValue()); else return src; } else return src; }
TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("position", tf.createIdent("relative"))); ret.push(createDeclaration("border-width", tf.createLength(1f, Unit.px))); ret.push(createDeclaration("border-style", tf.createIdent("solid"))); ret.push(createDeclaration("border-color", tf.createColor(0, 0, 255))); ret.push(createDeclaration("margin", tf.createLength(0.5f, Unit.em))); ret.push(createDeclaration("width", tf.createLength(w, unit))); ret.push(createDeclaration("height", tf.createLength(h, unit)));
ret.push(createDeclaration("position", tf.createIdent("absolute"))); ret.push(createDeclaration("overflow", tf.createIdent("hidden"))); ret.push(createDeclaration("left", tf.createLength(style.getLeft(), unit))); ret.push(createDeclaration("top", tf.createLength(style.getTop(), unit))); ret.push(createDeclaration("line-height", tf.createLength(style.getLineHeight(), unit))); if (style.getFontFamily() != null) ret.push(createDeclaration("font-family", tf.createString(style.getFontFamily()))); if (style.getFontFamily() == null) size = size * unknownFontScale; ret.push(createDeclaration("font-size", tf.createLength(size, unit))); ret.push(createDeclaration("font-style", tf.createIdent(style.getFontStyle()))); if (style.getWordSpacing() != 0) ret.push(createDeclaration("word-spacing", tf.createLength((float) style.getWordSpacing(), unit))); if (style.getLetterSpacing() != 0) ret.push(createDeclaration("letter-spacing", tf.createLength((float) style.getLetterSpacing(), unit))); if (style.getColor() != null) ret.push(createDeclaration("width", tf.createLength(width, unit)));
protected NodeData createLineStyle(float x1, float y1, float x2, float y2) { HtmlDivLine line = new HtmlDivLine(x1, y1, x2, y2); String bside = line.getBorderSide(); NodeData ret = CSSFactory.createNodeData(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("position", tf.createIdent("absolute"))); ret.push(createDeclaration("position", tf.createIdent("absolute"))); ret.push(createDeclaration("left", tf.createLength(line.getLeft(), unit))); ret.push(createDeclaration("top", tf.createLength(line.getTop(), unit))); ret.push(createDeclaration("width", tf.createLength(line.getWidth(), unit))); ret.push(createDeclaration("height", tf.createLength((float) line.getHeight(), unit))); ret.push(createDeclaration(bside + "-width", tf.createLength(line.getLineStrokeWidth(), unit))); ret.push(createDeclaration(bside + "-style", tf.createIdent("solid"))); String color = colorString(getGraphicsState().getStrokingColor()); ret.push(createDeclaration(bside + "-color", tf.createColor(color))); if (line.getAngleDegrees() != 0) { TermFunction rotate = tf.createFunction(); rotate.setFunctionName("rotate").add(tf.createAngle(String.valueOf(line.getAngleDegrees()), Unit.deg, 1)); ret.push(createDeclaration("transform", rotate)); } return ret; }
if (CSSFactory.getImplyPixelLength() || ((TermInteger) term).getValue() == 0) { //0 is always allowed with no units TermLength tl = tf.createLength(((TermInteger) term).getValue(), TermNumber.Unit.px); return genericTerm(TermLength.class, tl, propertyName, lengthIdentification, sanify, properties, values); } else {
TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("position", tf.createIdent("absolute"))); ret.push(createDeclaration("left", tf.createLength(x, unit))); ret.push(createDeclaration("top", tf.createLength(y, unit))); ret.push(createDeclaration("width", tf.createLength(width - wcor, unit))); ret.push(createDeclaration("height", tf.createLength(height - wcor, unit))); ret.push(createDeclaration("border-width", tf.createLength(lw, unit))); ret.push(createDeclaration("border-style", tf.createIdent("solid"))); String color = colorString(getGraphicsState().getStrokingColor());
if (CSSFactory.getImplyPixelLength() || ((TermInteger) term).getValue() == 0) { //0 is always allowed with no units TermLength tl = tf.createLength(((TermInteger) term).getValue(), TermNumber.Unit.px); return genericTerm(TermLength.class, tl, propertyName, lengthIdentification, sanify, properties, values); } else {
if (CSSFactory.getImplyPixelLength() || ((TermInteger) term).getValue() == 0) { //0 is always allowed with no units TermLength tl = tf.createLength(((TermInteger) term).getValue(), TermNumber.Unit.px); return genericTerm(TermLength.class, tl, propertyName, lengthIdentification, range, properties, values); } else {
if (CSSFactory.getImplyPixelLength() || ((TermInteger) term).getValue() == 0) { //0 is always allowed with no units TermLength tl = tf.createLength(((TermInteger) term).getValue(), TermNumber.Unit.px); return genericTerm(TermLength.class, tl, propertyName, lengthIdentification, range, properties, values); } else {
vpos = tf.createPercent(50.0f); if (zpos == null) zpos = tf.createLength(0.0f);
vpos = tf.createPercent(50.0f); if (zpos == null) zpos = tf.createLength(0.0f);