Package com.adobe.dp.css

Examples of com.adobe.dp.css.Selector


    if (className == null)
      className = "z";
    props = props.cloneObject();
    int count = 1;
    cls = className;
    Selector selector;
    while (true) {
      selector = css.getSimpleSelector(null, cls);
      if (css.getRuleForSelector(selector, false) == null)
        break;
      cls = className + (count++);
View Full Code Here


    return e;
  }

  protected Object getBuiltInProperty(String propName) {
    if (builtInStylesheet != null) {
      Selector selector = builtInStylesheet.getSimpleSelector(elementName, null);
      SelectorRule rule = builtInStylesheet.getRuleForSelector(selector, false);
      if (rule != null)
        return rule.get(propName);
    }
    return null;
View Full Code Here

      // create a stylesheet
      StyleResource style = epub.createStyleResource("OPS/styles.css");
      Stylesheet stylesheet = style.getStylesheet();

      // style h1 element
      Selector h1Selector = stylesheet.getSimpleSelector("h1", null);
      SelectorRule h1Rule = stylesheet.getRuleForSelector(h1Selector,
          true);
      h1Rule.set("color", new CSSName("gray"));
      CSSValue[] border = { new CSSLength(2, "px"), new CSSName("solid"),
          new CSSName("gray") };
      h1Rule.set("border-bottom", new CSSValueList(' ', border));
      h1Rule.set("text-align", new CSSName("right"));
      CSSValue[] margin = { new CSSLength(2, "em"),
          new CSSLength(8, "px"), new CSSLength(1, "em"),
          new CSSLength(0, "px") };
      h1Rule.set("margin", new CSSValueList(' ', margin));

      // style p element
      Selector pSelector = stylesheet.getSimpleSelector("p", null);
      SelectorRule pRule = stylesheet.getRuleForSelector(pSelector, true);
      pRule.set("margin", new CSSLength(0, "px"));
      pRule.set("text-indent", new CSSLength(1, "em"));
      pRule.set("text-align", new CSSName("justify"));
View Full Code Here

      // create a stylesheet
      StyleResource style = epub.createStyleResource("OPS/styles.css");
      Stylesheet stylesheet = style.getStylesheet();

      // style h1 element
      Selector h1Selector = stylesheet.getSimpleSelector("h1", null);
      SelectorRule h1Rule = stylesheet.getRuleForSelector(h1Selector,
          true);
      h1Rule.set("color", new CSSName("gray"));
      CSSValue[] border = { new CSSLength(2, "px"), new CSSName("solid"),
          new CSSName("gray") };
      h1Rule.set("border-bottom", new CSSValueList(' ', border));
      h1Rule.set("text-align", new CSSName("right"));
      CSSValue[] margin = { new CSSLength(2, "em"),
          new CSSLength(8, "px"), new CSSLength(1, "em"),
          new CSSLength(0, "px") };
      h1Rule.set("margin", new CSSValueList(' ', margin));
      h1Rule.set("font-family", new CSSQuotedString("Adobe Garamond Pro"));

      // style p element
      Selector pSelector = stylesheet.getSimpleSelector("p", null);
      SelectorRule pRule = stylesheet.getRuleForSelector(pSelector, true);
      pRule.set("margin", new CSSLength(0, "px"));
      pRule.set("text-indent", new CSSLength(1, "em"));
      pRule.set("text-align", new CSSName("justify"));
      h1Rule.set("font-family", new CSSQuotedString("Chaparral Pro"));

      // style bitmap class (JPEG image)
      Selector bitmapSelector = stylesheet.getSimpleSelector(null,
          "bitmap");
      SelectorRule bitmapRule = stylesheet.getRuleForSelector(
          bitmapSelector, true);
      bitmapRule.set("width", new CSSLength(80, "%"));
      bitmapRule.set("max-width", new CSSLength(553, "px"));

      // style container class (container for JPEG image)
      Selector containerSelector = stylesheet.getSimpleSelector("p",
          "container");
      SelectorRule containerRule = stylesheet.getRuleForSelector(
          containerSelector, true);
      containerRule.set("text-align", new CSSName("center"));
      containerRule.set("text-indent", new CSSLength(0, "px"));
      CSSValue[] padval = { new CSSLength(0.5, "em"), new CSSLength(0, "px") };
      containerRule.set("padding", new CSSValueList(' ', padval));

      // style svgimage class (embedded SVG)
      Selector svgimageSelector = stylesheet.getSimpleSelector(null,
          "svgimage");
      SelectorRule svgimageRule = stylesheet.getRuleForSelector(svgimageSelector, true);
      svgimageRule.set("width", new CSSLength(80, "%"));
      CSSValue[] padval1 = { new CSSLength(0.5, "em"), new CSSLength(10, "%") };
      svgimageRule.set("padding", new CSSValueList(' ', padval1));

      // style label1 class (text in embedded SVG)
      Selector label1Selector = stylesheet.getSimpleSelector(null,
          "label1");
      SelectorRule label1Rule = stylesheet.getRuleForSelector(label1Selector, true);
      label1Rule.set("font-size", new CSSLength(36, "px"));
      label1Rule.set("font-family", new CSSQuotedString("Chaparral Pro"));

      // style label2 class (text in embedded SVG)
      Selector label2Selector = stylesheet.getSimpleSelector(null,
          "label2");
      SelectorRule label2Rule = stylesheet.getRuleForSelector(label2Selector, true);
      label2Rule.set("font-size", new CSSLength(48, "px"));
      label2Rule.set("font-family", new CSSQuotedString("Comic Sans MS"));
View Full Code Here

                    if(r!=null){
                      r.setId("cover-image");
                      getEpub().addMetadata(null, "cover", "cover-image");
                      //
                      covelem.setClassName("cover");
                      Selector selector = getStylesheet().getSimpleSelector("div", "cover");
                      SelectorRule rule = getStylesheet().getRuleForSelector(selector, true);
                      rule.set("width", new CSSName("100%"));
                      rule.set("text-align", new CSSName("center"));
                      getCoverResource().getDocument().getBody().add(covelem);
                      //TODO: uncomment the following row for best practies. But doing this some readers put the cover at the epub's end and not at the epub's beginning
View Full Code Here

            TableTableElement otl = (TableTableElement) e;
            dstElement = getCurrentResource().getDocument().getBody();
            newElement = getCurrentResource().getDocument().createElement("table");
            dstElement.add(newElement);
            newElement.setClassName(otl.getStyleName());
            Selector selector = getStylesheet().getSimpleSelector(null, otl.getStyleName());
            SelectorRule rule = getStylesheet().getRuleForSelector(selector, true);
          
            rule.set("width", new CSSName("100%"));
            selector = getStylesheet().getSimpleSelector("table", null);
            rule = getStylesheet().getRuleForSelector(selector, true);
View Full Code Here

        stylesPropsToCSS(props, null, className);

    }

    public void stylesPropsToCSS(Map<OdfStyleProperty, String> props, String elementName, String className) {
        Selector selector = getStylesheet().getSimpleSelector(elementName, className);
        for (Entry<OdfStyleProperty, String> e : props.entrySet()) {
            if (e.getKey().getName().getLocalName().equals("font-style")
                    || e.getKey().getName().getLocalName().equals("font-weight") ||

                    e.getKey().getName().getLocalName().equals("background-color")
View Full Code Here

    protected Element addImageBox(OdfDrawFrame box, Element dstElem) {
      
     
     
     
        Selector selector = getStylesheet().getSimpleSelector(null, box.getStyleName());
        SelectorRule rule = getStylesheet().getRuleForSelector(selector, true);
        rule.set("width", new CSSName("100%"));

        rule.set("text-align", new CSSName("center"));
        Element idiv = getFootnotesResource().getDocument().createElement("div");
View Full Code Here

    /**
     * Used to prevent negative indentations and to set default styles
     */
    public void setFootnotesCSSStyles() {
        Selector selector = getStylesheet().getSimpleSelector(null, "fnDiv");
        SelectorRule rule = getStylesheet().getRuleForSelector(selector, true);
        rule.set("page-break-before", new CSSName("always"));
        rule.set("margin-left", new CSSName("0em"));
        rule.set("margin-right", new CSSName("0em"));
        // if(rule.get("text-indent")!=null&&rule.get("text-indent").toCSSString().startsWith("-")){
View Full Code Here

                Utils.printStyleProps(ds.getStyleProperties());
            }
        }

       
        Selector selector = getStylesheet().getSimpleSelector("body", null);
        SelectorRule rule = getStylesheet().getRuleForSelector(selector, true);
        CSSValue minh = rule.get("font-size");
        selector = getStylesheet().getSimpleSelector("p", null);
        rule = getStylesheet().getRuleForSelector(selector, true);
        if (rule.get("margin-top") == null) {
View Full Code Here

TOP

Related Classes of com.adobe.dp.css.Selector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.