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 Vadim Bogdanov
20: * @version $Revision$
21: */package javax.swing.plaf.metal;
22:
23: import java.awt.Color;
24: import java.awt.Graphics;
25: import java.awt.Rectangle;
26: import java.awt.Shape;
27:
28: final class MetalBumps {
29: public static void paintBumps(final Graphics g,
30: final Rectangle bounds, final Color highlight,
31: final Color shadow) {
32: paintBumps(g, bounds.x, bounds.y, bounds.width, bounds.height,
33: highlight, shadow);
34: }
35:
36: public static void paintBumps(final Graphics g, final int x,
37: final int y, final int w, final int h,
38: final Color highlight, final Color shadow) {
39: if (w <= 0 || h <= 0) {
40: return;
41: }
42:
43: Shape oldClip = g.getClip();
44: g.clipRect(x, y, w, h);
45: g.translate(x, y);
46: Color oldColor = g.getColor();
47:
48: paintLines(g, 0, w, h, highlight);
49: paintLines(g, 2, w, h, shadow);
50:
51: g.setColor(oldColor);
52: g.translate(-x, -y);
53: g.setClip(oldClip);
54: }
55:
56: private static void paintLines(final Graphics g, final int offset,
57: final int w, final int h, final Color color) {
58: g.setColor(color);
59: for (int i = offset; i <= h + w; i += 7) {
60: g.drawLine(0, i, w, i - w);
61: }
62: }
63: }
|