本文整理了Java中javax.swing.text.AttributeSet.isDefined()
方法的一些代码示例,展示了AttributeSet.isDefined()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AttributeSet.isDefined()
方法的具体详情如下:
包路径:javax.swing.text.AttributeSet
类名称:AttributeSet
方法名:isDefined
暂无
代码示例来源:origin: net.java.abeille/abeille
/** Get element name if defined */
public String getName() {
if (attrs.isDefined(ElementNameAttribute)) {
return (String) attrs.getAttribute(ElementNameAttribute);
}
return null;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** Get element name if defined */
public String getName() {
if (attrs.isDefined(ElementNameAttribute)) {
return (String)attrs.getAttribute(ElementNameAttribute);
}
return null;
}
代码示例来源:origin: omegat-org/omegat
@Override
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr)
throws BadLocationException {
super.insertString(fb, offset, string, attr);
if (attr != null && attr.isDefined(StyleConstants.ComposedTextAttribute)) {
// ignore
} else {
SwingUtilities.invokeLater(this::refreshPane);
}
}
代码示例来源:origin: girtel/Net2Plan
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;
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
/** Method tests whether the image within a link
*/
boolean isLink()
{
AttributeSet anchorAttr = (AttributeSet)fElement.getAttributes().getAttribute(HTML.Tag.A);
if(anchorAttr != null)
{
return anchorAttr.isDefined(HTML.Attribute.HREF);
}
return false;
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
if(attr.isDefined(name))
代码示例来源:origin: eu.mihosoft.vrl/vrl
/**
* Convenience method for getting an integer attribute from the elements
* AttributeSet.
*/
private int getIntAttr(HTML.Attribute name, int deflt) {
AttributeSet attr = getElement().getAttributes();
if (attr.isDefined(name)) { // does not check parents!
int i;
String val = (String) attr.getAttribute(name);
if (val == null) {
i = deflt;
} else {
try {
i = Math.max(0, Integer.parseInt(val));
} catch (NumberFormatException x) {
i = deflt;
}
}
return i;
} else {
return deflt;
}
}
代码示例来源:origin: stackoverflow.com
if (anchorAttr != null && anchorAttr.isDefined
(HTML.Attribute.HREF)) {
synchronized(this) {
代码示例来源:origin: RPTools/maptool
/**
* Convenience method for getting an integer attribute from the elements AttributeSet.
*/
private int getIntAttr(HTML.Attribute name, int deflt) {
AttributeSet attr = getElement().getAttributes();
if (attr.isDefined(name)) { // does not check parents!
int i;
String val = (String) attr.getAttribute(name);
if (val == null) {
i = deflt;
} else {
try {
i = Math.max(0, Integer.parseInt(val));
} catch (NumberFormatException x) {
i = deflt;
}
}
return i;
} else
return deflt;
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-mobility-svgcore
private static String getElemTextWithId(BaseDocument doc, DocumentElement de, String id) throws BadLocationException {
String elemText;
int startOffset = de.getStartOffset();
if (de.getAttributes().isDefined(SVGConstants.SVG_ID_ATTRIBUTE)) {
elemText = doc.getText(startOffset, de.getEndOffset() - startOffset + 1);
} else {
String tag = de.getName();
startOffset += 1 + tag.length();
StringBuilder sb = new StringBuilder("<"); //NOI18N
sb.append(tag);
sb.append(' ');
injectId(sb, id);
sb.append(doc.getText(startOffset, de.getEndOffset() - startOffset + 1));
elemText = sb.toString();
}
return elemText;
}
代码示例来源:origin: chatty/chatty
/**
* Gets the first element containing the given key in it's attributes, or
* null if it wasn't found.
*
* @param parent The Element whose subelements are searched
* @param key The key of the attributes the searched element should have
* @return The found Element
*/
private static Element getElementContainingAttributeKey(Element parent, Object key) {
for (int i = 0; i < parent.getElementCount(); i++) {
Element element = parent.getElement(i);
if (element.getAttributes().isDefined(key)) {
return element;
}
}
return null;
}
代码示例来源:origin: omegat-org/omegat
@Override
public void remove(FilterBypass fb, int offset, int length) throws BadLocationException {
boolean refresh = true;
final AttributeSet attr = ((StyledDocument) fb.getDocument()).getCharacterElement(offset).getAttributes();
if (attr != null && attr.isDefined(StyleConstants.ComposedTextAttribute)) {
refresh = false;
}
super.remove(fb, offset, length);
if (refresh && length != 0 && fb.getDocument().getLength() != 0) {
timer.restart();
}
}
代码示例来源:origin: omegat-org/omegat
@Override
public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs)
throws BadLocationException {
UIThreadsUtil.mustBeSwingThread();
if (attrs != null) {
((Document3) fb.getDocument()).textBeingComposed = attrs
.isDefined(StyleConstants.ComposedTextAttribute);
}
if (isPossible(fb.getDocument(), offset, length)) {
super.replace(fb, offset, length, text, attrs);
}
}
代码示例来源:origin: omegat-org/omegat
@Override
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr)
throws BadLocationException {
UIThreadsUtil.mustBeSwingThread();
if (attr != null) {
((Document3) fb.getDocument()).textBeingComposed = attr
.isDefined(StyleConstants.ComposedTextAttribute);
}
if (isPossible(fb.getDocument(), offset, 0)) {
super.insertString(fb, offset, string, attr);
}
}
代码示例来源:origin: chatty/chatty
for (int i=0;i<count;i++) {
Element element = line.getElement(i);
if (element.getAttributes().isDefined(ChannelTextPane.Attribute.USER)) {
if (element.getAttributes().isDefined(ChannelTextPane.Attribute.IS_APPENDED_INFO)) {
代码示例来源:origin: org.gosu-lang.gosu/gosu-lab
/**
* Fetch a reasonable location to start scanning
* given the desired start location. This allows
* for adjustments needed to accomodate multiline
* comments.
*/
public int getScannerStart( int p )
{
Element elem = getDefaultRootElement();
int lineNum = elem.getElementIndex( p );
Element line = elem.getElement( lineNum );
AttributeSet a = line.getAttributes();
while( a.isDefined( CommentAttribute ) && lineNum > 0 )
{
lineNum -= 1;
line = elem.getElement( lineNum );
a = line.getAttributes();
}
return line.getStartOffset();
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-editor
/**
* Fetch a reasonable location to start scanning
* given the desired start location. This allows
* for adjustments needed to accomodate multiline
* comments.
*/
public int getScannerStart( int p )
{
Element elem = getDefaultRootElement();
int lineNum = elem.getElementIndex( p );
Element line = elem.getElement( lineNum );
AttributeSet a = line.getAttributes();
while( a.isDefined( CommentAttribute ) && lineNum > 0 )
{
lineNum -= 1;
line = elem.getElement( lineNum );
a = line.getAttributes();
}
return line.getStartOffset();
}
代码示例来源:origin: RPTools/maptool
if (anchorAttr != null && anchorAttr.isDefined(HTML.Attribute.HREF)) {
synchronized (this) {
state |= LINK_FLAG;
代码示例来源:origin: stackoverflow.com
private void blockURLTyping(MutableAttributeSet inputAttr, int dot, int mark)
{
StyledDocument doc = getStyledDocument();
int begin = (dot < mark) ? dot - 1 : mark - 1;
if(begin >= 0)
{
Element dotEl = doc.getCharacterElement(begin);
Element markEl = doc.getCharacterElement((dot < mark) ? mark : dot);
AttributeSet dotAttr = dotEl.getAttributes();
AttributeSet markAttr = markEl.getAttributes();
if(dotAttr.isDefined(HTML.Attribute.HREF)) // Ensure atleast one of them isn't null
{
if(dotAttr.getAttribute(HTML.Attribute.HREF) == markAttr.getAttribute(HTML.Attribute.HREF))
{
inputAttr.addAttribute(HTML.Attribute.HREF, dotAttr.getAttribute(HTML.Attribute.HREF));
inputAttr.addAttribute(StyleConstants.Foreground, Color.BLUE);
inputAttr.addAttribute(StyleConstants.Underline, true);
return;
}
}
}
if(inputAttr.isDefined(HTML.Attribute.HREF)) // In all other cases => remove
{
inputAttr.removeAttribute(HTML.Attribute.HREF);
inputAttr.removeAttribute(StyleConstants.Foreground);
inputAttr.removeAttribute(StyleConstants.Underline);
}
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu
public void insertUpdate(final DocumentEvent de)
{
final Document d;
//Runnable r;
d = de.getDocument();
final int i1, i2;
final int l;
i1 = de.getOffset();
i2 = de.getLength();
l = d.getLength();
if (l == i1 + i2)
{
Element e1 = d.getDefaultRootElement();
Element e2 = e1.getElement(e1.getElementIndex(i1));
while (!e2.isLeaf())
e2 = e2.getElement(e2.getElementIndex(i1));
final Element e3 = e2;
AttributeSet as = e3.getAttributes();
if (as.isDefined(tubeSortieFenetre))
if (getCaretPosition() != l)
{
setCaretPosition(l);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!