001: /*---------------- FILE HEADER ------------------------------------------
002:
003: This file is part of deegree.
004: Copyright (C) 2001 by:
005: EXSE, Department of Geography, University of Bonn
006: http://www.giub.uni-bonn.de/exse/
007: lat/lon Fitzke/Fretter/Poth GbR
008: http://www.lat-lon.de
009:
010: This library is free software; you can redistribute it and/or
011: modify it under the terms of the GNU Lesser General Public
012: License as published by the Free Software Foundation; either
013: version 2.1 of the License, or (at your option) any later version.
014:
015: This library is distributed in the hope that it will be useful,
016: but WITHOUT ANY WARRANTY; without even the implied warranty of
017: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
018: Lesser General Public License for more details.
019:
020: You should have received a copy of the GNU Lesser General Public
021: License along with this library; if not, write to the Free Software
022: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
023:
024: Contact:
025:
026: Andreas Poth
027: lat/lon Fitzke/Fretter/Poth GbR
028: Meckenheimer Allee 176
029: 53115 Bonn
030: Germany
031: E-Mail: poth@lat-lon.de
032:
033: Jens Fitzke
034: Department of Geography
035: University of Bonn
036: Meckenheimer Allee 166
037: 53115 Bonn
038: Germany
039: E-Mail: jens.fitzke@uni-bonn.de
040:
041:
042: ---------------------------------------------------------------------------*/
043:
044: package de.latlon.deejump.plugin.style;
045:
046: import java.awt.Graphics2D;
047: import java.awt.Polygon;
048: import java.awt.Shape;
049: import java.awt.geom.Point2D;
050:
051: import com.vividsolutions.jump.workbench.ui.renderer.style.VertexStyle;
052:
053: /**
054: * ...
055: *
056: * @author <a href="mailto:taddei@lat-lon.de">Ugo Taddei</a>
057: *
058: */
059: public class StarVertexStyle extends VertexStyle {
060:
061: public StarVertexStyle() {
062: super (createDefaultTriangle());
063: }
064:
065: public void paint(Graphics2D g, Point2D p) {
066: int s = getSize();
067: int x0 = (int) p.getX();
068: int y0 = (int) p.getY();
069: double sin36 = Math.sin(Math.toRadians(36));
070: double cos36 = Math.cos(Math.toRadians(36));
071: double sin18 = Math.sin(Math.toRadians(18));
072: double cos18 = Math.cos(Math.toRadians(18));
073: int smallRadius = (int) (s * sin18 / Math.sin(Math
074: .toRadians(54)));
075:
076: int p0X = x0;
077: int p0Y = y0 - s;
078: int p1X = x0 + (int) (smallRadius * sin36);
079: int p1Y = y0 - (int) (smallRadius * cos36);
080: int p2X = x0 + (int) (s * cos18);
081: int p2Y = y0 - (int) (s * sin18);
082: int p3X = x0 + (int) (smallRadius * cos18);
083: int p3Y = y0 + (int) (smallRadius * sin18);
084: int p4X = x0 + (int) (s * sin36);
085: int p4Y = y0 + (int) (s * cos36);
086: int p5Y = y0 + smallRadius;
087: int p6X = x0 - (int) (s * sin36);
088: int p7X = x0 - (int) (smallRadius * cos18);
089: int p8X = x0 - (int) (s * cos18);
090: int p9X = x0 - (int) (smallRadius * sin36);
091:
092: ((Polygon) this .shape).xpoints = new int[] { p0X, p1X, p2X,
093: p3X, p4X, p0X, p6X, p7X, p8X, p9X };
094:
095: ((Polygon) this .shape).ypoints = new int[] { p0Y, p1Y, p2Y,
096: p3Y, p4Y, p5Y, p4Y, p3Y, p2Y, p1Y };
097:
098: ((Polygon) this .shape).npoints = ((Polygon) this .shape).xpoints.length;
099:
100: render(g);
101: }
102:
103: private static Shape createDefaultTriangle() {
104: return new Polygon();
105: }
106:
107: }
|