Coverage Report - com.timjohnstondev.unitconverter.view.UnitLabelPanel
 
Classes in this File Line Coverage Branch Coverage Complexity
UnitLabelPanel
0%
0/31
0%
0/4
1.5
 
 1  
 /**
 2  
  * Copyright 2009 Timothy Johnston Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
 3  
  * file except in compliance with the License. You may obtain a copy of the License at
 4  
  * 
 5  
  * http://www.apache.org/licenses/LICENSE-2.0
 6  
  * 
 7  
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 8  
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 9  
  * specific language governing permissions and limitations under the License.
 10  
  */
 11  
 package com.timjohnstondev.unitconverter.view;
 12  
 
 13  
 import java.awt.Color;
 14  
 import java.awt.Component;
 15  
 import java.awt.Dimension;
 16  
 import java.util.ResourceBundle;
 17  
 import javax.swing.BorderFactory;
 18  
 import javax.swing.Box;
 19  
 import javax.swing.BoxLayout;
 20  
 import javax.swing.JLabel;
 21  
 import javax.swing.JPanel;
 22  
 
 23  
 /**
 24  
  * This panel holds the labels for the {@link UnitPanel}.
 25  
  */
 26  
 public class UnitLabelPanel extends JPanel implements Configuration
 27  
 {
 28  
   /**
 29  
    * Constructs a {@code UnitLabelPanel} setting the label sizes to match the UnitPanel lists.
 30  
    */
 31  
   public UnitLabelPanel()
 32  0
   {
 33  0
     setPreferredSize(new Dimension(500, 20));
 34  0
     setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
 35  0
     setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
 36  
 
 37  0
     final ResourceBundle resources = ResourceBundle.getBundle("com.timjohnstondev.unitconverter.view.View");
 38  0
     final JLabel properties = new JLabel(resources.getString("UnitLabelPanel.properties"));
 39  0
     final JLabel fromUnits = new JLabel(resources.getString("UnitLabelPanel.fromUnits"));
 40  0
     final JLabel toUnits = new JLabel(resources.getString("UnitLabelPanel.toUnits"));
 41  
 
 42  0
     properties.setPreferredSize(new Dimension(170, 20));
 43  0
     properties.setMaximumSize(new Dimension(170, 20));
 44  0
     fromUnits.setPreferredSize(new Dimension(110, 20));
 45  0
     fromUnits.setMaximumSize(new Dimension(110, 20));
 46  0
     toUnits.setPreferredSize(new Dimension(110, 20));
 47  0
     toUnits.setMaximumSize(new Dimension(110, 20));
 48  
 
 49  0
     add(properties);
 50  0
     add(fromUnits);
 51  0
     add(toUnits);
 52  0
     add(Box.createHorizontalGlue());
 53  0
   }
 54  
 
 55  
   @Override
 56  
   public final void setBackgroundColor(final Color color)
 57  
   {
 58  0
     setBackground(color);
 59  0
   }
 60  
 
 61  
   @Override
 62  
   public final void setFontSize(final float fontSize)
 63  
   {
 64  0
     setFont(getFont().deriveFont(fontSize));
 65  0
     final Component[] children = getComponents();
 66  0
     for (Component child : children)
 67  
     {
 68  0
       child.setFont(child.getFont().deriveFont(fontSize));
 69  
     }
 70  0
   }
 71  
 
 72  
   @Override
 73  
   public final void setForegroundColor(final Color color)
 74  
   {
 75  0
     setForeground(color);
 76  0
     final Component[] children = getComponents();
 77  0
     for (Component child : children)
 78  
     {
 79  0
       child.setForeground(color);
 80  
     }
 81  0
   }
 82  
 }