Source Code Cross Referenced for InterpolationChartRenderer.java in  » Chart » charting-0.94 » de » progra » charting » render » 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.render 
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:            InterpolationRenderer.java
021:            Created on 24. September 2001, 12:50
022:         */
023:
024:        package de.progra.charting.render;
025:
026:        import java.awt.geom.Line2D;
027:        import java.awt.geom.Point2D;
028:        import java.awt.geom.Area;
029:        import de.progra.charting.CoordSystem;
030:        import java.awt.geom.AffineTransform;
031:        import de.progra.charting.PointToPixelTranslator;
032:        import de.progra.charting.ChartUtilities;
033:        import java.awt.Graphics2D;
034:        import java.awt.Color;
035:        import de.progra.charting.model.ChartDataModel;
036:
037:        /**
038:         * This renderer creates a InterpolationChart.
039:         * @author  mueller
040:         * @version 1.0
041:         */
042:        public class InterpolationChartRenderer extends AbstractChartRenderer {
043:
044:            /** Creates new InterpolationChartRenderer
045:             * @param rcm the RowColorModel needed to determine the right colors
046:             * @param cs the CoordSystem used to translate values into points
047:             * @param model the DataModel that should be rendered
048:             */
049:            public InterpolationChartRenderer(CoordSystem cs,
050:                    ChartDataModel model) {
051:                super (cs, model);
052:            }
053:
054:            /** Finally renders the Object in the Graphics object.
055:             * @param g the Graphics2D object in which to render
056:             */
057:            public void renderChart(Graphics2D g) {
058:                ChartDataModel m = getChartDataModel();
059:                RowColorModel rcm = getRowColorModel();
060:                AffineTransform yaxis1 = getTransform(CoordSystem.FIRST_YAXIS);
061:
062:                int datasetcount = m.getDataSetNumber();
063:                Point2D val;
064:                Point2D paint = null;
065:                Point2D oldpaint = null;
066:                if (!m.isColumnNumeric())
067:                    return;
068:
069:                for (int set = 0; set < datasetcount; set++) {
070:                    // Creating Interpolated Function Data
071:                    /*
072:                     "for i in range(AMOUNT) :\n"+
073:                     "   x = lowrange + i * (float(abs(highrange - lowrange)) / AMOUNT)\n"+
074:                     "   columns.append(x)\n"+
075:                     "   model.append("+function+")\n";
076:                     */
077:
078:                    double[] x = new double[m.getDataSetLength(set)];
079:                    double[] y = new double[x.length];
080:
081:                    for (int i = 0; i < m.getDataSetLength(set); i++) {
082:                        x[i] = ((Number) m.getColumnValueAt(set, i))
083:                                .doubleValue();
084:
085:                        // Catch x[i] == Not A Number
086:                        if (x[i] != x[i])
087:                            x[i] = 0.0;
088:
089:                        y[i] = m.getValueAt(set, i).doubleValue();
090:                    }
091:
092:                    int AMOUNT = 2000;
093:                    double lowrange = m.getChartDataModelConstraints(
094:                            CoordSystem.FIRST_YAXIS).getMinimumColumnValue();
095:                    double hirange = m.getChartDataModelConstraints(
096:                            CoordSystem.FIRST_YAXIS).getMaximumColumnValue();
097:
098:                    double xa[] = new double[AMOUNT];
099:                    double ya[] = new double[AMOUNT];
100:
101:                    for (int i = 0; i < AMOUNT; i++) {
102:                        xa[i] = lowrange
103:                                + i
104:                                * (Math.abs(hirange - lowrange) / (double) AMOUNT);
105:                        ya[i] = ChartUtilities.interpolate(x, y, xa[i]);
106:                    }
107:
108:                    // Rendering xa[] and ya[]
109:                    for (int i = 0; i < AMOUNT; i++) {
110:
111:                        val = new Point2D.Double(xa[i], ya[i]);
112:
113:                        oldpaint = paint;
114:                        if (yaxis1.transform(val, null) != null)
115:                            paint = yaxis1.transform(val, paint);
116:                        else
117:                            continue;
118:
119:                        g.setColor(rcm.getColor(set));
120:
121:                        if (oldpaint != null) {
122:
123:                            g.drawLine((int) oldpaint.getX(), (int) oldpaint
124:                                    .getY(), (int) paint.getX(), (int) paint
125:                                    .getY());
126:                        }
127:                    }
128:                    oldpaint = null;
129:                    paint = null;
130:                }
131:            }
132:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.