Example usage for javax.swing.text Element getAttributes

List of usage examples for javax.swing.text Element getAttributes

Introduction

In this page you can find the example usage for javax.swing.text Element getAttributes.

Prototype

public AttributeSet getAttributes();

Source Link

Document

Fetches the collection of attributes this element contains.

Usage

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatConversationPanel.java

/**
 * Returns the date of the first message in the current page.
 *
 * @return the date of the first message in the current page
 *//*from w ww.j  av a  2 s.c om*/
public Date getPageFirstMsgTimestamp() {
    Element firstHeaderElement = document.getElement(ChatHtmlUtils.MESSAGE_HEADER_ID);

    if (firstHeaderElement == null)
        return new Date(Long.MAX_VALUE);

    String dateObject = firstHeaderElement.getAttributes().getAttribute(ChatHtmlUtils.DATE_ATTRIBUTE)
            .toString();

    SimpleDateFormat sdf = new SimpleDateFormat(HistoryService.DATE_FORMAT);
    try {
        return sdf.parse(dateObject);
    } catch (ParseException e) {
        return new Date(0);
    }
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatConversationPanel.java

/**
 * Retrieves the contents of the sent message with the given ID.
 *
 * @param messageUID The ID of the message to retrieve.
 * @return The contents of the message, or null if the message is not found.
 */// www  .j  av a2s.  com
public String getMessageContents(String messageUID) {
    Element root = document.getDefaultRootElement();
    Element e = document.getElement(root, Attribute.ID, ChatHtmlUtils.MESSAGE_TEXT_ID + messageUID);
    if (e == null) {
        logger.warn("Could not find message with ID " + messageUID);
        return null;
    }

    Object original_message = e.getAttributes().getAttribute(ChatHtmlUtils.ORIGINAL_MESSAGE_ATTRIBUTE);
    if (original_message == null) {
        logger.warn("Message with ID " + messageUID + " does not have original_message attribute");
        return null;
    }

    String res = new String(net.java.sip.communicator.util.Base64.decode(original_message.toString()));
    // Remove all newline characters that were inserted to make copying
    // newlines from the conversation panel work.
    // They shouldn't be in the write panel, because otherwise a newline
    // would consist of two chars, one of them invisible (the 
), but
    // both of them have to be deleted in order to remove it.
    // On the other hand this means that copying newlines from the write
    // area produces only spaces, but this seems like the better option.
    res = res.replace("
", "");
    return res;
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatConversationPanel.java

/**
 * Replaces the contents of the message with ID of the corrected message
 * specified in chatMessage, with this message.
 *
 * @param chatMessage A <tt>ChatMessage</tt> that contains all the required
 * information to correct the old message.
 *///from   w w w.jav a  2 s  .c  om
public void correctMessage(final ChatMessage chatMessage) {
    lastMessageUID = chatMessage.getMessageUID();

    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                correctMessage(chatMessage);
            }
        });
        return;
    }

    String correctedUID = chatMessage.getCorrectedMessageUID();
    Element root = document.getDefaultRootElement();
    Element correctedMsgElement = document.getElement(root, Attribute.ID,
            ChatHtmlUtils.MESSAGE_TEXT_ID + correctedUID);

    if (correctedMsgElement == null) {
        logger.warn("Could not find message with ID " + correctedUID);
        return;
    }

    String contactAddress = (String) correctedMsgElement.getAttributes().getAttribute(Attribute.NAME);

    boolean isHistory = (chatMessage.getMessageType().equals(Chat.HISTORY_INCOMING_MESSAGE)
            || chatMessage.getMessageType().equals(Chat.HISTORY_OUTGOING_MESSAGE)) ? true : false;

    String newMessage = ChatHtmlUtils.createMessageTag(chatMessage.getMessageUID(), contactAddress,
            formatMessageAsHTML(chatMessage.getMessage(), chatMessage.getContentType(), ""),
            ChatHtmlUtils.HTML_CONTENT_TYPE, chatMessage.getDate(), true, isHistory, isSimpleTheme);

    synchronized (scrollToBottomRunnable) {
        try {
            document.setOuterHTML(correctedMsgElement, newMessage);

            // Need to call explicitly scrollToBottom, because for some
            // reason the componentResized event isn't fired every time
            // we add text.
            SwingUtilities.invokeLater(scrollToBottomRunnable);
        } catch (BadLocationException ex) {
            logger.error("Could not replace chat message", ex);
        } catch (IOException ex) {
            logger.error("Could not replace chat message", ex);
        }
    }

    finishMessageAdd(newMessage);
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatConversationPanel.java

