Java 8 CSSStyleDeclaration - 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 CSSStyleDeclaration class.

This code example shows how to use the following methods:getPropertyCSSValue
	 
	public Color getSelectedForegroundColor() {
		if( style == null ) {
			return null; 
		} 
		return getColor(style.getPropertyCSSValue("pshelf-selected-foregroundcolor"), null);
	} 
	 
	public Font getSelectedFont() { 
		if( style == null ) {
			return null; 
		} 
		return getFont("pshelf-selected-"); 
	} 
	 
	public Font getUnselectedFont() { 
		if( style == null ) {
			return null; 
		} 
		return getFont("pshelf-unselected-"); 
4
CodeRank
This code example shows how to use the following methods:getPropertyCSSValue
				+ "Button { color: black }\n"; 
		ViewCSS viewCSS = createViewCss(css);
 
		TestElement button = new TestElement("Button", engine);
		CSSStyleDeclaration style = viewCSS.getComputedStyle(button, null);
		assertEquals("black", style.getPropertyCSSValue("color").getCssText());
		assertEquals("bold", style.getPropertyCSSValue("font-weight")
				.getCssText());
	} 
 
	@Test
	public void testSpecificity() throws Exception {
		// Two rules with different specificity, the first should take 
		// precedence because of its higher specificity 
		String css = "Label, Button.special { color: black; }\n"
				+ "Button { color: blue; font-weight: bold; }\n"; 
		ViewCSS viewCSS = createViewCss(css);
 
		TestElement button = new TestElement("Button", engine);
		CSSStyleDeclaration style = viewCSS.getComputedStyle(button, null);
5
CodeRank
This code example shows how to use the following methods:getCssText, getLength
		final TestElement composite = new TestElement("Composite", shell, engine);
		final TestElement button = new TestElement("Button", composite, engine);
 
		CSSStyleDeclaration buttonStyle = viewCSS.getComputedStyle(button, null);
		assertNotNull(buttonStyle);
		assertEquals(1, buttonStyle.getLength());
		assertEquals("color: blue;", buttonStyle.getCssText());
	} 
 
	@Test
	public void testBug419482_order2() throws Exception {
		String css = "Button { color: blue; }\n" + "Shell > * > * { color: red; }\n";
		ViewCSS viewCSS = createViewCss(css);
 
		final TestElement shell = new TestElement("Shell", engine);
		final TestElement composite = new TestElement("Composite", shell, engine);
		final TestElement button = new TestElement("Button", composite, engine);
 
		CSSStyleDeclaration buttonStyle = viewCSS.getComputedStyle(button, null);
		assertNotNull(buttonStyle);
5
CodeRank
This code example shows how to use the following methods:getPropertyCSSValue
	 */ 
	public int getMarginRight(int defaultValue) {
		if (style == null)
			return defaultValue;
		return getPxValue( 
				style.getPropertyCSSValue("margin-right"), defaultValue); //$NON-NLS-1$
	} 
 
	private int getPxValue(CSSValue value, int defaultValue) {
		if (value != null
				&& (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE)
				&& (((CSSPrimitiveValue) value).getPrimitiveType() == CSSPrimitiveValue.CSS_PX)) {
			return (int) ((CSSPrimitiveValue) value)
					.getFloatValue(CSSPrimitiveValue.CSS_PX);
		} 
		return defaultValue;
	} 
} 
4
CodeRank
This code example shows how to use the following methods:getPropertyValue
        String value = null;
        String style = imageParameters.get("style");
        if (StringUtils.isNotBlank(style)) {
            try { 
                CSSStyleDeclaration sd = this.cssParser.parseStyleDeclaration(new InputSource(new StringReader(style)));
                value = sd.getPropertyValue(dimension);
            } catch (Exception e) {
                // Ignore the style parameter but log a warning to let the user know. 
                this.logger.warn("Failed to parse CSS style [{}]", style);
            } 
        } 
        if (StringUtils.isBlank(value)) {
            // Fall back on the value of the dimension parameter. 
            value = imageParameters.get(dimension);
        } 
        return value;
    } 
 
    /** 
     * Creates the query string that can be added to an image URL to resize the image on the server side. 
4
CodeRank
This code example shows how to use the following methods:getPropertyCSSValue
		CSSStyleDeclaration styleBeta = viewCSS.getComputedStyle(buttonBeta,
				null); 
 
		assertEquals("value", styleAlpha.getPropertyCSSValue("property")
				.getCssText());
		assertEquals("value2", styleBeta.getPropertyCSSValue("property")
				.getCssText());
	} 
 
	private File createTempCssFile(String cssString) throws Exception {
		File result = File.createTempFile("e4.ui.tests-", ".css");
		FileWriter fileWriter = new FileWriter(result);
		try { 
			fileWriter.write(cssString);
			return result;
		} finally { 
			try { 
				fileWriter.close();
			} catch (IOException e) {
			} 
4
CodeRank
See Code Examples for Java 8 CSSStyleDeclaration Methods: