01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /**
19: * @author Sergey Burlak
20: * @version $Revision$
21: */package javax.swing.plaf.metal;
22:
23: import java.awt.Graphics;
24:
25: import javax.swing.JComponent;
26: import javax.swing.JSplitPane;
27: import javax.swing.plaf.ComponentUI;
28: import javax.swing.plaf.basic.BasicSplitPaneDivider;
29: import javax.swing.plaf.basic.BasicSplitPaneUI;
30:
31: public class MetalSplitPaneUI extends BasicSplitPaneUI {
32: public static ComponentUI createUI(final JComponent c) {
33: return new MetalSplitPaneUI();
34: }
35:
36: public BasicSplitPaneDivider createDefaultDivider() {
37: return new MetalSplitPaneDivider(this );
38: }
39:
40: private class MetalSplitPaneDivider extends BasicSplitPaneDivider {
41: public MetalSplitPaneDivider(final BasicSplitPaneUI ui) {
42: super (ui);
43: }
44:
45: public boolean isOpaque() {
46: return true;
47: }
48:
49: public void paint(final Graphics g) {
50: g.setColor(getForeground());
51: g.fillRect(0, 0, getWidth(), getHeight());
52: super .paint(g);
53:
54: if (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
55: int leftButtonHeight = leftButton == null ? 0
56: : leftButton.getHeight();
57: int rightButtonHeight = rightButton == null ? 0
58: : rightButton.getHeight();
59: final int buttonsSize = leftButtonHeight
60: + rightButtonHeight + 6;
61: MetalBumps.paintBumps(g, 1, buttonsSize + 4,
62: getWidth() - 3, getHeight() - buttonsSize - 8,
63: getForeground().darker(), getForeground()
64: .brighter());
65: } else {
66: int leftButtonWidth = leftButton == null ? 0
67: : leftButton.getWidth();
68: int rightButtonWidth = rightButton == null ? 0
69: : rightButton.getWidth();
70: final int buttonsSize = leftButtonWidth
71: + rightButtonWidth + 6;
72: MetalBumps.paintBumps(g, buttonsSize + 4, 1, getWidth()
73: - 8 - buttonsSize, getHeight() - 3,
74: getForeground().darker(), getForeground()
75: .brighter());
76: }
77: }
78: }
79: }
|