KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > border > SBevelBorder


1 /*
2  * $Id: SBevelBorder.java,v 1.7 2005/05/27 09:17:33 blueshift Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.border;
15
16 import org.wings.style.CSSProperty;
17
18 import java.awt.*;
19
20 /**
21  * Draw a beveled border around a component.
22  * <span style="border-style: outset; border-width: 3px;">RAISED</span>
23  * <span style="border-style: inset; border-width: 3px;">LOWERED</span>
24  *
25  * @author <a HREF="mailto:haaf@mercatis.de">Armin Haaf</a>
26  * @author <a HREF="mailto:andre@lison.de">Andre Lison</a>
27  * @version $Revision: 1.7 $
28  */

29 public class SBevelBorder
30         extends SAbstractBorder {
31     public static final int RAISED = 0;
32     public static final int LOWERED = 1;
33
34     private int bevelType = RAISED;
35
36     /**
37      * Creates a new beveled raised border.
38      */

39     public SBevelBorder() {
40         setBevelType(RAISED);
41     }
42
43     /**
44      * Creates a new beveled border with the given type.
45      *
46      * @param bevelType one of the following constants:
47      * <code>RAISED</code> or <code>LOWERED</code>
48      */

49     public SBevelBorder(int bevelType) {
50         setBevelType(bevelType);
51     }
52
53     /**
54      * Creates a new beveled border with the given type and insets.
55      *
56      * @param bevelType one of the following constants:
57      * <code>RAISED</code> or <code>LOWERED</code>
58      * @param insets (space between border and component) around
59      */

60     public SBevelBorder(int bevelType, Insets insets) {
61         super(Color.black, 2, insets);
62         setBevelType(bevelType);
63     }
64
65     /**
66      * Creates a new beveled border with the given type, insets and
67      * border thickness
68      *
69      * @param bevelType one of the following constants:
70      * <code>RAISED</code> or <code>LOWERED</code>
71      * @param insets padding (space between border and component) around
72      * @param thickness the thickness of drawn line
73      */

74     public SBevelBorder(int bevelType, Insets insets, int thickness) {
75         super(Color.black, thickness, insets);
76         setBevelType(bevelType);
77     }
78
79     /**
80      * sets the bevel type.
81      *
82      * @param bevelType one of the following constants:
83      * <code>RAISED</code> or <code>LOWERED</code>
84      */

85     public void setBevelType(int bevelType) {
86         this.bevelType = bevelType;
87         attributes.put(CSSProperty.BORDER_STYLE, bevelType == RAISED ? "outset" : "inset");
88     }
89
90     /**
91      * returns the bevel type.
92      *
93      * @return the current bevel type
94      * @see #setBevelType
95      */

96     public int getBevelType() {
97         return bevelType;
98     }
99 }
100
101
102
Popular Tags