Package hamsam.api

Examples of hamsam.api.TextComponent


    // pieces.
    if(foundPos != -1)
    {
      String left = text.substring(0, foundPos);
      String right = text.substring(foundPos + foundLength);
      MessageComponent[] leftComp = splitForSmileys(new TextComponent(left));
      MessageComponent[] rightComp = splitForSmileys(new TextComponent(right));

      for(int i = 0; i < leftComp.length; i++)
        ret.add(leftComp[i]);
      ret.add(smileys[foundSmiley]);
      for(int i = 0; i < rightComp.length; i++)
        ret.add(rightComp[i]);
    }
    else
      ret.add(new TextComponent(text));

    return (MessageComponent[]) ret.toArray(new MessageComponent[0]);
  }
View Full Code Here


    for(int i = 0; i < comp.length; i++)
    {
      if(comp[i] instanceof TextComponent)
      {
        TextComponent txt = (TextComponent) comp[i];
        MessageComponent[] msgs = splitFontAndColor(txt);
        for(int j = 0; j < msgs.length; j++)
          ret.add(msgs[j]);
      }
      else
View Full Code Here

    {
      int txtEnd = m.end();
      if(txtStart < txtEnd)
      {
        String text = sb.substring(txtStart, txtEnd);
        ret.add(new TextComponent(text, currentFont, currentColor));
      }
      txtStart = txtEnd;

      String fontFace = m.group(3);
      String fontSize = m.group(4);
      String colorCodeStr = m.group(7);
      String colorStr = m.group(9);

      if(fontFace != null)
        currentFont = new Font(fontFace, currentFontStyle, currentFontSize);
      if(fontSize != null)
      {
        currentFontSize = Integer.parseInt(fontSize);
        currentFont = currentFont.deriveFont((float)currentFontSize);
      }
      if(colorCodeStr != null)
      {
        switch(Integer.parseInt(colorCodeStr))
        {
          case 38:
            currentColor = new Color(0xff0000);
            break;
          case 34:
            currentColor = new Color(0x00ff00);
            break;
          case 39:
            currentColor = new Color(0xffff00);
            break;
          case 31:
            currentColor = new Color(0x0000ff);
            break;
          case 36:
            currentColor = new Color(0xff00ff);
            break;
          case 32:
            currentColor = new Color(0x00ffff);
            break;
          case 37:
            currentColor = new Color(0xff8000);
            break;
          case 35:
            currentColor = new Color(0xff0080);
            break;
          case 33:
            currentColor = new Color(0x808080);
            break;
        }
      }
      if(colorStr != null)
      {
        currentColor = new Color(Integer.parseInt(colorStr, 16));
      }
    }
    if(txtStart < sb.length())
    {
      String text = sb.substring(txtStart);
      ret.add(new TextComponent(text, currentFont, currentColor));
    }

    return (MessageComponent[]) ret.toArray(new MessageComponent[0]);
  }
View Full Code Here

    Enumeration e = msg.getComponents();
    while (e.hasMoreElements()) {
      MessageComponent comp = (MessageComponent) e.nextElement();
      if (comp instanceof TextComponent) {
        TextComponent txt = (TextComponent) comp;
        System.out.print("<text>" + new String(txt.getSequence()));
      }
      else if (comp instanceof SmileyComponent) {
        SmileyComponent sml = (SmileyComponent) comp;
        System.out.print("<smiley>" + sml.getName());
      }
View Full Code Here

  {
    try
    {
      Message msg = new Message();
      String text = this.owner.getMessageFieldText();
      msg.addComponent(new TextComponent(text));
      this.buddy.sendInstantMessage(msg);
      this.owner.messageSent(text);
      this.owner.setMessageFieldText("");
    }
    catch(IllegalStateException e)
View Full Code Here

    while(e.hasMoreElements())
    {
      MessageComponent comp = (MessageComponent) e.nextElement();
      if(comp instanceof TextComponent)
      {
        TextComponent text = (TextComponent) comp;
        if(font == null)
          font = text.getFont();
        if(color == null)
          color = text.getColor();
        buff.append(text.getSequence());
      }
      else if(comp instanceof SmileyComponent)
      {
        SmileyComponent smiley = (SmileyComponent) comp;
        buff.append(smiley.getText());
View Full Code Here

TOP

Related Classes of hamsam.api.TextComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.