本文整理汇总了Java中cz.vutbr.web.css.StyleSheet类的典型用法代码示例。如果您正苦于以下问题:Java StyleSheet类的具体用法?Java StyleSheet怎么用?Java StyleSheet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StyleSheet类属于cz.vutbr.web.css包,在下文中一共展示了StyleSheet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: DOMAnalyzer
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
/**
* Creates a new DOM analyzer.
* @param doc the document to be analyzed
* @param baseUrl the base URL for loading the style sheets. If <code>detectBase</code>, this URL may be redefined by the <code><base></code> tag used in the
* document header.
* @param detectBase sets whether to try to accept the <code><base></code> tags in the document header.
*/
public DOMAnalyzer(org.w3c.dom.Document doc, URL baseUrl, boolean detectBase)
{
this.doc = doc;
this.encoding = null;
this.media = DEFAULT_MEDIA;
styles = new Vector<StyleSheet>();
this.baseUrl = baseUrl;
if (detectBase)
{
String docbase = getDocumentBase();
if (docbase != null)
{
try {
this.baseUrl = new URL(baseUrl, docbase);
System.err.println("DOMAnalyzer: Using specified document base " + this.baseUrl);
} catch (MalformedURLException e) {
System.err.println("DOMAnalyzer: error: malformed base URL " + docbase);
}
}
}
stylemap = null;
istylemap = null;
}
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:31,代码来源:DOMAnalyzer.java
示例2: feedLexer
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
private static CommonTokenStream feedLexer(CSSInputStream source,
StyleSheet stylesheet) throws CSSException {
// we have to unpack runtime exception
// because of Java limitation
// to change method contract with different type of exception
try {
CSSLexer lexer = new CSSLexer(source);
lexer.init(stylesheet);
return new CommonTokenStream(lexer);
} catch (RuntimeException re) {
if (re.getCause() instanceof CSSException) {
throw (CSSException) re.getCause();
}
// this is some other exception
else {
log.error("LEXER THROWS:", re);
throw re;
}
}
}
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:22,代码来源:CSSParserFactory.java
示例3: feedAST
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
private static CSSTreeParser feedAST(CommonTokenStream source,
CommonTree ast, Preparator preparator, StyleSheet stylesheet) {
if (log.isTraceEnabled()) {
log.trace("Feeding tree parser with AST:\n{}", TreeUtil
.toStringTree(ast));
}
// Walk resulting tree; create tree-node stream first
CommonTreeNodeStream nodes = new CommonTreeNodeStream(ast);
// AST nodes have payloads that point into token stream
nodes.setTokenStream(source);
CSSTreeParser parser = new CSSTreeParser(nodes);
return parser.init(stylesheet, preparator);
}
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:19,代码来源:CSSParserFactory.java
示例4: getOriginOrder
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
/**
* Computes the priority order of the declaration based on its origin and importance
* according to the CSS specification.
* @return The priority order (1..5).
* @see <a href="http://www.w3.org/TR/CSS21/cascade.html#cascading-order">http://www.w3.org/TR/CSS21/cascade.html#cascading-order</a>
*/
public int getOriginOrder()
{
if (important)
{
if (origin == StyleSheet.Origin.AUTHOR)
return 4;
else if (origin == StyleSheet.Origin.AGENT)
return 1;
else
return 5;
}
else
{
if (origin == StyleSheet.Origin.AUTHOR)
return 3;
else if (origin == StyleSheet.Origin.AGENT)
return 1;
else
return 2;
}
}
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:28,代码来源:AssignedDeclaration.java
示例5: DOMAnalyzer
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
/**
* Creates a new DOM analyzer.
* @param doc the document to be analyzed
* @param baseUrl the base URL for loading the style sheets. If <code>detectBase</code>, this URL may be redefined by the <code><base></code> tag used in the
* document header.
* @param detectBase sets whether to try to accept the <code><base></code> tags in the document header.
*/
public DOMAnalyzer(org.w3c.dom.Document doc, URL baseUrl, boolean detectBase)
{
this.doc = doc;
this.encoding = null;
this.media = new MediaSpec(DEFAULT_MEDIA);
styles = new Vector<StyleSheet>();
this.baseUrl = baseUrl;
if (detectBase)
{
String docbase = getDocumentBase();
if (docbase != null)
{
try {
this.baseUrl = new URL(baseUrl, docbase);
log.info("Using specified document base " + this.baseUrl);
} catch (MalformedURLException e) {
log.warn("Malformed base URL " + docbase);
}
}
}
stylemap = null;
istylemap = null;
}
开发者ID:radkovo,项目名称:CSSBox,代码行数:31,代码来源:DOMAnalyzer.java
示例6: pseudoClassDirect
import cz.vutbr.web.css.StyleSheet; //导入依赖的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)));
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:24,代码来源:PseudoClassTest.java
示例7: testRGBFunction1
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
@Test
public void testRGBFunction1() throws IOException, CSSException {
StyleSheet ss = CSSFactory.parseString(TEST_RGBFUNCTION1, null);
assertEquals("One rule is set", 1, ss.size());
RuleSet rule = (RuleSet) ss.get(0);
assertArrayEquals("Rule contains one selector BODY ",
SelectorsUtil.createSelectors("BODY"),
rule.getSelectors());
assertEquals("Rule contains one declaration {color: #00aa85;}",
DeclarationsUtil.appendDeclaration(null, "color",
tf.createColor(192, 64, 32)),
rule.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:19,代码来源:SimpleTest.java
示例8: testRGBFunction2
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
@Test
public void testRGBFunction2() throws IOException, CSSException {
StyleSheet ss = CSSFactory.parseString(TEST_RGBFUNCTION2, null);
assertEquals("One rule is set", 1, ss.size());
RuleSet rule = (RuleSet) ss.get(0);
assertArrayEquals("Rule contains one selector BODY ",
SelectorsUtil.createSelectors("BODY"),
rule.getSelectors());
assertEquals("Rule contains one declaration {color: rgb(50%,40%,30%);}",
DeclarationsUtil.appendDeclaration(null, "color",
tf.createColor(127, 102, 76)),
rule.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:18,代码来源:SimpleTest.java
示例9: testHSLFunction1
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
@Test
public void testHSLFunction1() throws IOException, CSSException {
StyleSheet ss = CSSFactory.parseString(TEST_HSLFUNCTION1, null);
assertEquals("One rule is set", 1, ss.size());
RuleSet rule = (RuleSet) ss.get(0);
assertArrayEquals("Rule contains one selector BODY ",
SelectorsUtil.createSelectors("BODY"),
rule.getSelectors());
assertEquals("Rule contains one declaration with color",
DeclarationsUtil.appendDeclaration(null, "color",
tf.createColor(0, 255, 0)),
rule.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:19,代码来源:SimpleTest.java
示例10: testRGBAFunction1
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
@Test
public void testRGBAFunction1() throws IOException, CSSException {
StyleSheet ss = CSSFactory.parseString(TEST_RGBAFUNCTION1, null);
assertEquals("One rule is set", 1, ss.size());
RuleSet rule = (RuleSet) ss.get(0);
assertArrayEquals("Rule contains one selector BODY ",
SelectorsUtil.createSelectors("BODY"),
rule.getSelectors());
assertEquals("Rule contains one declaration with color",
DeclarationsUtil.appendDeclaration(null, "color",
tf.createColor(255, 0, 0, 51)),
rule.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:19,代码来源:SimpleTest.java
示例11: testHSLAFunction1
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
@Test
public void testHSLAFunction1() throws IOException, CSSException {
StyleSheet ss = CSSFactory.parseString(TEST_HSLAFUNCTION1, null);
assertEquals("One rule is set", 1, ss.size());
RuleSet rule = (RuleSet) ss.get(0);
assertArrayEquals("Rule contains one selector BODY ",
SelectorsUtil.createSelectors("BODY"),
rule.getSelectors());
assertEquals("Rule contains one declaration with color",
DeclarationsUtil.appendDeclaration(null, "color",
tf.createColor(0, 0, 255, 102)),
rule.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:19,代码来源:SimpleTest.java
示例12: testHashColor2
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
@Test
public void testHashColor2() throws IOException, CSSException {
StyleSheet ss = CSSFactory.parseString(TEST_HASH_COLOR2, null);
assertEquals("One rule is set", 1, ss.size());
final RuleSet rule = (RuleSet) ss.get(0);
assertArrayEquals("Rule contains two selectors DIV, P",
SelectorsUtil.createSelectors("DIV", "P"),
rule.getSelectors());
assertEquals("Rule contains one declaration {color: #CCC;}",
DeclarationsUtil.appendDeclaration(null, "color",
tf.createColor(204,204,204)),
rule.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:18,代码来源:SimpleTest.java
示例13: testInvalidPseudoSelector2
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
@Test
public void testInvalidPseudoSelector2() throws IOException, CSSException {
StyleSheet ss = CSSFactory.parseString(TEST_INVALID_PSEUDO_SELECTOR2, null);
assertEquals("One rule is set", 1, ss.size());
RuleSet rule = (RuleSet) ss.get(0);
assertArrayEquals("Rule contains one selector p ",
SelectorsUtil.createSelectors("p"),
rule.getSelectors());
assertEquals("Rule contains one declaration {background: green}",
DeclarationsUtil.appendDeclaration(null, "background",
tf.createColor(0, 128, 0)),
rule.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:17,代码来源:SimpleTest.java
示例14: testAttributePresence
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
@Test
public void testAttributePresence() throws CSSException, IOException {
StyleSheet ss = CSSFactory.parseString(TEST_ATTRIB_PRESENCE, null);
assertEquals("One rule is set", 1, ss.size());
List<CombinedSelector> cslist = SelectorsUtil.appendCS(null);
SelectorsUtil.appendSimpleSelector(cslist, "*", null, rf
.createAttribute(null, false, Selector.Operator.NO_OPERATOR,
"href"));
assertArrayEquals("Rule 1 contains one combined selector *[href]", cslist.toArray(),
((RuleSet) ss.get(0)).getSelectors());
List<Term<?>> terms = DeclarationsUtil.appendTerm(null, null, tf
.createIdent("Verdana"));
DeclarationsUtil.appendCommaTerm(terms, tf.createIdent("monospace"));
assertEquals(
"Rule contains one declaration { text-decoration: underline }",
DeclarationsUtil.appendDeclaration(null, "text-decoration", tf
.createIdent("underline")), ((RuleSet) ss.get(0))
.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:26,代码来源:SelectorTest.java
示例15: checkDataCSS
import cz.vutbr.web.css.StyleSheet; //导入依赖的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"));
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:27,代码来源:ImportTest1.java
示例16: testFFMultiSrc
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
@Test
public void testFFMultiSrc() throws IOException, CSSException {
log.info("input:\n\n\n" + TEST_STRING2 + "\n\n\n");
StyleSheet ss;
ss = CSSFactory.parseString(TEST_STRING2, null);
assertEquals("One rule is set", 1, ss.size());
RuleFontFace rule = (RuleFontFace) ss.get(0);
assertEquals("Rule contains 2 declarations ", 2, rule.size());
assertEquals("Rule contains font-family declaration", "font-family: 'MyWebFont';\n", rule.get(0).toString());
assertEquals("Rule contains scr declaration",
"src: url('myfont.woff2') format('woff2'), url('myfont.woff') format('woff'), url('myfont.ttf') format('truetype');\n",
rule.get(1).toString());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:18,代码来源:FontFaceTest.java
示例17: pseudoClassDirectNonStatic
import cz.vutbr.web.css.StyleSheet; //导入依赖的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)));
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:24,代码来源:PseudoClassTest.java
示例18: testDescendant
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
@Test
public void testDescendant() throws CSSException, IOException {
StyleSheet ss = CSSFactory.parseString(TEST_DESCENDANT, null);
assertEquals("One rule is set", 1, ss.size());
RuleSet rule = (RuleSet) ss.get(0);
List<CombinedSelector> cslist = SelectorsUtil.appendCS(null);
SelectorsUtil.appendSimpleSelector(cslist, "H1", null);
SelectorsUtil.appendDescendant(cslist, "P");
assertArrayEquals("Rule contains one combined selectors H1 P ", cslist.toArray(),
rule.getSelectors());
assertEquals("Rule contains one declaration {display:inline;}",
DeclarationsUtil.appendDeclaration(null, "display", tf
.createIdent("inline")), rule.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:21,代码来源:SelectorTest.java
示例19: testAdjacent
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
@Test
public void testAdjacent() throws CSSException, IOException {
StyleSheet ss = CSSFactory.parseString(TEST_ADJACENT, null);
assertEquals("One rule is set", 1, ss.size());
RuleSet rule = (RuleSet) ss.get(0);
List<CombinedSelector> cslist = SelectorsUtil.appendCS(null);
SelectorsUtil.appendSimpleSelector(cslist, "DIV", null);
SelectorsUtil.appendAdjacent(cslist, "P");
assertArrayEquals("Rule contains one combined selectors DIV+P ", cslist.toArray(),
rule.getSelectors());
assertEquals("Rule contains one declaration {color:blue;}",
DeclarationsUtil.appendDeclaration(null, "color", tf
.createColor(0, 0, 255)), rule.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:21,代码来源:SelectorTest.java
示例20: testClass
import cz.vutbr.web.css.StyleSheet; //导入依赖的package包/类
@Test
public void testClass() throws CSSException, IOException {
StyleSheet ss = CSSFactory.parseString(TEST_CLASS, null);
assertEquals("One rule is set", 1, ss.size());
RuleSet rule = (RuleSet) ss.get(0);
List<CombinedSelector> cslist = SelectorsUtil.appendCS(null);
SelectorsUtil.appendSimpleSelector(cslist, null, null, rf
.createClass("fit"));
assertArrayEquals("Rule contains one class selector .fit", cslist.toArray(), rule
.getSelectors());
assertEquals("Rule contains one declaration { width: 80%;}",
DeclarationsUtil.appendDeclaration(null, "width", tf
.createPercent(80.0f)), rule.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:20,代码来源:SelectorTest.java
注:本文中的cz.vutbr.web.css.StyleSheet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论