import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
@Override
public boolean checkElement(StyledDocument doc, Element element, int offset) {
if (bold != null) {
if (StyleConstants.isBold(element.getAttributes()) != bold.booleanValue()) {
return false;
}
}
if (italic != null) {
if (StyleConstants.isItalic(element.getAttributes()) != italic.booleanValue()) {
return false;
}
}
if (strike != null) {
if (StyleConstants.isStrikeThrough(element.getAttributes()) != strike.booleanValue()) {
return false;
}
}
if (understrike != null) {
if (StyleConstants.isUnderline(element.getAttributes()) != understrike.booleanValue()) {
return false;
}
}
if (fontSize != null) {
if (StyleConstants.getFontSize(element.getAttributes()) != fontSize.intValue()) {
return false;
}
}
if (alignment != null) {
if (StyleConstants.getAlignment(element.getAttributes()) != alignment.intValue()) {
return false;
}
}
if (fontFamily != null) {
if (!StyleConstants.getFontFamily(element.getAttributes()).equals(fontFamily)) {
return false;
}
}
if (background != null) {
if (!StyleConstants.getBackground(element.getAttributes()).equals(background)) {
return false;
}
}
if (foreground != null) {
if (!StyleConstants.getForeground(element.getAttributes()).equals(foreground)) {
return false;
}
}
return true;
}