本文整理汇总了Java中cz.vutbr.web.domassign.StyleMap类的典型用法代码示例。如果您正苦于以下问题:Java StyleMap类的具体用法?Java StyleMap怎么用?Java StyleMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StyleMap类属于cz.vutbr.web.domassign包,在下文中一共展示了StyleMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: combinators
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
@Test
public void combinators() throws SAXException, IOException {
DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/selectors3.html"));
Document doc = ds.parse();
ElementMap elements = new ElementMap(doc);
StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/simple/selectors3.html"),"screen", true);
NodeData i1 = getStyleById(elements, decl, "i1");
NodeData i2 = getStyleById(elements, decl, "i2");
NodeData i3 = getStyleById(elements, decl, "i3");
NodeData i4 = getStyleById(elements, decl, "i4");
assertThat("Descendant combinator", i1.getValue(TermColor.class, "color"), is(tf.createColor(0,128,0)));
assertThat("Child combinator", i2.getValue(TermColor.class, "color"), is(tf.createColor(0,128,0)));
assertThat("Adjacent sibling combinator", i3.getValue(TermColor.class, "color"), is(tf.createColor(0,128,0)));
assertThat("Generic sibling combinator", i4.getValue(TermColor.class, "color"), is(tf.createColor(0,128,0)));
}
示例2: inherit
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
@Test
public void inherit() throws SAXException, IOException {
DOMSource ds = new DOMSource(getClass().getResourceAsStream("/advanced/inherit.html"));
Document doc = ds.parse();
ElementMap elements = new ElementMap(doc);
StyleMap decl = CSSFactory.assignDOM(doc, null,
getClass().getResource("/advanced/inherit.html"),"screen", true);
NodeData data = decl.get(elements.getElementById("item1"));
assertNotNull("Data for #item1 exist", data);
assertThat(data.getValue(TermLength.class, "border-top-width"), is(tf.createLength(1.0f, Unit.px)));
assertThat(data.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0, 128, 0)));
assertThat((CSSProperty.BorderStyle) data.getProperty("border-top-style"), is(CSSProperty.BorderStyle.SOLID));
assertThat(data.getValue(TermLength.class, "margin-top"), is(tf.createLength(1.0f, Unit.em)));
assertThat(data.getValue(TermLength.class, "margin-bottom"), is(tf.createLength(3.0f, Unit.em)));
data = decl.get(elements.getElementById("item2"));
assertNotNull("Data for #item2 exist", data);
assertThat(data.getValue(TermLength.class, "border-top-width"), is(tf.createLength(5.0f, Unit.px)));
assertThat(data.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0, 128, 0)));
assertThat((CSSProperty.BorderStyle) data.getProperty("border-top-style"), is(CSSProperty.BorderStyle.DOTTED));
assertThat(data.getValue(TermLength.class, "margin-top"), is(tf.createLength(1.0f, Unit.em)));
assertNull(data.getValue(TermLength.class, "margin-bottom"));
}
示例3: initial
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
@Test
public void initial() throws SAXException, IOException {
DOMSource ds = new DOMSource(getClass().getResourceAsStream("/advanced/initial.html"));
Document doc = ds.parse();
ElementMap elements = new ElementMap(doc);
StyleMap decl = CSSFactory.assignDOM(doc, null,
getClass().getResource("/advanced/initial.html"),"screen", true);
NodeData data = decl.get(elements.getElementById("item1"));
assertNotNull("Data for #item1 exist", data);
assertThat(data.getSpecifiedValue(TermColor.class, "border-top-color"), is(tf.createColor(0, 0, 0)));
assertThat(data.getSpecifiedValue(TermColor.class, "color"), is(tf.createColor(0, 0, 0)));
data = decl.get(elements.getElementById("item4"));
assertNotNull("Data for #item4 exist", data);
assertThat(data.getSpecifiedValue(TermColor.class, "border-top-color"), is(tf.createColor(255, 0, 0)));
assertThat(data.getSpecifiedValue(TermColor.class, "color"), is(tf.createColor(255, 0, 0)));
}
示例4: defaulting
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
@Test
public void defaulting() throws SAXException, IOException {
DOMSource ds = new DOMSource(getClass().getResourceAsStream("/advanced/initial.html"));
Document doc = ds.parse();
ElementMap elements = new ElementMap(doc);
StyleMap decl = CSSFactory.assignDOM(doc, null,
getClass().getResource("/advanced/initial.html"),"screen", true);
NodeData data = decl.get(elements.getElementById("content"));
assertNotNull("Data for #content exist", data);
//cascaded value
assertNull(data.getProperty("border-top-color"));
assertNull(data.getValue(TermColor.class, "border-top-color"));
//specified value
assertThat((CSSProperty.BorderColor) data.getSpecifiedProperty("border-top-color"), is(CSSProperty.BorderColor.color));
assertThat(data.getSpecifiedValue(TermColor.class, "border-top-color"), is(tf.createColor(tf.createIdent("currentColor"))));
}
示例5: invalidValues
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
@Test
public void invalidValues() throws SAXException, IOException {
DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/invval.html"));
Document doc = ds.parse();
ElementMap elements = new ElementMap(doc);
StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/simple/invval.html"), "screen", true);
NodeData data = decl.get(elements.getElementById("test"));
assertNotNull("Data for #test exist", data);
assertThat("Reference border width parsed", data.getValue(TermLength.class, "border-top-width"), is(tf.createLength(3.0f, Unit.px)));
assertThat("Negative zero treated as zero", data.getValue(TermLength.class, "border-right-width"), is(tf.createLength(0.0f, Unit.px)));
assertThat("Reference padding parsed", data.getValue(TermLength.class, "padding-bottom"), is(tf.createLength(1.0f, Unit.em)));
assertThat("Negative padding ignored", data.getValue(TermLength.class, "padding-top"), is(tf.createLength(1.0f, Unit.em)));
assertThat("Reference margin parsed", data.getValue(TermLength.class, "margin-top"), is(tf.createLength(2.0f, Unit.em)));
assertThat("Negative margin accepted", data.getValue(TermLength.class, "margin-bottom"), is(tf.createLength(-5.0f, Unit.em)));
}
示例6: invalidSelector
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
@Test
public void invalidSelector() throws IOException, CSSException, SAXException {
StyleSheet sheet = CSSFactory.parseString(TEST_INVALID_SELECTOR, null);
DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/h1.html"));
Document doc = ds.parse();
Analyzer analyzer = new Analyzer(sheet);
StyleMap decl = analyzer.evaluateDOM(doc, "all", true);
ElementMap elements = new ElementMap(doc);
NodeData nd = decl.get(elements.getLastElementByName("h1"));
Assert.assertNull("There is no color", nd.getProperty("color"));
Assert.assertEquals("There is font-family", FontFamily.list_values, nd
.getProperty("font-family"));
Assert.assertEquals("Font is 'Times New Roman'", tf
.createString("Times New Roman"), nd.getValue(TermList.class,
"font-family").get(0));
}
示例7: checkDataCSS
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
private void checkDataCSS(StyleSheet ss) {
Analyzer analyzer = new Analyzer(ss);
StyleMap decl = analyzer.evaluateDOM(doc, "all", true);
ElementMap elements = new ElementMap(doc);
Element marginator = elements.getElementById("marginator");
assertNotNull("Element marginator exists", marginator);
NodeData data = decl.get(marginator);
assertEquals(
"<div id=\"marginator\"> contains margin with for same values",
Margin.length, data.getProperty("margin-top"));
assertEquals(
"<div id=\"marginator\"> contains margin with for same values",
Margin.length, data.getProperty("margin-bottom"));
assertEquals("Margin of 100px", new Float(100.0f), data.getValue(
TermLength.class, "margin-top").getValue());
assertEquals("Margin of 100px", TermNumeric.Unit.px, data.getValue(
TermLength.class, "margin-top").getUnit());
assertEquals("for all for both values", data.getValue(TermLength.class,
"margin-bottom"), data
.getValue(TermLength.class, "margin-left"));
}
示例8: evaluateSimple
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
@Test
public void evaluateSimple() {
StyleMap decl = analyzer.evaluateDOM(doc, "all", false);
Node current = walker.getCurrentNode();
NodeData data = (current instanceof Element) ? decl.get((Element) current) : null;
assertEquals("<body> nodedata contains color", CSSProperty.Color.color,
data.getProperty("color"));
assertEquals("color declaration contains red color",
new Color(255, 0, 0), data.getValue(TermColor.class,
"color").getValue());
assertEquals("<body> nodedata contains font-weight: 200",
CSSProperty.FontWeight.numeric_200, data
.getProperty("font-weight"));
walker.setCurrentNode(current);
}
示例9: testRepeaterOnMargin
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
@Test
public void testRepeaterOnMargin() {
StyleMap decl = analyzer.evaluateDOM(doc, "all", false);
Element marginator = elements.getElementById("marginator");
assertNotNull("Element marginator exists", marginator);
NodeData data = decl.get(marginator);
assertEquals(
"<div id=\"marginator\"> contains margin with for same values",
Margin.length, data.getProperty("margin-top"));
assertEquals(
"<div id=\"marginator\"> contains margin with for same values",
Margin.length, data.getProperty("margin-bottom"));
assertEquals("Margin of 100px", new Float(100.0f), data.getValue(
TermLength.class, "margin-top").getValue());
assertEquals("Margin of 100px", TermNumeric.Unit.px, data.getValue(
TermLength.class, "margin-top").getUnit());
assertEquals("for all for both values", data.getValue(TermLength.class,
"margin-bottom"), data
.getValue(TermLength.class, "margin-left"));
}
示例10: checkDocument
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
private void checkDocument(String name, ElementMatcher matcher, TermColor[] expect, String msg) throws SAXException, IOException
{
DOMSource ds = new DOMSource(getClass().getResourceAsStream(name));
Document doc = ds.parse();
ElementMap elements = new ElementMap(doc);
CSSFactory.registerElementMatcher(matcher);
StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource(name),"screen", true);
Element list = elements.getElementById("list");
NodeList items = list.getElementsByTagName("li");
for (int i = 0; i < items.getLength(); i++)
{
NodeData style = decl.get((Element) items.item(i));
assertEquals(msg + " : line " + (i+1), expect[i], style.getValue(TermColor.class, "color"));
}
}
示例11: main
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
final String src = "/profiling/slate.html";
//final String src = "/profiling/lidovky2.html";
Date start = new Date();
DOMSource ds = new DOMSource(AnalyzerTest.class.getResourceAsStream(src));
Document doc = ds.parse();
Date analyze = new Date();
StyleMap decl = CSSFactory.assignDOM(doc, null, ProfilerEntryPointAnalyzer.class.getResource(src), "screen", true);
Date end = new Date();
System.out.println("DOM parsing: " + (analyze.getTime() - start.getTime()) + " ms");
System.out.println("CSS analysis: " + (end.getTime() - analyze.getTime()) + " ms");
System.out.println("Obtained " + decl.size() + " node styles");
}
示例12: pseudoClassMap
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
@Test
public void pseudoClassMap() 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", PseudoDeclaration.LINK);
cond.addMatch(elements.getElementById("l2"), PseudoDeclaration.HOVER);
cond.addMatch(elements.getElementById("l3"), PseudoDeclaration.VISITED);
cond.addMatch(elements.getElementById("l3"), PseudoDeclaration.HOVER);
cond.removeMatch(elements.getElementById("l3"), PseudoDeclaration.HOVER);
CSSFactory.registerDefaultMatchCondition(cond);
StyleMap decl = CSSFactory.assignDOM(doc, null, createBaseFromFilename("data/simple/pseudo.html"),"screen", true);
NodeData l1 = getStyleById(elements, decl, "l1");
NodeData l2 = getStyleById(elements, decl, "l2");
NodeData l3 = getStyleById(elements, decl, "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)));
}
示例13: pseudoClassMapNonStatic
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
@Test
public void pseudoClassMapNonStatic() 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", PseudoDeclaration.LINK);
cond.addMatch(elements.getElementById("l2"), PseudoDeclaration.HOVER);
cond.addMatch(elements.getElementById("l3"), PseudoDeclaration.VISITED);
cond.addMatch(elements.getElementById("l3"), PseudoDeclaration.HOVER);
cond.removeMatch(elements.getElementById("l3"), PseudoDeclaration.HOVER);
StyleMap decl = CSSFactory.assignDOM(doc, null, createBaseFromFilename("data/simple/pseudo.html"),"screen", true, cond);
NodeData l1 = getStyleById(elements, decl, "l1");
NodeData l2 = getStyleById(elements, decl, "l2");
NodeData l3 = getStyleById(elements, decl, "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)));
}
示例14: structureSelectors
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
@Test
public void structureSelectors() throws SAXException, IOException {
DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/selectors.html"));
Document doc = ds.parse();
ElementMap elements = new ElementMap(doc);
StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/simple/selectors.html"),"screen", true);
NodeData i1 = getStyleById(elements, decl, "i1");
NodeData i2 = getStyleById(elements, decl, "i2");
NodeData i5 = getStyleById(elements, decl, "i5");
NodeData i6 = getStyleById(elements, decl, "i6");
NodeData i8 = getStyleById(elements, decl, "i8");
NodeData empty = getStyleById(elements, decl, "empty");
NodeData only = getStyleById(elements, decl, "only");
NodeData html = decl.get(doc.getDocumentElement());
assertNotNull("Data for <html> exists", html);
assertThat(i1.getValue(TermColor.class, "color"), is(tf.createColor(255,0,0)));
assertNull(i2.getValue(TermColor.class, "color"));
assertThat(i5.getValue(TermColor.class, "background-color"), is(tf.createColor(255,0,0)));
assertThat(i6.getValue(TermColor.class, "background-color"), is(tf.createColor(0,128,0)));
assertThat(i8.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0,0,255)));
assertThat(only.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0,0,255)));
assertThat(only.getValue(TermColor.class, "background-color"), is(tf.createColor(0,255,255)));
assertThat(empty.getValue(TermColor.class, "border-top-color"), is(tf.createColor(255,0,0)));
assertThat(html.getValue(TermColor.class, "background-color"), is(tf.createColor(238,238,238)));
}
示例15: indexSelectors
import cz.vutbr.web.domassign.StyleMap; //导入依赖的package包/类
@Test
public void indexSelectors() throws SAXException, IOException {
DOMSource ds = new DOMSource(getClass().getResourceAsStream("/simple/selectors2.html"));
Document doc = ds.parse();
ElementMap elements = new ElementMap(doc);
StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/simple/selectors2.html"),"screen", true);
NodeData i1 = getStyleById(elements, decl, "i1");
NodeData i2 = getStyleById(elements, decl, "i2");
NodeData i3 = getStyleById(elements, decl, "i3");
NodeData i5 = getStyleById(elements, decl, "i5");
NodeData i7 = getStyleById(elements, decl, "i7");
NodeData i8 = getStyleById(elements, decl, "i8");
NodeData i9 = getStyleById(elements, decl, "i9");
NodeData html = decl.get(doc.getDocumentElement());
assertNotNull("Data for <html> exists", html);
assertNull(i1.getValue(TermColor.class, "color"));
assertNull(i1.getValue(TermColor.class, "border-top-color"));
assertNull(i1.getValue(TermColor.class, "background-color"));
assertNull(i7.getValue(TermColor.class, "color"));
assertNull(i7.getValue(TermColor.class, "border-top-color"));
assertNull(i7.getValue(TermColor.class, "background-color"));
assertThat(i2.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0,128,0)));
assertThat(i5.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0,128,0)));
assertThat(i8.getValue(TermColor.class, "border-top-color"), is(tf.createColor(0,128,0)));
assertThat(i8.getValue(TermColor.class, "color"), is(tf.createColor(255,0,0)));
assertThat(i3.getValue(TermColor.class, "background-color"), is(tf.createColor(238,238,238)));
assertThat(i9.getValue(TermColor.class, "background-color"), is(tf.createColor(238,238,238)));
assertThat(i5.getValue(TermColor.class, "background-color"), is(tf.createColor(170,170,255)));
}