001: package org.columba.mail.gui.message.viewer;
002:
003: import java.awt.Color;
004: import java.awt.Component;
005: import java.awt.Graphics;
006: import java.awt.Insets;
007:
008: import javax.swing.border.AbstractBorder;
009:
010: public class MessageBorder extends AbstractBorder {
011:
012: protected Color lineColor;
013:
014: protected int thickness;
015:
016: protected boolean roundedCorners;
017:
018: protected int arc = 6;
019:
020: public MessageBorder(Color lineColor, int thickness,
021: boolean roundedCorners) {
022: super ();
023:
024: this .lineColor = lineColor;
025: this .thickness = thickness;
026: this .roundedCorners = roundedCorners;
027:
028: }
029:
030: /**
031: * Paints the border for the specified component with the specified position
032: * and size.
033: *
034: * @param c
035: * the component for which this border is being painted
036: * @param g
037: * the paint graphics
038: * @param x
039: * the x position of the painted border
040: * @param y
041: * the y position of the painted border
042: * @param width
043: * the width of the painted border
044: * @param height
045: * the height of the painted border
046: */
047: public void paintBorder(Component c, Graphics g, int x, int y,
048: int width, int height) {
049: Color oldColor = g.getColor();
050: int i;
051:
052: g.setColor(lineColor);
053: for (i = 0; i < thickness; i++) {
054: if (!roundedCorners)
055: g.drawRect(x + i, y + i, width - i - i - 1, height - i
056: - i - 1);
057: else
058: g.drawRoundRect(x + i, y + i, width - i - i - 1, height
059: - i - i - 1, arc, arc);
060: }
061: g.setColor(oldColor);
062: }
063:
064: /**
065: * Returns the insets of the border.
066: *
067: * @param c
068: * the component for which this border insets value applies
069: */
070: public Insets getBorderInsets(Component c) {
071: return new Insets(thickness, thickness, thickness, thickness);
072: }
073:
074: /**
075: * Reinitialize the insets parameter with this Border's current Insets.
076: *
077: * @param c
078: * the component for which this border insets value applies
079: * @param insets
080: * the object to be reinitialized
081: */
082: public Insets getBorderInsets(Component c, Insets insets) {
083: insets.left = insets.top = insets.right = insets.bottom = thickness;
084: return insets;
085: }
086:
087: /**
088: * Returns the color of the border.
089: */
090: public Color getLineColor() {
091: return lineColor;
092: }
093:
094: /**
095: * Returns the thickness of the border.
096: */
097: public int getThickness() {
098: return thickness;
099: }
100:
101: }
|