/** * Sets the current smiley icon in the attribute set. * * @param smileyAttr The attribute set for the inserted string. * @param smiley The smiley containing the icon to set. */ private void registerSmileyIcon(final MutableAttributeSet smileyAttr, final Smiley smiley) { StyleConstants.setIcon(smileyAttr, smiley.getIcon()); }
/** * Creates a style for the given icon. Also modifies the icon to add a * little space on the side, so it can be displayed easier. It caches * styles, so it only needs to create the style and modify the icon * once. * * @param icon * @return The created style (or read from the cache) */ public MutableAttributeSet makeIconStyle(Usericon icon) { MutableAttributeSet style = savedIcons.get(icon); if (style == null) { //System.out.println("Creating icon style: "+icon); style = new SimpleAttributeSet(nick()); if (icon != null && icon.image != null) { StyleConstants.setIcon(style, addSpaceToIcon(icon.image)); style.addAttribute(Attribute.USERICON, icon); } savedIcons.put(icon, style); } return style; }
StyleConstants.setIcon(style, new ImageIcon(image)); document.insertString(document.getLength(), "ignored text", style); } catch (Exception e){
public void insereIcone(final String _name, final Icon _icon, final String _text) { if (type_ == HTML) { return; } final Document dk = getDocument(); final Style defaultStyle = getStyle(StyleContext.DEFAULT_STYLE); final Style iconStyle = addStyle(_name + "-icon", defaultStyle); StyleConstants.setIcon(iconStyle, _icon); StyleConstants.setAlignment(iconStyle, StyleConstants.ALIGN_CENTER); try { dk.insertString(dk.getLength(), CtuluLibString.LINE_SEP, iconStyle); } catch (final BadLocationException ex) {} if (!"".equals(_text)) { final Style textStyle = addStyle(_name + "-text", defaultStyle); StyleConstants.setAlignment(textStyle, StyleConstants.ALIGN_CENTER); StyleConstants.setItalic(iconStyle, true); StyleConstants.setFontSize(iconStyle, 10); try { dk.insertString(dk.getLength(), _text + CtuluLibString.LINE_SEP, textStyle); } catch (final BadLocationException ex) {} } }
getContentPane().add(p, BorderLayout.CENTER); SimpleAttributeSet attrs = new SimpleAttributeSet(); StyleConstants.setIcon(attrs, getImage()); p.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent e) { doc.remove(index, 2); SimpleAttributeSet attrs = new SimpleAttributeSet(); StyleConstants.setIcon(attrs, getImage()); doc.insertString(index, ":)", attrs);
doc.getCharacterElement(start+i).getAttributes()); if (StyleConstants.getIcon(attrs)==null) { StyleConstants.setIcon(attrs, SMILE_IMG); doc.remove(start+i, 2); doc.insertString(start+i,":)", attrs);
StyleConstants.setIcon(style, createImage());
doc.getCharacterElement(start+i).getAttributes()); if (StyleConstants.getIcon(attrs)==null) { StyleConstants.setIcon(attrs, SMILE_IMG); doc.remove(start+i, 2); doc.insertString(start+i,":)", attrs);
if(smileys.contains(s)) StyleConstants.setIcon(aset, icons.getIcon(s));
if(smileys.contains(s)) StyleConstants.setIcon(aset, icons.getIcon(s));
/** * Make a style with the given icon. * * @param emoticon * @return */ public MutableAttributeSet emoticon(Emoticon emoticon) { // Does this need any other attributes e.g. standard? SimpleAttributeSet emoteStyle = new SimpleAttributeSet(); EmoticonImage emoteImage = emoticon.getIcon( emoticonScaleFactor(), emoticonMaxHeight(), ChannelTextPane.this); StyleConstants.setIcon(emoteStyle, emoteImage.getImageIcon()); emoteStyle.addAttribute(Attribute.EMOTICON, emoteImage); emoteStyle.addAttribute(Attribute.IMAGE_ID, idCounter.getAndIncrement()); emoteStyle.addAttribute(Attribute.ANIMATED, emoticon.isAnimated()); Emoticons.addInfo(main.emoticons.getEmotesetInfo(), emoticon); return emoteStyle; }
StyleConstants.setIcon(style, new ImageIcon(img));