Source Code Cross Referenced for Line.java in  » Report » datavision-1.1.0 » jimm » datavision » 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 » Report » datavision 1.1.0 » jimm.datavision 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jimm.datavision;
002:
003:        import jimm.util.XMLWriter;
004:        import java.awt.Color;
005:
006:        /**
007:         * A line is a visual report element. Lines are used in field {@link
008:         * jimm.datavision.field.Border}s and independently.
009:         * <p>
010:         * Note that currently, line thickness is ignored in the Java GUI (but not
011:         * in layout engines such as the LaTeXLE).
012:         *
013:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
014:         */
015:        public class Line extends Element {
016:
017:            protected static final Color DEFAULT_COLOR = Color.black;
018:
019:            protected double thickness;
020:            protected Point[] points;
021:            protected Color color;
022:
023:            /**
024:             * Constructor.
025:             *
026:             * @param report the report containing this line
027:             * @param section the section containing this line
028:             * @param thickness the line thickness
029:             * @param color may be <code>null</code>
030:             * @param visible show/hide flag
031:             */
032:            public Line(Report report, Section section, double thickness,
033:                    Color color, boolean visible) {
034:                this (report, section, thickness, color, visible, null, null);
035:            }
036:
037:            /**
038:             * Constructor.
039:             *
040:             * @param report the report containing this line
041:             * @param section the section containing this line
042:             * @param thickness the line thickness
043:             * @param color may be <code>null</code>
044:             * @param visible show/hide flag
045:             * @param p0 one end point of the line
046:             * @param p1 the other end point of the line
047:             */
048:            public Line(Report report, Section section, double thickness,
049:                    Color color, boolean visible, Point p0, Point p1) {
050:                super (report, section, visible);
051:                this .thickness = thickness;
052:                points = new Point[2];
053:                points[0] = p0;
054:                points[1] = p1;
055:                this .color = color == null ? DEFAULT_COLOR : color;
056:            }
057:
058:            /**
059:             * Adds an end point to the line. Used when constructing a line from XML,
060:             * where we don't see the point until after creating this line.
061:             *
062:             * @param x the x coordinate
063:             * @param y the y coordinate
064:             */
065:            public void addEndPoint(double x, double y) {
066:                Point p = new Point(x, y);
067:                if (points[0] == null)
068:                    points[0] = p;
069:                else
070:                    points[1] = p;
071:                p.addObserver(this );
072:            }
073:
074:            /**
075:             * Returns the line thickness.
076:             *
077:             * @return the line thickness
078:             */
079:            public double getThickness() {
080:                return thickness;
081:            }
082:
083:            /**
084:             * Sets the line thickness.
085:             *
086:             * @param newThickness the new line thickness
087:             */
088:            public void setThickness(double newThickness) {
089:                if (thickness != newThickness) {
090:                    thickness = newThickness;
091:                    setChanged();
092:                    notifyObservers();
093:                }
094:            }
095:
096:            /**
097:             * Returns one of the two end points of the line.
098:             *
099:             * @param index either 0 or 1
100:             * @return a point
101:             */
102:            public Point getPoint(int index) {
103:                return points[index];
104:            }
105:
106:            /**
107:             * Sets one of the two end points.
108:             *
109:             * @param newPoint a point
110:             * @param index either 0 or 1
111:             */
112:            public void setPoint(Point newPoint, int index) {
113:                if (points[index] != newPoint) {
114:                    if (points[index] != null)
115:                        points[index].deleteObserver(this );
116:                    points[index] = newPoint;
117:                    if (points[index] != null)
118:                        points[index].addObserver(this );
119:                    setChanged();
120:                    notifyObservers();
121:                }
122:            }
123:
124:            /**
125:             * Returns the length of the line.
126:             *
127:             * @return the distance between the two end points
128:             */
129:            public double length() {
130:                return points[0].distanceTo(points[1]);
131:            }
132:
133:            /**
134:             * Returns a string representation of this line.
135:             *
136:             * @return a string representing this line
137:             */
138:            public String toString() {
139:                return "(" + points[0] + ", " + points[1] + ")";
140:            }
141:
142:            /**
143:             * Returns the line's color. The return value will never be
144:             * <code>null</code>.
145:             *
146:             * @return the line's color
147:             */
148:            public Color getColor() {
149:                return color == null ? DEFAULT_COLOR : color;
150:            }
151:
152:            /**
153:             * Sets the line's color. If <var>c</var> is <code>null</code>, then the
154:             * color is set to <code>DEFAULT_COLOR</code>.
155:             *
156:             * @param c new line color; if <code>null</code>, color is set to
157:             * <code>DEFAULT_COLOR</code>
158:             */
159:            public void setColor(Color c) {
160:                color = c == null ? DEFAULT_COLOR : c;
161:            }
162:
163:            /**
164:             * Writes this line as an XML tag.
165:             *
166:             * @param out a writer that knows how to write XML
167:             */
168:            public void writeXML(XMLWriter out) {
169:                out.startElement("line");
170:                out.attr("thickness", thickness);
171:                if (color != null && !color.equals(DEFAULT_COLOR))
172:                    out.attr("color", color);
173:                if (!visible)
174:                    out.attr("visible", visible);
175:                points[0].writeXML(out);
176:                points[1].writeXML(out);
177:                out.endElement();
178:            }
179:
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.