/**
 * Indicates if this is a consecutive message.
 *
 * @param chatMessage the message to verify
 * @return <tt>true</tt> if the given message is a consecutive message,
 * <tt>false</tt> - otherwise
 *//*from   w w  w . j  a va 2 s  .c o  m*/
private boolean isConsecutiveMessage(ChatMessage chatMessage) {
    if (lastMessageUID == null)
        return false;

    Element lastMsgElement = document.getElement(ChatHtmlUtils.MESSAGE_TEXT_ID + lastMessageUID);

    if (lastMsgElement == null) {
        // This will happen if the last message is a non-user message, such
        // as a system message. For these messages we *do* update the
        // lastMessageUID, however we do *not* include the new UID in the
        // newly appended message.
        logger.info("Could not find message with ID " + lastMessageUID);
        return false;
    }

    String contactAddress = (String) lastMsgElement.getAttributes().getAttribute(Attribute.NAME);

    if (contactAddress != null
            && (chatMessage.getMessageType().equals(Chat.INCOMING_MESSAGE)
                    || chatMessage.getMessageType().equals(Chat.OUTGOING_MESSAGE)
                    || chatMessage.getMessageType().equals(Chat.HISTORY_INCOMING_MESSAGE)
                    || chatMessage.getMessageType().equals(Chat.HISTORY_OUTGOING_MESSAGE))
            && contactAddress.equals(chatMessage.getContactName())
            // And if the new message is within a minute from the last one.
            && ((chatMessage.getDate().getTime() - lastMessageTimestamp.getTime()) < 60000)) {
        lastMessageTimestamp = chatMessage.getDate();

        return true;
    }

    return false;
}

From source file:com.hexidec.ekit.EkitCore.java

/**
 * Searches the specified element for CLASS attribute setting
 *///from www .j a va 2s.c om
private String findStyle(Element element) {
    AttributeSet as = element.getAttributes();
    if (as == null) {
        return null;
    }
    Object val = as.getAttribute(HTML.Attribute.CLASS);
    if (val != null && (val instanceof String)) {
        return (String) val;
    }
    for (Enumeration e = as.getAttributeNames(); e.hasMoreElements();) {
        Object key = e.nextElement();
        if (key instanceof HTML.Tag) {
            AttributeSet eas = (AttributeSet) (as.getAttribute(key));
            if (eas != null) {
                val = eas.getAttribute(HTML.Attribute.CLASS);
                if (val != null) {
                    return (String) val;
                }
            }
        }

    }
    return null;
}

From source file:com.hexidec.ekit.EkitCore.java

/**
 * Method for finding (and optionally replacing) a string in the text
 *//*from w  ww .  j a  va  2  s.  c o  m*/
private int findText(String findTerm, String replaceTerm, boolean bCaseSenstive, int iOffset) {
    JTextComponent jtpFindSource;
    if (sourceWindowActive || jtpSource.hasFocus()) {
        jtpFindSource = (JTextComponent) jtpSource;
    } else {
        jtpFindSource = (JTextComponent) jtpMain;
    }
    int searchPlace = -1;
    try {
        Document baseDocument = jtpFindSource.getDocument();
        searchPlace = (bCaseSenstive
                ? baseDocument.getText(0, baseDocument.getLength()).indexOf(findTerm, iOffset)
                : baseDocument.getText(0, baseDocument.getLength()).toLowerCase()
                        .indexOf(findTerm.toLowerCase(), iOffset));
        if (searchPlace > -1) {
            if (replaceTerm != null) {
                AttributeSet attribs = null;
                if (baseDocument instanceof HTMLDocument) {
                    Element element = ((HTMLDocument) baseDocument).getCharacterElement(searchPlace);
                    attribs = element.getAttributes();
                }
                baseDocument.remove(searchPlace, findTerm.length());
                baseDocument.insertString(searchPlace, replaceTerm, attribs);
                jtpFindSource.setCaretPosition(searchPlace + replaceTerm.length());
                jtpFindSource.requestFocus();
                jtpFindSource.select(searchPlace, searchPlace + replaceTerm.length());
            } else {
                jtpFindSource.setCaretPosition(searchPlace + findTerm.length());
                jtpFindSource.requestFocus();
                jtpFindSource.select(searchPlace, searchPlace + findTerm.length());
            }
        }
    } catch (BadLocationException ble) {
        logException("BadLocationException in actionPerformed method", ble);
        new SimpleInfoDialog(this.getWindow(), Translatrix.getTranslationString("Error"), true,
                Translatrix.getTranslationString("ErrorBadLocationException"), SimpleInfoDialog.ERROR);
    }
    return searchPlace;
}

