Coverage Report - org.jtheque.core.managers.view.impl.components.filthy.java2d.AbstractAboutPane
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractAboutPane
0 %
0/23
0 %
0/2
1.059
AbstractAboutPane$1
N/A
N/A
1.059
AbstractAboutPane$Info
0 %
0/17
N/A
1.059
 
 1  
 package org.jtheque.core.managers.view.impl.components.filthy.java2d;
 2  
 
 3  
 import org.jdesktop.animation.timing.Animator;
 4  
 import org.jdesktop.swingx.JXPanel;
 5  
 import org.jtheque.core.managers.Managers;
 6  
 import org.jtheque.core.managers.language.ILanguageManager;
 7  
 
 8  
 import java.util.ArrayList;
 9  
 import java.util.Arrays;
 10  
 import java.util.Collection;
 11  
 
 12  
 /*
 13  
  * This file is part of JTheque.
 14  
  *
 15  
  * JTheque is free software: you can redistribute it and/or modify
 16  
  * it under the terms of the GNU General Public License as published by
 17  
  * the Free Software Foundation, either version 3 of the License.
 18  
  *
 19  
  * JTheque is distributed in the hope that it will be useful,
 20  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 21  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 22  
  * GNU General Public License for more details.
 23  
  *
 24  
  * You should have received a copy of the GNU General Public License
 25  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 26  
  */
 27  
 
 28  
 /**
 29  
  * An abstract about pane view.
 30  
  *
 31  
  * @author Baptiste Wicht
 32  
  */
 33  0
 public abstract class AbstractAboutPane extends JXPanel {
 34  
     private Animator animator;
 35  
 
 36  
     private String licence;
 37  
     private String copyright;
 38  
     private Info[] infos;
 39  
     private Collection<String> credits;
 40  
 
 41  
     /**
 42  
      * Init the view.
 43  
      */
 44  
     void init() {
 45  0
         copyright = Managers.getCore().getApplication().getCopyright();
 46  0
         licence = getMessage("about.actions.read");
 47  
 
 48  0
         infos = new Info[4];
 49  
 
 50  0
         infos[0] = new Info(getMessage("about.view.version"),
 51  
                 Managers.getCore().getApplication().getVersion().getVersion(), false, false);
 52  0
         infos[1] = new Info(getMessage("about.view.author"),
 53  
                 Managers.getCore().getApplication().getAuthor(), false, false);
 54  0
         infos[2] = new Info(getMessage("about.view.site"),
 55  
                 Managers.getCore().getApplication().getSite(), true, false);
 56  0
         infos[3] = new Info(getMessage("about.view.mail"),
 57  
                 Managers.getCore().getApplication().getEmail(), false, true);
 58  
 
 59  0
         credits = new ArrayList<String>(Managers.getCore().getCreditsMessage().size() * 4);
 60  
 
 61  0
         for (String key : Managers.getCore().getCreditsMessage()) {
 62  0
             String[] messages = Managers.getManager(ILanguageManager.class).getLinesMessage(key);
 63  
 
 64  0
             credits.addAll(Arrays.asList(messages));
 65  0
         }
 66  0
     }
 67  
 
 68  
     /**
 69  
      * Return an internationalized message.
 70  
      *
 71  
      * @param key The internationalization key.
 72  
      * @return The internationalized message.
 73  
      */
 74  
     private static String getMessage(String key) {
 75  0
         return Managers.getManager(ILanguageManager.class).getMessage(key);
 76  
     }
 77  
 
 78  
     /**
 79  
      * The animator of the view.
 80  
      *
 81  
      * @return The animator of the view.
 82  
      */
 83  
     public final Animator getAnimator() {
 84  0
         return animator;
 85  
     }
 86  
 
 87  
     /**
 88  
      * Set the animator of the view.
 89  
      *
 90  
      * @param animator The animator of the view.
 91  
      */
 92  
     final void setAnimator(Animator animator) {
 93  0
         this.animator = animator;
 94  0
     }
 95  
 
 96  
     /**
 97  
      * The licence message.
 98  
      *
 99  
      * @return The licence message.
 100  
      */
 101  
     final String getLicenceMessage() {
 102  0
         return licence;
 103  
     }
 104  
 
 105  
     /**
 106  
      * Return the copyright to display on the view.
 107  
      *
 108  
      * @return The copyright to display on the view.
 109  
      */
 110  
     final String getCopyright() {
 111  0
         return copyright;
 112  
     }
 113  
 
 114  
     /**
 115  
      * Return all the informations to display on the view.
 116  
      *
 117  
      * @return All the informations to display.
 118  
      */
 119  
     final Info[] getInfos() {
 120  0
         return infos;
 121  
     }
 122  
 
 123  
     /**
 124  
      * Return all the credits to display.
 125  
      *
 126  
      * @return All the credits to display.
 127  
      */
 128  
     final Collection<String> getCredits() {
 129  0
         return credits;
 130  
     }
 131  
 
 132  
     /**
 133  
      * An info about the application to display.
 134  
      *
 135  
      * @author Baptiste Wicht
 136  
      */
 137  0
     static final class Info {
 138  
         private final String left;
 139  
         private final String right;
 140  
         private final boolean url;
 141  
         private final boolean mail;
 142  
 
 143  
         private int leftWidth;
 144  
         private int rightWidth;
 145  
 
 146  
         /**
 147  
          * Create a new Info.
 148  
          *
 149  
          * @param left  The left part of the information.
 150  
          * @param right The right part of the information.
 151  
          * @param url   Indicate if the information is an url or not.
 152  
          * @param mail  Indicate if the information is an email address or not.
 153  
          */
 154  
         private Info(String left, String right, boolean url, boolean mail) {
 155  0
             super();
 156  
 
 157  0
             this.left = left;
 158  0
             this.right = right;
 159  0
             this.url = url;
 160  0
             this.mail = mail;
 161  0
         }
 162  
 
 163  
         /**
 164  
          * Return the left part of the information.
 165  
          *
 166  
          * @return The left part of the information.
 167  
          */
 168  
         public String getLeft() {
 169  0
             return left;
 170  
         }
 171  
 
 172  
         /**
 173  
          * Return the right part of the information.
 174  
          *
 175  
          * @return The right part of the information.
 176  
          */
 177  
         public String getRight() {
 178  0
             return right;
 179  
         }
 180  
 
 181  
         /**
 182  
          * Indicate if the info is an url or not.
 183  
          *
 184  
          * @return true if the info is an url else false.
 185  
          */
 186  
         public boolean isUrl() {
 187  0
             return url;
 188  
         }
 189  
 
 190  
         /**
 191  
          * Indicate if the info is a mail or not.
 192  
          *
 193  
          * @return true if the info is a mail else false.
 194  
          */
 195  
         public boolean isMail() {
 196  0
             return mail;
 197  
         }
 198  
 
 199  
         /**
 200  
          * Return the width of the left part of the information.
 201  
          *
 202  
          * @return The width of the left part of the information.
 203  
          */
 204  
         public int getLeftWidth() {
 205  0
             return leftWidth;
 206  
         }
 207  
 
 208  
         /**
 209  
          * Set the width of the left part of the information.
 210  
          *
 211  
          * @param leftWidth The width of the left part of the information.
 212  
          */
 213  
         public void setLeftWidth(int leftWidth) {
 214  0
             this.leftWidth = leftWidth;
 215  0
         }
 216  
 
 217  
         /**
 218  
          * Return the width of the right part of the information.
 219  
          *
 220  
          * @return The width of the right part of the information.
 221  
          */
 222  
         public int getRightWidth() {
 223  0
             return rightWidth;
 224  
         }
 225  
 
 226  
         /**
 227  
          * Set the width of the right part of the information.
 228  
          *
 229  
          * @param rightWidth The width of the right part of the information.
 230  
          */
 231  
         public void setRightWidth(int rightWidth) {
 232  0
             this.rightWidth = rightWidth;
 233  0
         }
 234  
     }
 235  
 }