Clover coverage report - Maven Clover report
Coverage timestamp: Thu Oct 11 2007 08:41:48 CEST
file stats: LOC: 80   Methods: 5
NCLOC: 40   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RoundedLineBorder.java 0% 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.*;
 22   
 23    import javax.swing.border.*;
 24   
 25    /**
 26    * Implements a dashed line border
 27    */
 28    public class RoundedLineBorder extends LineBorder
 29    {
 30    private float[] dashedPattern;
 31    private int arcWidth;
 32   
 33   
 34    static private int defaultThickness = 1;
 35    static private int defaultArcWidth = 20;
 36   
 37  0 public RoundedLineBorder(Color color)
 38    {
 39  0 this(color, defaultThickness, defaultArcWidth);
 40    }
 41   
 42  0 public RoundedLineBorder(Color color, int thickness)
 43    {
 44  0 this(color, thickness, defaultArcWidth);
 45    }
 46   
 47  0 public RoundedLineBorder(Color color, int thickness, int arcWidth)
 48    {
 49  0 super(color, thickness);
 50  0 this.arcWidth = arcWidth;
 51    }
 52   
 53  0 public Insets getBorderInsets(Component c) {
 54  0 return new Insets(4, 4, 4, 4);
 55    }
 56   
 57   
 58  0 public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
 59    {
 60  0 Graphics2D g2d = (Graphics2D) g;
 61  0 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 62   
 63   
 64  0 Color oldColor = g.getColor();
 65   
 66  0 g.setColor(lineColor);
 67   
 68  0 g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashedPattern, 0.0f));
 69   
 70  0 for(int i = 0; i < thickness; i++)
 71    {
 72  0 g2d.drawRoundRect(x+i, y+i, width-i-i-1, height-i-i-1, arcWidth, arcWidth);
 73    }
 74  0 g.setColor(oldColor);
 75   
 76  0 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
 77   
 78    }
 79   
 80    }