本文整理汇总了Java中javax.swing.text.html.HTML.Attribute类的典型用法代码示例。如果您正苦于以下问题:Java Attribute类的具体用法?Java Attribute怎么用?Java Attribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Attribute类属于javax.swing.text.html.HTML包,在下文中一共展示了Attribute类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getAttribute
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
@Override public String getAttribute(final String name) {
if ("text".equals(name)) {
return getText();
}
if ("hRefIndex".equals(name)) {
return getHRefIndex() + "";
}
if ("textIndex".equals(name)) {
return getTextIndex() + "";
}
return EventQueueWait.exec(new Callable<String>() {
@Override public String call() throws Exception {
Iterator iterator = findTag((HTMLDocument) ((JEditorPane) parent.getComponent()).getDocument());
AttributeSet attributes = iterator.getAttributes();
Attribute attr = findAttribute(name);
if (attr != null && attributes.isDefined(attr)) {
return attributes.getAttribute(attr).toString();
}
return null;
}
});
}
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:23,代码来源:JEditorPaneTagJavaElement.java
示例2: getImageURL
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
* Get the URL location of the image to render. If this method returns null,
* the "no image" icon is rendered instead. By defaul, url must be present as
* the "src" property of the IMG tag. If it is missing, null is returned and
* the "no image" icon is rendered.
*
* @return the URL location of the image to render.
*/
public URL getImageURL()
{
Element el = getElement();
String src = (String) el.getAttributes().getAttribute(Attribute.SRC);
URL url = null;
if (src != null)
{
URL base = ((HTMLDocument) getDocument()).getBase();
try
{
url = new URL(base, src);
}
catch (MalformedURLException ex)
{
// Return null.
}
}
return url;
}
开发者ID:vilie,项目名称:javify,代码行数:28,代码来源:ImageView.java
示例3: setPropertiesFromAttributes
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
* Update all cached properties from the attribute set, returned by the
* {@link #getAttributes}.
*/
protected void setPropertiesFromAttributes()
{
AttributeSet atts = getAttributes();
StyleSheet ss = getStyleSheet();
float emBase = ss.getEMBase(atts);
float exBase = ss.getEXBase(atts);
spans[X_AXIS] = (Length) atts.getAttribute(CSS.Attribute.WIDTH);
if (spans[X_AXIS] != null)
{
spans[X_AXIS].setFontBases(emBase, exBase);
}
spans[Y_AXIS] = (Length) atts.getAttribute(CSS.Attribute.HEIGHT);
if (spans[Y_AXIS] != null)
{
spans[Y_AXIS].setFontBases(emBase, exBase);
}
}
开发者ID:vilie,项目名称:javify,代码行数:22,代码来源:ImageView.java
示例4: getImageURL
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
* Get the URL location of the image to render. If this method returns null,
* the "no image" icon is rendered instead. By defaul, url must be present as
* the "src" property of the IMG tag. If it is missing, null is returned and
* the "no image" icon is rendered.
*
* @return the URL location of the image to render.
*/
public URL getImageURL()
{
Element el = getElement();
String src = (String) el.getAttributes().getAttribute(Attribute.SRC);
URL url = null;
if (src != null)
{
URL base = ((HTMLDocument) getDocument()).getBase();
try
{
url = new URL(base, src);
}
catch (MalformedURLException ex)
{
// Return null.
}
}
return url;
}
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:28,代码来源:ImageView.java
示例5: generateDist
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
* Generate DCAT distribution.
*
* @param store RDF store
* @param dataset URI
* @param access access URL of the dataset
* @param link link element
* @param i row sequence
* @param lang language code
* @throws MalformedURLException
* @throws RepositoryException
*/
private void generateDist(Storage store, IRI dataset, URL access,
Elements link, int i, String lang)
throws MalformedURLException, RepositoryException {
String href = link.first().attr(Attribute.HREF.toString());
URL download = makeAbsURL(href);
URL u = makeDistURL(i + "/" + lang);
IRI dist = store.getURI(u.toString());
logger.debug("Generating distribution {}", dist.toString());
store.add(dataset, DCAT.HAS_DISTRIBUTION, dist);
store.add(dist, RDF.TYPE, DCAT.DISTRIBUTION);
store.add(dist, DCTERMS.LANGUAGE, MDR_LANG.MAP.get(lang));
store.add(dist, DCTERMS.TITLE, link.first().ownText(), lang);
store.add(dist, DCAT.ACCESS_URL, access);
store.add(dist, DCAT.DOWNLOAD_URL, download);
store.add(dist, DCAT.MEDIA_TYPE, getFileExt(href));
}
开发者ID:Fedict,项目名称:dcattools,代码行数:31,代码来源:HtmlFodMobilit.java
示例6: scrapeDatasetList
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
* Get the list of all the downloads (DCAT Dataset).
*
* @return List of URLs
* @throws IOException
*/
@Override
protected List<URL> scrapeDatasetList() throws IOException {
List<URL> urls = new ArrayList<>();
URL base = getBase();
String front = makeRequest(base);
// Get all the main themes
Elements themes = Jsoup.parse(front).select(LINK_THEME);
if (themes != null) {
for (Element theme: themes) {
String href = theme.attr(Attribute.HREF.toString());
urls.addAll(scrapeSubList(href));
sleep();
}
} else {
logger.error("No themes {} found", LINK_THEME);
}
return urls;
}
开发者ID:Fedict,项目名称:dcattools,代码行数:28,代码来源:HtmlStatbelPubs.java
示例7: generateDist
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
* Generate DCAT Distribution.
*
* @param store RDF store
* @param dataset dataset URI
* @param access access URL
* @param link link element
* @param lang language code
* @throws MalformedUrlException
* @throws RepositoryException
*/
private void generateDist(Storage store, IRI dataset, URL access, Element link,
String lang) throws MalformedURLException, RepositoryException {
String href = link.attr(Attribute.HREF.toString());
URL download = makeAbsURL(href);
// important for EDP: does not like different datasets pointing to same distribution
String id = makeHashId(dataset.toString()) + "/" + makeHashId(download.toString());
IRI dist = store.getURI(makeDistURL(id).toString() + "/" + lang);
logger.debug("Generating distribution {}", dist.toString());
store.add(dataset, DCAT.HAS_DISTRIBUTION, dist);
store.add(dist, RDF.TYPE, DCAT.DISTRIBUTION);
store.add(dist, DCTERMS.LANGUAGE, MDR_LANG.MAP.get(lang));
store.add(dist, DCTERMS.TITLE, link.ownText(), lang);
store.add(dist, DCAT.ACCESS_URL, access);
store.add(dist, DCAT.DOWNLOAD_URL, download);
store.add(dist, DCAT.MEDIA_TYPE, getFileExt(href));
}
开发者ID:Fedict,项目名称:dcattools,代码行数:30,代码来源:HtmlStatbelPubs.java
示例8: scrapeDatasetList
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
* Get the list of all the downloads (DCAT Dataset).
*
* @return List of URLs
* @throws IOException
*/
@Override
protected List<URL> scrapeDatasetList() throws IOException {
List<URL> urls = new ArrayList<>();
URL base = getBase();
// Go through all the pages
for(int i = 1; ; i++) {
logger.info("Scraping page {}", i);
String page = makeRequest(new URL(base + "?page=" + i));
Elements links = Jsoup.parse(page).select(VIEW_HREF);
if (links == null || links.isEmpty()) {
break;
}
for (Element link: links) {
String href = link.attr(Attribute.HREF.toString());
urls.add(makeAbsURL(href));
}
sleep();
}
return urls;
}
开发者ID:Fedict,项目名称:dcattools,代码行数:29,代码来源:HtmlStatbelOpen.java
示例9: generateDist
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
* Generate DCAT Distribution.
*
* @param store RDF store
* @param dataset dataset URI
* @param access access URL
* @param link link element
* @param lang language code
* @throws MalformedUrlException
* @throws RepositoryException
*/
private void generateDist(Storage store, IRI dataset, URL access, Element link,
String lang) throws MalformedURLException, RepositoryException {
String href = link.attr(Attribute.HREF.toString());
URL download = makeAbsURL(href);
String id = makeHashId(dataset.toString()) + "/" + makeHashId(download.toString());
IRI dist = store.getURI(makeDistURL(id).toString() + "/" + lang);
logger.debug("Generating distribution {}", dist.toString());
store.add(dataset, DCAT.HAS_DISTRIBUTION, dist);
store.add(dist, RDF.TYPE, DCAT.DISTRIBUTION);
store.add(dist, DCTERMS.LANGUAGE, MDR_LANG.MAP.get(lang));
store.add(dist, DCTERMS.TITLE, link.ownText(), lang);
store.add(dist, DCAT.ACCESS_URL, access);
store.add(dist, DCAT.DOWNLOAD_URL, download);
store.add(dist, DCAT.MEDIA_TYPE, link.ownText());
}
开发者ID:Fedict,项目名称:dcattools,代码行数:29,代码来源:HtmlStatbelOpen.java
示例10: generateDist
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
* Generate DCAT distribution.
*
* @param store RDF store
* @param dataset URI
* @param name short name
* @param access URL of the acess page
* @param link download link element
* @param lang language code
* @throws MalformedURLException
* @throws RepositoryException
*/
private void generateDist(Storage store, IRI dataset, String name, String access,
Element link, String lang) throws MalformedURLException, RepositoryException {
String href = link.attr(Attribute.HREF.toString());
String fmt = link.ownText().replaceAll("/", "")
.replaceAll(" ", "")
.replaceAll(" ", "");
URL u = makeDistURL(name + "/" + fmt);
IRI dist = store.getURI(u.toString());
logger.debug("Generating distribution {}", dist.toString());
store.add(dataset, DCAT.HAS_DISTRIBUTION, dist);
store.add(dist, RDF.TYPE, DCAT.DISTRIBUTION);
store.add(dist, DCTERMS.LANGUAGE, MDR_LANG.MAP.get(lang));
store.add(dist, DCTERMS.TITLE, fmt, lang);
store.add(dist, DCAT.ACCESS_URL, makeAbsURL(access));
store.add(dist, DCAT.DOWNLOAD_URL, makeAbsURL(href));
store.add(dist, DCAT.MEDIA_TYPE, fmt);
}
开发者ID:Fedict,项目名称:dcattools,代码行数:31,代码来源:HtmlBrugge.java
示例11: generateDist
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
* Generate DCAT distribution.
*
* @param store RDF store
* @param dataset URI
* @param access access URL of the dataset
* @param row row element
* @param link link element
* @param lang language code
* @throws MalformedURLException
* @throws RepositoryException
*/
private void generateDist(Storage store, IRI dataset, URL access,
String text, Element link, String lang)
throws MalformedURLException, RepositoryException {
String href = link.attr(Attribute.HREF.toString());
URL download = makeAbsURL(href);
String id = makeHashId(dataset.toString()) + "/" + makeHashId(download.toString());
IRI dist = store.getURI(makeDistURL(id).toString());
logger.debug("Generating distribution {}", dist.toString());
store.add(dataset, DCAT.HAS_DISTRIBUTION, dist);
store.add(dist, RDF.TYPE, DCAT.DISTRIBUTION);
store.add(dist, DCTERMS.LANGUAGE, MDR_LANG.MAP.get(lang));
store.add(dist, DCTERMS.TITLE, link.ownText(), lang);
store.add(dist, DCTERMS.DESCRIPTION, text, lang);
store.add(dist, DCAT.ACCESS_URL, access);
store.add(dist, DCAT.DOWNLOAD_URL, download);
store.add(dist, DCAT.MEDIA_TYPE, getFileExt(href));
}
开发者ID:Fedict,项目名称:dcattools,代码行数:32,代码来源:HtmlFodFin.java
示例12: generateDist
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
* Generate DCAT distribution.
*
* @param store RDF store
* @param dataset URI
* @param access access URL of the dataset
* @param link link element
* @param code dataset code
* @param lang language code
* @throws MalformedURLException
* @throws RepositoryException
*/
private void generateDist(Storage store, IRI dataset, URL access,
Elements link, String code, String lang)
throws MalformedURLException, RepositoryException {
String href = link.first().attr(Attribute.HREF.toString());
URL download = makeAbsURL(href);
// file type e.g. in "Link (pdf)"
String txt = link.first().text();
String ftype = txt.replaceAll("(\\w+\\s*\\()(\\w+)\\)", "$2");
URL u = makeDistURL(code + "/" + lang);
IRI dist = store.getURI(u.toString());
logger.debug("Generating distribution {}", dist.toString());
store.add(dataset, DCAT.HAS_DISTRIBUTION, dist);
store.add(dist, RDF.TYPE, DCAT.DISTRIBUTION);
store.add(dist, DCTERMS.LANGUAGE, MDR_LANG.MAP.get(lang));
store.add(dist, DCTERMS.TITLE, link.first().ownText(), lang);
store.add(dist, DCAT.ACCESS_URL, access);
store.add(dist, DCAT.DOWNLOAD_URL, download);
store.add(dist, DCAT.MEDIA_TYPE, ftype.toLowerCase());
}
开发者ID:Fedict,项目名称:dcattools,代码行数:35,代码来源:HtmlFodDiplomatie.java
示例13: viewCreated
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
* Inform view creation.
* @param view the newly created view.
*/
protected void viewCreated(ViewFactory factory, View view)
{
if(view instanceof ImageView)
{
Element e = findFirstElement(view.getElement(), "img");
if(e == null)
return;
Object src = e.getAttributes().getAttribute(Attribute.SRC);
if(src != null && src instanceof String
&& ((String)src).endsWith("gif"))
{
imageViews.add((ImageView)view);
}
}
}
开发者ID:jitsi,项目名称:jitsi,代码行数:22,代码来源:ChatConversationPanel.java
示例14: filterAttributeSet
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
private MutableAttributeSet filterAttributeSet(Tag t, MutableAttributeSet a) {
for(Object aName: Collections.list((Enumeration<Object>)a.getAttributeNames())) {
List<Attribute> lAttr = acceptedAttributes.get(t);
if(lAttr == null || !lAttr.contains(aName)) {
a.removeAttribute(aName);
}
else {
if(aName == HTML.Attribute.STYLE) {
//System.out.println(">> " + aName + ": " + a.getAttribute(aName));
if(t.isBlock()) {
a.addAttribute(aName, DocumentUtil.ensureAcceptedCssProperties(
(String) a.getAttribute(aName), acceptedBlockCssProperties));
}
else {
a.addAttribute(aName, DocumentUtil.ensureAcceptedCssProperties(
(String) a.getAttribute(aName), acceptedInlineCssProperties));
}
}
}
}
return a;
}
开发者ID:lexml,项目名称:lexml-swing-editorhtml,代码行数:23,代码来源:ExtendedHTMLDocument.java
示例15: corrigePImplied
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
public static void corrigePImplied(ExtendedHTMLDocument doc) {
List<Element> tds = findElementByTag(doc, Tag.TD);
for(Element td: tds) {
if(td.getElementCount() > 0) {
Element p = td.getElement(0);
AttributeSet attrs = p.getAttributes();
if(attrs.containsAttribute(StyleConstants.NameAttribute, Tag.IMPLIED) &&
attrs.isDefined(CSS.Attribute.TEXT_ALIGN)) {
SimpleAttributeSet s = new SimpleAttributeSet();
s.addAttribute(StyleConstants.NameAttribute, Tag.P);
doc.setParagraphAttributes(p.getStartOffset(), p.getEndOffset(),
s, false);
}
}
}
}
开发者ID:lexml,项目名称:lexml-swing-editorhtml,代码行数:17,代码来源:DocumentUtil.java
示例16: handleStartTag
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
public void handleStartTag(Tag t, MutableAttributeSet a, int pos) {
if(t == Tag.TABLE) {
tableDepth++;
}
if(isAccepted(t)) {
a = filterAttributeSet(t, a);
if(t == Tag.TABLE) {
a.addAttribute(Attribute.WIDTH, "100%");
}
else if(t == Tag.TD) {
a.addAttribute(Attribute.VALIGN, "top");
}
reader.handleStartTag(t, a, pos);
}
}
开发者ID:lexml,项目名称:lexml-swing-editorhtml,代码行数:18,代码来源:ExtendedHTMLDocument.java
示例17: hasClass
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
public static boolean hasClass(AttributeSet attr, String className) {
String classValue = (String) attr.getAttribute(Attribute.CLASS);
if(classValue == null) {
return false;
}
String[] classNames = classValue.split(" ");
for(String c: classNames) {
if(c.equals(className)) {
return true;
}
}
return false;
}
开发者ID:lexml,项目名称:lexml-swing-editorhtml,代码行数:18,代码来源:DocumentUtil.java
示例18: findFirstElement
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
/**
*
* @param element
* @param attrName
* @param matchStrings
* @return
*/
private Element findFirstElement( Element element,
HTML.Attribute attrName,
String[] matchStrings)
{
String attr = (String) element.getAttributes().getAttribute(attrName);
if(attr != null)
for (String matchString : matchStrings)
if (attr.startsWith(matchString))
return element;
Element resultElement = null;
// Count how many messages we have in the document.
for (int i = 0; i < element.getElementCount(); i++)
{
resultElement = findFirstElement(element.getElement(i),
attrName,
matchStrings);
if (resultElement != null)
return resultElement;
}
return null;
}
开发者ID:jitsi,项目名称:jitsi,代码行数:33,代码来源:ChatConversationPanel.java
示例19: findAttribute
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
private Attribute findAttribute(String attrName) {
for (Attribute attr : allAttributes) {
if (attrName.toUpperCase().equals(attr.toString().toUpperCase())) {
return attr;
}
}
return null;
}
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:9,代码来源:JEditorPaneTagJavaElement.java
示例20: getHRefIndex
import javax.swing.text.html.HTML.Attribute; //导入依赖的package包/类
public int getHRefIndex() {
return EventQueueWait.exec(new Callable<Integer>() {
@Override public Integer call() throws Exception {
String href = getAttribute("href");
int hRefIndex = 0;
int current = 0;
JEditorPane editor = (JEditorPane) parent.getComponent();
HTMLDocument document = (HTMLDocument) editor.getDocument();
Iterator iterator = document.getIterator(Tag.A);
while (iterator.isValid()) {
if (current++ >= index) {
return hRefIndex;
}
AttributeSet attributes = iterator.getAttributes();
if (attributes != null) {
Object attributeObject = attributes.getAttribute(HTML.Attribute.HREF);
if (attributeObject != null) {
String attribute = attributeObject.toString();
if (attribute.equals(href)) {
hRefIndex++;
}
}
}
iterator.next();
}
return -1;
}
});
}
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:30,代码来源:JEditorPaneTagJavaElement.java
注:本文中的javax.swing.text.html.HTML.Attribute类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论