Source Code Cross Referenced for DrawablePanel.java in  » Graphic-Library » jcommon-components » org » jfree » ui » 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 » Graphic Library » jcommon components » org.jfree.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * ========================================
003:         * JCommon : a free Java report library
004:         * ========================================
005:         *
006:         * Project Info:  http://www.jfree.org/jcommon/
007:         * Project Lead:  Thomas Morgner;
008:         *
009:         * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors.
010:         *
011:         * This library is free software; you can redistribute it and/or modify it under the terms
012:         * of the GNU Lesser General Public License as published by the Free Software Foundation;
013:         * either version 2.1 of the License, or (at your option) any later version.
014:         *
015:         * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
016:         * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
017:         * See the GNU Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public License along with this
020:         * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
021:         * Boston, MA 02111-1307, USA.
022:         *
023:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
024:         * in the United States and other countries.]
025:         *
026:         * ------------
027:         * DrawablePanel.java
028:         * ------------
029:         * (C) Copyright 2002-2006, by Object Refinery Limited.
030:         *
031:         * Original Author:  Thomas Morgner;
032:         * Contributor(s):   -;
033:         *
034:         * $Id: DrawablePanel.java,v 1.2 2006/11/17 20:09:50 taqua Exp $
035:         *
036:         * Changes
037:         * -------
038:         *
039:         *
040:         */package org.jfree.ui;
041:
042:        import java.awt.Graphics;
043:        import java.awt.Graphics2D;
044:        import java.awt.Dimension;
045:        import java.awt.geom.Rectangle2D;
046:        import javax.swing.JPanel;
047:
048:        import org.jfree.util.Log;
049:
050:        /**
051:         * A component, that accepts a drawable and which draws that drawable.
052:         *
053:         * @author Thomas Morgner
054:         */
055:        public class DrawablePanel extends JPanel {
056:            private Drawable drawable;
057:
058:            public DrawablePanel() {
059:                setOpaque(false);
060:            }
061:
062:            public Drawable getDrawable() {
063:                return drawable;
064:            }
065:
066:            public void setDrawable(final Drawable drawable) {
067:                this .drawable = drawable;
068:                revalidate();
069:                repaint();
070:            }
071:
072:            /**
073:             * If the <code>preferredSize</code> has been set to a non-<code>null</code>
074:             * value just returns it. If the UI delegate's <code>getPreferredSize</code>
075:             * method returns a non <code>null</code> value then return that; otherwise
076:             * defer to the component's layout manager.
077:             *
078:             * @return the value of the <code>preferredSize</code> property
079:             * @see #setPreferredSize
080:             * @see javax.swing.plaf.ComponentUI
081:             */
082:            public Dimension getPreferredSize() {
083:                if (drawable instanceof  ExtendedDrawable) {
084:                    final ExtendedDrawable ed = (ExtendedDrawable) drawable;
085:                    return ed.getPreferredSize();
086:                }
087:                return super .getPreferredSize();
088:            }
089:
090:            /**
091:             * If the minimum size has been set to a non-<code>null</code> value just
092:             * returns it.  If the UI delegate's <code>getMinimumSize</code> method
093:             * returns a non-<code>null</code> value then return that; otherwise defer to
094:             * the component's layout manager.
095:             *
096:             * @return the value of the <code>minimumSize</code> property
097:             * @see #setMinimumSize
098:             * @see javax.swing.plaf.ComponentUI
099:             */
100:            public Dimension getMinimumSize() {
101:                if (drawable instanceof  ExtendedDrawable) {
102:                    final ExtendedDrawable ed = (ExtendedDrawable) drawable;
103:                    return ed.getPreferredSize();
104:                }
105:                return super .getMinimumSize();
106:            }
107:
108:            /**
109:             * Returns true if this component is completely opaque.
110:             * <p/>
111:             * An opaque component paints every pixel within its rectangular bounds. A
112:             * non-opaque component paints only a subset of its pixels or none at all,
113:             * allowing the pixels underneath it to "show through".  Therefore, a
114:             * component that does not fully paint its pixels provides a degree of
115:             * transparency.
116:             * <p/>
117:             * Subclasses that guarantee to always completely paint their contents should
118:             * override this method and return true.
119:             *
120:             * @return true if this component is completely opaque
121:             * @see #setOpaque
122:             */
123:            public boolean isOpaque() {
124:                if (drawable == null) {
125:                    return false;
126:                }
127:                return super .isOpaque();
128:            }
129:
130:            /**
131:             * Calls the UI delegate's paint method, if the UI delegate is
132:             * non-<code>null</code>.  We pass the delegate a copy of the
133:             * <code>Graphics</code> object to protect the rest of the paint code from
134:             * irrevocable changes (for example, <code>Graphics.translate</code>).
135:             * <p/>
136:             * If you override this in a subclass you should not make permanent changes to
137:             * the passed in <code>Graphics</code>. For example, you should not alter the
138:             * clip <code>Rectangle</code> or modify the transform. If you need to do
139:             * these operations you may find it easier to create a new
140:             * <code>Graphics</code> from the passed in <code>Graphics</code> and
141:             * manipulate it. Further, if you do not invoker super's implementation you
142:             * must honor the opaque property, that is if this component is opaque, you
143:             * must completely fill in the background in a non-opaque color. If you do not
144:             * honor the opaque property you will likely see visual artifacts.
145:             * <p/>
146:             * The passed in <code>Graphics</code> object might have a transform other
147:             * than the identify transform installed on it.  In this case, you might get
148:             * unexpected results if you cumulatively apply another transform.
149:             *
150:             * @param g the <code>Graphics</code> object to protect
151:             * @see #paint
152:             * @see javax.swing.plaf.ComponentUI
153:             */
154:            protected void paintComponent(Graphics g) {
155:                super .paintComponent(g);
156:                if (drawable == null) {
157:                    return;
158:                }
159:
160:                final Graphics2D g2 = (Graphics2D) g.create(0, 0, getWidth(),
161:                        getHeight());
162:
163:                drawable.draw(g2, new Rectangle2D.Double(0, 0, getWidth(),
164:                        getHeight()));
165:                g2.dispose();
166:            }
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.