From source file:org.alder.fotobuchconvert.scribus.RtfToScribusConverter.java

void output(XmlBuilder xml, DefaultStyledDocument doc, ScribusWriter scribus) {
    log.debug("Starting conversion of RTF data");
    if (log.isTraceEnabled())
        doc.dump(System.err);//from w w w. j  a  va2  s  .  co m

    try {
        Element section = doc.getDefaultRootElement();
        log.trace(section);
        assert section.getName().equals("section");

        final int nj = section.getElementCount();
        for (int j = 0; j < nj; j++) {
            Element paragraph = section.getElement(j);
            log.trace(paragraph);
            assert section.getName().equals("paragraph");

            // boolean firstInPara = true;
            AttributeSet attr = paragraph.getAttributes();
            Integer alignment = (Integer) attr.getAttribute(StyleConstants.Alignment);

            boolean elementsInThisLine = false;
            final int ni = paragraph.getElementCount();
            for (int i = 0; i < ni; i++) {
                Element content = paragraph.getElement(i);
                assert section.getName().equals("content");

                int start = content.getStartOffset();
                int end = content.getEndOffset();

                attr = content.getAttributes();
                Boolean italic = (Boolean) attr.getAttribute(StyleConstants.Italic);
                Boolean bold = (Boolean) attr.getAttribute(StyleConstants.Bold);
                Boolean underline = (Boolean) attr.getAttribute(StyleConstants.Underline);
                String family = (String) attr.getAttribute(StyleConstants.Family);
                Integer fontSize = (Integer) attr.getAttribute(StyleConstants.Size);
                Color color = (Color) attr.getAttribute(StyleConstants.ColorConstants.Foreground);

                String text = doc.getText(start, end - start);

                // if (firstInPara && text.trim().isEmpty() && family ==
                // null
                // && fontSize == null)
                // continue;
                // else
                // firstInPara = false;
                if (i == ni - 1 && text.trim().isEmpty() && text.length() < 3)
                    continue;
                elementsInThisLine = true;

                while (text.endsWith("\n") || text.endsWith("\r"))
                    text = text.substring(0, text.length() - 1);

                log.debug(italic + " " + bold + " " + underline + " " + family + " " + fontSize + " " + color
                        + "\t\"" + text + "\"");

                XmlBuilder el = xml.add(C.EL_ITEXT).set(C.CH, text);

                if (bold == Boolean.TRUE && italic == Boolean.TRUE)
                    el.set(C.FONT, family + " Bold Italic");
                else if (bold == Boolean.TRUE)
                    el.set(C.FONT, family + " Bold");
                else if (italic == Boolean.TRUE)
                    el.set(C.FONT, family + " Italic");
                else
                    el.set(C.FONT, family + " Regular");

                if (fontSize != null)
                    el.set(C.FONTSIZE, fontSize);

                if (color != null && color.equals(Color.BLACK) && scribus != null) {
                    String colname = scribus.colorManager.getColorName(color);
                    el.set(C.FCOLOR, colname);
                }
            }

            if (!elementsInThisLine && j == nj - 1)
                break; // don't convert last line if empty

            XmlBuilder el = xml.add(C.EL_PARA);
            if (alignment != null)
                switch (alignment) {
                case StyleConstants.ALIGN_LEFT:
                    el.set(C.ALIGN, 0);
                    break;
                case StyleConstants.ALIGN_CENTER:
                    el.set(C.ALIGN, 1);
                    break;
                case StyleConstants.ALIGN_RIGHT:
                    el.set(C.ALIGN, 2);
                    break;
                case StyleConstants.ALIGN_JUSTIFIED:
                    el.set(C.ALIGN, 3);
                    break;
                }
        }
    } catch (BadLocationException e) {
        throw new RuntimeException("This error should not occour", e);
    }

}

