001    // This file is part of the Attempto Java Packages.
002    // Copyright 2008, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch).
003    //
004    // The Attempto Java Packages is free software: you can redistribute it and/or modify it under the
005    // terms of the GNU Lesser General Public License as published by the Free Software Foundation,
006    // either version 3 of the License, or (at your option) any later version.
007    //
008    // The Attempto Java Packages is distributed in the hope that it will be useful, but WITHOUT ANY
009    // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
010    // PURPOSE. See the GNU Lesser General Public License for more details.
011    //
012    // You should have received a copy of the GNU Lesser General Public License along with the Attempto
013    // Java Packages. If not, see http://www.gnu.org/licenses/.
014    
015    package ch.uzh.ifi.attempto.echocomp;
016    
017    import nextapp.echo2.app.Extent;
018    import nextapp.echo2.app.Font;
019    import nextapp.echo2.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.echo2.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    }