本文整理汇总了Java中javax.swing.text.html.HTML.Attribute类的典型用法代码示例。如果您正苦于以下问题:Java Attribute类的具体用法?Java Attribute怎么用?Java Attribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Attribute类属于javax.swing.text.html.HTML包,在下文中一共展示了Attribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
});
}
示例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;
}
示例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);
}
}
示例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;
}
示例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));
}
示例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;
}
示例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));
}
示例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;
}
示例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());
}
示例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);
}
示例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));
}
示例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());
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
}
}