From source file:org.deegree.tools.metadata.InspireValidator.java

/**
 * parse INSPIRE metadata validator response and print out result onto the console
 * //www .j  ava2  s.c o  m
 * @param response
 * @throws IOException
 * @throws IllegalStateException
 */
private void parseServiceResponse(HttpResponse response) throws Exception {
    String s = FileUtils.readTextFile(((BasicHttpResponse) response).getEntity().getContent()).toString();
    if (response.getStatusLine().getStatusCode() != 200) {
        outputWriter.println(s);
        outputWriter.println();
        return;
    }
    s = "<html><head></head><body>" + s + "</body></html>";
    BufferedReader br = new BufferedReader(new StringReader(s));

    HTMLEditorKit htmlKit = new HTMLEditorKit();
    HTMLDocument htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument();
    HTMLEditorKit.Parser parser = new ParserDelegator();
    HTMLEditorKit.ParserCallback callback = htmlDoc.getReader(0);
    parser.parse(br, callback, true);

    // Parse
    ElementIterator iterator = new ElementIterator(htmlDoc);
    Element element;
    while ((element = iterator.next()) != null) {
        AttributeSet attributes = element.getAttributes();
        Object name = attributes.getAttribute(StyleConstants.NameAttribute);
        if ((name instanceof HTML.Tag) && ((name == HTML.Tag.IMPLIED))) {
            // Build up content text as it may be within multiple elements
            StringBuffer text = new StringBuffer();
            int count = element.getElementCount();
            for (int i = 0; i < count; i++) {
                Element child = element.getElement(i);
                AttributeSet childAttributes = child.getAttributes();
                if (childAttributes.getAttribute(StyleConstants.NameAttribute) == HTML.Tag.CONTENT) {
                    int startOffset = child.getStartOffset();
                    int endOffset = child.getEndOffset();
                    int length = endOffset - startOffset;
                    text.append(htmlDoc.getText(startOffset, length));
                }
            }
            outputWriter.println(text.toString());
        }
    }
    outputWriter.println("---------------------------------------------------------------------");
    outputWriter.println();
}

From source file:org.pmedv.core.components.RelativeImageView.java

/**
 * initialization method.//ww  w .  j  av a 2  s  .  c  om
 * 
 * @param elem
 *            an element
 */

@SuppressWarnings("rawtypes")
private void initialize(Element elem) {

    synchronized (this) {
        bLoading = true;
        fWidth = 0;
        fHeight = 0;
    }

    int width = 0;
    int height = 0;
    boolean customWidth = false;
    boolean customHeight = false;

    try {
        fElement = elem;
        // request image from document's cache
        AttributeSet myAttr = elem.getAttributes();
        if (isURL()) {
            URL src = getSourceURL();
            if (src != null) {
                Dictionary cache = (Dictionary) getDocument().getProperty(IMAGE_CACHE_PROPERTY);
                if (cache != null) {
                    fImage = (Image) cache.get(src);
                } else {
                    fImage = Toolkit.getDefaultToolkit().getImage(src);
                }
            }
        } else {
            // load image from relative path
            String src = (String) fElement.getAttributes().getAttribute(HTML.Attribute.SRC);
            try {
                src = processSrcPath(src);
            } catch (Throwable e) {
                log.warn("exception thrown while processing src path. " + e.fillInStackTrace());
                src = (String) fElement.getAttributes().getAttribute(HTML.Attribute.SRC);
            }
            log.warn("trying to load the image from src " + src);
            fImage = Toolkit.getDefaultToolkit().createImage(src);
            try {
                waitForImage();
            } catch (InterruptedException ie) {
                fImage = null;
                log.warn("loading image from relative path failed.");
                // possibly replace with the ImageBroken icon, if that's
                // what is happening
            }
        }

        // get height & width from params or image or defaults
        height = getIntAttr(HTML.Attribute.HEIGHT, -1);
        customHeight = (height > 0);
        if (!customHeight && fImage != null) {
            height = fImage.getHeight(this);
        }
        if (height <= 0) {
            height = DEFAULT_HEIGHT;
        }

        width = getIntAttr(HTML.Attribute.WIDTH, -1);
        customWidth = (width > 0);
        if (!customWidth && fImage != null) {
            width = fImage.getWidth(this);
        }

        if (width <= 0) {
            width = DEFAULT_WIDTH;
        }

        if (fImage != null) {
            if (customHeight && customWidth) {
                Toolkit.getDefaultToolkit().prepareImage(fImage, height, width, this);
            } else {
                Toolkit.getDefaultToolkit().prepareImage(fImage, -1, -1, this);
            }
        }
    } finally {
        synchronized (this) {
            bLoading = false;
            if (customHeight || fHeight == 0) {
                fHeight = height;
            }

            if (customWidth || fWidth == 0) {
                fWidth = width;
            }
        }
    }
}

