1 19 27 28 package org.netbeans.modules.xml.wsdl.ui.view.grapheditor.border; 29 30 import java.awt.BasicStroke ; 31 import java.awt.Color ; 32 import java.awt.Graphics2D ; 33 import java.awt.Insets ; 34 import java.awt.Rectangle ; 35 import java.awt.Stroke ; 36 import java.awt.geom.Rectangle2D ; 37 import java.awt.geom.RoundRectangle2D ; 38 import org.netbeans.api.visual.border.Border; 39 40 44 public class RoundDashedBorder implements Border { 45 46 private int mArcWidth; 47 private int mArcHeight; 48 float[] mDash; 49 int mThickness = 0; 50 Insets mInsets; 51 Color mFillColor; 52 Color mDrawColor; 53 Stroke mStroke; 54 55 56 public RoundDashedBorder (int arcWidth, 57 int arcHeight, 58 float[] dash, 59 int thickness, 60 Insets insets, 61 Color fillColor, 62 Color drawColor ) { 63 64 this.mArcWidth = arcWidth; 65 this.mArcHeight = arcHeight; 66 this.mDash = dash; 67 this.mThickness = thickness; 68 this.mInsets = insets; 69 this.mFillColor = fillColor; 70 this.mDrawColor = drawColor; 71 72 if (thickness < 1) { 73 throw new IllegalArgumentException ("Invalid thickness: " + thickness); 74 } 75 76 mStroke = new BasicStroke (mThickness, 77 BasicStroke.CAP_BUTT, 78 BasicStroke.JOIN_ROUND, 79 BasicStroke.JOIN_MITER, 80 mDash, 81 0); 82 83 } 84 85 public Insets getInsets() { 86 if(this.mInsets == null) { 87 this.mInsets = new Insets (mThickness,mThickness,mThickness,mThickness); 88 } 89 return this.mInsets; 90 } 91 92 public void paint(Graphics2D gr, Rectangle bounds) { 93 Stroke oldStroke = gr.getStroke(); 94 Color oldColor = gr.getColor(); 95 gr.setStroke(mStroke); 96 97 if (mFillColor != null) { 98 gr.setColor (mFillColor); 99 gr.fill (new RoundRectangle2D.Float (bounds.x, bounds.y, bounds.width, bounds.height, mArcWidth, mArcHeight)); 100 } 101 if (mDrawColor != null) { 102 gr.setColor (mDrawColor); 103 gr.drawRect(bounds.x,bounds.y,bounds.width-mThickness,bounds.height-mThickness); 104 105 } 108 109 } 112 113 public boolean isOpaque() { 114 return true; 115 } 116 117 118 } 119 | Popular Tags |