本文整理汇总了Java中javax.swing.text.html.HTML.Tag方法的典型用法代码示例。如果您正苦于以下问题:Java HTML.Tag方法的具体用法?Java HTML.Tag怎么用?Java HTML.Tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.html.HTML
的用法示例。
在下文中一共展示了HTML.Tag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ulActionB_actionPerformed
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
public void ulActionB_actionPerformed(ActionEvent e) {
String parentname =
document
.getParagraphElement(editor.getCaretPosition())
.getParentElement()
.getName();
HTML.Tag parentTag = HTML.getTag(parentname);
HTMLEditorKit.InsertHTMLTextAction ulAction =
new HTMLEditorKit.InsertHTMLTextAction(
"insertUL",
"<ul><li></li></ul>",
parentTag,
HTML.Tag.UL);
ulAction.actionPerformed(e);
}
示例2: actionPerformed
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
String elName =
document
.getParagraphElement(editor.getCaretPosition())
.getName();
/*
* if ((elName.toUpperCase().equals("PRE")) ||
* (elName.toUpperCase().equals("P-IMPLIED"))) {
* editor.replaceSelection("\r"); return;
*/
HTML.Tag tag = HTML.getTag(elName);
if (elName.toUpperCase().equals("P-IMPLIED"))
tag = HTML.Tag.IMPLIED;
HTMLEditorKit.InsertHTMLTextAction hta =
new HTMLEditorKit.InsertHTMLTextAction(
"insertBR",
"<br>",
tag,
HTML.Tag.BR);
hta.actionPerformed(e);
//insertHTML("<br>",editor.getCaretPosition());
}
示例3: writeEmbeddedTags
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
/**
* Searches for embedded tags in the AttributeSet
* and writes them out. It also stores these tags in a vector
* so that when appropriate the corresponding end tags can be
* written out.
*
* @exception IOException on any I/O error
*/
protected void writeEmbeddedTags(AttributeSet attr) throws IOException {
// translate css attributes to html
attr = convertToHTML(attr, oConvAttr);
Enumeration names = attr.getAttributeNames();
while (names.hasMoreElements()) {
Object name = names.nextElement();
if (name instanceof HTML.Tag) {
HTML.Tag tag = (HTML.Tag) name;
if (tag == HTML.Tag.FORM || tags.contains(tag)) {
continue;
}
write('<');
write(tag.toString());
Object o = attr.getAttribute(tag);
if (o != null && o instanceof AttributeSet) {
writeAttributes((AttributeSet) o);
}
write('>');
tags.addElement(tag);
tagValues.addElement(o);
}
}
}
示例4: handleStartTag
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
public @Override void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {
if ( t == HTML.Tag.DT ) {
where = IN_DT;
currentDii = null;
}
else if ( t == HTML.Tag.A && where == IN_DT ) {
where = IN_AREF;
Object val = a.getAttribute( HTML.Attribute.HREF );
if ( val != null ) {
hrefVal = val.toString();
currentDii = new DocIndexItem( null, null, contextURL, hrefVal );
}
}
else if ( t == HTML.Tag.A && (where == IN_DESCRIPTION_SUFFIX || where == IN_DESCRIPTION) ) {
// Just ignore
}
else if ( (t == HTML.Tag.B || t == HTML.Tag.SPAN) && where == IN_AREF ) {
where = IN_AREF;
}
else {
where = IN_BALAST;
}
}
示例5: noMatchForTagInAttributes
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
/**
* Searches the attribute set for a tag, both of which
* are passed in as a parameter. Returns true if no match is found
* and false otherwise.
*/
private boolean noMatchForTagInAttributes(AttributeSet attr, HTML.Tag t, Object tagValue) {
if (attr != null && attr.isDefined(t)) {
Object newValue = attr.getAttribute(t);
if ((tagValue == null) ? (newValue == null) : (newValue != null && tagValue.equals(newValue))) {
return false;
}
}
return true;
}
示例6: writeAttributes
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
/**
* Writes out the attribute set. Ignores all
* attributes with a key of type HTML.Tag,
* attributes with a key of type StyleConstants,
* and attributes with a key of type
* HTML.Attribute.ENDTAG.
*
* @param attr an AttributeSet
* @exception IOException on any I/O error
*
*/
protected void writeAttributes(AttributeSet attr) throws IOException {
// translate css attributes to html
convAttr.removeAttributes(convAttr);
convertToHTML32(attr, convAttr);
Enumeration names = convAttr.getAttributeNames();
while (names.hasMoreElements()) {
Object name = names.nextElement();
if (name instanceof HTML.Tag || name instanceof StyleConstants || name == HTML.Attribute.ENDTAG) {
continue;
}
write(" " + name + "=\"" + convAttr.getAttribute(name) + "\"");
}
}
示例7: isBlockTag
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
/**
* Determines if the HTML.Tag associated with the
* element is a block tag.
*
* @param attr an AttributeSet
* @return true if tag is block tag, false otherwise.
*/
protected boolean isBlockTag(AttributeSet attr) {
Object o = attr.getAttribute(StyleConstants.NameAttribute);
if (o instanceof HTML.Tag) {
HTML.Tag name = (HTML.Tag) o;
return name.isBlock();
}
return false;
}
示例8: create
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
@Override
public View create(Element elem) {
Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
if (o instanceof HTML.Tag) {
HTML.Tag kind = (HTML.Tag) o;
if (kind == HTML.Tag.IMG) {
return new ClasspathImageView(elem);
}
}
return super.create(elem);
}
示例9: handleEndTag
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
@Override
public void handleEndTag(HTML.Tag t, int pos) {
String tag = t.toString();
logger.log(Level.FINE, "EndTag <{0}>", tag);
if (TAG_TITLE.equalsIgnoreCase(tag)) {
readingTitle = false;
}
if (TAG_FORM.equalsIgnoreCase(tag)) {
readingForm = false;
}
}
示例10: actionPerformed
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
String elName =
document
.getParagraphElement(editor.getCaretPosition())
.getName();
/*
* if ((elName.toUpperCase().equals("PRE")) ||
* (elName.toUpperCase().equals("P-IMPLIED"))) {
* editor.replaceSelection("\r"); return;
*/
HTML.Tag tag = HTML.getTag(elName);
if (elName.toUpperCase().equals("P-IMPLIED"))
{
tag = HTML.Tag.IMPLIED;
}
HTMLEditorKit.InsertHTMLTextAction hta =
new HTMLEditorKit.InsertHTMLTextAction(
"insertBR",
"<br>",
tag,
HTML.Tag.BR);
hta.actionPerformed(e);
//insertHTML("<br>",editor.getCaretPosition());
}
示例11: handleStartTag
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
public @Override void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {
if (t == HTML.Tag.BODY) {
try {
this.in.close ();
} catch (IOException ioe) {/*Ignore it*/}
}
}
示例12: ulActionB_actionPerformed
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
public void ulActionB_actionPerformed(ActionEvent e) {
String parentname =
document
.getParagraphElement(editor.getCaretPosition())
.getParentElement()
.getName();
HTML.Tag parentTag = HTML.getTag(parentname);
HTMLEditorKit.InsertHTMLTextAction ulAction =
new HTMLEditorKit.InsertHTMLTextAction(
"insertUL",
"<ul><li></li></ul>",
parentTag,
HTML.Tag.UL);
ulAction.actionPerformed(e);
//removeIfEmpty(document.getParagraphElement(editor.getCaretPosition()-1));
list = true;
/*
* Element pEl =
* document.getParagraphElement(editor.getCaretPosition());
* StringWriter sw = new StringWriter(); try { editorKit.write(sw,
* document, pEl.getStartOffset(),
* pEl.getEndOffset()-pEl.getStartOffset()); String copy =
* sw.toString(); String elName = pEl.getName(); copy =
* copy.substring(copy.indexOf(" <"+elName)); copy =
* copy.substring(0,copy.indexOf(" </"+elName)+elName.length()+3);
* document.setOuterHTML(pEl, " <ul><li> "+copy+" </li></ul> ");
* System.out.println(copy); } catch (Exception ex){
* ex.printStackTrace();
*/
}
示例13: handleSimpleTag
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos) {
elist.add(pIndent() + "Tag(<" + t.toString() + ">, " +
a.getAttributeCount() + " attrs)");
}
示例14: handleStartTag
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {
elist.add(pIndent() + "Tag start(<" + t.toString() + " " + a + ">, " +
a.getAttributeCount() + " attrs)");
indent();
}
示例15: closeOutUnwantedEmbeddedTags
import javax.swing.text.html.HTML; //导入方法依赖的package包/类
/**
* Searches the attribute set and for each tag
* that is stored in the tag vector. If the tag isnt found,
* then the tag is removed from the vector and a corresponding
* end tag is written out.
*
* @exception IOException on any I/O error
*/
protected void closeOutUnwantedEmbeddedTags(AttributeSet attr) throws IOException {
tagsToRemove.removeAllElements();
// translate css attributes to html
attr = convertToHTML(attr, null);
HTML.Tag t;
Object tValue;
int firstIndex = -1;
int size = tags.size();
// First, find all the tags that need to be removed.
for (int i = size - 1; i >= 0; i--) {
t = (HTML.Tag) tags.elementAt(i);
tValue = tagValues.elementAt(i);
if ((attr == null) || noMatchForTagInAttributes(attr, t, tValue)) {
firstIndex = i;
tagsToRemove.addElement(t);
}
}
if (firstIndex != -1) {
// Then close them out.
boolean removeAll = ((size - firstIndex) == tagsToRemove.size());
for (int i = size - 1; i >= firstIndex; i--) {
t = (HTML.Tag) tags.elementAt(i);
if (removeAll || tagsToRemove.contains(t)) {
tags.removeElementAt(i);
tagValues.removeElementAt(i);
}
write('<');
write('/');
write(t.toString());
write('>');
}
// Have to output any tags after firstIndex that still remaing,
// as we closed them out, but they should remain open.
size = tags.size();
for (int i = firstIndex; i < size; i++) {
t = (HTML.Tag) tags.elementAt(i);
write('<');
write(t.toString());
Object o = tagValues.elementAt(i);
if (o != null && o instanceof AttributeSet) {
writeAttributes((AttributeSet) o);
}
write('>');
}
}
}