Coverage Report - org.jtheque.core.managers.view.impl.components.filthy.FilthyList
 
Classes in this File Line Coverage Branch Coverage Complexity
FilthyList
0 %
0/19
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.JList;
 6  
 import javax.swing.ListModel;
 7  
 import java.awt.AlphaComposite;
 8  
 import java.awt.BasicStroke;
 9  
 import java.awt.Color;
 10  
 import java.awt.Composite;
 11  
 import java.awt.Graphics;
 12  
 import java.awt.Graphics2D;
 13  
 import java.awt.RenderingHints;
 14  
 import java.awt.Shape;
 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 list.
 36  
  *
 37  
  * @author Baptiste Wicht
 38  
  */
 39  
 public final class FilthyList extends JList {
 40  
     /**
 41  
      * Construct a new <code>FilthyList</code>.
 42  
      *
 43  
      * @param dataModel The model to store data.
 44  
      */
 45  
     public FilthyList(ListModel dataModel) {
 46  0
         super(dataModel);
 47  
 
 48  0
         setOpaque(false);
 49  0
         setBorder(Borders.createEmptyBorder(5));
 50  0
     }
 51  
 
 52  
     @Override
 53  
     protected void paintComponent(Graphics g) {
 54  0
         Graphics2D g2 = (Graphics2D) g;
 55  0
         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
 56  
                 RenderingHints.VALUE_ANTIALIAS_ON);
 57  
 
 58  0
         Composite composite = g2.getComposite();
 59  0
         g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.05f));
 60  
 
 61  0
         g2.setColor(Color.white);
 62  
 
 63  0
         Shape background = new RoundRectangle2D.Double(3.0, 3.0,
 64  
                 (double) getWidth() - 18.0,
 65  
                 (double) getHeight() - 6.0,
 66  
                 10, 10);
 67  0
         g2.fill(background);
 68  
 
 69  0
         g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
 70  0
         Stroke stroke = g2.getStroke();
 71  0
         g2.setStroke(new BasicStroke(3.0f));
 72  0
         g2.draw(background);
 73  0
         g2.setStroke(stroke);
 74  
 
 75  0
         g2.setComposite(composite);
 76  
 
 77  0
         super.paintComponent(g);
 78  0
     }
 79  
 }