Package com.adobe.dp.css

Examples of com.adobe.dp.css.CSSName


        FontResource fontResource = epub.createFontResource(folder + "fonts/" + resName + ".otf", bds);
        FontFaceRule face = styleResource.getStylesheet().createFontFace(fontResource);
        face.set("font-family", new CSSQuotedString(entry.familyName));
        switch (entry.weight) {
        case FontPropertyConstants.WEIGHT_NORMAL:
          face.set("font-weight", new CSSName("normal"));
          break;
        case FontPropertyConstants.WEIGHT_BOLD:
          face.set("font-weight", new CSSName("bold"));
          break;
        default:
          face.set("font-weight", new CSSNumber(new Integer(entry.weight)));
          break;
        }
        switch (entry.style) {
        case FontPropertyConstants.STYLE_ITALIC:
          face.set("font-style", new CSSName("italic"));
          break;
        case FontPropertyConstants.STYLE_OBLIQUE:
          face.set("font-style", new CSSName("oblique"));
          break;
        default:
          face.set("font-style", new CSSName("normal"));
          break;
        }

      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here


      // 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"));

      // create first chapter resource
      OPSResource chapter1 = epub.createOPSResource("OPS/chapter1.html");
      epub.addToSpine(chapter1);
View Full Code Here

      // 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)
View Full Code Here

                      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
                      //getCoverResource().putSerializationAttribute(null, "linear", "no");
                      getEpub().addToSpine(getCoverResource());
                    }
View Full Code Here

            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);
            rule.set("border-collapse", new CSSName("collapse"));
            rule.set("border", new CSSName("1px solid black"));
            selector = getStylesheet().getSimpleSelector("td",null);
            rule = getStylesheet().getRuleForSelector(selector, true);
            rule.set("border", new CSSName("1px solid black"));
            selector = getStylesheet().getSimpleSelector("tr", null);
            rule = getStylesheet().getRuleForSelector(selector, true);
            rule.set("border", new CSSName("1px solid black"));

        } else if (e instanceof TableTableRowElement) {
            TableTableRowElement otl = (TableTableRowElement) e;
            newElement = getCurrentResource().getDocument().createElement("tr");
            dstElement.add(newElement);
View Full Code Here

                    || e.getKey().getName().getLocalName().equals("margin-bottom")
                    || e.getKey().getName().getLocalName().equals("line-height")) {

                SelectorRule rule = getStylesheet().getRuleForSelector(selector, true);

                rule.set(e.getKey().getName().getLocalName(), new CSSName(e.getValue()));
            } else if (e.getKey().getName().getLocalName().equals("font-size")) {
                SelectorRule rule = getStylesheet().getRuleForSelector(selector, true);
                String s = e.getValue();
                if (s.endsWith("pt")) {
                    s = s.substring(0, s.length() - 2);
                    BigDecimal ref = new BigDecimal(12);
                    BigDecimal val = new BigDecimal(s);

                    rule.set(e.getKey().getName().getLocalName(), new CSSLength(val
                            .divide(ref, 2, RoundingMode.HALF_UP).doubleValue(), "em"));
                } else {
                    rule.set(e.getKey().getName().getLocalName(), new CSSName(e.getValue()));
                }
            } else if (e.getKey().getName().getLocalName().equals("text-underline-style")&&!e.getValue().equals("none")) {
                SelectorRule rule = getStylesheet().getRuleForSelector(selector, true);
                rule.set("text-decoration", new CSSName("underline"));
                rule.set(e.getKey().getName().getLocalName(), new CSSName(e.getValue()));
            } else if (e.getKey().getName().getLocalName().equals("text-align")) {
                SelectorRule rule = getStylesheet().getRuleForSelector(selector, true);
                String val = e.getValue();
                if (val.equals("end")) {
                    val = "right";
                } else if (val.equals("start")) {
                    val = "left";
                }
                rule.set(e.getKey().getName().getLocalName(), new CSSName(val));
            } else if (e.getKey().getName().getLocalName().equals("font-name")) {
                SelectorRule rule = getStylesheet().getRuleForSelector(selector, true);

                rule.set("font-family", new CSSQuotedString(e.getValue()));
            } else if (e.getKey().getName().getLocalName().equals("text-indent")) {
                SelectorRule rule = getStylesheet().getRuleForSelector(selector, true);

                rule.set(e.getKey().getName().getLocalName(), new CSSName(e.getValue()));
            }else if (e.getKey().getName().getLocalName().equals("horizontal-pos")) {//for images
                SelectorRule rule = getStylesheet().getRuleForSelector(selector, true);
                String pos="center";
                if(e.getValue().contains("left")){
                  pos="left";
View Full Code Here

     
     
     
        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");
        idiv.setClassName(box.getStyleName());
        stylesPropsToCSS(box.getAutomaticStyle().getStyleProperties(), idiv.getClassName());
        dstElem.add(idiv);
        return idiv;
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("-")){
        // rule.set("text-indent", new CSSLength(0,"em"));
        // }
        selector = getStylesheet().getSimpleSelector(null, "Footnote");
        rule = getStylesheet().getRuleForSelector(selector, true);

        // if(rule.get("text-indent")!=null&&rule.get("text-indent").toCSSString().startsWith("-")){
        // rule.set("text-indent", new CSSLength(0,"em"));
        // }

        selector = getStylesheet().getSimpleSelector("a", "fnLink");
        rule = getStylesheet().getRuleForSelector(selector, true);
        rule.set("vertical-align", new CSSName("super"));
        rule.set("font-size", new CSSLength(0.80, "em"));
    }
View Full Code Here

TOP

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

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.