1 package org.columba.mail.gui.message.viewer; 2 3 import java.awt.Color ; 4 import java.awt.Component ; 5 import java.awt.Graphics ; 6 import java.awt.Insets ; 7 8 import javax.swing.border.AbstractBorder ; 9 10 public class MessageBorder extends AbstractBorder { 11 12 protected Color lineColor; 13 14 protected int thickness; 15 16 protected boolean roundedCorners; 17 18 protected int arc = 6; 19 20 public MessageBorder(Color lineColor, int thickness, boolean roundedCorners) { 21 super(); 22 23 this.lineColor = lineColor; 24 this.thickness = thickness; 25 this.roundedCorners = roundedCorners; 26 27 } 28 29 46 public void paintBorder(Component c, Graphics g, int x, int y, int width, 47 int height) { 48 Color oldColor = g.getColor(); 49 int i; 50 51 g.setColor(lineColor); 52 for (i = 0; i < thickness; i++) { 53 if (!roundedCorners) 54 g.drawRect(x + i, y + i, width - i - i - 1, height - i - i - 1); 55 else 56 g.drawRoundRect(x + i, y + i, width - i - i - 1, height - i - i 57 - 1, arc, arc); 58 } 59 g.setColor(oldColor); 60 } 61 62 68 public Insets getBorderInsets(Component c) { 69 return new Insets (thickness, thickness, thickness, thickness); 70 } 71 72 80 public Insets getBorderInsets(Component c, Insets insets) { 81 insets.left = insets.top = insets.right = insets.bottom = thickness; 82 return insets; 83 } 84 85 88 public Color getLineColor() { 89 return lineColor; 90 } 91 92 95 public int getThickness() { 96 return thickness; 97 } 98 99 } 100 | Popular Tags |