01: /*
02: * @(#)VsnetSeparatorUI.java 3/3/2006
03: *
04: * Copyright 2002 - 2006 JIDE Software Inc. All rights reserved.
05: */
06:
07: package com.jidesoft.plaf.vsnet;
08:
09: import com.jidesoft.plaf.UIDefaultsLookup;
10: import com.jidesoft.swing.JideSwingUtilities;
11: import com.jidesoft.utils.SecurityUtils;
12: import com.sun.java.swing.plaf.windows.WindowsSeparatorUI;
13:
14: import javax.swing.*;
15: import javax.swing.plaf.ComponentUI;
16: import java.awt.*;
17:
18: /**
19: * PopupMenuSeparator UI implementation
20: */
21: public class VsnetSeparatorUI extends WindowsSeparatorUI {
22: public static final int HEIGHT = 3;
23:
24: public static ComponentUI createUI(JComponent c) {
25: return new VsnetSeparatorUI();
26: }
27:
28: @Override
29: protected void installDefaults(JSeparator s) {
30: }
31:
32: @Override
33: public void paint(Graphics g, JComponent c) {
34: if (!(c.getParent() instanceof JPopupMenu)) {
35: super .paint(g, c);
36: return;
37: }
38:
39: Dimension s = c.getSize();
40:
41: int defaultShadowWidth = UIDefaultsLookup
42: .getInt("MenuItem.shadowWidth");
43: int defaultTextIconGap = UIDefaultsLookup
44: .getInt("MenuItem.textIconGap");
45: Color shadowColor = UIDefaultsLookup
46: .getColor("MenuItem.shadowColor");
47: Color foreground = UIDefaultsLookup
48: .getColor("PopupMenuSeparator.foreground");
49: Color background = UIDefaultsLookup
50: .getColor("PopupMenuSeparator.background");
51:
52: g.setColor(shadowColor);
53: if (c.getComponentOrientation().isLeftToRight()) {
54: g.fillRect(0, 0, defaultShadowWidth, HEIGHT);
55: if ("true".equals(SecurityUtils.getProperty("shadingtheme",
56: "false"))) {
57: JideSwingUtilities.fillSingleGradient(g, new Rectangle(
58: 0, 0, defaultShadowWidth, HEIGHT),
59: SwingConstants.EAST, 255);
60: }
61:
62: g.setColor(background);
63: g.fillRect(defaultShadowWidth, 0, s.width
64: - defaultShadowWidth, HEIGHT);
65:
66: g.setColor(foreground);
67: g.drawLine(defaultShadowWidth + defaultTextIconGap, 1,
68: s.width, 1);
69: } else {
70: g.fillRect(s.width, 0, defaultShadowWidth, HEIGHT);
71: if ("true".equals(SecurityUtils.getProperty("shadingtheme",
72: "false"))) {
73: JideSwingUtilities.fillSingleGradient(g, new Rectangle(
74: s.width - defaultTextIconGap, 0,
75: defaultShadowWidth, 2), SwingConstants.WEST,
76: 255);
77: }
78:
79: g.setColor(background);
80: g.fillRect(0, 0, s.width - defaultShadowWidth, HEIGHT);
81:
82: g.setColor(foreground);
83: g.drawLine(defaultTextIconGap, 1, s.width
84: - defaultShadowWidth, 1);
85: }
86: }
87:
88: @Override
89: public Dimension getPreferredSize(JComponent c) {
90: return new Dimension(0, HEIGHT);
91: }
92:
93: }
|