Package org.w3c.dom.css

Examples of org.w3c.dom.css.CSSPrimitiveValue


 
  public SpaceAfter(CSSValue value) { 
   
    debug(CSS_NAME, value);
   
    CSSPrimitiveValue cssPrimitiveValue = (CSSPrimitiveValue)value; 
    short ignored = 1;
    float fVal = cssPrimitiveValue.getFloatValue(ignored); // unit type ignored in cssparser
    if (fVal==0f) {
      this.setObject(BigInteger.ZERO);
      return;
    }

    int twip;
   
    short type = cssPrimitiveValue.getPrimitiveType();
    if (CSSPrimitiveValue.CSS_IN == type) {
      twip = UnitsOfMeasurement.inchToTwip(fVal);
    } else if (CSSPrimitiveValue.CSS_MM == type) {
      twip = UnitsOfMeasurement.mmToTwip(fVal)
    } else if (CSSPrimitiveValue.CSS_PT == type) {
View Full Code Here


      float fRed;
      float fGreen;
      float fBlue;

      CSSPrimitiveValue cssPrimitiveValue = (CSSPrimitiveValue) value;
      try {
          fRed = cssPrimitiveValue.getRGBColorValue().getRed()
                  .getFloatValue(ignored);
          fGreen = cssPrimitiveValue.getRGBColorValue().getGreen()
                  .getFloatValue(ignored);
          fBlue = cssPrimitiveValue.getRGBColorValue().getBlue()
                  .getFloatValue(ignored);
        shd.setFill(UnitsOfMeasurement.rgbTripleToHex(fRed, fGreen, fBlue)  );
       
      } catch (UnsupportedOperationException e) {
       
View Full Code Here

    CTShd shd = Context.getWmlObjectFactory().createCTShd();

    // PrimitiveType 25 -> RGBCOLOR
    short ignored = 1;

    CSSPrimitiveValue cssPrimitiveValue = (CSSPrimitiveValue)value;
    float fRed = cssPrimitiveValue.getRGBColorValue().getRed().getFloatValue(ignored);
    float fGreen = cssPrimitiveValue.getRGBColorValue().getGreen().getFloatValue(ignored);
    float fBlue = cssPrimitiveValue.getRGBColorValue().getBlue().getFloatValue(ignored);
   
    shd.setFill(UnitsOfMeasurement.rgbTripleToHex(fRed, fGreen, fBlue)  );

    this.setObject( shd  );
  }
View Full Code Here

    init(suffix);
    this.setObject(val);
  }
 
  public AbstractCellMargin(CSSValue value, String suffix) { 
    CSSPrimitiveValue cssPrimitiveValue = (CSSPrimitiveValue)value;
    TblWidth tblWidth = Context.getWmlObjectFactory().createTblWidth();
    short ignored = 1;
    float fVal = cssPrimitiveValue.getFloatValue(ignored); // unit type ignored in cssparser

    int twip;
   
    short type = cssPrimitiveValue.getPrimitiveType();
    if (CSSPrimitiveValue.CSS_IN == type) {
      twip = UnitsOfMeasurement.inchToTwip(fVal);
    } else if (CSSPrimitiveValue.CSS_MM == type) {
      twip = UnitsOfMeasurement.mmToTwip(fVal);   
    } else if (CSSPrimitiveValue.CSS_PERCENTAGE == type) {
View Full Code Here

    if (mediumHalfPts.get()!=null) {
      mediumHP = mediumHalfPts.get().intValue();
    }
       
    HpsMeasure hpsMeasure = Context.getWmlObjectFactory().createHpsMeasure();
    CSSPrimitiveValue cssPrimitiveValue = (CSSPrimitiveValue)value;
    // Assume size is in points; sanity test.
    if (cssPrimitiveValue.getPrimitiveType()==CSSPrimitiveValue.CSS_IDENT) {
     
      String adjective = cssPrimitiveValue.getStringValue();
      if (adjective.equals("medium")) {
        hpsMeasure.setVal( BigInteger.valueOf( mediumHP) );
      } else if (adjective.equals("xx-small")) {
        hpsMeasure.setVal( BigInteger.valueOf( Math.round(0.6*mediumHP) ));
      } else if (adjective.equals("x-small")) {
        hpsMeasure.setVal( BigInteger.valueOf( Math.round(0.75*mediumHP) ));
      } else if (adjective.equals("small")) {
        hpsMeasure.setVal( BigInteger.valueOf( Math.round(0.89*mediumHP) ));
      } else if (adjective.equals("large")) {
        hpsMeasure.setVal( BigInteger.valueOf( Math.round(1.2*mediumHP) ));
      } else if (adjective.equals("x-large")) {
        hpsMeasure.setVal( BigInteger.valueOf( Math.round(1.5*mediumHP) ));
      } else if (adjective.equals("xx-large")) {
        hpsMeasure.setVal( BigInteger.valueOf( Math.round(2*mediumHP) ));
      } else {
        log.warn("TODO Handle FontSize units properly: " + adjective );             
        hpsMeasure.setVal( BigInteger.valueOf( mediumHP) );
      }
      this.setObject(hpsMeasure);       
     
    } else if(cssPrimitiveValue.getPrimitiveType() == CSSPrimitiveValue.CSS_PX){
     
        float pxVal = cssPrimitiveValue.getFloatValue(CSSPrimitiveValue.CSS_PX);
        int iVal = UnitsOfMeasurement.pxToTwip(pxVal)/10;
        hpsMeasure.setVal(BigInteger.valueOf(iVal));
        this.setObject(hpsMeasure);
       
    } else  if (cssPrimitiveValue.getPrimitiveType()!=CSSPrimitiveValue.CSS_PT) {
     
      log.error("TODO FontSize Handle units: " + cssPrimitiveValue.getPrimitiveType() );
      debug(CSS_NAME, value);
     
    } else { // CSS_PT points
     
      short ignored = 1;
      float fVal = cssPrimitiveValue.getFloatValue(ignored); // unit type ignored in cssparser
      int iVal = Math.round(fVal*2);
     
      hpsMeasure.setVal( BigInteger.valueOf(iVal) );
      this.setObject(hpsMeasure);
    }
View Full Code Here

      case CSSValue.CSS_INHERIT:
        log.warn("valueType INHERIT for " + propertyName + " - NOT IMPLEMENTED ");
        break;
      case CSSValue.CSS_PRIMITIVE_VALUE:
        log.debug("valueType PRIMITIVE for " + propertyName );
        CSSPrimitiveValue cssPrimitiveValue = (CSSPrimitiveValue)value;
        log.debug("PrimitiveType: " + cssPrimitiveValue.getPrimitiveType() );
        break;
      case CSSValue.CSS_VALUE_LIST:
        log.debug("valueType LIST for " + propertyName );
        CSSValueList cssValueList = (CSSValueList)value;
        break;
View Full Code Here

    float fRed;
    float fGreen;
    float fBlue;

    CSSPrimitiveValue cssPrimitiveValue = (CSSPrimitiveValue) value;
    Color color = Context.getWmlObjectFactory().createColor();
    try {
      fRed = cssPrimitiveValue.getRGBColorValue().getRed()
          .getFloatValue(ignored);
      fGreen = cssPrimitiveValue.getRGBColorValue().getGreen()
          .getFloatValue(ignored);
      fBlue = cssPrimitiveValue.getRGBColorValue().getBlue()
          .getFloatValue(ignored);
      color.setVal(UnitsOfMeasurement.rgbTripleToHex(fRed, fGreen, fBlue));
     
    } catch (UnsupportedOperationException e) {     
         
View Full Code Here

   
    debug(CSS_NAME, value);
   
    TblWidth tblWidth = Context.getWmlObjectFactory().createTblWidth();
   
    CSSPrimitiveValue cssPrimitiveValue = (CSSPrimitiveValue)value; 
    short ignored = 1;
    float fVal = cssPrimitiveValue.getFloatValue(ignored); // unit type ignored in cssparser

    int twip;
   
    short type = cssPrimitiveValue.getPrimitiveType();
    if (CSSPrimitiveValue.CSS_IN == type) {
      twip = UnitsOfMeasurement.inchToTwip(fVal);
    } else if (CSSPrimitiveValue.CSS_MM == type) {
      twip = UnitsOfMeasurement.mmToTwip(fVal);   
    } else {
View Full Code Here

            for (int i = 0; i < n.getLength(); i++) {
                String name = n.item(i);

                if (n.getPropertyCSSValue(name) instanceof CSSPrimitiveValue) {

                    CSSPrimitiveValue value = (CSSPrimitiveValue) n.getPropertyCSSValue(name);

                    if (name.equalsIgnoreCase("color")) {
                        model.setColor(getColor(value));
                    }

                    if (name.equalsIgnoreCase("border-color")) {
                        model.getBorder().setColor(getColor(value));
                    }

                    if (name.equalsIgnoreCase("border-width")) {
                        model.getBorder().setWidth(getSize(value));
                    }

                    if (name.equalsIgnoreCase("width")) {
                        model.setWidth(getSize(value));
                    }

                    if (name.equalsIgnoreCase("height")) {
                        model.setHeight(getSize(value));
                    }

                    if (name.equalsIgnoreCase("border")) {
                        CSSValueList list = (CSSValueList) n.getPropertyCSSValue(name);
                        model.setBorder(getBorder(list));
                    }

                    if (name.equalsIgnoreCase("margin")) {
                        CSSValueList list = (CSSValueList) n.getPropertyCSSValue(name);
                        model.setMargings(getMargins(list));
                    }

                    if (name.equalsIgnoreCase("border-style")) {
                        model.getBorder().setStyle(value.getStringValue());
                    }

                    if (name.equalsIgnoreCase("background")) {
                        model.setBackground(getColor(value));
                    }

                    if (name.equalsIgnoreCase("background-color")) {
                        model.setBackground(getColor(value));
                    }

                    if (name.equalsIgnoreCase("font")) {
                        if (model.getFont() == null) model.setFont(new StyleFontModel());
                        CSSValueList list = (CSSValueList) n.getPropertyCSSValue(name);
                        model.setFont(getFont(model, list));
                    }

                    if (name.equalsIgnoreCase("font-family")) {
                        if (model.getFont() == null) model.setFont(new StyleFontModel());
                        model.getFont().setName(value.getCssText());
                    }

                    if (name.equalsIgnoreCase("font-style")) {
                        if (model.getFont() == null) model.setFont(new StyleFontModel());
                        String stringFontStyleValue = value.getStringValue();
                        int fontStyleValue = 0;
                        if (stringFontStyleValue.equalsIgnoreCase("italic")) {
                            fontStyleValue = Font.ITALIC;
                            isItalic = true;
                        }
                        model.getFont().setStyle(fontStyleValue);
                    }

                    if (name.equalsIgnoreCase("font-weight")) {
                        if (model.getFont() == null) model.setFont(new StyleFontModel());
                        String stringFontWeightValue = value.getStringValue();
                        int fontStyleValue = 0;
                        if (stringFontWeightValue.equalsIgnoreCase("bold")) {
                            fontStyleValue = Font.BOLD;
                            isBold = true;
                        }
View Full Code Here

    private static Integer[] getMargins(CSSValueList list) {
        Integer[] result = new Integer[4];

        if (list.getLength() == 0) {
            CSSPrimitiveValue itemValue = (CSSPrimitiveValue) list;
            result[0] = getSize(itemValue);
            result[1] = getSize(itemValue);
            result[2] = getSize(itemValue);
            result[3] = getSize(itemValue);
        } else {
            for (int i = 0; i < list.getLength(); i++) {
                CSSPrimitiveValue itemValue = (CSSPrimitiveValue) list.item(i);
                if (itemValue.getPrimitiveType() == CSSPrimitiveValue.CSS_PX) {
                    result[i] = getSize(itemValue);
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.w3c.dom.css.CSSPrimitiveValue

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.