本文整理汇总了Java中cz.vutbr.web.css.CSSFactory类的典型用法代码示例。如果您正苦于以下问题:Java CSSFactory类的具体用法?Java CSSFactory怎么用?Java CSSFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CSSFactory类属于cz.vutbr.web.css包,在下文中一共展示了CSSFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createAnonymousStyle
import cz.vutbr.web.css.CSSFactory; //导入依赖的package包/类
/**
* Creates the style definition for an anonymous box. It contains only the class name set to "Xanonymous"
* and the display: property set according to the parametres.
* @param display <code>display:</code> property value of the resulting style.
* @return Resulting style definition
*/
public NodeData createAnonymousStyle(String display)
{
NodeData ret = CSSFactory.createNodeData();
Declaration cls = CSSFactory.getRuleFactory().createDeclaration();
cls.unlock();
cls.setProperty("class");
cls.add(CSSFactory.getTermFactory().createString("Xanonymous"));
ret.push(cls);
Declaration disp = CSSFactory.getRuleFactory().createDeclaration();
disp.unlock();
disp.setProperty("display");
disp.add(CSSFactory.getTermFactory().createIdent(display));
ret.push(disp);
return ret;
}
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:25,代码来源:BoxFactory.java
示例2: getElementStyle
import cz.vutbr.web.css.CSSFactory; //导入依赖的package包/类
/**
* Computes the style of an element with an eventual pseudo element for the given media.
* @param el The DOM element.
* @param pseudo A pseudo element that should be used for style computation or <code>null</code> if no pseudo element should be used (e.g. :after).
* @param media Used media name (e.g. "screen" or "all")
* @return The relevant declarations from the registered style sheets.
*/
public NodeData getElementStyle(Element el, PseudoDeclaration pseudo, String media)
{
Holder holder;
if (UNIVERSAL_HOLDER.equals(media))
holder = rules.get(UNIVERSAL_HOLDER);
else
holder = Holder.union(rules.get(UNIVERSAL_HOLDER), rules.get(media));
List<Declaration> decls = getDeclarationsForElement(el, pseudo, holder);
NodeData main = CSSFactory.createNodeData();
for (Declaration d : decls)
main.push(d);
return main;
}
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:24,代码来源:DirectAnalyzer.java
示例3: genericTermLength
import cz.vutbr.web.css.CSSFactory; //导入依赖的package包/类
/**
* Converts term into TermLength and stores values and types in maps
*
* @param <T>
* CSSProperty
* @param term
* Term to be parsed
* @param propertyName
* How to store colorIdentificiton
* @param lengthIdentification
* What to store under propertyName
* @param properties
* Map to store property types
* @param values
* Map to store property values
* @return <code>true</code> in case of success, <code>false</code>
* otherwise
*/
protected <T extends CSSProperty> boolean genericTermLength(Term<?> term,
String propertyName, T lengthIdentification, boolean sanify,
Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
if (term instanceof TermInteger && ((TermInteger) term).getUnit().equals(TermNumber.Unit.none)) {
if (CSSFactory.getImplyPixelLength() || ((TermInteger) term).getValue() == 0) { //0 is always allowed with no units
// convert to length with units of px
TermLength tl = tf.createLength(((TermInteger) term).getValue(), TermNumber.Unit.px);
return genericTerm(TermLength.class, tl, propertyName, lengthIdentification, sanify, properties, values);
} else {
return false;
}
}
else if (term instanceof TermLength) {
return genericTerm(TermLength.class, term, propertyName, lengthIdentification, sanify, properties, values);
}
return false;
}
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:39,代码来源:DeclarationTransformer.java
示例4: createTermColor
import cz.vutbr.web.css.CSSFactory; //导入依赖的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);
}
开发者ID:radkovo,项目名称:Pdf2Dom,代码行数:22,代码来源:CSSBoxTree.java
示例5: testPseudo
import cz.vutbr.web.css.CSSFactory; //导入依赖的package包/类
@Test
public void testPseudo() throws CSSException, IOException {
StyleSheet ss = CSSFactory.parseString(TEST_PSEUDO, 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
.createPseudoPage("hover", null));
assertArrayEquals("Rule contains one pseudoselector :hover", cslist.toArray(), rule
.getSelectors());
assertEquals(
"Rule contains one declaration { text-decoration: underline; }",
DeclarationsUtil.appendDeclaration(null, "text-decoration", tf
.createIdent("underline")), rule.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:21,代码来源:SelectorTest.java
示例6: createPageStyle
import cz.vutbr.web.css.CSSFactory; //导入依赖的package包/类
/**
* Creates a style definition used for pages.
* @return The page style definition.
*/
protected NodeData createPageStyle()
{
NodeData ret = createBlockStyle();
TermFactory tf = CSSFactory.getTermFactory();
ret.push(createDeclaration("position", tf.createIdent("relative")));
ret.push(createDeclaration("border-width", tf.createLength(1f, Unit.px)));
ret.push(createDeclaration("border-style", tf.createIdent("solid")));
ret.push(createDeclaration("border-color", tf.createColor(0, 0, 255)));
ret.push(createDeclaration("margin", tf.createLength(0.5f, Unit.em)));
PDRectangle layout = getCurrentMediaBox();
if (layout != null)
{
float w = layout.getWidth();
float h = layout.getHeight();
final int rot = pdpage.getRotation();
if (rot == 90 || rot == 270)
{
float x = w; w = h; h = x;
}
ret.push(createDeclaration("width", tf.createLength(w, unit)));
ret.push(createDeclaration("height", tf.createLength(h, unit)));
}
else
log.warn("No media box found");
return ret;
}
开发者ID:radkovo,项目名称:Pdf2Dom,代码行数:34,代码来源:CSSBoxTree.java
示例7: Viewport
import cz.vutbr.web.css.CSSFactory; //导入依赖的package包/类
/**
* Creates a new Viewport with the given initial size. The actual size may be increased during the layout.
*
* @param e The anonymous element representing the viewport.
* @param g
* @param ctx
* @param factory The factory used for creating the child boxes.
* @param root The root element of the rendered document.
* @param width Preferred (minimal) width.
* @param height Preferred (minimal) height.
*/
public Viewport(Element e, Graphics2D g, VisualContext ctx, BoxFactory factory, Element root, int width, int height)
{
super(e, g, ctx);
ctx.setViewport(this);
this.factory = factory;
this.root = root;
style = CSSFactory.createNodeData(); //Viewport starts with an empty style
nested = new Vector<Box>();
startChild = 0;
endChild = 0;
this.width = width;
this.height = height;
isblock = true;
contblock = true;
root = null;
visibleRect = new Rectangle(0, 0, width, height);
}
开发者ID:radkovo,项目名称:CSSBox,代码行数:29,代码来源:Viewport.java
示例8: pseudoClassDirect
import cz.vutbr.web.css.CSSFactory; //导入依赖的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
示例9: genericTermLength
import cz.vutbr.web.css.CSSFactory; //导入依赖的package包/类
/**
* Converts term into TermLength and stores values and types in maps
*
* @param <T>
* CSSProperty
* @param term
* Term to be parsed
* @param propertyName
* How to store colorIdentificiton
* @param lengthIdentification
* What to store under propertyName
* @param properties
* Map to store property types
* @param values
* Map to store property values
* @return <code>true</code> in case of success, <code>false</code>
* otherwise
*/
protected <T extends CSSProperty> boolean genericTermLength(Term<?> term,
String propertyName, T lengthIdentification, ValueRange range,
Map<String, CSSProperty> properties, Map<String, Term<?>> values) {
if (term instanceof TermInteger && ((TermInteger) term).getUnit().equals(TermNumber.Unit.none)) {
if (CSSFactory.getImplyPixelLength() || ((TermInteger) term).getValue() == 0) { //0 is always allowed with no units
// convert to length with units of px
TermLength tl = tf.createLength(((TermInteger) term).getValue(), TermNumber.Unit.px);
return genericTerm(TermLength.class, tl, propertyName, lengthIdentification, range, properties, values);
} else {
return false;
}
}
else if (term instanceof TermLength) {
return genericTerm(TermLength.class, term, propertyName, lengthIdentification, range, properties, values);
}
return false;
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:39,代码来源:DeclarationTransformerImpl.java
示例10: testPseudoFunc
import cz.vutbr.web.css.CSSFactory; //导入依赖的package包/类
@Test
public void testPseudoFunc() throws CSSException, IOException {
StyleSheet ss = CSSFactory.parseString(TEST_PSEUDO_FUNC, 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
.createPseudoPage("fr", "lang"));
SelectorsUtil.appendChild(cslist, "Q");
assertArrayEquals("Rule contains one combined pseudoselector :lang(fr)>Q",
cslist.toArray(), rule.getSelectors());
List<Term<?>> terms = DeclarationsUtil.appendTerm(null, null, tf
.createString("« "));
DeclarationsUtil.appendSpaceTerm(terms, tf.createString(" »"));
assertEquals("Rule contains one declaration { quotes: '« ' ' »' }",
DeclarationsUtil.appendDeclaration(null, "quotes", terms), rule
.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:25,代码来源:SelectorTest.java
示例11: 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)));
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:20,代码来源:DOMAssignTest.java
示例12: 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"));
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:27,代码来源:DOMAssignTest.java
示例13: 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)));
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:20,代码来源:DOMAssignTest.java
示例14: 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"))));
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:19,代码来源:DOMAssignTest.java
示例15: 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)));
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:20,代码来源:DOMAssignTest.java
示例16: testRGBFunction1
import cz.vutbr.web.css.CSSFactory; //导入依赖的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
示例17: testRGBFunctionInvalid
import cz.vutbr.web.css.CSSFactory; //导入依赖的package包/类
@Test
public void testRGBFunctionInvalid() throws IOException, CSSException {
StyleSheet ss = CSSFactory.parseString(TEST_RGBFUNCTION_INVALID, 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", 1, rule.size());
Term<?> value = rule.get(0).get(0);
assertTrue("Assigned value is TermFunction (not TermColor)", value instanceof TermFunction);
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:17,代码来源:SimpleTest.java
示例18: testHSLFunction1
import cz.vutbr.web.css.CSSFactory; //导入依赖的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
示例19: testHashColor1
import cz.vutbr.web.css.CSSFactory; //导入依赖的package包/类
@Test
public void testHashColor1() throws IOException, CSSException {
StyleSheet ss = CSSFactory.parseString(TEST_HASH_COLOR1, 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(0, 170, 133)),
rule.asList());
}
开发者ID:radkovo,项目名称:jStyleParser,代码行数:19,代码来源:SimpleTest.java
示例20: testHashColor2
import cz.vutbr.web.css.CSSFactory; //导入依赖的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
注:本文中的cz.vutbr.web.css.CSSFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论