Source Code Cross Referenced for ArrowLineStringEndpointStyle.java in  » GIS » openjump » com » vividsolutions » jump » workbench » ui » renderer » style » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » openjump » com.vividsolutions.jump.workbench.ui.renderer.style 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
003:         * for visualizing and manipulating spatial features with geometry and attributes.
004:         *
005:         * Copyright (C) 2003 Vivid Solutions
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or (at your option) any later version.
011:         * 
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         * 
021:         * For more information, contact:
022:         *
023:         * Vivid Solutions
024:         * Suite #1A
025:         * 2328 Government Street
026:         * Victoria BC  V8T 5G5
027:         * Canada
028:         *
029:         * (250)385-6040
030:         * www.vividsolutions.com
031:         */
032:
033:        package com.vividsolutions.jump.workbench.ui.renderer.style;
034:
035:        import java.awt.BasicStroke;
036:        import java.awt.Graphics2D;
037:        import java.awt.geom.AffineTransform;
038:        import java.awt.geom.GeneralPath;
039:        import java.awt.geom.NoninvertibleTransformException;
040:        import java.awt.geom.Point2D;
041:
042:        import com.vividsolutions.jump.I18N;
043:        import com.vividsolutions.jump.workbench.model.Layer;
044:        import com.vividsolutions.jump.workbench.ui.GUIUtil;
045:        import com.vividsolutions.jump.workbench.ui.Viewport;
046:        import com.vividsolutions.jump.workbench.ui.images.IconLoader;
047:
048:        public class ArrowLineStringEndpointStyle extends
049:                LineStringEndpointStyle {
050:            private final static double SMALL_ANGLE = 10;
051:            private final static double MEDIUM_ANGLE = 30;
052:
053:            private final static double MEDIUM_LENGTH = 10;
054:            private final static double LARGE_LENGTH = 15;
055:            private boolean filled;
056:            private double finAngle;
057:            protected double finLength;
058:
059:            /**
060:             * @param finAngle degrees
061:             * @param finLength pixels
062:             */
063:            public ArrowLineStringEndpointStyle(String name, boolean start,
064:                    String iconFile, double finAngle, double finLength,
065:                    boolean filled) {
066:                super (name, IconLoader.icon(iconFile), start);
067:                this .finAngle = finAngle;
068:                this .finLength = finLength;
069:                this .filled = filled;
070:            }
071:
072:            protected void paint(Point2D terminal, Point2D next,
073:                    Viewport viewport, Graphics2D graphics)
074:                    throws NoninvertibleTransformException {
075:                if (terminal.equals(next)) {
076:                    return;
077:                }
078:
079:                graphics.setColor(lineColorWithAlpha);
080:                graphics.setStroke(stroke);
081:
082:                GeneralPath arrowhead = arrowhead(terminal, next, finLength,
083:                        finAngle);
084:
085:                if (filled) {
086:                    arrowhead.closePath();
087:                    graphics.fill(arrowhead);
088:                }
089:
090:                //#fill isn't affected by line width, but #draw is. Therefore, draw even
091:                //if we've already filled. [Jon Aquino]
092:                graphics.draw(arrowhead);
093:            }
094:
095:            /**
096:             * @param tail the tail of the whole arrow; just used to determine angle
097:             * @param finLength required distance from the tip to each fin's tip
098:             */
099:            private GeneralPath arrowhead(Point2D shaftTip, Point2D shaftTail,
100:                    double finLength, double finAngle) {
101:                GeneralPath arrowhead = new GeneralPath();
102:                Point2D finTip1 = fin(shaftTip, shaftTail, finLength, finAngle);
103:                Point2D finTip2 = fin(shaftTip, shaftTail, finLength, -finAngle);
104:                arrowhead
105:                        .moveTo((float) finTip1.getX(), (float) finTip1.getY());
106:                arrowhead.lineTo((float) shaftTip.getX(), (float) shaftTip
107:                        .getY());
108:                arrowhead
109:                        .lineTo((float) finTip2.getX(), (float) finTip2.getY());
110:
111:                return arrowhead;
112:            }
113:
114:            private Point2D fin(Point2D shaftTip, Point2D shaftTail,
115:                    double length, double angle) {
116:                double shaftLength = shaftTip.distance(shaftTail);
117:                Point2D finTail = shaftTip;
118:                Point2D finTip = GUIUtil.add(GUIUtil.multiply(GUIUtil.subtract(
119:                        shaftTail, shaftTip), length / shaftLength), finTail);
120:                AffineTransform affineTransform = new AffineTransform();
121:                affineTransform.rotate((angle * Math.PI) / 180, finTail.getX(),
122:                        finTail.getY());
123:
124:                return affineTransform.transform(finTip, null);
125:            }
126:
127:            public abstract static class Feathers extends
128:                    ArrowLineStringEndpointStyle {
129:                private final static int SPACING = 5;
130:                private final static int FEATHERS = 2;
131:
132:                public Feathers(String name, boolean start, String iconFile) {
133:                    super (name, start, iconFile, MEDIUM_ANGLE, MEDIUM_LENGTH,
134:                            false);
135:                }
136:
137:                protected void paint(Point2D terminal, Point2D next,
138:                        Viewport viewport, Graphics2D graphics)
139:                        throws NoninvertibleTransformException {
140:                    for (int i = 0; i < FEATHERS; i++) {
141:                        Point2D unit = GUIUtil.multiply(GUIUtil.subtract(next,
142:                                terminal), 1d / next.distance(terminal));
143:                        Point2D pseudoTerminal = GUIUtil.add(terminal, GUIUtil
144:                                .multiply(unit, (finLength + (i * SPACING))));
145:                        super .paint(pseudoTerminal, terminal, viewport,
146:                                graphics);
147:                    }
148:                }
149:
150:                public void initialize(Layer layer) {
151:                    super .initialize(layer);
152:
153:                    //Force line width to 1; anything thicker looks ugly (feathers will run
154:                    //into each other). [Jon Aquino]
155:                    stroke = new BasicStroke(1, BasicStroke.CAP_ROUND,
156:                            BasicStroke.JOIN_ROUND);
157:                }
158:            }
159:
160:            public static class FeathersStart extends Feathers {
161:                public FeathersStart() {
162:                    super (
163:                            I18N
164:                                    .get("ui.renderer.style.ArrowLineStringEndpointStyle.start-feathers"),
165:                            true, "FeathersStart.gif");
166:                }
167:            }
168:
169:            public static class FeathersEnd extends Feathers {
170:                public FeathersEnd() {
171:                    super (
172:                            I18N
173:                                    .get("ui.renderer.style.ArrowLineStringEndpointStyle.end-feathers"),
174:                            false, "FeathersEnd.gif");
175:                }
176:            }
177:
178:            public static class OpenStart extends ArrowLineStringEndpointStyle {
179:                public OpenStart() {
180:                    super (
181:                            I18N
182:                                    .get("ui.renderer.style.ArrowLineStringEndpointStyle.start-arrow-open"),
183:                            true, "ArrowStartOpen.gif", MEDIUM_ANGLE,
184:                            MEDIUM_LENGTH, false);
185:                }
186:            }
187:
188:            public static class OpenEnd extends ArrowLineStringEndpointStyle {
189:                public OpenEnd() {
190:                    super (
191:                            I18N
192:                                    .get("ui.renderer.style.ArrowLineStringEndpointStyle.end-arrow-open"),
193:                            false, "ArrowEndOpen.gif", MEDIUM_ANGLE,
194:                            MEDIUM_LENGTH, false);
195:                }
196:            }
197:
198:            public static class SolidStart extends ArrowLineStringEndpointStyle {
199:                public SolidStart() {
200:                    super (
201:                            I18N
202:                                    .get("ui.renderer.style.ArrowLineStringEndpointStyle.start-arrow-solid"),
203:                            true, "ArrowStartSolid.gif", MEDIUM_ANGLE,
204:                            MEDIUM_LENGTH, true);
205:                }
206:            }
207:
208:            public static class SolidEnd extends ArrowLineStringEndpointStyle {
209:                public SolidEnd() {
210:                    super (
211:                            I18N
212:                                    .get("ui.renderer.style.ArrowLineStringEndpointStyle.end-arrow-solid"),
213:                            false, "ArrowEndSolid.gif", MEDIUM_ANGLE,
214:                            MEDIUM_LENGTH, true);
215:                }
216:            }
217:
218:            public static class NarrowSolidStart extends
219:                    ArrowLineStringEndpointStyle {
220:                public NarrowSolidStart() {
221:                    super (
222:                            I18N
223:                                    .get("ui.renderer.style.ArrowLineStringEndpointStyle.start-arrow-solid-narrow"),
224:                            true, "ArrowStartSolidNarrow.gif", SMALL_ANGLE,
225:                            LARGE_LENGTH, true);
226:                }
227:            }
228:
229:            public static class NarrowSolidEnd extends
230:                    ArrowLineStringEndpointStyle {
231:                public NarrowSolidEnd() {
232:                    super (
233:                            I18N
234:                                    .get("ui.renderer.style.ArrowLineStringEndpointStyle.end-arrow-solid-narrow"),
235:                            false, "ArrowEndSolidNarrow.gif", SMALL_ANGLE,
236:                            LARGE_LENGTH, true);
237:                }
238:            }
239:        }
w___ww_.___j_a___v__a2___s___._c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.