01: /*
02: * Copyright (C) 2004 NNL Technology AB
03: * Visit www.infonode.net for information about InfoNode(R)
04: * products and how to contact NNL Technology AB.
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19: * MA 02111-1307, USA.
20: */
21:
22: // $Id: PolygonBorder.java,v 1.8 2005/02/16 11:28:13 jesper Exp $
23: package net.infonode.gui.shaped.border;
24:
25: import net.infonode.gui.colorprovider.ColorProvider;
26:
27: import java.awt.*;
28:
29: /**
30: * @author $Author: jesper $
31: * @version $Revision: 1.8 $
32: */
33: public class PolygonBorder extends AbstractPolygonBorder {
34: private static final long serialVersionUID = 1;
35:
36: private int[] coords;
37: private float[] widthFactors;
38: private float[] heightFactors;
39:
40: public PolygonBorder(ColorProvider lineColor, int[] coords,
41: float[] widthFactors, float[] heightFactors) {
42: super (lineColor);
43: this .coords = coords;
44: this .widthFactors = widthFactors;
45: this .heightFactors = heightFactors;
46: }
47:
48: public PolygonBorder(ColorProvider lineColor,
49: ColorProvider highlightColor, int[] coords,
50: float[] widthFactors, float[] heightFactors) {
51: super (lineColor, highlightColor);
52: this .coords = coords;
53: this .widthFactors = widthFactors;
54: this .heightFactors = heightFactors;
55: }
56:
57: public PolygonBorder(ColorProvider lineColor,
58: ColorProvider highlightColor, ColorProvider middleColor,
59: ColorProvider shadowColor, int[] coords,
60: float[] widthFactors, float[] heightFactors) {
61: super (lineColor, highlightColor, middleColor, shadowColor);
62: this .coords = coords;
63: this .widthFactors = widthFactors;
64: this .heightFactors = heightFactors;
65: }
66:
67: protected Polygon createPolygon(Component c, int width, int height) {
68: int[] xc = new int[coords.length / 2];
69: int[] yc = new int[coords.length / 2];
70: int n = 0;
71:
72: for (int i = 0; i < xc.length; i++) {
73: xc[i] = (int) (widthFactors[n] * width)
74: + (int) (heightFactors[n] * height) + coords[n];//(coords[n] >= 0 ? coords[n] : width + coords[n]);
75: n++;
76: yc[i] = (int) (widthFactors[n] * width)
77: + (int) (heightFactors[n] * height) + coords[n];//(coords[n] >= 0 ? coords[n] : height + coords[n]);
78: n++;
79: }
80:
81: return new Polygon(xc, yc, xc.length);
82: }
83:
84: }
|