From source file:tufts.vue.RichTextBox.java

/***********
 *******NOTES FROM FONT EDITOR PANEL TO HELP WITH COPY/PASTE OF STYLES.
globalSizeListener = new ActionListener(){
        /*  ww  w  .  j  a  v a 2s  .  co m*/
   public void actionPerformed(ActionEvent fe) 
   {
              
      if (suspendItemListeners)
         return;
              
      if (lwtext == null)
         return;
        
      lwtext.richLabelBox.selectAll();
      final String textSize = mSizeField.getSelectedItem().toString();
      SHTMLDocument doc = (SHTMLDocument)lwtext.richLabelBox.getDocument();
      SimpleAttributeSet set = new SimpleAttributeSet();
        Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_SIZE,
                 textSize);
        set.addAttribute(HTML.Attribute.SIZE, textSize);
        lwtext.richLabelBox.applyAttributes(set, false);
                
      lwtext.richLabelBox.select(0,0);
      //lwtext.setLabel0(lwtext.richLabelBox.getRichText(), false);
      lwtext.richLabelBox.setSize(lwtext.richLabelBox.getPreferredSize());                                        
               
          if (lwtext.getParent() !=null)
              lwtext.getParent().layout();                                                  
                 
       lwtext.notify(lwtext.richLabelBox, LWKey.Repaint);                     
               
               
   }
 };
                     
  globalFaceListener = new ActionListener(){ 
     public void actionPerformed(ActionEvent fe) 
     {                
        if (suspendItemListeners)
         return;
              
        if (lwtext == null)
         return;
        lwtext.richLabelBox.selectAll();
      SHTMLDocument doc = (SHTMLDocument)lwtext.richLabelBox.getDocument();
      SimpleAttributeSet set = new SimpleAttributeSet();
        Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_FAMILY,
                 mFontCombo.getSelectedItem().toString());
        set.addAttribute(HTML.Attribute.FACE, mFontCombo.getSelectedItem().toString());
        lwtext.richLabelBox.applyAttributes(set, false);
                
      lwtext.richLabelBox.select(0,0);
           
      lwtext.richLabelBox.setSize(lwtext.richLabelBox.getPreferredSize());                                        
               
          if (lwtext.getParent() !=null)
              lwtext.getParent().layout();
                 
                 
                
                 
       lwtext.notify(lwtext.richLabelBox, LWKey.Repaint); 
     }
   };
           
     private final PropertyChangeListener RichTextColorChangeListener =
