if (att_.toString().equalsIgnoreCase("title")) { return attSet_.getAttribute(att_).toString();
sourceKeys[i] = (String) temp.toString(); sourceValues[i] = new String(); sourceValues[i] = (String) sourceAS.getAttribute(temp).toString(); i++; removeValues[j] = (String) removeAS.getAttribute(removeKeys[j]).toString(); j++;
JEditorPane editorPane = new JEditorPane() { @Override public String getToolTipText(MouseEvent evt) { String text = null; int pos = viewToModel(evt.getPoint()); if (pos >= 0) { HTMLDocument hdoc = (HTMLDocument) getDocument(); javax.swing.text.Element e = hdoc.getCharacterElement(pos); AttributeSet a = e.getAttributes(); SimpleAttributeSet value = (SimpleAttributeSet) a.getAttribute(HTML.Tag.A); if (value != null) { String href = (String) value.getAttribute(HTML.Attribute.HREF); if (href != null) { text = href; } } } return text; } };
EditorKit kit = new HTMLEditorKit(); HTMLDocument doc = (HTMLDocument)kit.createDefaultDocument(); doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE); kit.read(reader, doc, 0); HTMLDocument.Iterator it = doc.getIterator(HTML.Tag.A); while (it.isValid()) { SimpleAttributeSet s = (SimpleAttributeSet)it.getAttributes(); String href = (String)s.getAttribute(HTML.Attribute.HREF); System.out.println( href ); it.next(); }
relationColors.add((Color)attributes.getAttribute(tempElem)); relationStyles.add((Integer)attributes.getAttribute(tempElem));
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"); } } }
Object entryValue = sasText.getAttribute(entryKey); if(entryKey.toString().equals(HTML.Tag.A.toString())) if(subKey.toString().toLowerCase().equals("href")) currentAnchor = ((SimpleAttributeSet)entryValue).getAttribute(subKey).toString(); break; Object entryValue = baseAttrs.getAttribute(entryKey); insertAttribute(sasAttr, entryKey, entryValue);
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); }
parentTextPane.setParagraphAttributes(sasPara, true); } else if (textLength < 0) { if (sasPara.getAttribute(StyleConstants.NameAttribute) == Tag.IMPLIED) sasPara.addAttribute( StyleConstants.NameAttribute, Tag.P); sasPara.addAttribute(HTML.Attribute.ALIGN, a_);
insertAttr(attrs, "face", attrs.getAttribute("face")); insertAttr(attrs, "font-family", attrs.getAttribute("face"));
@Override public void mouseClicked(MouseEvent e) { Point point = e.getPoint(); AccessibleText at = (AccessibleText) label.getAccessibleContext(); int pos = at.getIndexAtPoint(point); AttributeSet as = at.getCharacterAttribute(pos); if (label.isEnabled() && as.getAttribute(A) != null) { label.setCursor(getPredefinedCursor(HAND_CURSOR)); SimpleAttributeSet attr = (SimpleAttributeSet) as.getAttribute(A); String href = (String) attr.getAttribute(HREF); fireActionPerformed(new ActionEvent(label, ACTION_PERFORMED, href)); } else { label.setCursor(getDefaultCursor()); } }
@Override public void mouseClicked(MouseEvent e) { Point point = e.getPoint(); AccessibleText at = (AccessibleText) label.getAccessibleContext(); int pos = at.getIndexAtPoint(point); AttributeSet as = at.getCharacterAttribute(pos); if (label.isEnabled() && as.getAttribute(HTML.Tag.A) != null) { label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); SimpleAttributeSet attr=(SimpleAttributeSet)as.getAttribute(HTML.Tag.A); String href=(String)attr.getAttribute(HTML.Attribute.HREF); fireActionPerformed( new ActionEvent(label,ActionEvent.ACTION_PERFORMED,href)); } else { label.setCursor(Cursor.getDefaultCursor()); } }
private void cacheLinkElements() { this.linkCache = new ArrayList<>(); final View view = (View) this.getClientProperty("html"); //NOI18N if (view != null) { final HTMLDocument doc = (HTMLDocument) view.getDocument(); final HTMLDocument.Iterator it = doc.getIterator(HTML.Tag.A); while (it.isValid()) { final SimpleAttributeSet s = (SimpleAttributeSet) it.getAttributes(); final String link = (String) s.getAttribute(HTML.Attribute.HREF); if (link != null) { this.linkCache.add(new HtmlLinkAddress(link, it.getStartOffset(), it.getEndOffset())); } it.next(); } } }
/** * 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(); }
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(); }
/** * 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(); }
resultSet.addAttribute("handles", inferiorSet.getAttribute("handles"));
StyleConstants.setForeground(handleStyle, (Color) markableAttributes.getAttribute("handles"));