Clover coverage report - Maven Clover report
Coverage timestamp: Thu Oct 11 2007 08:41:48 CEST
file stats: LOC: 101   Methods: 8
NCLOC: 64   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DashedLineBorder.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    import javax.swing.border.*;
 23   
 24    /**
 25    * Implements a dashed line border
 26    */
 27    public class DashedLineBorder extends LineBorder
 28    {
 29    private float[] dashedPattern;
 30    private int arcWidth;
 31   
 32    static private float[] defaultDashPattern = new float[]{5.0f, 5.0f};
 33    static private int defaultThickness = 1;
 34    static private boolean defaultRoundedCorners = true;
 35    static private int defaultArcWidth = 20;
 36   
 37  0 public DashedLineBorder(Color color)
 38    {
 39  0 this(color, defaultThickness, defaultDashPattern, defaultRoundedCorners, defaultArcWidth);
 40    }
 41   
 42  0 public DashedLineBorder(Color color, boolean roundedCorners)
 43    {
 44  0 this(color, defaultThickness, defaultDashPattern, roundedCorners, defaultArcWidth);
 45    }
 46   
 47  0 public DashedLineBorder(Color color, boolean roundedCorners, int arcWidth)
 48    {
 49  0 this(color, defaultThickness, defaultDashPattern, roundedCorners, arcWidth);
 50    }
 51   
 52  0 public DashedLineBorder(Color color, float[] dashPattern)
 53    {
 54  0 this(color, defaultThickness, dashPattern, defaultRoundedCorners, defaultArcWidth);
 55    }
 56   
 57  0 public DashedLineBorder(Color color, int thickness, float[] dashPattern)
 58    {
 59  0 this(color, thickness, dashPattern, defaultRoundedCorners, defaultArcWidth);
 60    }
 61   
 62  0 public DashedLineBorder(Color color, int thickness, float[] dashPattern, boolean roundedCorners)
 63    {
 64  0 this(color, thickness, dashPattern, roundedCorners, defaultArcWidth);
 65    }
 66   
 67  0 public DashedLineBorder(Color color, int thickness, float[] dashedPattern, boolean roundedCorners, int arcWidth)
 68    {
 69  0 super(color, thickness, roundedCorners);
 70  0 this.dashedPattern = dashedPattern;
 71  0 this.arcWidth = arcWidth;
 72    }
 73   
 74   
 75  0 public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
 76    {
 77  0 Color oldColor = g.getColor();
 78   
 79  0 g.setColor(lineColor);
 80  0 Graphics2D g2d = (Graphics2D) g;
 81  0 g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashedPattern, 0.0f));
 82   
 83  0 if(roundedCorners)
 84    {
 85  0 for(int i = 0; i < thickness; i++)
 86    {
 87  0 g2d.drawRoundRect(x+i, y+i, width-i-i-1, height-i-i-1, arcWidth, arcWidth);
 88    }
 89    }
 90    else
 91    {
 92  0 for(int i = 0; i < thickness; i++)
 93    {
 94  0 g2d.drawRect(x+i, y+i, width-i-i-1, height-i-i-1);
 95    }
 96    }
 97   
 98  0 g.setColor(oldColor);
 99    }
 100   
 101    }