Java 8 CSSPrimitiveValue - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CSSPrimitiveValue class.

This code example shows how to use the following methods:getFloatValue, getPrimitiveType
		 
		debug(CSS_NAME, value);
				 
		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 { 
			log.error("No support for unit " + type);
			twip = 0;
		} 
		this.setObject(BigInteger.valueOf(twip) );
		 
6
CodeRank
This code example shows how to use the following methods:getFloatValue, getPrimitiveType
		 
		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 { 
			log.error("No support for unit " + type);
			twip = 0;
		} 
		tblWidth.setW(BigInteger.valueOf(twip) );		
		tblWidth.setType("dxa");		
6
CodeRank
This code example shows how to use the following methods:getFloatValue, getPrimitiveType
		 
		debug(CSS_NAME, value);
		 
		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 if (CSSPrimitiveValue.CSS_PERCENTAGE == type) {
			twip = twipFromPercentage(fVal);
		} else if (CSSPrimitiveValue.CSS_IDENT == type) {
			if (value.getCssText().equals("normal")) {
				// no need to set LineSpacing 
				return; 
6
CodeRank
This code example shows how to use the following methods:getFloatValue, getPrimitiveType
		 
		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) {
			twip = UnitsOfMeasurement.pointToTwip(fVal);	
6
CodeRank
This code example shows how to use the following methods:getFloatValue, getPrimitiveType
	} 
	 
	public static int getTwip(CSSPrimitiveValue cssPrimitiveValue) {
 
		short ignored = 1;
		float fVal = cssPrimitiveValue.getFloatValue(ignored); // unit type ignored in cssparser
		log.debug("margin-left: " + fVal);
		if (fVal==0f) {
			return 0; 
		} 
		 
		int twip;
		 
		short type = cssPrimitiveValue.getPrimitiveType();		
		 
		// TODO 
//		CSSPrimitiveValue.CSS_EMS (Unit 3) 
//		(the 'font-size' of the relevant font) 
//		 
//		CSSPrimitiveValue.CSS_EMX (Unit 4) 
5
CodeRank
This code example shows how to use the following methods:getPrimitiveType, getStringValue
	 * 
	 * @param value 
	 * @return 
	 */ 
	public static String getCSSFontPropertyName(CSSPrimitiveValue value) {
		short type = value.getPrimitiveType();
		switch (type) {
		case CSSPrimitiveValue.CSS_STRING:
		case CSSPrimitiveValue.CSS_IDENT:
			String s = value.getStringValue();
			if (/* "normal".equals(s) || */"italic".equals(s)
					|| "oblique".equals(s)) {
				return "font-style"; 
			} 
			if ("normal".equals(s) || "bold".equals(s) || "bolder".equals(s)) {
				return "font-weight"; 
			} 
			return "font-family"; 
		case CSSPrimitiveValue.CSS_PT:
		case CSSPrimitiveValue.CSS_NUMBER:
5
CodeRank
This code example shows how to use the following methods:getPrimitiveType, getStringValue
	@Override 
	public void applyCSSProperty(Object element, CSSValue value, String pseudo,
			CSSEngine engine) throws Exception {
		if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
			CSSPrimitiveValue primitiveValue = (CSSPrimitiveValue) value;
			short type = primitiveValue.getPrimitiveType();
			switch (type) {
			case CSSPrimitiveValue.CSS_IDENT:
				if (CSS2ColorHelper 
						.isColorName(primitiveValue.getStringValue())) {
					engine.applyCSSProperty(element, "border-color", value,
							pseudo);
				} else { 
					engine.applyCSSProperty(element, "border-style", value,
							pseudo);
				} 
				break; 
			case CSSPrimitiveValue.CSS_RGBCOLOR:
				engine.applyCSSProperty(element, "border-color", value, pseudo);
				break; 
5
CodeRank
This code example shows how to use the following methods:getPrimitiveType
				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; 
 
			default: 
				log.error("Unexpected valueType " + valueType + " for " + propertyName );
				return; 
				 
		} 
		 
	} 
 
5
CodeRank
This code example shows how to use the following methods:getPrimitiveType, getStringValue
This code example shows how to use the following methods:getCssText
     * 
     * @return Returns 
     */ 
    public IdentValue asIdentValue() { 
        if (!identIsSet) {
            _identVal = IdentValue.getByIdentString(cssPrimitiveValue.getCssText());
            identIsSet = true;
        } 
        return _identVal;
    } 
 
    public String getDeclarationStandardText() {
        return cssName + ": " + cssPrimitiveValue.getCssText() + ";";
    } 
     
    public String getFingerprint() {
        if (_fingerprint == null) {
            _fingerprint = 'P' + cssName.FS_ID + ':' + ((PropertyValue)cssPrimitiveValue).getFingerprint() + ';';    
        } 
        return _fingerprint;
5
CodeRank
See Code Examples for Java 8 CSSPrimitiveValue Methods: