Source Code Cross Referenced for AbstractRenderer.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:            AbstractRenderer.java
021:            Created on 21. Juni 2001, 12:32
022:         */
023:
024:        package de.progra.charting.render;
025:
026:        import java.awt.image.BufferedImage;
027:        import java.awt.Rectangle;
028:        import java.awt.Image;
029:        import java.awt.Graphics2D;
030:        import java.awt.Dimension;
031:        import java.awt.Color;
032:
033:        /**
034:         * The AbstractRenderer provides default implementations for the set and
035:         * get methods of every Renderer. Especially it provides a default mechanism
036:         * for scaling Renderer instances whose actual bounds are smaller than their
037:         * preferred size. As a consequence, every Renderer instance only needs
038:         * to implement paintDefault() which has to render the object from coordinates
039:         * 0,0 onwards using the preferred size.
040:         * @author mueller
041:         * @version 1.0
042:         */
043:        public abstract class AbstractRenderer implements  Renderer {
044:
045:            Rectangle bounds = new Rectangle(0, 0, Integer.MAX_VALUE,
046:                    Integer.MAX_VALUE);
047:
048:            /** Creates new AbstractRenderer */
049:            public AbstractRenderer() {
050:            }
051:
052:            /** Sets the bounds the layout manager has assigned to
053:             * this renderer. Those, of course, have to be
054:             * considered in the rendering process.
055:             * @param bounds the new bounds for the renderer.
056:             */
057:            public void setBounds(Rectangle bounds) {
058:                this .bounds = bounds;
059:            }
060:
061:            /** Gets the bounds for this renderer.
062:             * @return the bounds of this renderer. If <code>setBounds</code> has not
063:             * been called before, the bounds computed from
064:             * <code>getPreferredSize</code> is returned.
065:             */
066:            public Rectangle getBounds() {
067:                return bounds;
068:            }
069:
070:            /** Renders the Object in the Graphics object. Creates a BufferedImage
071:             * and the corresponding Graphics2D object to paint in. The Image is
072:             * created using the preferred size. Afterwards <code>paintDefault</code>
073:             * is called to perform a standard painting in the Graphics object.
074:             * If the bounds and the preferred size don't match the image is 
075:             * scaled afterwards.
076:             * @param g the Graphics2D object in which to render
077:             */
078:            public void render(Graphics2D g) {
079:                Dimension d = getPreferredSize();
080:                BufferedImage im = new BufferedImage((int) d.width,
081:                        (int) d.height, BufferedImage.TYPE_INT_RGB);
082:                Graphics2D g2 = im.createGraphics();
083:                g2.setColor(Color.white);
084:                g2.fillRect(0, 0, d.width, d.height);
085:                g2.setColor(Color.black);
086:
087:                paintDefault(g2);
088:
089:                if (d.width > getBounds().getWidth()
090:                        || d.height > getBounds().getHeight()) {
091:                    // Scale Image
092:                    Image scale = im.getScaledInstance((int) getBounds()
093:                            .getWidth(), (int) getBounds().getHeight(),
094:                            Image.SCALE_SMOOTH);
095:
096:                    g.drawImage(scale, (int) getBounds().getX(),
097:                            (int) getBounds().getY(), null);
098:                } else
099:                    g.drawImage(im, (int) getBounds().getX(), (int) getBounds()
100:                            .getY(), null);
101:            }
102:
103:            /** This method is called by the paint method to do the actual painting.
104:             * The painting is supposed to start at point (0,0) and the size is
105:             * always the same as the preferred size. The paint method performs
106:             * the possible scaling.
107:             * @param g the Graphics2D object to paint in.
108:             */
109:            public abstract void paintDefault(Graphics2D g);
110:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.