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