Source Code Cross Referenced for CategoryAxis3D.java in  » Chart » jfreechart » org » jfree » chart » axis » 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 » Chart » jfreechart » org.jfree.chart.axis 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ===========================================================
002:         * JFreeChart : a free chart library for the Java(tm) platform
003:         * ===========================================================
004:         *
005:         * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors.
006:         *
007:         * Project Info:  http://www.jfree.org/jfreechart/index.html
008:         *
009:         * This library is free software; you can redistribute it and/or modify it 
010:         * under the terms of the GNU Lesser General Public License as published by 
011:         * the Free Software Foundation; either version 2.1 of the License, or 
012:         * (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but 
015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017:         * License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022:         * USA.  
023:         *
024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025:         * in the United States and other countries.]
026:         *
027:         * -------------------
028:         * CategoryAxis3D.java
029:         * -------------------
030:         * (C) Copyright 2003-2006, by Klaus Rheinwald and Contributors.
031:         *
032:         * Original Author:  Klaus Rheinwald;
033:         * Contributor(s):   Tin Luu,
034:         *                   David Gilbert (for Object Refinery Limited);
035:         *                   Adriaan Joubert;
036:         *
037:         * Changes
038:         * -------
039:         * 19-Feb-2003 : File creation;
040:         * 21-Mar-2003 : Added to JFreeChart CVS, see bug id 685501 for code 
041:         *               contribution from KR (DG);
042:         * 26-Mar-2003 : Implemented Serializable (DG);
043:         * 13-May-2003 : Renamed HorizontalCategoryAxis3D --> CategoryAxis3D, and 
044:         *               modified to take into account the plot orientation (DG);
045:         * 14-Aug-2003 : Implemented Cloneable (DG);
046:         * 21-Aug-2003 : Fixed draw() method bugs (DG);
047:         * 22-Mar-2004 : Added workaround for bug 920959 (null pointer exception with 
048:         *               no renderer) (DG);
049:         * ------------- JFREECHART 1.0.x ---------------------------------------------
050:         * 18-Aug-2006 : Fix for bug drawing category labels, thanks to Adriaan
051:         *               Joubert (1277726) (DG);
052:         *
053:         */
054:
055:        package org.jfree.chart.axis;
056:
057:        import java.awt.Graphics2D;
058:        import java.awt.geom.Rectangle2D;
059:        import java.io.Serializable;
060:
061:        import org.jfree.chart.Effect3D;
062:        import org.jfree.chart.plot.CategoryPlot;
063:        import org.jfree.chart.plot.PlotRenderingInfo;
064:        import org.jfree.chart.renderer.category.CategoryItemRenderer;
065:        import org.jfree.ui.RectangleEdge;
066:
067:        /**
068:         * An axis that displays categories and has a 3D effect.
069:         * Used for bar charts and line charts.
070:         */
071:        public class CategoryAxis3D extends CategoryAxis implements  Cloneable,
072:                Serializable {
073:
074:            /** For serialization. */
075:            private static final long serialVersionUID = 4114732251353700972L;
076:
077:            /**
078:             * Creates a new axis.
079:             */
080:            public CategoryAxis3D() {
081:                this (null);
082:            }
083:
084:            /**
085:             * Creates a new axis using default attribute values.
086:             *
087:             * @param label  the axis label (<code>null</code> permitted).
088:             */
089:            public CategoryAxis3D(String label) {
090:                super (label);
091:            }
092:
093:            /**
094:             * Draws the axis on a Java 2D graphics device (such as the screen or a 
095:             * printer).
096:             *
097:             * @param g2  the graphics device (<code>null</code> not permitted).
098:             * @param cursor  the cursor location.
099:             * @param plotArea  the area within which the axis should be drawn 
100:             *                  (<code>null</code> not permitted).
101:             * @param dataArea  the area within which the plot is being drawn 
102:             *                  (<code>null</code> not permitted).
103:             * @param edge  the location of the axis (<code>null</code> not permitted).
104:             * @param plotState  collects information about the plot (<code>null</code>
105:             *                   permitted).
106:             * 
107:             * @return The axis state (never <code>null</code>).
108:             */
109:            public AxisState draw(Graphics2D g2, double cursor,
110:                    Rectangle2D plotArea, Rectangle2D dataArea,
111:                    RectangleEdge edge, PlotRenderingInfo plotState) {
112:
113:                // if the axis is not visible, don't draw it...
114:                if (!isVisible()) {
115:                    return new AxisState(cursor);
116:                }
117:
118:                // calculate the adjusted data area taking into account the 3D effect...
119:                // this assumes that there is a 3D renderer, all this 3D effect is a 
120:                // bit of an ugly hack...
121:                CategoryPlot plot = (CategoryPlot) getPlot();
122:
123:                Rectangle2D adjustedDataArea = new Rectangle2D.Double();
124:                if (plot.getRenderer() instanceof  Effect3D) {
125:                    Effect3D e3D = (Effect3D) plot.getRenderer();
126:                    double adjustedX = dataArea.getMinX();
127:                    double adjustedY = dataArea.getMinY();
128:                    double adjustedW = dataArea.getWidth() - e3D.getXOffset();
129:                    double adjustedH = dataArea.getHeight() - e3D.getYOffset();
130:
131:                    if (edge == RectangleEdge.LEFT
132:                            || edge == RectangleEdge.BOTTOM) {
133:                        adjustedY += e3D.getYOffset();
134:                    } else if (edge == RectangleEdge.RIGHT
135:                            || edge == RectangleEdge.TOP) {
136:                        adjustedX += e3D.getXOffset();
137:                    }
138:                    adjustedDataArea.setRect(adjustedX, adjustedY, adjustedW,
139:                            adjustedH);
140:                } else {
141:                    adjustedDataArea.setRect(dataArea);
142:                }
143:
144:                // draw the category labels and axis label
145:                AxisState state = new AxisState(cursor);
146:                state = drawCategoryLabels(g2, plotArea, adjustedDataArea,
147:                        edge, state, plotState);
148:                state = drawLabel(getLabel(), g2, plotArea, dataArea, edge,
149:                        state);
150:
151:                return state;
152:
153:            }
154:
155:            /**
156:             * Returns the Java 2D coordinate for a category.
157:             * 
158:             * @param anchor  the anchor point.
159:             * @param category  the category index.
160:             * @param categoryCount  the category count.
161:             * @param area  the data area.
162:             * @param edge  the location of the axis.
163:             * 
164:             * @return The coordinate.
165:             */
166:            public double getCategoryJava2DCoordinate(CategoryAnchor anchor,
167:                    int category, int categoryCount, Rectangle2D area,
168:                    RectangleEdge edge) {
169:
170:                double result = 0.0;
171:                Rectangle2D adjustedArea = area;
172:                CategoryPlot plot = (CategoryPlot) getPlot();
173:                CategoryItemRenderer renderer = plot.getRenderer();
174:                if (renderer instanceof  Effect3D) {
175:                    Effect3D e3D = (Effect3D) renderer;
176:                    double adjustedX = area.getMinX();
177:                    double adjustedY = area.getMinY();
178:                    double adjustedW = area.getWidth() - e3D.getXOffset();
179:                    double adjustedH = area.getHeight() - e3D.getYOffset();
180:
181:                    if (edge == RectangleEdge.LEFT
182:                            || edge == RectangleEdge.BOTTOM) {
183:                        adjustedY += e3D.getYOffset();
184:                    } else if (edge == RectangleEdge.RIGHT
185:                            || edge == RectangleEdge.TOP) {
186:                        adjustedX += e3D.getXOffset();
187:                    }
188:                    adjustedArea = new Rectangle2D.Double(adjustedX, adjustedY,
189:                            adjustedW, adjustedH);
190:                }
191:
192:                if (anchor == CategoryAnchor.START) {
193:                    result = getCategoryStart(category, categoryCount,
194:                            adjustedArea, edge);
195:                } else if (anchor == CategoryAnchor.MIDDLE) {
196:                    result = getCategoryMiddle(category, categoryCount,
197:                            adjustedArea, edge);
198:                } else if (anchor == CategoryAnchor.END) {
199:                    result = getCategoryEnd(category, categoryCount,
200:                            adjustedArea, edge);
201:                }
202:                return result;
203:
204:            }
205:
206:            /**
207:             * Returns a clone of the axis.
208:             * 
209:             * @return A clone.
210:             * 
211:             * @throws CloneNotSupportedException If the axis is not cloneable for 
212:             *         some reason.
213:             */
214:            public Object clone() throws CloneNotSupportedException {
215:                return super.clone();
216:            }
217:
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.