main.push(d); main.inheritFrom(result.get((Element) walker.parentNode(), null)); result.put((Element) current, null, main.concretize()); pdata.push(d); pdata.inheritFrom(main); //always inherit from the main element style result.put((Element) current, pseudo, pdata.concretize());
private static void insertStyle(StringBuilder builder, NodeData nodeData) { List<String> keys = new ArrayList<String>(nodeData.getPropertyNames()); keys.remove("page"); Collections.sort(keys); for(String key : keys) { builder.append(key).append(": "); Term<?> value = nodeData.getValue(key, true); if (value != null) builder.append(termToString.apply(value)); else { CSSProperty prop = nodeData.getProperty(key); builder.append(prop); } builder.append("; "); } }
private static Map<String,RulePage> getPageRule(NodeData nodeData, Map<String,Map<String,RulePage>> pageRules) { BrailleCSSProperty.Page pageProperty; { if (nodeData != null) pageProperty = nodeData.<BrailleCSSProperty.Page>getProperty("page", false); else pageProperty = null; } String name; { if (pageProperty != null) { if (pageProperty == BrailleCSSProperty.Page.identifier) name = nodeData.<TermIdent>getValue(TermIdent.class, "page", false).getValue(); else name = pageProperty.toString(); } else name = null; } if (name != null) return getPageRule(name, pageRules); else return null; }
static NodeData makeNodeData(final List<Declaration> decls) { final NodeData main = CSSFactory.createNodeData(); for (final Declaration d : decls) main.push(d); return main; }
static NodeData makeNodeData(final List<Declaration> decls) { final NodeData main = CSSFactory.createNodeData(); for (final Declaration d : decls) main.push(d); return main; }
main.push(d); main.inheritFrom(result.get((Element) walker.parentNode(), null)); result.put((Element) current, null, main.concretize()); pdata.push(d); pdata.inheritFrom(main); //always inherit from the main element style result.put((Element) current, pseudo, pdata.concretize());
/** * Computes the style of an element with an eventual pseudo element for the given media. * @param el The DOM element. * @param pseudo A pseudo element that should be used for style computation or <code>null</code> if no pseudo element should be used (e.g. :after). * @param media Used media name (e.g. "screen" or "all") * @return The relevant declarations from the registered style sheets. */ public NodeData getElementStyle(Element el, PseudoDeclaration pseudo, String media) { Holder holder; if (UNIVERSAL_HOLDER.equals(media)) holder = rules.get(UNIVERSAL_HOLDER); else holder = Holder.union(rules.get(UNIVERSAL_HOLDER), rules.get(media)); List<Declaration> decls = getDeclarationsForElement(el, pseudo, holder); NodeData main = CSSFactory.createNodeData(); for (Declaration d : decls) main.push(d); return main; }
for (String property : nd.getPropertyNames()) { if (mCSS2Properties.contains(property)) { Term<?> t = nd.getValue(property, false); String str = null; if (t == null || t.getValue() == null) { str = nd.getProperty(property, false).toString().replace("_", "-") .toLowerCase(); } else if (t.getValue() instanceof List<?>) {
main.push(d); main.inheritFrom(result.get((Element) walker.parentNode(), null)); result.put((Element) current, null, main.concretize()); pdata.push(d); pdata.inheritFrom(main); //always inherit from the main element style result.put((Element) current, pseudo, pdata.concretize());
/** * Computes the style of an element with an eventual pseudo element for the given media. * @param el The DOM element. * @param pseudo A pseudo element that should be used for style computation or <code>null</code> if no pseudo element should be used (e.g. :after). * @param media Used media specification. * @return The relevant declarations from the registered style sheets. */ public NodeData getElementStyle(Element el, PseudoElement pseudo, MediaSpec media) { if (rules == null) classifyAllSheets(media); List<Declaration> decls = getDeclarationsForElement(el, pseudo, rules); NodeData main = CSSFactory.createNodeData(); for (Declaration d : decls) main.push(d); return main; }
main.push(d); main.inheritFrom(result.get((Element) walker.parentNode(), null)); result.put((Element) current, null, main.concretize()); pdata.push(d); pdata.inheritFrom(main); //always inherit from the main element style result.put((Element) current, pseudo, pdata.concretize());
/** * 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; }
/** * Creates a style definition used for the body element. * @return The body style definition. */ protected NodeData createBodyStyle() { NodeData ret = createBlockStyle(); TermFactory tf = CSSFactory.getTermFactory(); ret.push(createDeclaration("background-color", tf.createColor(255, 255, 255))); return ret; }
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)));
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; }
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()); ret.push(createDeclaration("border-color", tf.createColor(color))); ret.push(createDeclaration("background-color", tf.createColor(color)));
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) fillColor = style.getStrokeColor(); ret.push(createDeclaration("color", createTermColor(fillColor))); ret.push(createDeclaration("width", tf.createLength(width, unit)));