本文整理汇总了Java中cz.vutbr.web.domassign.StyleMap.get方法的典型用法代码示例。如果您正苦于以下问题:Java StyleMap.get方法的具体用法?Java StyleMap.get怎么用?Java StyleMap.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cz.vutbr.web.domassign.StyleMap
的用法示例。
在下文中一共展示了StyleMap.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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"));
}
示例2: 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)));
}
示例3: 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"))));
}
示例4: 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)));
}
示例5: 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));
}
示例6: 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"));
}
示例7: 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);
}
示例8: 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"));
}
示例9: 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"));
}
}
示例10: 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)));
}
示例11: 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)));
}
示例12: 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"));
}
示例13: evaluateForMedia
import cz.vutbr.web.domassign.StyleMap; //导入方法依赖的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;
}
示例14: backgrounds
import cz.vutbr.web.domassign.StyleMap; //导入方法依赖的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));
}
示例15: basic
import cz.vutbr.web.domassign.StyleMap; //导入方法依赖的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)));
}