本文整理汇总了Java中cz.vutbr.web.css.CSSFactory.assignDOM方法的典型用法代码示例。如果您正苦于以下问题:Java CSSFactory.assignDOM方法的具体用法?Java CSSFactory.assignDOM怎么用?Java CSSFactory.assignDOM使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cz.vutbr.web.css.CSSFactory
的用法示例。
在下文中一共展示了CSSFactory.assignDOM方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: combinators
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的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.css.CSSFactory; //导入方法依赖的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.css.CSSFactory; //导入方法依赖的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.css.CSSFactory; //导入方法依赖的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.css.CSSFactory; //导入方法依赖的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: checkDocument
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的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"));
}
}
示例7: main
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的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");
}
示例8: pseudoClassMap
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的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)));
}
示例9: pseudoClassMapNonStatic
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的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)));
}
示例10: structureSelectors
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的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)));
}
示例11: indexSelectors
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的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)));
}
示例12: evaluateForMedia
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
private NodeData evaluateForMedia(MediaSpec spec) throws SAXException, IOException
{
DOMSource ds = new DOMSource(getClass().getResourceAsStream("/media/media1.html"));
Document doc = ds.parse();
ElementMap elements = new ElementMap(doc);
StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/media/media1.html"), spec, true);
NodeData data = decl.get(elements.getElementById("test"));
return data;
}
示例13: backgrounds
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@Test
public void backgrounds() throws SAXException, IOException {
DOMSource ds = new DOMSource(getClass().getResourceAsStream("/advanced/background.html"));
Document doc = ds.parse();
ElementMap elements = new ElementMap(doc);
StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/advanced/background.html"), "screen", true);
NodeData data = decl.get(elements.getElementById("bg1"));
assertNotNull("Data for #bg1 exist", data);
assertEquals(data.getValue(TermList.class, "background-position").size(), 2);
assertEquals(stripOperator((TermLength) data.getValue(TermList.class, "background-position").get(0)), tf.createLength(25.0f, Unit.px));
assertEquals(stripOperator((TermLength) data.getValue(TermList.class, "background-position").get(1)), tf.createLength(25.0f, Unit.px));
assertEquals(data.getValue(TermList.class, "background-size").size(), 2);
assertEquals(stripOperator((TermLength) data.getValue(TermList.class, "background-size").get(0)), tf.createLength(1.0f, Unit.px));
assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-size").get(1)), tf.createPercent(10.0f));
assertEquals(data.getValue(TermColor.class, "background-color"), tf.createColor(0, 0, 255));
data = decl.get(elements.getElementById("bg2"));
assertNotNull("Data for #bg2 exist", data);
assertEquals(data.getValue(TermList.class, "background-position").size(), 2);
assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-position").get(0)), tf.createPercent(100.0f));
assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-position").get(1)), tf.createPercent(100.0f));
assertEquals(data.getProperty("background-size"), BackgroundSize.COVER);
assertEquals(data.getValue(TermColor.class, "background-color"), tf.createColor(255, 255, 0));
data = decl.get(elements.getElementById("bg3"));
assertNotNull("Data for #bg3 exist", data);
assertEquals(data.getValue(TermList.class, "background-position").size(), 2);
assertEquals(stripOperator((TermLength) data.getValue(TermList.class, "background-position").get(0)), tf.createLength(10.0f, Unit.pt));
assertEquals(stripOperator((TermPercent) data.getValue(TermList.class, "background-position").get(1)), tf.createPercent(50.0f));
assertEquals(data.getValue(TermList.class, "background-size").size(), 2);
assertEquals(stripOperator((TermLength) data.getValue(TermList.class, "background-size").get(0)), tf.createLength(20.0f, Unit.px));
assertEquals(data.getValue(TermList.class, "background-size").get(1), tf.createIdent("auto"));
assertEquals(data.getValue(TermColor.class, "background-color"), tf.createColor(0, 128, 0));
}
示例14: basic
import cz.vutbr.web.css.CSSFactory; //导入方法依赖的package包/类
@Test
public void basic() throws SAXException, IOException {
DOMSource ds = new DOMSource(getClass().getResourceAsStream("/advanced/domassign.html"));
Document doc = ds.parse();
ElementMap elements = new ElementMap(doc);
StyleMap decl = CSSFactory.assignDOM(doc, null, getClass().getResource("/advanced/domassign.html"), "screen", true);
NodeData data = decl.get(elements.getElementById("bp"));
assertNotNull("Data for #bp exist", data);
assertThat(data.getValue(TermList.class, "background-position").size(), is(2));
assertThat(data.getValue(TermColor.class, "color"), is(tf.createColor(255, 255, 255)));
data = decl.get(elements.getElementById("battlecruiser"));
assertThat(tf.createColor(255, 255, 0), is(data.getValue(TermColor.class, "color")));
data = decl.get(elements.getElementById("border"));
assertNotNull("Data for #border exist", data);
assertThat(data.getValue(TermColor.class, "border-bottom-color"),
is(tf.createColor(255,255,255)));
}