Source Code Cross Referenced for PagesFrame.java in  » Report » iReport-2.0.5 » be » savat » components » 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 » Report » iReport 2.0.5 » be.savat.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * PagesFrame.java
003:         *
004:         * Created on April 20, 2007, 1:37 AM
005:         */
006:
007:        package be.savat.components;
008:
009:        import it.businesslogic.ireport.util.Misc;
010:        import java.awt.Color;
011:        import java.awt.Graphics;
012:        import java.awt.Image;
013:        import java.awt.Point;
014:        import java.awt.image.BufferedImage;
015:        import javax.swing.JFrame;
016:        import net.sf.jasperreports.engine.JRExporterParameter;
017:        import net.sf.jasperreports.engine.JasperPrint;
018:        import net.sf.jasperreports.engine.export.JRGraphics2DExporter;
019:        import net.sf.jasperreports.engine.export.JRGraphics2DExporterParameter;
020:
021:        /**
022:         *
023:         * @author  gtoffoli
024:         */
025:        public class PagesFrame extends javax.swing.JFrame {
026:
027:            private JasperPrint jrPrint = null;
028:            private JRGraphics2DExporter exporter = null;
029:            private Point pageSize = new Point(350, 472);
030:            JBookPanel turnerNewsPaper = null;
031:
032:            /** Creates new form PagesFrame */
033:            public PagesFrame(JasperPrint jrPrint) {
034:                initAll(jrPrint);
035:
036:                Misc.centerFrame(this );
037:            }
038:
039:            public void initAll(JasperPrint jrPrint) {
040:
041:                initComponents();
042:                this .jrPrint = jrPrint;
043:                try {
044:                    exporter = new JRGraphics2DExporter();
045:                } catch (Exception ex) {
046:                }
047:
048:                setTitle("JBookPanel from Pieter-Jan Savat!!! Great job!");
049:
050:                setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
051:                setSize(800, 600);
052:
053:                turnerNewsPaper = new JBookPanel() {
054:
055:                    protected Image loadPage(int index) {
056:
057:                        BufferedImage img = new BufferedImage(getPageSize().x,
058:                                getPageSize().y, BufferedImage.TYPE_INT_RGB);
059:                        Graphics gfx = img.getGraphics();
060:                        //gfx.setColor(Color.WHITE);
061:                        //gfx.fillRect(0, 0, img.getWidth(), img.getHeight());
062:                        exporter.setParameter(JRExporterParameter.JASPER_PRINT,
063:                                getJrPrint());
064:                        exporter.setParameter(JRExporterParameter.PAGE_INDEX,
065:                                new Integer(index));
066:                        exporter.setParameter(
067:                                JRGraphics2DExporterParameter.GRAPHICS_2D, gfx);
068:                        exporter.setParameter(
069:                                JRGraphics2DExporterParameter.ZOOM_RATIO,
070:                                new Float((float) getPageSize().x
071:                                        / (float) getJrPrint().getPageWidth()));
072:
073:                        try {
074:                            exporter.exportReport();
075:                        } catch (Exception ex) {
076:                        }
077:                        return img;
078:                    }
079:                };
080:
081:                turnerNewsPaper.setMargins(30, 40);
082:                turnerNewsPaper.setBackground(new Color(157, 185, 235));
083:                turnerNewsPaper.setLeftPageIndex(-1);
084:                getContentPane().add(turnerNewsPaper,
085:                        java.awt.BorderLayout.CENTER);
086:
087:                updateViewerSize();
088:
089:            }
090:
091:            public JasperPrint getJrPrint() {
092:                return jrPrint;
093:            }
094:
095:            void updateViewerSize() {
096:                System.out.println("Updating page size: " + getPageSize());
097:                System.out.flush();
098:
099:                int imageWidth = jrPrint.getPageWidth();
100:                int imageHeight = jrPrint.getPageHeight();
101:
102:                int width = getContentPane().getWidth() / 2 - 40;
103:                int height = getContentPane().getHeight() - 60;
104:
105:                if (imageWidth <= width && imageHeight <= height) {
106:                    getPageSize().x = width;
107:                    getPageSize().y = height;
108:                } else if (width > 0 && height > 0)// Resize based on minor x/WIDTH... e y/HEIGHT
109:                {
110:                    if ((double) ((double) imageWidth / (double) width) > (double) ((double) imageHeight / (double) height)) {
111:                        getPageSize().x = width;
112:                        getPageSize().y = Math.min((imageHeight * width)
113:                                / imageWidth, height);
114:
115:                    } else {
116:                        getPageSize().x = Math.min((imageWidth * height)
117:                                / imageHeight, width);
118:                        getPageSize().y = height;
119:
120:                    }
121:                }
122:
123:                int index = -1;
124:                index = turnerNewsPaper.getLeftPageIndex();
125:                //getContentPane().removeAll();
126:
127:                turnerNewsPaper.setPages("", "", "",
128:                        jrPrint.getPages().size() - 1, getPageSize().x,
129:                        getPageSize().y);
130:
131:                turnerNewsPaper.setLeftPageIndex(index);
132:
133:                System.out.println("New size: " + getPageSize());
134:                System.out.flush();
135:            }
136:
137:            public void setJrPrint(JasperPrint jrPrint) {
138:                this .jrPrint = jrPrint;
139:            }
140:
141:            public JRGraphics2DExporter getExporter() {
142:                return exporter;
143:            }
144:
145:            public void setExporter(JRGraphics2DExporter exporter) {
146:                this .exporter = exporter;
147:            }
148:
149:            public Point getPageSize() {
150:                return pageSize;
151:            }
152:
153:            public void setPageSize(Point pageSize) {
154:                this .pageSize = pageSize;
155:            }
156:
157:            /** This method is called from within the constructor to
158:             * initialize the form.
159:             * WARNING: Do NOT modify this code. The content of this method is
160:             * always regenerated by the Form Editor.
161:             */
162:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
163:            private void initComponents() {
164:
165:                setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
166:                addComponentListener(new java.awt.event.ComponentAdapter() {
167:                    public void componentResized(
168:                            java.awt.event.ComponentEvent evt) {
169:                        formComponentResized(evt);
170:                    }
171:                });
172:
173:                pack();
174:            }// </editor-fold>//GEN-END:initComponents
175:
176:            private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
177:
178:                updateViewerSize();
179:            }//GEN-LAST:event_formComponentResized
180:
181:            // Variables declaration - do not modify//GEN-BEGIN:variables
182:            // End of variables declaration//GEN-END:variables
183:
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.