terms_stack.peek().term = tf.createString(extractTextUnescaped(ctx.string().getText())); } else if (ctx.IDENT() != null) { log.debug("VP - ident"); terms_stack.peek().term = tf.createIdent(extractTextUnescaped(ctx.IDENT().getText()), terms_stack.peek().dash); } else if (ctx.HASH() != null) { log.debug("VP - hash"); terms_stack.peek().term = tf.createColor(ctx.HASH().getText()); if (terms_stack.peek().term == null) { declaration_stack.peek().invalid = true; terms_stack.peek().term = tf.createPercent(ctx.PERCENTAGE().getText(), terms_stack.peek().unary); } else if (ctx.DIMENSION() != null) { log.debug("VP - dimension"); String dim = ctx.DIMENSION().getText(); terms_stack.peek().term = tf.createDimension(dim, terms_stack.peek().unary); if (terms_stack.peek().term == null) { log.info("Unable to create dimension from {}, unary {}", dim, terms_stack.peek().unary); terms_stack.peek().term = tf.createNumeric(ctx.NUMBER().getText(), terms_stack.peek().unary); } else if (ctx.UNIRANGE() != null) { log.debug("VP - unirange"); terms_stack.peek().term = tf.createUnicodeRange(ctx.UNIRANGE().getText()); } else if (ctx.URI() != null) { log.debug("VP - uri"); terms_stack.peek().term = tf.createURI(extractTextUnescaped(ctx.URI().getText()), extractBase(ctx.URI())); } else if (ctx.UNCLOSED_URI() != null && ((CSSToken) ctx.UNCLOSED_URI().getSymbol()).isValid()) { log.debug("VP - unclosed_uri"); terms_stack.peek().term = tf.createURI(extractTextUnescaped(ctx.UNCLOSED_URI().getText()), extractBase(ctx.UNCLOSED_URI())); } else if (ctx.funct() != null) {
cz.vutbr.web.css.Term<?> term = t.get(0); if (term instanceof cz.vutbr.web.css.TermString && term.getOperator() == null) terms_stack.peek().term = tf.createURI(((cz.vutbr.web.css.TermString) term).getValue(), extractBase(ctx.FUNCTION())); else declaration_stack.peek().invalid = true; declaration_stack.peek().invalid = true; else { TermCalc calc = tf.createCalc(t); if (calc != null) terms_stack.peek().term = calc; cz.vutbr.web.css.TermFunction function = tf.createFunction(); function.setFunctionName(fname); if (terms_stack.peek().unary == -1) //if started with minus, add the minus to the function name
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)));
/** * Tries to convert generic terms to more specific value types. Currently, colors (TermColor) and * rectangles (TermRect) are supported. * @param term the term to be converted * @return the corresponding more specific term type or {@code null} when nothing was found. */ private Term<?> findSpecificType(Term<?> term) { TermColor colorTerm = null; TermRect rectTerm = null; if (term instanceof TermIdent) { //idents - try to convert colors colorTerm = tf.createColor((TermIdent) term); } else if (term instanceof TermFunction) { // rgba(0,0,0) colorTerm = tf.createColor((TermFunction) term); if (colorTerm == null) rectTerm = tf.createRect((TermFunction) term); } //replace with more specific value if (colorTerm != null) { log.debug("term color is OK - creating - " + colorTerm.toString()); return colorTerm; } else if (rectTerm != null) { log.debug("term rect is OK - creating - " + rectTerm.toString()); return rectTerm; } else return null; }
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; }
termList.add(tf.createPair(counterName, new Integer(0))); termList.add(tf.createPair(counterName, ((TermInteger) term).getIntValue())); counterName = null; TermList list = tf.createList(termList.size()); list.addAll(termList); properties.put("counter-set", CounterReset.list_values);
((terms_scope)terms_stack.peek()).term = tf.createIdent(extractText(i), ((terms_scope)terms_stack.peek()).dash); ((terms_scope)terms_stack.peek()).term = tf.createNumeric(extractText(n), ((terms_scope)terms_stack.peek()).unary); ((terms_scope)terms_stack.peek()).term = tf.createPercent(extractText(p), ((terms_scope)terms_stack.peek()).unary); ((terms_scope)terms_stack.peek()).term = tf.createDimension(dim, ((terms_scope)terms_stack.peek()).unary); if(((terms_scope)terms_stack.peek()).term==null) { log.info("Unable to create dimension from {}, unary {}", dim, ((terms_scope)terms_stack.peek()).unary); if(s!=null) ((terms_scope)terms_stack.peek()).term = tf.createString(s); else ((declaration_scope)declaration_stack.peek()).invalid =true; ((terms_scope)terms_stack.peek()).term = tf.createURI(extractText(u), extractBase(u)); ((terms_scope)terms_stack.peek()).term = tf.createColor(extractText(h)); if(((terms_scope)terms_stack.peek()).term==null) ((declaration_scope)declaration_stack.peek()).invalid = true; TermExpression expr = tf.createExpression(exprval.substring(11,exprval.length()-1)); //strip the 'expression()' ((terms_scope)terms_stack.peek()).term = expr; TermFunction function = tf.createFunction(); function.setFunctionName(extractText(f)); if (((terms_scope)terms_stack.peek()).unary == -1) //if started with minus, add the minus to the function name TermColor colorTerm = null; if(term instanceof TermIdent) { colorTerm = tf.createColor((TermIdent)term);
funct_args_stack.peek().term = tf.createOperator('+'); } else if (ctx.MINUS() != null) { log.debug("VP - minus"); funct_args_stack.peek().term = tf.createOperator('-'); } else if (ctx.ASTERISK() != null) { log.debug("VP - *"); funct_args_stack.peek().term = tf.createOperator('*'); } else if (ctx.SLASH() != null) { log.debug("VP - /"); funct_args_stack.peek().term = tf.createOperator('/'); } else if (ctx.LPAREN() != null) { log.debug("VP - ("); funct_args_stack.peek().term = tf.createOperator('('); } else if (ctx.RPAREN() != null) { log.debug("VP - )"); funct_args_stack.peek().term = tf.createOperator(')'); } else if (ctx.COMMA() != null) { log.debug("VP - comma"); funct_args_stack.peek().term = tf.createOperator(','); } else if (ctx.string() != null) { log.debug("VP - string"); funct_args_stack.peek().term = tf.createString(extractTextUnescaped(ctx.string().getText())); } else if (ctx.IDENT() != null) { log.debug("VP - ident"); funct_args_stack.peek().term = tf.createIdent(extractTextUnescaped(ctx.IDENT().getText())); } else if (ctx.PERCENTAGE() != null) { log.debug("VP - percentage"); funct_args_stack.peek().term = tf.createPercent(ctx.PERCENTAGE().getText(), 1); } else if (ctx.DIMENSION() != null) {
"rotatez", "perspective")); TermList list = tf.createList();
Term<?> term = tf.createString(name); if (!storage.isEmpty()) term.setOperator(Operator.COMMA); allowedFamilies, tf.createIdent(name)); Term<?> term = tf.createTerm(generic); if (!storage.isEmpty()) term.setOperator(Operator.COMMA); Term<?> term = tf.createString(name); if (!storage.isEmpty()) term.setOperator(Operator.COMMA);
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; }
TermList list = tf.createList(2); for (int j = 0; j < 2; j++) list.add(tf.createPercent(50.0f)); else return false; //no values set else if (sz[1] == null) sz[1] = tf.createIdent("auto"); else //if used two elements, inform master iteration.inc(); TermList szlist = tf.createList(2); szlist.add(sz[0]); szlist.add(sz[1]);
vpos = tf.createPercent(0.0f); else return false; vpos = tf.createPercent(100.0f); else return false; hpos = tf.createPercent(0.0f); else return false; hpos = tf.createPercent(100.0f); else return false; value = tf.createPercent(50.0f); hpos = tf.createPercent(50.0f); if (vpos == null) vpos = tf.createPercent(50.0f); if (zpos == null) zpos = tf.createLength(0.0f); TermList list = tf.createList(); list.add(hpos); list.add(vpos);
TermList list = tf.createList(); TextDecoration dec = null; for (Term<?> term : d.asList()) { availableDecorations, (TermIdent) term)) != null) { list.add(tf.createTerm(dec)); } else return false;
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.getFontSize() != 0) if (style.getFontFamily() == null) size = size * unknownFontScale; ret.push(createDeclaration("font-size", tf.createLength(size, unit))); ret.push(createDeclaration("font-weight", tf.createIdent(style.getFontWeight()))); if (style.getFontStyle() != null) 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)));
@Override public Term<?> getSpecifiedValue(String name) { Term<?> ret = getValue(name, true); if (ret == null) ret = css.getDefaultValue(name); if (ret != null) { if (ret instanceof TermColor && ((TermColor) ret).getKeyword() == Keyword.CURRENT_COLOR) { //clone the value fot setting the current color final TermFactory tf = CSSFactory.getTermFactory(); ret = tf.createColor(tf.createIdent("currentColor")); //set the current color value TermColor cvalue = getValue(TermColor.class, "color", true); if (cvalue == null) cvalue = (TermColor) css.getDefaultValue("color"); ((TermColor) ret).setValue(cvalue.getValue()); } } return ret; }
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; }
TermList list = tf.createList(2); for (int j = 0; j < 2; j++) if (vv[j] == null) list.add(tf.createPercent(50.0f)); else list.add(vv[j]);
/** * Creates an empty block style definition. * @return */ protected NodeData createBlockStyle() { NodeData ret = CSSFactory.createNodeData(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("display", tf.createIdent("block"))); return ret; }
private void storeBackgroundPosition(Term<?>[] storage, BackgroundPosition bp, Term<?> term) { if (bp == BackgroundPosition.LEFT) setPositionValue(storage, 0, tf.createPercent(0.0f)); else if (bp == BackgroundPosition.RIGHT) setPositionValue(storage, 0, tf.createPercent(100.0f)); else if (bp == BackgroundPosition.TOP) setPositionValue(storage, 1, tf.createPercent(0.0f)); else if (bp == BackgroundPosition.BOTTOM) setPositionValue(storage, 1, tf.createPercent(100.0f)); else if (bp == BackgroundPosition.CENTER) setPositionValue(storage, -1, tf.createPercent(50.0f)); else setPositionValue(storage, -1, term); }