new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent e) {
        
        if (e instanceof LWPropertyChangeEvent == false)
            return;
                
        final RichTextBox activeRTB = (RichTextBox) VUE.getActive(RichTextBox.class);
                
                
        if (activeRTB == null && lwtext == null) {
            // no problem: just ignore if there's no active edit
            //tufts.Util.printStackTrace("FEP propertyChange: no active RichTextBox: " + e);
            return;
        }
                
        if (lwtext !=null)
           lwtext.richLabelBox.selectAll();
                
               
        final Color color = (Color) e.getNewValue();
        final SimpleAttributeSet set = new SimpleAttributeSet();
        final String colorString = "#" + Integer.toHexString(color.getRGB()).substring(2);
        toggleBulletsAction.setColor(colorString);
        toggleNumbersAction.setColor(colorString);
        Util.styleSheet().addCSSAttribute(set, CSS.Attribute.COLOR, colorString);
                
        set.addAttribute(HTML.Attribute.COLOR, colorString);
        if (activeRTB != null)
           activeRTB.applyAttributes(set, false);
        else
           lwtext.richLabelBox.applyAttributes(set, false);
                
        if (lwtext !=null)
        {
           lwtext.richLabelBox.select(0,0);
                    
           lwtext.richLabelBox.select(0,0);
          //lwtext.setLabel0(lwtext.richLabelBox.getRichText(), false);
          lwtext.richLabelBox.setSize(lwtext.richLabelBox.getPreferredSize());                                        
                   
              if (lwtext.getParent() !=null)
                  lwtext.getParent().layout();
                     
                     
                    
                     
           lwtext.notify(lwtext.richLabelBox, LWKey.Repaint); 
        }
    }
};
 ************/
