• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CSSRule类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.w3c.dom.css.CSSRule的典型用法代码示例。如果您正苦于以下问题:Java CSSRule类的具体用法?Java CSSRule怎么用?Java CSSRule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CSSRule类属于org.w3c.dom.css包,在下文中一共展示了CSSRule类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
private void init() {
    if (style != null) {
        String styleContent = style.getValue().getText();
        if (styleContent != null && !styleContent.isEmpty()) {
            InputSource source = new InputSource(new StringReader(styleContent));
            CSSOMParser parser = new CSSOMParser(new SACParserCSS3());
            parser.setErrorHandler(new ParserErrorHandler());
            try {
                styleSheet = parser.parseStyleSheet(source, null, null);
                cssFormat = new CSSFormat().setRgbAsHex(true);

                CSSRuleList rules = styleSheet.getCssRules();
                for (int i = 0; i < rules.getLength(); i++) {
                    final CSSRule rule = rules.item(i);
                    if (rule instanceof CSSStyleRuleImpl) {
                        styleRuleMap.put(((CSSStyleRuleImpl) rule).getSelectorText(), (CSSStyleRuleImpl) rule);
                    }
                }

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
 
开发者ID:misakuo,项目名称:svgtoandroid,代码行数:26,代码来源:StyleParser.java


示例2: checkForCSSPseudoRules

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
private void checkForCSSPseudoRules() {
        Collection ss = document.getStyleSheets();
        java.util.Iterator itss = ss.iterator();
        Pattern patRule = Pattern.compile("^([^:]+?):(link|active|visited|hover)\\s+(\\{.+)$");
        HashSet newRules = new HashSet();
        while (itss.hasNext()) {
        	CSSStyleSheetImpl ss1 = (CSSStyleSheetImpl)itss.next();
        	CSSRuleList ruleList = ss1.getCssRules();
        	for (int i=0; i < ruleList.getLength(); i++) {
        		CSSRule rule = ruleList.item(i);
        		String ruleText = rule.getCssText();
//        		System.out.println("rule : "+ruleText);
        		Matcher mpatRule = patRule.matcher(ruleText);
        		if (mpatRule.find()) {
        			String newRuleText = mpatRule.group(1)+" "+mpatRule.group(3);
        			if (!newRules.contains(mpatRule.group(1))) {
        				newRules.add(mpatRule.group(1));
//        				System.out.println("***new rule : "+newRuleText);
        				ss1.insertRule(newRuleText, i++);
        			}
        		}
        	}
        }
    }
 
开发者ID:LowResourceLanguages,项目名称:InuktitutComputing,代码行数:25,代码来源:NRC_HTMLDocumentByCobra.java


示例3: readObject

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
	baseUri_ = (String) in.readObject();
	cssRules_ = (CSSRuleList) in.readObject();
	if (cssRules_ != null) {
		for (int i = 0; i < cssRules_.getLength(); i++) {
			final CSSRule cssRule = cssRules_.item(i);
			if (cssRule instanceof AbstractCSSRuleImpl) {
				((AbstractCSSRuleImpl) cssRule).setParentStyleSheet(this);
			}
		}
	}
	disabled_ = in.readBoolean();
	href_ = (String) in.readObject();
	media_ = (MediaList) in.readObject();
	// TODO ownerNode may not be serializable!
	// ownerNode = (Node) in.readObject();
	readOnly_ = in.readBoolean();
	title_ = (String) in.readObject();
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:20,代码来源:CSSStyleSheetImpl.java


示例4: showStyleSheet

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
/**
 * Show style sheet.
 *
 * @param styleSheet
 *            the style sheet
 */
private void showStyleSheet(CSSStyleSheet styleSheet) {
	StringWriter stringWriter = new StringWriter();
	PrintWriter writer = new PrintWriter(stringWriter);
	writer.println("<DL>");
	CSSRuleList ruleList = styleSheet.getCssRules();
	int length = ruleList.getLength();
	for (int i = 0; i < length; i++) {
		CSSRule rule = ruleList.item(i);
		writer.println("<DT><strong>Rule: type=" + rule.getType() + ",class=" + rule.getClass().getName()
				+ "</strong></DT>");
		writer.println("<DD>");
		this.writeRuleInfo(writer, rule);
		writer.println("</DD>");
	}
	writer.println("</DL>");
	writer.flush();
	String html = stringWriter.toString();
	HtmlRendererContext rcontext = new SimpleHtmlRendererContext(this.cssOutput, (UserAgentContext) null);
	this.cssOutput.setHtml(html, "about:css", rcontext);
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:27,代码来源:CssParserTest.java


示例5: parseStyleSheetDefinition

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
public static StyleSheetDefinition parseStyleSheetDefinition(final String cssPath,
                                                             final InputStream cssStream) throws TranslatorException {
    final CSSStyleSheetImpl sheet = parseStyleSheet(new InputSource(new InputStreamReader(cssStream)));
    final CSSRuleList cssRules = sheet.getCssRules();
    final StyleSheetDefinition result = new StyleSheetDefinition(cssPath);
    for (int i = 0; i < cssRules.getLength(); i++) {
        final CSSRule item = cssRules.item(i);
        if (CSSRule.STYLE_RULE == item.getType()) {
            final CSSStyleRuleImpl rule = (CSSStyleRuleImpl) item;
            final String selectorText = rule.getSelectorText();
            final CSSStyleDeclaration declaration = rule.getStyle();
            final StyleDefinition styleDefinition = parseStyleDefinition(declaration);
            result.addStyle(selectorText, styleDefinition);
        }
    }
    return result;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:18,代码来源:SVGStyleTranslatorHelper.java


示例6: jdkClasses

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
@DataProvider(name = "jdkClasses")
public Object[][] jdkClasses() {
    return new Object[][] {
        { java.awt.Button.class,             null },
        { java.lang.Object.class,            null },
        { org.w3c.dom.css.CSSRule.class,     null },
        { loadClass("org.w3c.dom.css.Fake"), loadClass("org.w3c.dom.css.FakePackage") },
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:PackageInfoTest.java


示例7: CSSOMSVGStyleDeclaration

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
/**
 * Creates a new CSSOMSVGStyleDeclaration.
 */
public CSSOMSVGStyleDeclaration(ValueProvider vp,
                                CSSRule parent,
                                CSSEngine eng) {
    super(vp, parent);
    cssEngine = eng;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:10,代码来源:CSSOMSVGStyleDeclaration.java


示例8: getParentRule

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
private CSSRule getParentRule() {
	if (!nodeStack_.empty() && nodeStack_.size() > 1) {
		final Object node = nodeStack_.get(nodeStack_.size() - 2);
		if (node instanceof CSSRule) {
			return (CSSRule) node;
		}
	}
	return null;
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:10,代码来源:CSSOMParser.java


示例9: getCssText

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String getCssText(final CSSFormat format) {
	final StringBuilder sb = new StringBuilder("@media ");

	sb.append(((MediaListImpl) getMedia()).getMediaText(format));
	sb.append(" {");
	for (int i = 0; i < getCssRules().getLength(); i++) {
		final CSSRule rule = getCssRules().item(i);
		sb.append(rule.getCssText()).append(" ");
	}
	sb.append("}");
	return sb.toString();
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:17,代码来源:CSSMediaRuleImpl.java


示例10: readObject

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {

		cssRules_ = (CSSRuleList) in.readObject();
		if (cssRules_ != null) {
			for (int i = 0; i < cssRules_.getLength(); i++) {
				final CSSRule cssRule = cssRules_.item(i);
				if (cssRule instanceof AbstractCSSRuleImpl) {
					((AbstractCSSRuleImpl) cssRule).setParentRule(this);
					((AbstractCSSRuleImpl) cssRule).setParentStyleSheet(getParentStyleSheetImpl());
				}
			}
		}
		media_ = (MediaList) in.readObject();
	}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:15,代码来源:CSSMediaRuleImpl.java


示例11: equals

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
@Override
public boolean equals(final Object obj) {
	if (this == obj) {
		return true;
	}
	if (!(obj instanceof CSSRule)) {
		return false;
	}
	return super.equals(obj);
	// don't use parentRule and parentStyleSheet in equals()
	// recursive loop -> stack overflow!
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:13,代码来源:AbstractCSSRuleImpl.java


示例12: item

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
@Override
public CSSRule item(final int index) {
	if (index < 0 || null == rules_ || index >= rules_.size()) {
		return null;
	}
	return rules_.get(index);
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:8,代码来源:CSSRuleListImpl.java


示例13: getCssText

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String getCssText(final CSSFormat format) {
	final StringBuilder sb = new StringBuilder();
	for (int i = 0; i < getLength(); i++) {
		if (i > 0) {
			sb.append("\r\n");
		}

		final CSSRule rule = item(i);
		sb.append(((CSSFormatable) rule).getCssText(format));
	}
	return sb.toString();
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:17,代码来源:CSSRuleListImpl.java


示例14: equalsRules

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
private boolean equalsRules(final CSSRuleList crl) {
	if ((crl == null) || (getLength() != crl.getLength())) {
		return false;
	}
	for (int i = 0; i < getLength(); i++) {
		final CSSRule cssRule1 = item(i);
		final CSSRule cssRule2 = crl.item(i);
		if (!LangUtils.equals(cssRule1, cssRule2)) {
			return false;
		}
	}
	return true;
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:14,代码来源:CSSRuleListImpl.java


示例15: addStyleSheet

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
/**
 * Adds the style sheet.
 *
 * @param styleSheet
 *            the style sheet
 * @throws MalformedURLException
 *             the malformed url exception
 * @throws UnsupportedEncodingException
 */
private final void addStyleSheet(CSSStyleSheet styleSheet)
		throws MalformedURLException, UnsupportedEncodingException {
	CSSRuleList ruleList = styleSheet.getCssRules();
	int length = ruleList.getLength();
	for (int i = 0; i < length; i++) {
		CSSRule rule = ruleList.item(i);
		this.addRule(styleSheet, rule);
	}
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:19,代码来源:StyleSheetAggregator.java


示例16: item

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
/**
 * Used to retrieve a CSS rule by ordinal index. The order in this collection
 * represents the order of the rules in the CSS style sheet. If index is
 * greater than or equal to the number of rules in the list, this returns
 * <code>null</code>.
 *
 * @param index
 *          Index into the collection
 * @return The style rule at the <code>index</code> position in the
 *         <code>CSSRuleList</code>, or <code>null</code> if that is not a
 *         valid index.
 */
public CSSRule item(final int index) {
  try {
    final RuleBlock<?> ruleBlock = jSheet.asList().get(index);
    if (ruleBlock instanceof RuleSet) {
      final RuleSet ruleSet = (RuleSet) ruleBlock;
      return new CSSStyleRuleImpl(ruleSet, parentStyleSheet);
    } else if (ruleBlock instanceof RuleFontFace) {
      final RuleFontFace ruleFontFace = (RuleFontFace) ruleBlock;
      return new CSSFontFaceRuleImpl(ruleFontFace, parentStyleSheet);
    } else if (ruleBlock instanceof RulePage) {
      final RulePage rulePage = (RulePage) ruleBlock;
      return new CSSPageRuleImpl(rulePage, parentStyleSheet);
    } else if (ruleBlock instanceof RuleMedia) {
      final RuleMedia mediaRule = (RuleMedia) ruleBlock;
      return new CSSMediaRuleImpl(mediaRule, parentStyleSheet);
    } else {
      // TODO need to return the other types of RuleBlocks as well.
      // * Import Rule
      // * Charset Rule
      // Currently returning Unknown rule
      return new CSSUnknownRuleImpl(parentStyleSheet);
    }
  } catch (final ArrayIndexOutOfBoundsException e) {
    return null;
  }
}
 
开发者ID:UprootLabs,项目名称:jStyleDomBridge,代码行数:39,代码来源:CSSRuleListImpl.java


示例17: extractCssStyleRules

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
public HashMap<String, CSSStyleRule> extractCssStyleRules(String cssFile) throws IOException {
    TEST_FILE_SYSTEM.filesExists(cssFile);
    CSSOMParser cssParser = new CSSOMParser();
    CSSStyleSheet css = cssParser.parseStyleSheet(new InputSource(new FileReader(TEST_FILE_SYSTEM.file(cssFile))), null, null);
    CSSRuleList cssRules = css.getCssRules();
    HashMap<String, CSSStyleRule> rules = new HashMap<String, CSSStyleRule>();
    for (int i = 0; i < cssRules.getLength(); i++) {
        CSSRule rule = cssRules.item(i);
        if (rule instanceof CSSStyleRule) {
            rules.put(((CSSStyleRule) rule).getSelectorText(), (CSSStyleRule) rule);
        }
    }
    return rules;
}
 
开发者ID:slezier,项目名称:SimpleFunctionalTest,代码行数:15,代码来源:CssParser.java


示例18: AttributeRuleList

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
public AttributeRuleList(CSSRuleList ruleList) {
	super(ruleList.getLength());
	
	for (int i = 0; i < ruleList.getLength(); i++) {
		CSSRule rule = ruleList.item(i);
		if(rule instanceof CSSStyleRule) {
			this.add((CSSStyleRule)rule);
		}
	}

}
 
开发者ID:connect-group,项目名称:thymesheet,代码行数:12,代码来源:AttributeRuleList.java


示例19: parseElementStyleDefinition

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
private static StyleDefinition parseElementStyleDefinition(final String styleRaw) throws TranslatorException {
    final CSSStyleSheetImpl sheet = parseElementStyleSheet(styleRaw);
    final CSSRuleList cssRules = sheet.getCssRules();
    for (int i = 0; i < cssRules.getLength(); i++) {
        final CSSRule item = cssRules.item(i);
        if (CSSRule.STYLE_RULE == item.getType()) {
            final CSSStyleRuleImpl rule = (CSSStyleRuleImpl) item;
            String selectorText = rule.getSelectorText();
            final CSSStyleDeclaration declaration = rule.getStyle();
            return parseStyleDefinition(declaration);
        }
    }
    return null;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:15,代码来源:SVGStyleTranslatorHelper.java


示例20: loadClass

import org.w3c.dom.css.CSSRule; //导入依赖的package包/类
private Class<?> loadClass(String name) {
    return Class.forName(CSSRule.class.getModule(), name);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:PackageInfoTest.java



注:本文中的org.w3c.dom.css.CSSRule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Destroyed类代码示例发布时间:2022-05-22
下一篇:
Java IconInfo类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap