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