Java Code Examples for cz.vutbr.web.css.CSSFactory#getUsedStyles()
The following examples show how to use
cz.vutbr.web.css.CSSFactory#getUsedStyles() .
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: PseudoClassTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void pseudoClassDirect() throws SAXException, IOException { DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/pseudo.html")); Document doc = ds.parse(); ElementMap elements = new ElementMap(doc); MatchConditionOnElements cond = new MatchConditionOnElements("a", PseudoClassType.LINK); cond.addMatch(elements.getElementById("l2"), PseudoClassType.HOVER); cond.addMatch(elements.getElementById("l3"), PseudoClassType.VISITED); CSSFactory.registerDefaultMatchCondition(cond); StyleSheet style = CSSFactory.getUsedStyles(doc, null, createBaseFromFilename("data/simple/selectors.html"),"screen"); DirectAnalyzer da = new DirectAnalyzer(style); NodeData l1 = getStyleById(elements, da, "l1"); NodeData l2 = getStyleById(elements, da, "l2"); NodeData l3 = getStyleById(elements, da, "l3"); assertThat(l1.getValue(TermColor.class, "color"), is(tf.createColor(0,255,0))); assertThat(l2.getValue(TermColor.class, "color"), is(tf.createColor(0,255,255))); assertThat(l3.getValue(TermColor.class, "color"), is(tf.createColor(0,0,170))); }
Example 2
Source File: PseudoClassTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void pseudoClassDirectNonStatic() throws SAXException, IOException { DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/pseudo.html")); Document doc = ds.parse(); ElementMap elements = new ElementMap(doc); MatchConditionOnElements cond = new MatchConditionOnElements("a", PseudoClassType.LINK); cond.addMatch(elements.getElementById("l2"), PseudoClassType.HOVER); cond.addMatch(elements.getElementById("l3"), PseudoClassType.VISITED); StyleSheet style = CSSFactory.getUsedStyles(doc, null, createBaseFromFilename("data/simple/selectors.html"),"screen"); DirectAnalyzer da = new DirectAnalyzer(style); da.registerMatchCondition(cond); NodeData l1 = getStyleById(elements, da, "l1"); NodeData l2 = getStyleById(elements, da, "l2"); NodeData l3 = getStyleById(elements, da, "l3"); assertThat(l1.getValue(TermColor.class, "color"), is(tf.createColor(0,255,0))); assertThat(l2.getValue(TermColor.class, "color"), is(tf.createColor(0,255,255))); assertThat(l3.getValue(TermColor.class, "color"), is(tf.createColor(0,0,170))); }
Example 3
Source File: DOMAnalyzer.java From CSSBox with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns a vector of CSSStyleSheet objects referenced from the document for the specified * media type with default values of the remaining media features. The internal style sheets * are read from the document directly, the external ones are downloaded and parsed automatically. * @param media the media type string */ public void getStyleSheets(String media) { this.media = new MediaSpec(media); StyleSheet newsheet = CSSFactory.getUsedStyles(doc, encoding, baseUrl, this.media); styles.add(newsheet); }
Example 4
Source File: DOMAnalyzer.java From CSSBox with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns a vector of CSSStyleSheet objects referenced from the document for the specified * media type and features. The internal style sheets are read from the document directly, the external * ones are downloaded and parsed automatically. * @param media the media specification */ public void getStyleSheets(MediaSpec media) { this.media = media; StyleSheet newsheet = CSSFactory.getUsedStyles(doc, encoding, baseUrl, this.media); styles.add(newsheet); }
Example 5
Source File: PseudoClassTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void pseudoClassVsPseudoElementSelector() throws SAXException, IOException { DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/pseudo.html")); Document doc = ds.parse(); ElementMap elements = new ElementMap(doc); StyleSheet style = CSSFactory.getUsedStyles(doc, null, createBaseFromFilename("data/simple/selectors.html"),"screen"); DirectAnalyzer da = new DirectAnalyzer(style); NodeData nodeData = getStyleById(elements, da, "p1"); assertThat(nodeData.getValue(TermColor.class, "color"), is(tf.createColor(0,128,0))); }
Example 6
Source File: PseudoClassTest.java From jStyleParser with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void childPseudoClassesTest() throws SAXException, IOException { DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/child-pseudo.html")); Document doc = ds.parse(); ElementMap elements = new ElementMap(doc); StyleSheet style = CSSFactory.getUsedStyles(doc, null, null, "screen"); DirectAnalyzer da = new DirectAnalyzer(style); TermColor[] expected = new TermColor[] { tf.createColor("#F0F"), tf.createColor("#00F"), tf.createColor("#00F"), tf.createColor("#0F0"), tf.createColor("#F00"), tf.createColor("#FFF"), tf.createColor("#FF0"), tf.createColor("#FFF"), tf.createColor("#000"), tf.createColor("#0F0"), tf.createColor("#000"), tf.createColor("#FFF"), tf.createColor("#0F0"), tf.createColor("#FFF"), tf.createColor("#F00"), tf.createColor("#0F0"), tf.createColor("#000"), tf.createColor("#0FF") }; for (int id = 1; id <= 18; id++) { NodeData nodeData = getStyleById(elements, da, "list-" + id); assertThat(nodeData.getValue(TermColor.class, "color"), is(expected[id - 1])); } }
Example 7
Source File: HtmlUtils.java From openemm with GNU Affero General Public License v3.0 | 4 votes |
public static DeclarationMap getDeclarationMap(Document document, String encoding, URL base, String media) { StyleSheet stylesheet = CSSFactory.getUsedStyles(document, encoding, base, media); return getDeclarationMap(document, stylesheet, media); }