Clover coverage report - Maven Clover report
Coverage timestamp: Thu Oct 11 2007 08:41:48 CEST
file stats: LOC: 80   Methods: 5
NCLOC: 47   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
FixedSquaredSizePanel.java - 0% 0% 0%
coverage
 1    /*
 2    * Copyright (C) 2007 Eric MIGNOT - mignots.eric@free.fr
 3    *
 4    * This library is free software; you can redistribute it and/or
 5    * modify it under the terms of the GNU Lesser General Public
 6    * License as published by the Free Software Foundation; either
 7    * version 2.1 of the License, or (at your option) any later version.
 8    *
 9    * This library is distributed in the hope that it will be useful,
 10    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12    * Lesser General Public License for more details.
 13    *
 14    * You should have received a copy of the GNU Lesser General Public
 15    * License along with this library; if not, write to the Free Software
 16    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 17    */
 18   
 19    package org.ericmignot.modeler.util.graphic;
 20   
 21    import java.awt.Color;
 22    import java.awt.Dimension;
 23    import java.awt.Graphics;
 24    import java.awt.Graphics2D;
 25    import java.awt.RenderingHints;
 26   
 27    import javax.swing.JPanel;
 28   
 29    public class FixedSquaredSizePanel extends JPanel
 30    {
 31    protected int fixedSize;
 32    protected Color fillColor;
 33    protected Color drawColor;
 34   
 35  0 public FixedSquaredSizePanel(Color fillColor, Color drawColor, int size)
 36    {
 37  0 this.fillColor = fillColor;
 38  0 this.drawColor = drawColor;
 39  0 this.fixedSize = size;
 40    }
 41   
 42  0 public Color getBackground()
 43    {
 44  0 return this.fillColor;
 45    }
 46   
 47  0 public Color getForeground()
 48    {
 49  0 return this.drawColor;
 50    }
 51   
 52  0 public Dimension getPreferredSize()
 53    {
 54  0 return new Dimension(fixedSize, fixedSize);
 55    }
 56   
 57  0 public void paintComponent(Graphics g)
 58    {
 59  0 int width = this.getSize().width;
 60  0 int x = (width - this.fixedSize ) / 2;
 61  0 int height = this.getSize().height;
 62  0 int y = (height - this.fixedSize) / 2;
 63   
 64  0 Color oldColor = g.getColor();
 65   
 66  0 Graphics2D g2d = (Graphics2D) g;
 67  0 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 68   
 69  0 g.setColor(this.getBackground());
 70  0 g.fillRect(x, y, this.fixedSize-1, this.fixedSize-1);
 71  0 g.setColor(this.getForeground());
 72  0 g.drawRect(x, y, this.fixedSize-1, this.fixedSize-1);
 73   
 74  0 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
 75  0 g.setColor(oldColor);
 76   
 77   
 78    }
 79   
 80    }