Coverage Report - org.jtheque.core.managers.view.impl.components.filthy.FilthyPanel
 
Classes in this File Line Coverage Branch Coverage Complexity
FilthyPanel
0 %
0/23
N/A
1
 
 1  
 package org.jtheque.core.managers.view.impl.components.filthy;
 2  
 
 3  
 import org.jtheque.core.utils.ui.Borders;
 4  
 
 5  
 import javax.swing.JPanel;
 6  
 import java.awt.AlphaComposite;
 7  
 import java.awt.BasicStroke;
 8  
 import java.awt.Color;
 9  
 import java.awt.Composite;
 10  
 import java.awt.FlowLayout;
 11  
 import java.awt.Graphics;
 12  
 import java.awt.Graphics2D;
 13  
 import java.awt.LayoutManager;
 14  
 import java.awt.RenderingHints;
 15  
 import java.awt.Stroke;
 16  
 import java.awt.geom.RoundRectangle2D;
 17  
 
 18  
 /*
 19  
  * This file is part of JTheque.
 20  
  *            
 21  
  * JTheque is free software: you can redistribute it and/or modify
 22  
  * it under the terms of the GNU General Public License as published by
 23  
  * the Free Software Foundation, either version 3 of the License. 
 24  
  *
 25  
  * JTheque is distributed in the hope that it will be useful,
 26  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 27  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 28  
  * GNU General Public License for more details.
 29  
  *
 30  
  * You should have received a copy of the GNU General Public License
 31  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 32  
  */
 33  
 
 34  
 /**
 35  
  * A filthy panel. It's an opaque panel with rounded rectangle borders.
 36  
  *
 37  
  * @author Baptiste Wicht
 38  
  */
 39  
 public final class FilthyPanel extends JPanel {
 40  
     /**
 41  
      * Construct a new <code>FilthyPanel</code>.
 42  
      */
 43  
     public FilthyPanel() {
 44  0
         this(new FlowLayout());
 45  0
     }
 46  
 
 47  
     /**
 48  
      * Construct a new <code>FilthyPanel</code>.
 49  
      *
 50  
      * @param layoutManager The layout manager to use.
 51  
      */
 52  
     public FilthyPanel(LayoutManager layoutManager) {
 53  0
         super(layoutManager);
 54  
 
 55  0
         setOpaque(false);
 56  0
         setBorder(Borders.createEmptyBorder(10));
 57  0
     }
 58  
 
 59  
     @Override
 60  
     public void paint(Graphics g) {
 61  0
         Graphics2D g2 = (Graphics2D) g;
 62  
 
 63  0
         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
 64  
                 RenderingHints.VALUE_ANTIALIAS_ON);
 65  
 
 66  0
         super.paint(g);
 67  0
     }
 68  
 
 69  
     @Override
 70  
     protected void paintComponent(Graphics g) {
 71  0
         Graphics2D g2 = (Graphics2D) g;
 72  
 
 73  0
         Composite composite = g2.getComposite();
 74  0
         g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
 75  
 
 76  0
         g2.setColor(Color.white);
 77  
 
 78  
         RoundRectangle2D background;
 79  0
         background = new RoundRectangle2D.Double(3.0, 3.0,
 80  
                 (double) getWidth() - 10.0 - 3.0,
 81  
                 (double) getHeight() - 6.0,
 82  
                 12, 12);
 83  
 
 84  0
         g2.fill(background);
 85  
 
 86  0
         g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
 87  0
         Stroke stroke = g2.getStroke();
 88  0
         g2.setStroke(new BasicStroke(3.0f));
 89  0
         g2.draw(background);
 90  0
         g2.setStroke(stroke);
 91  
 
 92  0
         g2.setComposite(composite);
 93  0
     }
 94  
 }