Java Code Examples for org.w3c.dom.css.CSSValue#CSS_PRIMITIVE_VALUE
The following examples show how to use
org.w3c.dom.css.CSSValue#CSS_PRIMITIVE_VALUE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GridPropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private boolean applyCSSPropertyWeight(final Object element, final Grid grid, final CSSValue value, String target) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(grid); boolean modified = false; if ("bold".equals(value.getCssText()) || "bolder".equals(value.getCssText())) { modified = (fd.getStyle() & SWT.BOLD) != SWT.BOLD; if (modified) { fd.setStyle(fd.getStyle() | SWT.BOLD); } } else { modified = (fd.getStyle() & SWT.BOLD) == SWT.BOLD; if (modified) { fd.setStyle(fd.getStyle() | ~SWT.BOLD); } } if (modified) { applyFont(grid, fd, target); } } return true; }
Example 2
Source File: BackgroundPositionYManager.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Implements {@link * ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}. */ public Value computeValue(CSSStylableElement elt, CSSEngine engine, int idx, Value value) { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { Value percentage = (Value) percentValues.get(value .getStringValue()); if (percentage != null) { return percentage; } throw createInvalidIdentifierDOMException(value .getStringValue()); } } return super.computeValue(elt, engine, idx, value); }
Example 3
Source File: TableComboPropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void applyCSSPropertyFont(final Object element, final Control widget, final CSSValue value) throws Exception { if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) { final CSSValueList valueList = (CSSValueList) value; final int length = valueList.getLength(); for (int i = 0; i < length; i++) { final CSSValue value2 = valueList.item(i); if (value2.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final String cssProp = CSS2FontHelper.getCSSFontPropertyName((CSSPrimitiveValue) value2); if (cssProp.equals("font-family")) { applyCSSPropertyFamily(element, widget, value2); } else if (cssProp.equals("font-size")) { applyCSSPropertySize(element, widget, value2); } else if (cssProp.equals("font-weight") && ("bold".equals(value2.getCssText()) || "bolder".equals(value2.getCssText()))) { applyCSSPropertyWeight(element, widget, value2); } else if (cssProp.equals("font-style") && ("italic".equals(value2.getCssText()) || "oblique".equals(value2.getCssText()))) { applyCSSPropertyStyle(element, widget, value2); } } } } }
Example 4
Source File: TableComboPropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private boolean applyCSSPropertyStyle(final Object element, final Control widget, final CSSValue value) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(widget); boolean modified = false; if ("italic".equals(value.getCssText()) || "oblique".equals(value.getCssText())) { modified = (fd.getStyle() & SWT.ITALIC) != SWT.ITALIC; if (modified) { fd.setStyle(fd.getStyle() | SWT.ITALIC); } } else { modified = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC; if (modified) { fd.setStyle(fd.getStyle() | ~SWT.ITALIC); } } if (modified) { applyFont(widget, fd); } } return true; }
Example 5
Source File: TableComboPropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private boolean applyCSSPropertyWeight(final Object element, final Control widget, final CSSValue value) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(widget); boolean modified = false; if ("bold".equals(value.getCssText()) || "bolder".equals(value.getCssText())) { modified = (fd.getStyle() & SWT.BOLD) != SWT.BOLD; if (modified) { fd.setStyle(fd.getStyle() | SWT.BOLD); } } else { modified = (fd.getStyle() & SWT.BOLD) == SWT.BOLD; if (modified) { fd.setStyle(fd.getStyle() | ~SWT.BOLD); } } if (modified) { applyFont(widget, fd); } } return true; }
Example 6
Source File: CDateTimePropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void applyCSSPropertyWeight(final Control widget, final CSSValue value, final boolean picker) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(widget); boolean modified = false; if ("bold".equals(value.getCssText()) || "bolder".equals(value.getCssText())) { modified = (fd.getStyle() & SWT.BOLD) != SWT.BOLD; if (modified) { fd.setStyle(fd.getStyle() | SWT.BOLD); } } else { modified = (fd.getStyle() & SWT.BOLD) == SWT.BOLD; if (modified) { fd.setStyle(fd.getStyle() | ~SWT.BOLD); } } if (modified) { if (picker) { applyFontForPicker((CDateTime) widget, fd); } else { applyFont(widget, fd); } } } }
Example 7
Source File: CDateTimePropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void applyCSSPropertyFont(final Control widget, final CSSValue value, final boolean picker) throws Exception { if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) { final CSSValueList valueList = (CSSValueList) value; final int length = valueList.getLength(); for (int i = 0; i < length; i++) { final CSSValue value2 = valueList.item(i); if (value2.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final String cssProp = CSS2FontHelper.getCSSFontPropertyName((CSSPrimitiveValue) value2); if (cssProp.equals("font-family")) { applyCSSPropertyFamily(widget, value2, picker); } else if (cssProp.equals("font-size")) { applyCSSPropertySize(widget, value2, picker); } else if (cssProp.equals("font-weight") && ("bold".equals(value2.getCssText()) || "bolder".equals(value2.getCssText()))) { applyCSSPropertyWeight(widget, value2, picker); } else if (cssProp.equals("font-style") && ("italic".equals(value2.getCssText()) || "oblique".equals(value2.getCssText()))) { applyCSSPropertyStyle(widget, value2, picker); } } } } }
Example 8
Source File: CDateTimePropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void applyCSSPropertyStyle(final Control widget, final CSSValue value, final boolean picker) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(widget); boolean modified = false; if ("italic".equals(value.getCssText()) || "oblique".equals(value.getCssText())) { modified = (fd.getStyle() & SWT.ITALIC) != SWT.ITALIC; if (modified) { fd.setStyle(fd.getStyle() | SWT.ITALIC); } } else { modified = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC; if (modified) { fd.setStyle(fd.getStyle() | ~SWT.ITALIC); } } if (modified) { if (picker) { applyFontForPicker((CDateTime) widget, fd); } else { applyFont(widget, fd); } } } }
Example 9
Source File: CDateTimePropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void applyCSSPropertySize(final Control widget, final CSSValue value, final boolean picker) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(widget); final Measure m = (Measure) value; final int newSize = Math.round(m.getFloatValue((short) 0)); final boolean modified = fd.getHeight() != newSize; if (modified) { fd.setHeight(newSize); if (picker) { applyFontForPicker((CDateTime) widget, fd); } else { applyFont(widget, fd); } } } }
Example 10
Source File: ListValue.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * A string representation of the current value. */ public String getCssText( ) { StringBuffer sb = new StringBuffer(); for ( int i = 0; i < length; i++) { Value value = (Value)items[i]; if (value == null) { continue; } short valueType = value.getCssValueType( ); if ( valueType == CSSValue.CSS_PRIMITIVE_VALUE ) { switch ( value.getPrimitiveType( ) ) { case CSSPrimitiveValue.CSS_STRING : sb.append( encodeString( value.getStringValue( ) ) ); break; case CSSPrimitiveValue.CSS_URI : sb.append( "url('" ); sb.append( value.getStringValue( ) ); sb.append( "')" ); break; default : sb.append( value.getCssText( ) ); } } else { sb.append(value.getCssText( )); } sb.append( separator ); } if (sb.length( ) != 0) { sb.setLength( sb.length() - 1 ); } return sb.toString(); }
Example 11
Source File: BorderWidthManager.java From birt with Eclipse Public License 1.0 | 5 votes |
public Value computeValue( CSSStylableElement elt, CSSEngine engine, int idx, Value value ) { IStyle cs = elt.getComputedStyle( ); CSSValue borderStyle = null; switch ( idx ) { case IStyle.STYLE_BORDER_TOP_WIDTH : borderStyle = cs.getProperty( IStyle.STYLE_BORDER_TOP_STYLE ); break; case IStyle.STYLE_BORDER_BOTTOM_WIDTH : borderStyle = cs.getProperty( IStyle.STYLE_BORDER_BOTTOM_STYLE ); break; case IStyle.STYLE_BORDER_LEFT_WIDTH : borderStyle = cs.getProperty( IStyle.STYLE_BORDER_LEFT_STYLE ); break; case IStyle.STYLE_BORDER_RIGHT_WIDTH : borderStyle = cs.getProperty( IStyle.STYLE_BORDER_RIGHT_STYLE ); break; } if ( borderStyle == CSSValueConstants.NONE_VALUE || borderStyle == CSSValueConstants.HIDDEN_VALUE ) { return CSSValueConstants.NUMBER_0; } if ( value.getCssValueType( ) == CSSValue.CSS_PRIMITIVE_VALUE ) { if ( value.getPrimitiveType( ) == CSSPrimitiveValue.CSS_IDENT ) { String ident = value.getStringValue( ); Value cv = (Value) computedValues.get( ident ); if ( cv != null ) { value = cv; } } } return super.computeValue( elt, engine, idx, value ); }
Example 12
Source File: AbstractLengthManager.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Implements {@link * ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}. */ public Value computeValue( CSSStylableElement elt, CSSEngine engine, int idx, Value value ) { if ( value.getCssValueType( ) == CSSValue.CSS_PRIMITIVE_VALUE ) { switch ( value.getPrimitiveType( ) ) { case CSSPrimitiveValue.CSS_NUMBER : case CSSPrimitiveValue.CSS_PX : case CSSPrimitiveValue.CSS_MM : case CSSPrimitiveValue.CSS_CM : case CSSPrimitiveValue.CSS_IN : case CSSPrimitiveValue.CSS_PT : case CSSPrimitiveValue.CSS_PC : return value; case CSSPrimitiveValue.CSS_EMS : float v = value.getFloatValue( ); Value fontSize = (Value) elt.getComputedStyle( ) .getProperty( IStyle.STYLE_FONT_SIZE ); float fs = fontSize.getFloatValue( ); return new FloatValue( fontSize.getPrimitiveType( ), v * fs ); case CSSPrimitiveValue.CSS_EXS : v = value.getFloatValue( ); fontSize = (Value) elt.getComputedStyle( ) .getProperty( IStyle.STYLE_FONT_SIZE ); fs = fontSize.getFloatValue( ); return new FloatValue( fontSize.getPrimitiveType( ), v * fs * 0.5f ); } } return value; }
Example 13
Source File: CDateTimePropertyHandler.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void applyCSSPropertyFamily(final Control widget, final CSSValue value, final boolean picker) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(widget); final boolean modified = !fd.getName().equals(value.getCssText()); if (modified) { fd.setName(value.getCssText()); if (picker) { applyFontForPicker((CDateTime) widget, fd); } else { applyFont(widget, fd); } } } }
Example 14
Source File: TableComboPropertyHandler.java From nebula with Eclipse Public License 2.0 | 5 votes |
private boolean applyCSSPropertyFamily(final Object element, final Control widget, final CSSValue value) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(widget); final boolean modified = !fd.getName().equals(value.getCssText()); if (modified) { fd.setName(value.getCssText()); applyFont(widget, fd); } } return true; }
Example 15
Source File: AbstractColorManager.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Implements {@link * ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}. */ public Value computeValue( CSSStylableElement elt, CSSEngine engine, int idx, Value value ) { if ( value.getCssValueType( ) == CSSValue.CSS_PRIMITIVE_VALUE ) { CSSPrimitiveValue pvalue = (CSSPrimitiveValue) value; int primitiveType = pvalue.getPrimitiveType( ); if ( primitiveType == CSSPrimitiveValue.CSS_IDENT ) { String ident = pvalue.getStringValue( ); // Search for a direct computed value. Value v = (Value) computedValues.get( ident ); if ( v != null ) { return v; } // Must be a system color... if ( values.get( ident ) == null ) { throw new InternalError( ); } return (Value) engine.getCSSContext( ).getSystemColor( ident ); } if ( primitiveType == CSSPrimitiveValue.CSS_RGBCOLOR ) { RGBColor color = value.getRGBColorValue( ); CSSPrimitiveValue red = color.getRed( ); CSSPrimitiveValue green = color.getGreen( ); CSSPrimitiveValue blue = color.getBlue( ); return createRGBColor( createColorComponent( red ), createColorComponent( green ), createColorComponent( blue ) ); } } return super.computeValue( elt, engine, idx, value ); }
Example 16
Source File: TabbedPropertyTitleCssPropertyHandler.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected void applyCSSProperty(Control control, String property, CSSValue value, String pseudo, CSSEngine engine) throws Exception { if (!(control instanceof TabbedPropertyTitle) || value.getCssValueType() != CSSValue.CSS_PRIMITIVE_VALUE || property == null || !cssPropertyToSWTProperty.containsKey(property)) { return; } TabbedPropertyTitle title = (TabbedPropertyTitle) control; title.setColor(cssPropertyToSWTProperty.get(property), CSSSWTColorHelper.getRGBA(value)); }
Example 17
Source File: GridPropertyHandler.java From nebula with Eclipse Public License 2.0 | 5 votes |
private boolean applyCSSPropertySize(final Object element, final Grid grid, final CSSValue value, String target) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(grid); final Measure m = (Measure) value; final int newSize = Math.round(m.getFloatValue((short) 0)); final boolean modified = fd.getHeight() != newSize; if (modified) { fd.setHeight(newSize); applyFont(grid, fd, target); } } return true; }
Example 18
Source File: Value.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Implements {@link Value#getCssValueType()}. */ public short getCssValueType( ) { return CSSValue.CSS_PRIMITIVE_VALUE; }
Example 19
Source File: AbstractStyle.java From birt with Eclipse Public License 1.0 | 4 votes |
public String getCssText( ) { StringBuffer sb = new StringBuffer( ); for ( int i = 0; i < NUMBER_OF_STYLE; i++ ) { //we don't return the format in css as the format //is a complex object which can't be represented as //css string. if (i == IStyle.STYLE_DATA_FORMAT) continue; CSSValue value = getProperty( i ); if ( value != null ) { sb.append( engine.getPropertyName( i ) ); sb.append( ": " ); short type = value.getCssValueType( ); switch ( type ) { case CSSValue.CSS_PRIMITIVE_VALUE : { CSSPrimitiveValue pv = (CSSPrimitiveValue) value; short unitType = pv.getPrimitiveType( ); switch ( unitType ) { case CSSPrimitiveValue.CSS_STRING : sb.append( "'" ); sb.append( pv.getStringValue( ) ); sb.append( "'" ); break; case CSSPrimitiveValue.CSS_URI : sb.append( "url('" ); sb.append( pv.getStringValue( ) ); sb.append( "')" ); break; default : sb.append( value.getCssText( ) ); } } break; default : sb.append( value.getCssText( ) ); } sb.append( "; " ); } } if ( sb.length( ) > 2 ) { sb.setLength( sb.length( ) - 2 ); } return sb.toString( ); }
Example 20
Source File: FontSizeManager.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Implements {@link * ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}. */ public Value computeValue(CSSStylableElement elt, CSSEngine engine, int idx, Value value) { CSSContext ctx = engine.getCSSContext(); float fs = ctx.getMediumFontSize(); // absolute size if (value == CSSValueConstants.XX_SMALL_VALUE) { return new FloatValue( CSSPrimitiveValue.CSS_PT, fs / 1.2f / 1.2f / 1.2f); } if (value == CSSValueConstants.X_SMALL_VALUE) { return new FloatValue( CSSPrimitiveValue.CSS_PT, fs / 1.2f / 1.2f); } if (value == CSSValueConstants.SMALL_VALUE) { return new FloatValue( CSSPrimitiveValue.CSS_PT, fs / 1.2f ); } if (value == CSSValueConstants.MEDIUM_VALUE) { return new FloatValue( CSSPrimitiveValue.CSS_PT, fs ); } if (value == CSSValueConstants.LARGE_VALUE) { return new FloatValue( CSSPrimitiveValue.CSS_PT, fs * 1.2f ); } if (value == CSSValueConstants.X_LARGE_VALUE) { return new FloatValue( CSSPrimitiveValue.CSS_PT, fs * 1.2f * 1.2f); } if (value == CSSValueConstants.XX_LARGE_VALUE) { return new FloatValue( CSSPrimitiveValue.CSS_PT, fs * 1.2f * 1.2f * 1.2f); } float scale = 1.0f; boolean doParentRelative = false; // relative size if (value == CSSValueConstants.SMALLER_VALUE) { doParentRelative = true; scale = 1.0f / 1.2f; } else if (value == CSSValueConstants.LARGER_VALUE) { doParentRelative = true; scale = 1.2f; } else if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { // relative length && percentage switch (value.getPrimitiveType()) { case CSSPrimitiveValue.CSS_EMS: doParentRelative = true; scale = value.getFloatValue(); break; case CSSPrimitiveValue.CSS_EXS: doParentRelative = true; scale = value.getFloatValue() * 0.5f; break; case CSSPrimitiveValue.CSS_PERCENTAGE: doParentRelative = true; scale = value.getFloatValue() * 0.01f; break; } } if (doParentRelative) { CSSStylableElement parent = (CSSStylableElement) elt.getParent(); if (parent != null) { IStyle style = parent.getComputedStyle(); if (style != null) { Value fontSize = (Value)style.getProperty(IStyle.STYLE_FONT_SIZE); if (fontSize != null) { fs = fontSize.getFloatValue(); return new FloatValue( fontSize.getPrimitiveType( ), fs * scale ); } } } return new FloatValue( CSSPrimitiveValue.CSS_PT, fs * scale ); } if(value.getPrimitiveType() == CSSPrimitiveValue.CSS_NUMBER) { return super.computeValue( elt, engine, idx, new FloatValue( CSSPrimitiveValue.CSS_PT, value.getFloatValue())); } return super.computeValue(elt, engine, idx, value); }