本文整理汇总了Java中cz.vutbr.web.css.TermColor类的典型用法代码示例。如果您正苦于以下问题:Java TermColor类的具体用法?Java TermColor怎么用?Java TermColor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TermColor类属于cz.vutbr.web.css包,在下文中一共展示了TermColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBorderColor
import cz.vutbr.web.css.TermColor; //导入依赖的package包/类
/**
* Returns color of border
*/
private Color getBorderColor(ElementBox elem, String side) {
Color clr = null;
// gets the color value from CSS property
CSSProperty.BorderColor bclr = elem.getStyle().getProperty("border-"+side+"-color");
TermColor tclr = elem.getStyle().getValue(TermColor.class, "border-"+side+"-color");
CSSProperty.BorderStyle bst = elem.getStyle().getProperty("border-"+side+"-style");
if (bst != CSSProperty.BorderStyle.HIDDEN && bclr != CSSProperty.BorderColor.TRANSPARENT) {
if (tclr != null) clr = tclr.getValue();
if (clr == null) {
clr = elem.getVisualContext().getColor();
if (clr == null) clr = Color.BLACK;
}
}
else { clr = elem.getBgcolor(); }
return clr;
}
示例2: createTermColor
import cz.vutbr.web.css.TermColor; //导入依赖的package包/类
private static TermColor createTermColor(String color)
{
TermFactory tf = CSSFactory.getTermFactory();
if (color.startsWith("rgba"))
{
color = color.replaceAll("rgba|\\)|\\(", "");
String[] params = color.split(",");
int[] colorValues = new int[params.length];
for (int i = 0; i < params.length; i++)
colorValues[i] = Integer.parseInt(params[i]);
TermColor termColor = tf.createColor(0, 0, 0);
termColor.setValue(new Color(colorValues[0], colorValues[1], colorValues[2], colorValues[3]));
return termColor;
}
else
return tf.createColor(color);
}
示例3: combinators
import cz.vutbr.web.css.TermColor; //导入依赖的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)));
}
示例4: inherit
import cz.vutbr.web.css.TermColor; //导入依赖的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"));
}
示例5: initial
import cz.vutbr.web.css.TermColor; //导入依赖的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)));
}
示例6: defaulting
import cz.vutbr.web.css.TermColor; //导入依赖的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"))));
}
示例7: evaluateSimple
import cz.vutbr.web.css.TermColor; //导入依赖的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: checkDocument
import cz.vutbr.web.css.TermColor; //导入依赖的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"));
}
}
示例9: pseudoClassMap
import cz.vutbr.web.css.TermColor; //导入依赖的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)));
}
示例10: pseudoClassDirect
import cz.vutbr.web.css.TermColor; //导入依赖的package包/类
@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", PseudoDeclaration.LINK);
cond.addMatch(elements.getElementById("l2"), PseudoDeclaration.HOVER);
cond.addMatch(elements.getElementById("l3"), PseudoDeclaration.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)));
}
示例11: pseudoClassMapNonStatic
import cz.vutbr.web.css.TermColor; //导入依赖的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)));
}
示例12: pseudoClassDirectNonStatic
import cz.vutbr.web.css.TermColor; //导入依赖的package包/类
@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", PseudoDeclaration.LINK);
cond.addMatch(elements.getElementById("l2"), PseudoDeclaration.HOVER);
cond.addMatch(elements.getElementById("l3"), PseudoDeclaration.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)));
}
示例13: writeBorderSVG
import cz.vutbr.web.css.TermColor; //导入依赖的package包/类
protected void writeBorderSVG(ElementBox eb, int x1, int y1, int x2, int y2, String side, int width, int right, int down, PrintWriter out) throws IOException
{
TermColor tclr = eb.getStyle().getValue(TermColor.class, "border-"+side+"-color");
CSSProperty.BorderStyle bst = eb.getStyle().getProperty("border-"+side+"-style");
if (tclr != null && bst != CSSProperty.BorderStyle.HIDDEN)
{
Color clr = tclr.getValue();
if (clr == null) clr = Color.BLACK;
String stroke = "";
if (bst == CSSProperty.BorderStyle.SOLID)
{
stroke = "stroke-width:" + width;
}
else if (bst == CSSProperty.BorderStyle.DOTTED)
{
stroke = "stroke-width:" + width + ";stroke-dasharray:" + width + "," + width;
}
else if (bst == CSSProperty.BorderStyle.DASHED)
{
stroke = "stroke-width:" + width + ";stroke-dasharray:" + (3*width) + "," + width;
}
else if (bst == CSSProperty.BorderStyle.DOUBLE)
{
//double is not supported yet, we'll use single
stroke = "stroke-width:" + width;
}
else //default or unsupported - draw a solid line
{
stroke = "stroke-width:" + width;
}
String coords = "M " + (x1+right) + "," + (y1+down) + " L " + (x2+right) + "," + (y2+down);
String style = "fill:none;stroke:" + colorString(clr) + ";" + stroke;
out.println("<path style=\"" + style + "\" d=\"" + coords + "\" />");
}
}
示例14: operation
import cz.vutbr.web.css.TermColor; //导入依赖的package包/类
@Override
protected boolean operation(int i, Map<String, CSSProperty> properties,
Map<String, Term<?>> values) {
return genericTermIdent(type, terms.get(i), AVOID_INH,
names.get(i), properties)
|| genericTerm(TermColor.class, terms.get(i), names.get(i),
BorderColor.color, false, properties, values);
}
示例15: operation
import cz.vutbr.web.css.TermColor; //导入依赖的package包/类
@Override
protected boolean operation(int i, Map<String, CSSProperty> properties,
Map<String, Term<?>> values) {
return genericTermIdent(type, terms.get(i), ALLOW_INH, names.get(i), properties)
|| genericTerm(TermColor.class, terms.get(i), names.get(i), BorderColor.color, false, properties, values);
}