001 // This file is part of AceWiki.
002 // Copyright 2008-2012, AceWiki developers.
003 //
004 // AceWiki is free software: you can redistribute it and/or modify it under the terms of the GNU
005 // Lesser General Public License as published by the Free Software Foundation, either version 3 of
006 // the License, or (at your option) any later version.
007 //
008 // AceWiki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009 // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
010 // Lesser General Public License for more details.
011 //
012 // You should have received a copy of the GNU Lesser General Public License along with AceWiki. If
013 // not, see http://www.gnu.org/licenses/.
014
015 package ch.uzh.ifi.attempto.echocomp;
016
017 import nextapp.echo.app.Extent;
018 import nextapp.echo.app.Font;
019 import nextapp.echo.app.ImageReference;
020
021 /**
022 * This is a convenience class for easy creation of labels.
023 *
024 * @author Tobias Kuhn
025 */
026 public class Label extends nextapp.echo.app.Label {
027
028 private static final long serialVersionUID = -1013262375038053365L;
029
030 /**
031 * Creates a new empty label.
032 */
033 public Label() {
034 super();
035 initLabel(Font.PLAIN, 13);
036 }
037
038 /**
039 * Creates a new label containing only an image.
040 *
041 * @param image The image.
042 */
043 public Label(ImageReference image) {
044 super(image);
045 initLabel(Font.PLAIN, 13);
046 }
047
048 /**
049 * Creates a new label.
050 *
051 * @param text The text of the label.
052 */
053 public Label(String text) {
054 super(text);
055 initLabel(Font.PLAIN, 13);
056 }
057
058 /**
059 * Creates a new label of the given style.
060 *
061 * @param text The text of the label.
062 * @param style The style of the label.
063 */
064 public Label(String text, int style) {
065 super(text);
066 initLabel(style, 13);
067 }
068
069 /**
070 * Creates a new label of the given style with the given text size.
071 *
072 * @param text The text of the label.
073 * @param style The style of the label.
074 * @param size The size of the text.
075 */
076 public Label(String text, int style, int size) {
077 super(text);
078 initLabel(style, size);
079 }
080
081 void initLabel(int style, int size) {
082 setFont(new Font(Style.fontTypeface, style, new Extent(size)));
083 }
084
085 }