// this called every time setText is called to ensure we get
// the font style encoded in our owning LWComponent
void copyStyle(LWComponent c) {
    if (DEBUG.TEXT)
        out("copyStyle " + c);

    //Basic Setup
    LWText srcText = (LWText) c;
    RichTextBox srcBox = srcText.getRichLabelBox();
    selectAll();
    SHTMLDocument srcDoc = (SHTMLDocument) srcBox.getDocument();
    SHTMLDocument doc = (SHTMLDocument) getDocument();
    SimpleAttributeSet set = new SimpleAttributeSet();
    SimpleAttributeSet alignSet = new SimpleAttributeSet();
    //Gather source information

    Element paragraphElement = srcDoc.getParagraphElement(1);

    if (paragraphElement.getName().equals("p-implied")) //we're in a list item
        paragraphElement = paragraphElement.getParentElement();

    AttributeSet paragraphAttributeSet = paragraphElement.getAttributes();

    Element charElem = srcDoc.getCharacterElement(1);
    AttributeSet charSet = charElem.getAttributes();
    Enumeration characterAttributeEnum = charSet.getAttributeNames();
    Enumeration elementEnum = paragraphAttributeSet.getAttributeNames();

    //Apply some attributes
    // System.out.println(paragraphElement.toString());
    while (elementEnum.hasMoreElements()) {
        Object o = elementEnum.nextElement();

        boolean isAlignSet = false;
        //System.out.println("P :: " +o.toString());
        if (o.toString().equals("text-align") && paragraphAttributeSet.getAttribute(o).toString().equals("left")
                && !isAlignSet) {
            //Left Align
            Util.styleSheet().addCSSAttribute(alignSet, CSS.Attribute.TEXT_ALIGN,
                    paragraphAttributeSet.getAttribute(o).toString());
            alignSet.addAttribute(HTML.Attribute.ALIGN, paragraphAttributeSet.getAttribute(o).toString());
        } else if (o.toString().equals("text-align")
                && paragraphAttributeSet.getAttribute(o).toString().equals("center") && !isAlignSet) {
            //Center Align
            Util.styleSheet().addCSSAttribute(alignSet, CSS.Attribute.TEXT_ALIGN,
                    paragraphAttributeSet.getAttribute(o).toString());
            alignSet.addAttribute(HTML.Attribute.ALIGN, paragraphAttributeSet.getAttribute(o).toString());
        } else if (o.toString().equals("text-align")
                && paragraphAttributeSet.getAttribute(o).toString().equals("right") && !isAlignSet) {
            //Right Align
            Util.styleSheet().addCSSAttribute(alignSet, CSS.Attribute.TEXT_ALIGN,
                    paragraphAttributeSet.getAttribute(o).toString());
            alignSet.addAttribute(HTML.Attribute.ALIGN, paragraphAttributeSet.getAttribute(o).toString());
        }

        if ((o.toString().equals("font-size")) || (o.toString().equals("size"))) {
            //Font Size
            Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_SIZE,
                    paragraphAttributeSet.getAttribute(o).toString());
            set.addAttribute(HTML.Attribute.SIZE, paragraphAttributeSet.getAttribute(o).toString());
        }

        else if ((o.toString().equals("font-family")) || (o.toString().equals("font-face"))
                || (o.toString().equals("face"))) {
            //Font Face
            Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_FAMILY,
                    paragraphAttributeSet.getAttribute(o).toString());
            set.addAttribute(HTML.Attribute.FACE, paragraphAttributeSet.getAttribute(o).toString());

        }
    }

    boolean isBold = false;
    boolean isItalic = false;
    boolean isUnderline = false;

    while (characterAttributeEnum.hasMoreElements()) {

        Object o = characterAttributeEnum.nextElement();
        //System.out.println("C :: " +o.toString() + "XXX " + charSet.getAttribute(o).toString());
        //System.out.println("Character element : " + o.toString() + " , " + charSet.getAttribute(o));
        if ((o.toString().equals("color"))) {
            //Color
            Util.styleSheet().addCSSAttribute(set, CSS.Attribute.COLOR, charSet.getAttribute(o).toString());
            set.addAttribute(HTML.Attribute.COLOR, charSet.getAttribute(o).toString());
        }

        if ((o.toString().equals("font-size")) || (o.toString().equals("size"))) {
            //Font Size
            Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_SIZE, charSet.getAttribute(o).toString());
            set.addAttribute(HTML.Attribute.SIZE, charSet.getAttribute(o).toString());
        }

        if ((o.toString().equals("font-family")) || (o.toString().equals("font-face"))
                || (o.toString().equals("face"))) {
            //Font Face
            Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_FAMILY,
                    charSet.getAttribute(o).toString());
            set.addAttribute(HTML.Attribute.FACE, charSet.getAttribute(o).toString());
        }

        if ((o.toString().equals("font-weight") && charSet.getAttribute(o).toString().equals("bold"))
                || o.toString().equals("b")) {
            Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_WEIGHT,
                    charSet.getAttribute(o).toString());
        }
        if ((o.toString().equals("font-style") && charSet.getAttribute(o).toString().equals("italic"))
                || o.toString().equals("i")) {
            Util.styleSheet().addCSSAttribute(set, CSS.Attribute.FONT_STYLE,
                    charSet.getAttribute(o).toString());
        }
        if ((o.toString().equals("text-decoration") && charSet.getAttribute(o).toString().equals("underline"))
                || o.toString().equals("u")) {
            Util.styleSheet().addCSSAttribute(set, CSS.Attribute.TEXT_DECORATION,
                    charSet.getAttribute(o).toString());
        }
    } //done looking at character attributes                                                

    applyAttributes(set, false);
    lwc.notify(this, LWKey.Repaint);
    applyAttributes(alignSet, true);
    lwc.notify(this, LWKey.Repaint);
    clearSelection();
    try {
        setSize(getPreferredSize());
    } catch (NullPointerException npe) {
    }
    /*      set = new SimpleAttributeSet();
          final String colorString = "#" + Integer.toHexString(color.getRGB()).substring(2);
          toggleBulletsAction.setColor(colorString);
          toggleNumbersAction.setColor(colorString);
          Util.styleSheet().addCSSAttribute(set, CSS.Attribute.COLOR, colorString);
                  
          set.addAttribute(HTML.Attribute.COLOR, colorString);
          if (activeRTB != null)
             activeRTB.applyAttributes(set, false);
          else
             lwtext.richLabelBox.applyAttributes(set, false);
                  
          if (lwtext !=null)
          {
             lwtext.richLabelBox.select(0,0);
            
             lwtext.richLabelBox.select(0,0);
            //lwtext.setLabel0(lwtext.richLabelBox.getRichText(), false);
            lwtext.richLabelBox.setSize(lwtext.richLabelBox.getPreferredSize());                                        
                     
      if (lwtext.getParent() !=null)
          lwtext.getParent().layout();
             
             
            
             
             lwtext.notify(lwtext.richLabelBox, LWKey.Repaint); 
          }*/
}