Source Code Cross Referenced for DefaultChart.java in  » Chart » charting-0.94 » de » progra » charting » 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 » charting 0.94 » de.progra.charting 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:            JOpenChart Java Charting Library and Toolkit
003:            Copyright (C) 2001  Sebastian Müller
004:            http://jopenchart.sourceforge.net
005:
006:            This library is free software; you can redistribute it and/or
007:            modify it under the terms of the GNU Lesser General Public
008:            License as published by the Free Software Foundation; either
009:            version 2.1 of the License, or (at your option) any later version.
010:
011:            This library is distributed in the hope that it will be useful,
012:            but WITHOUT ANY WARRANTY; without even the implied warranty of
013:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:            Lesser General Public License for more details.
015:
016:            You should have received a copy of the GNU Lesser General Public
017:            License along with this library; if not, write to the Free Software
018:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:
020:            DefaultChart.java
021:            Created on 26. Juni 2001, 22:49
022:         */
023:
024:        package de.progra.charting;
025:
026:        import de.progra.charting.model.ChartDataModel;
027:        import java.util.*;
028:        import de.progra.charting.render.AbstractChartRenderer;
029:        import de.progra.charting.render.RowColorModel;
030:        import java.awt.geom.AffineTransform;
031:        import java.awt.Rectangle;
032:        import java.awt.Graphics2D;
033:        import java.awt.Dimension;
034:        import java.awt.Color;
035:
036:        /** The Default class to create a chart.
037:         * @author mueller
038:         * @version 1.0
039:         */
040:        public class DefaultChart extends AbstractChart {
041:
042:            public static int LINEAR_X_LINEAR_Y = 0;
043:            public static int NO_COORDINATE_SYSTEM = 1;
044:
045:            /** Creates new empty DefaultChart.*/
046:            protected DefaultChart() {
047:            }
048:
049:            /** Creates a new DefaultChart with the given model
050:             * and title string and no coordinate system.
051:             * @param model the ChartDataModel
052:             * @param title the title String
053:             */
054:            public DefaultChart(ChartDataModel model, String title) {
055:                this ();
056:                setChartDataModel(model);
057:                setRowColorModel(new RowColorModel(model));
058:
059:                setLegend(new Legend(getRowColorModel()));
060:                setTitle(new Title(title));
061:            }
062:
063:            /** Creates a new DefaultChart with the given model
064:             * and title string and a coordinate system.
065:             * @param model the ChartDataModel
066:             * @param title the title String
067:             * @param coord the id of the coordinate system configuration
068:             */
069:            public DefaultChart(ChartDataModel model, String title, int coord) {
070:                this (model, title);
071:
072:                if (coord == this .LINEAR_X_LINEAR_Y)
073:                    this .setCoordSystem(new CoordSystem(model));
074:            }
075:
076:            /** Creates a new DefaultChart with the given model
077:             * and title string and a coordinate system.
078:             * @param model the ChartDataModel
079:             * @param title the title String
080:             * @param coord the id of the coordinate system configuration
081:             * @param xaxis the x-axis' unit
082:             * @param yaxis the y-axis' unit
083:             */
084:            public DefaultChart(ChartDataModel model, String title, int coord,
085:                    String xaxis, String yaxis) {
086:                this (model, title, coord);
087:
088:                this .getCoordSystem().setXAxisUnit(xaxis);
089:                this .getCoordSystem().setYAxisUnit(yaxis);
090:            }
091:
092:            /** Should compute the preferred size of the Chart
093:             * @return <CODE>null</CODE>
094:             */
095:            public Dimension getPreferredSize() {
096:                return null;
097:            }
098:
099:            /** Does the layout of the title, legend and coordinate system and
100:             * calls the render method of all those including the ChartRenderers.
101:             * @param g the <CODE>Graphics2D</CODE> object to paint in.
102:             */
103:            public void render(Graphics2D g) {
104:
105:                //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
106:                //                   RenderingHints.VALUE_ANTIALIAS_ON);
107:
108:                int width = (int) getBounds().getWidth();
109:                int height = (int) getBounds().getHeight();
110:
111:                Title t = getTitle();
112:                Legend l = getLegend();
113:                CoordSystem c = getCoordSystem();
114:                Collection renderer = getChartRenderer().values();
115:
116:                g.setColor(Color.white);
117:                g.fillRect(0, 0, width, height);
118:
119:                g.setColor(Color.black);
120:
121:                int titleheight = 0;
122:                int legendwidth = 0;
123:
124:                if (t != null) {
125:                    Dimension title = t.getPreferredSize();
126:                    t.setBounds(new Rectangle((int) (width / 2 - (int) (title
127:                            .getWidth() / 2)), 0, (int) title.getWidth(),
128:                            (int) title.getHeight()));
129:                    t.render(g);
130:                    titleheight = (int) t.getBounds().getHeight();
131:                }
132:                if (l != null) {
133:                    Dimension legend = l.getPreferredSize();
134:                    l
135:                            .setBounds(new Rectangle((int) (width - legend
136:                                    .getWidth()), (int) (height / 2
137:                                    - legend.getHeight() / 2 + titleheight),
138:                                    (int) legend.getWidth(), (int) legend
139:                                            .getHeight()));
140:                    l.render(g);
141:                    legendwidth = (int) l.getBounds().getWidth();
142:                }
143:                if (c != null) {
144:                    c.setBounds(new Rectangle(0, (int) titleheight,
145:                            (int) (width - legendwidth),
146:                            (int) (height - titleheight)));
147:                }
148:                if (!renderer.isEmpty()) {
149:                    Iterator i = renderer.iterator();
150:                    while (i.hasNext()) {
151:                        AbstractChartRenderer cr = (AbstractChartRenderer) i
152:                                .next();
153:                        cr.setBounds(new Rectangle(0, (int) titleheight,
154:                                (int) (width - legendwidth),
155:                                (int) (height - titleheight) - 5));
156:
157:                        // cr.setPointToPixelTranslator()
158:
159:                        cr.render(g);
160:                    }
161:                }
162:                if (c != null)
163:                    c.render(g);
164:
165:                /*
166:                g.setColor(Color.pink);
167:                
168:                g.draw(t.getBounds());
169:                g.draw(l.getBounds());
170:                g.draw(c.getBounds());
171:                g.draw(c.getInnerBounds());
172:                 */
173:                //System.out.println("** Bounds: "+c.getBounds());
174:                //System.out.println("** InnerBounds: "+c.getInnerBounds());
175:            }
176:
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.