01: /*
02: * @(#)Office2003SeparatorUI.java 3/3/2006
03: *
04: * Copyright 2002 - 2006 JIDE Software Inc. All rights reserved.
05: */
06:
07: package com.jidesoft.plaf.office2003;
08:
09: import com.jidesoft.plaf.UIDefaultsLookup;
10: import com.jidesoft.plaf.basic.ThemePainter;
11: import com.jidesoft.plaf.vsnet.VsnetSeparatorUI;
12:
13: import javax.swing.*;
14: import javax.swing.plaf.ComponentUI;
15: import java.awt.*;
16:
17: /**
18: * Separator UI implementation.
19: */
20: public class Office2003SeparatorUI extends VsnetSeparatorUI {
21: public static ComponentUI createUI(JComponent c) {
22: return new Office2003SeparatorUI();
23: }
24:
25: private ThemePainter _painter;
26:
27: @Override
28: protected void installDefaults(JSeparator s) {
29: _painter = (ThemePainter) UIDefaultsLookup.get("Theme.painter");
30: super .installDefaults(s);
31: }
32:
33: @Override
34: protected void uninstallDefaults(JSeparator s) {
35: _painter = null;
36: super .uninstallDefaults(s);
37: }
38:
39: @Override
40: public void paint(Graphics g, JComponent c) {
41: if (!(c.getParent() instanceof JPopupMenu)) {
42: super .paint(g, c);
43: return;
44: }
45:
46: Dimension s = c.getSize();
47:
48: int defaultShadowWidth = UIDefaultsLookup
49: .getInt("MenuItem.shadowWidth");
50: int defaultTextIconGap = UIDefaultsLookup
51: .getInt("MenuItem.textIconGap");
52:
53: if (c.getComponentOrientation().isLeftToRight()) {
54: _painter.paintMenuShadow(c, g, new Rectangle(0, 0,
55: defaultShadowWidth, HEIGHT),
56: SwingConstants.HORIZONTAL,
57: ThemePainter.STATE_DEFAULT);
58:
59: g.setColor(_painter.getMenuItemBackground());
60: g.fillRect(defaultShadowWidth, 0, s.width
61: - defaultShadowWidth, HEIGHT);
62:
63: g.setColor(_painter.getSeparatorForeground());
64: g.drawLine(defaultShadowWidth + defaultTextIconGap, 1,
65: s.width, 1);
66: } else {
67: g.fillRect(s.width, 0, defaultShadowWidth, HEIGHT);
68:
69: g.setColor(_painter.getMenuItemBackground());
70: g.fillRect(0, 0, s.width - defaultShadowWidth, HEIGHT);
71:
72: g.setColor(_painter.getSeparatorForeground());
73: g.drawLine(defaultTextIconGap, 1, s.width
74: - defaultShadowWidth, 1);
75: }
76: }
77:
78: @Override
79: public Dimension getPreferredSize(JComponent c) {
80: return new Dimension(0, HEIGHT);
81: }
82:
83: }
|