private void insertAttr(SimpleAttributeSet attrs, Object key, Object value) { while(attrs.isDefined(key)) { attrs.removeAttribute(key); } attrs.addAttribute(key, value); } }
public class ExtendedHTMLEditorKit extends HTMLEditorKit{ //.... other code here public class MyHTMLFactory extends HTMLFactory{ //other code here @Override public View create(Element elem) { if (isLayered(elem)){ //it means, it has position attribute return new PositionedView(elem); } else return super.create(elem); } boolean isLayered(Element elem){ SimpleAttributeSet sas = new SimpleAttributeSet(elem); StyleSheet styles = (HTMLDocument elem.getDocument).getStyleSheet(); Tag tag = element.getAttributes().getAttribute(AttributeSet.NameAttribute); sas.addAttributes(styleSheet.getRule(tag, element)); return sas.isDefined("position") && !sas.getAttribute("position").toString().equalsIgnorecase("static"); } } }
private static void addColor( String tokenType, SimpleAttributeSet sas, Map<String,AttributeSet> colorsMap, Map<String,AttributeSet> defaultsMap ) { if (sas == null) sas = new SimpleAttributeSet(); else sas = new SimpleAttributeSet(sas); String colorName = (String) sas.getAttribute(StyleConstants.NameAttribute); if (colorName == null) colorName = tokenType; sas.addAttribute(StyleConstants.NameAttribute, colorName); sas.addAttribute(EditorStyleConstants.DisplayName, colorName); if (!sas.isDefined(EditorStyleConstants.Default)) { String def = colorName; int i = def.lastIndexOf('_'); if (i > 0) def = def.substring(i + 1); if (defaultsMap.containsKey(def)) sas.addAttribute(EditorStyleConstants.Default, def); } colorsMap.put(colorName, sas); }
if(attrs.isDefined("face"))
/** * Creates a link button. This is just a JButton with default settings. */ private void createLinkButton() { LookAndFeel.installBorder(this, buttonPropertyPrefix + "border"); setBorderPainted(true); setFocusPainted(true); setAlignmentY(Container.CENTER_ALIGNMENT); setContentAreaFilled(true); setBackground(UIManager.getColor(buttonPropertyPrefix + "background")); if (textAttribs != null && textAttribs.isDefined(StyleConstants.Foreground)) { setForeground((Color)textAttribs.getAttribute(StyleConstants.Foreground)); } else { setForeground(UIManager.getColor(buttonPropertyPrefix + "foreground")); } invalidate(); }
/** * Creates a link label. A link label is a form of a JButton but without a * button like appearance. */ private void createLinkLabel() { setBorder(new EmptyBorder(1,1,1,1)); setBorderPainted(false); setFocusPainted(false); setAlignmentY(getPreferredLabelAlignment()); setContentAreaFilled(false); setBackground(UIManager.getColor(editorPropertyPrefix + "background")); if (textAttribs != null && textAttribs.isDefined(StyleConstants.Foreground)) { setForeground((Color)textAttribs.getAttribute(StyleConstants.Foreground)); } else { setForeground(Color.blue); } invalidate(); }
private void createLinkLabel() { setBorder(new EmptyBorder(1, 1, 1, 1)); setBorderPainted(false); setFocusPainted(false); setAlignmentY(getPreferredAlignmentY()); setContentAreaFilled(false); setHorizontalAlignment(LEFT); setBackground(UIManager.getColor("EditorPane.background")); if (textAttribs != null && textAttribs.isDefined(Foreground)) { setForeground((Color) textAttribs.getAttribute(Foreground)); } else { setForeground(blue); } invalidate(); }
if (superiorSet.isDefined("handles")==false) if (inferiorSet.isDefined("handles")) if (superiorSet.isDefined(StyleConstants.Foreground)) else if (inferiorSet.isDefined(StyleConstants.Foreground)) if (superiorSet.isDefined(StyleConstants.Background)) else if (inferiorSet.isDefined(StyleConstants.Background)) if (inferiorSet.isDefined(StyleConstants.FontSize)) if (superiorSet.isDefined(StyleConstants.FontSize)==false)
if (styleToUse.isDefined(StyleConstants.FontSize)==false) if (styleToUse.isDefined(StyleConstants.FontFamily)==false) if (styleToUse.isDefined(StyleConstants.FontSize)==false) if (styleToUse.isDefined(StyleConstants.FontFamily)==false) if (markableAttributes.isDefined("handles")) if (markableAttributes.isDefined(StyleConstants.FontSize)) if (markableAttributes.isDefined(StyleConstants.FontFamily)) if (styleToUse.isDefined(StyleConstants.FontSize)==false)