File Source: EtchedLineBorder.java
/*
P/P * Method: com.dmdirc.installer.ui.EtchedLineBorder__static_init
*/
1 /*
2 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.dmdirc.installer.ui;
24
25 import java.awt.Component;
26 import java.awt.Graphics;
27
28 import javax.swing.border.EtchedBorder;
29
30 import static com.dmdirc.installer.ui.InstallerDialog.SMALL_GAP;
31
32 /**
33 * An etched line border.
34 */
35 class EtchedLineBorder extends EtchedBorder {
36
37 /**
38 * A version number for this class. It should be changed whenever the class
39 * structure is changed (or anything else that would prevent serialized
40 * objects being unserialized with the new class).
41 */
42 private static final long serialVersionUID = 1;
43 /** Border side. */
44 private final BorderSide side;
45
46 /** Border side. */
/*
P/P * Method: void com.dmdirc.installer.ui.EtchedLineBorder$BorderSide(String, int)
*/
47 public enum BorderSide {
48
49 /** Creates a border at the top. */
/*
P/P * Method: com.dmdirc.installer.ui.EtchedLineBorder$BorderSide__static_init
*
* Postconditions:
* $VALUES == &new EtchedLineBorder$BorderSide[](EtchedLineBorder$BorderSide__static_init#3)
* BOTTOM == &new EtchedLineBorder$BorderSide(EtchedLineBorder$BorderSide__static_init#2)
* $VALUES[1] == &new EtchedLineBorder$BorderSide(EtchedLineBorder$BorderSide__static_init#2)
* TOP == &new EtchedLineBorder$BorderSide(EtchedLineBorder$BorderSide__static_init#1)
* $VALUES[0] == &new EtchedLineBorder$BorderSide(EtchedLineBorder$BorderSide__static_init#1)
* new EtchedLineBorder$BorderSide(EtchedLineBorder$BorderSide__static_init#1) num objects == 1
* new EtchedLineBorder$BorderSide(EtchedLineBorder$BorderSide__static_init#2) num objects == 1
* new EtchedLineBorder$BorderSide[](EtchedLineBorder$BorderSide__static_init#3) num objects == 1
* $VALUES.length == 2
*/
50 TOP,
51 /** Creates a border at the bottom. */
52 BOTTOM,
53 };
54
55 /**
56 * Creates a new etched line border.
57 *
58 * @param type Etch type
59 * @param side Border side
60 */
61 public EtchedLineBorder(final int type, final BorderSide side) {
/*
P/P * Method: void com.dmdirc.installer.ui.EtchedLineBorder(int, EtchedLineBorder$BorderSide)
*
* Postconditions:
* this.side == side
* init'ed(this.side)
*/
62 super(type);
63
64 this.side = side;
65 }
66
67 /** {@inheritDoc} */
68 @Override
69 public void paintBorder(final Component c, final Graphics g, final int x,
70 final int y, final int width, final int height) {
/*
P/P * Method: void paintBorder(Component, Graphics, int, int, int, int)
*
* Preconditions:
* g != null
* init'ed(this.etchType)
* this.side != null
* x <= 231
* y <= 231
* (soft) init'ed(com.dmdirc.installer.ui.EtchedLineBorder$1__static_init.new int[](EtchedLineBorder$1__static_init#1)[...])
* (soft) height <= 232-6
* (soft) width <= 232-6
*
* Presumptions:
* com.dmdirc.installer.ui.EtchedLineBorder_BorderSide:ordinal(...)@75 in {0,1}
* com.dmdirc.installer.ui.EtchedLineBorder_BorderSide:ordinal(...)@88 in {0,1}
*
* Test Vectors:
* com.dmdirc.installer.ui.EtchedLineBorder$1__static_init.new int[](EtchedLineBorder$1__static_init#1)[...]: {1}, {2}, {-231..0, 3..232-1}
* this.etchType: {-231..0, 2..232-1}, {1}
*/
71 g.translate(x, y);
72
73 g.setColor(
74 etchType == LOWERED ? getShadowColor(c) : getHighlightColor(c));
/*
P/P * Method: com.dmdirc.installer.ui.EtchedLineBorder$1__static_init
*
* Preconditions:
* (soft) init'ed(com.dmdirc.installer.ui.EtchedLineBorder$BorderSide__static_init.new EtchedLineBorder$BorderSide[](EtchedLineBorder$BorderSide__static_init#3)[...])
*
* Presumptions:
* com.dmdirc.installer.ui.EtchedLineBorder_BorderSide:ordinal(...)@75 in {0,1}
* com.dmdirc.installer.ui.EtchedLineBorder_BorderSide:ordinal(...)@75 - values(...).length in range
*
* Postconditions:
* new int[](EtchedLineBorder$1__static_init#1) num objects == 1
*/
75 switch (side) {
76 case TOP:
77 g.drawLine(-SMALL_GAP, -SMALL_GAP, width + SMALL_GAP, -SMALL_GAP);
78 break;
79 case BOTTOM:
80 g.drawLine(-SMALL_GAP, height + SMALL_GAP, width + SMALL_GAP, height + SMALL_GAP);
81 break;
82 default:
83 break;
84 }
85
86 g.setColor(
87 etchType == LOWERED ? getHighlightColor(c) : getShadowColor(c));
88 switch (side) {
89 case TOP:
90 g.drawLine(-SMALL_GAP, -SMALL_GAP - 1, width + SMALL_GAP, -SMALL_GAP - 1);
91 break;
92 case BOTTOM:
93 g.drawLine(-SMALL_GAP, height + SMALL_GAP - 1, width + SMALL_GAP, height + SMALL_GAP - 1);
94 break;
95 default:
96 break;
97 }
98
99 g.translate(-x, -y);
100 }
101 }
SofCheck Inspector Build Version : 2.17854
| EtchedLineBorder.java |
2009-Jun-25 01:54:24 |
| EtchedLineBorder.class |
2009-Sep-02 17:04:16 |
| EtchedLineBorder$1.class |
2009-Sep-02 17:04:16 |
| EtchedLineBorder$BorderSide.class |
2009-Sep-02 17:04:16 |