View Javadoc

1   /*
2    * $Id: HTMLTextFormatter.java 178 2010-10-31 18:01:20Z roland $
3    * Copyright (C) 2007 Roland Krueger
4    * Created on 18.11.2009
5    *
6    * Author: Roland Krueger (www.rolandkrueger.info)
7    *
8    * This file is part of RoKlib.
9    *
10   * This library is free software; you can redistribute it and/or
11   * modify it under the terms of the GNU Lesser General Public License
12   * as published by the Free Software Foundation; either version 2.1 of
13   * the License, or (at your option) any later version.
14   *
15   * This library is distributed in the hope that it will be useful, but
16   * WITHOUT ANY WARRANTY; without even the implied warranty of
17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18   * Lesser General Public License for more details.
19   *
20   * You should have received a copy of the GNU Lesser General Public
21   * License along with this library; if not, write to the Free Software
22   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23   * USA
24   */
25  package info.rolandkrueger.roklib.util.formatter;
26  
27  import java.awt.Color;
28  
29  public class HTMLTextFormatter implements ITextFormatter
30  {
31    public CharSequence append (CharSequence text)
32    {
33      return text;
34    }
35  
36    public CharSequence appendBold (CharSequence text)
37    {
38      return String.format ("<b>%s</b>", text);
39    }
40  
41    public CharSequence appendColored (CharSequence text, Color color)
42    {
43      // TODO
44      return String.format ("<font >%s</font>", text);
45    }
46  
47    public CharSequence appendItalic (CharSequence text)
48    {
49      return String.format ("<i>%s</i>", text);
50    }
51  
52    public CharSequence appendMonospaced (CharSequence text)
53    {
54      return String.format ("<pre>%s</pre>", text);
55    }
56  
57    public CharSequence appendSubscript (CharSequence text)
58    {
59      return String.format ("<sub>%s</sub>", text);
60    }
61  
62    public CharSequence appendSuperscript (CharSequence text)
63    {
64      return String.format ("<sup>%s</sup>", text);
65    }
66  
67    public CharSequence appendUnderlined (CharSequence text)
68    {
69      return String.format ("<u>%s</u>", text);
70    }
71  
72    public CharSequence appendStrikeThrough (CharSequence text)
73    {
74      return String.format ("<del>%s</del>", text);
75    }
76  
77    public CharSequence encloseText (CharSequence text)
78    {
79      return String.format ("<html>%s</html>", text);
80    }
81  }