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


001:        package jimm.datavision.field;
002:
003:        import jimm.util.XMLWriter;
004:        import java.util.Observable;
005:
006:        /**
007:         * A <i>border edge</i> represents one of the four edges of a {@link Border}.
008:         * It has its own line style, thickness, and number of lines. <p> Note: line
009:         * thickness is currently ignored.
010:         *
011:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
012:         */
013:        public class BorderEdge extends Observable implements  Cloneable {
014:
015:            /** Draw simple lines. This is the default style. */
016:            public static final int STYLE_LINE = 0;
017:            /** Draw dashed lines. */
018:            public static final int STYLE_DASH = 1;
019:            /** Draw dotted lines. */
020:            public static final int STYLE_DOT = 2;
021:
022:            public static final int DEFAULT_STYLE = STYLE_LINE;
023:            public static final int DEFAULT_NUMBER = 1;
024:            public static final double DEFAULT_THICKNESS = 1.0;
025:
026:            protected int style; // none, line, dash, dot
027:            protected double thickness; // in points
028:            protected int number;
029:
030:            /**
031:             * Returns the integer style constant associated with the specified string.
032:             * The string must be <code>null</code>, "none", "line", "dash", or "dot"
033:             * and comes from the XML files that describe reports. If the string is
034:             * <code>null</code>, then we return the default value of STYLE_LINE;
035:             *
036:             * @param styleStr one of <code>null</code>, "none", "line", "dash", or "dot"
037:             * @return one of the <code>STYLE_*</code> constants; <code>STYLE_LINE</code>
038:             * is returned if styleStr is <code>null</code>
039:             */
040:            public static int styleFromString(String styleStr) {
041:                if (styleStr == null || styleStr.length() == 0) // Default
042:                    return DEFAULT_STYLE;
043:
044:                styleStr = styleStr.toLowerCase();
045:                int style = DEFAULT_STYLE;
046:                if (styleStr.equals("line"))
047:                    style = STYLE_LINE;
048:                else if (styleStr.equals("dash"))
049:                    style = STYLE_DASH;
050:                else if (styleStr.equals("dot"))
051:                    style = STYLE_DOT;
052:
053:                return style;
054:            }
055:
056:            /**
057:             * Creates a new edge with <code>DEFAULT_NUMBER</code> lines of
058:             * <code>DEFAULT_STYLE</code> and <code>DEFAULT_THICKNESS</code>.
059:             */
060:            public BorderEdge() {
061:                this (DEFAULT_STYLE, DEFAULT_THICKNESS, DEFAULT_NUMBER);
062:            }
063:
064:            /**
065:             * Creates a new edge with <code>DEFAULT_NUMBER</code> lines of
066:             * the specified style and <code>DEFAULT_THICKNESS</code>.
067:             *
068:             * @param style one of the <code>STYLE_</code> constants
069:             */
070:            public BorderEdge(int style) {
071:                this (style, DEFAULT_THICKNESS, DEFAULT_NUMBER);
072:            }
073:
074:            /**
075:             * Creates a new edge with <code>DEFAULT_NUMBER</code> lines of
076:             * the specified style and thickness.
077:             *
078:             * @param style one of the <code>STYLE_</code> constants
079:             * @param thickness line thickness
080:             */
081:            public BorderEdge(int style, double thickness) {
082:                this (style, thickness, DEFAULT_NUMBER);
083:            }
084:
085:            /**
086:             * Creates a new edge with <var>number</var> lines of the specified style
087:             * and thickness.
088:             *
089:             * @param style one of the <code>STYLE_</code> constants
090:             * @param thickness line thickness
091:             * @param number the number of liens to draw
092:             */
093:            public BorderEdge(int style, double thickness, int number) {
094:                this .style = style;
095:                this .thickness = thickness;
096:                this .number = number;
097:            }
098:
099:            /**
100:             * Returns a clone of this border. All edges are cloned as well.
101:             */
102:            public Object clone() {
103:                BorderEdge be = new BorderEdge(style, thickness, number);
104:                return be;
105:            }
106:
107:            public boolean equals(Object obj) {
108:                if (obj == null || !(obj instanceof  BorderEdge))
109:                    return false;
110:                if (obj == this )
111:                    return true;
112:
113:                BorderEdge be = (BorderEdge) obj;
114:                return number == be.number && thickness == be.thickness
115:                        && style == be.style;
116:            }
117:
118:            public int hashCode() {
119:                return style + number * 10 + (int) (thickness * 1000);
120:            }
121:
122:            /**
123:             * Returns the edge's style.
124:             *
125:             * @return one of the <code>STYLE_</code> constants
126:             */
127:            public int getStyle() {
128:                return style;
129:            }
130:
131:            /**
132:             * Sets the edge's style.
133:             *
134:             * @param newStyle one of the <code>STYLE_</code> constants
135:             */
136:            public void setStyle(int newStyle) {
137:                if (style != newStyle) {
138:                    style = newStyle;
139:                    setChanged();
140:                    notifyObservers();
141:                }
142:            }
143:
144:            /**
145:             * Returns the edge's thickness.
146:             *
147:             * @return the thickness
148:             */
149:            public double getThickness() {
150:                return thickness;
151:            }
152:
153:            /**
154:             * Sets the edge's thickness.
155:             *
156:             * @param newThickness line thickness
157:             */
158:            public void setThickness(double newThickness) {
159:                if (thickness != newThickness) {
160:                    thickness = newThickness;
161:                    setChanged();
162:                    notifyObservers();
163:                }
164:            }
165:
166:            /**
167:             * Returns the number of lines to draw along this border edge.
168:             *
169:             * @return the number of lines to draw along this border edge
170:             */
171:            public int getNumber() {
172:                return number;
173:            }
174:
175:            /**
176:             * Sets the number of lines to draw along this border edge.
177:             *
178:             * @param newNumber the number of lines to draw
179:             */
180:            public void setNumber(int newNumber) {
181:                if (number != newNumber) {
182:                    number = newNumber;
183:                    setChanged();
184:                    notifyObservers();
185:                }
186:            }
187:
188:            /**
189:             * Writes this edge as an XML tag.
190:             *
191:             * @param out a writer that knows how to write XML
192:             * @param location from the border; the string "top", "bottom", "left", or
193:             * "right"
194:             */
195:            public void writeXML(XMLWriter out, String location) {
196:                String styleStr = null;
197:                if (style != DEFAULT_STYLE) {
198:                    switch (style) {
199:                    case STYLE_LINE:
200:                        styleStr = "line";
201:                        break;
202:                    case STYLE_DASH:
203:                        styleStr = "dash";
204:                        break;
205:                    case STYLE_DOT:
206:                        styleStr = "dot";
207:                        break;
208:                    }
209:                }
210:
211:                out.startElement("edge");
212:                out.attr("location", location);
213:                if (number != DEFAULT_NUMBER)
214:                    out.attr("number", number);
215:                if (thickness != DEFAULT_THICKNESS)
216:                    out.attr("thickness", thickness);
217:                if (styleStr != null)
218:                    out.attr("style", styleStr);
219:                out.endElement();
220:            }
221:
222:            public String toString() {
223:                return "BorderEdge[style=" + style + ", thickness=" + thickness
224:                        + ", number=" + number + "]";
225:            }
226:
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.