Source Code Cross Referenced for SideLinealComponent.java in  » Report » pentaho-report » org » pentaho » reportdesigner » crm » report » 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 » pentaho report » org.pentaho.reportdesigner.crm.report 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-2007 Pentaho Corporation.  All rights reserved.
003:         * This software was developed by Pentaho Corporation and is provided under the terms
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005:         * this file except in compliance with the license. If you need a copy of the license,
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007:         *
008:         * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to
010:         * the license for the specific language governing your rights and limitations.
011:         *
012:         * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013:         */
014:        package org.pentaho.reportdesigner.crm.report;
015:
016:        import org.jetbrains.annotations.NotNull;
017:        import org.jetbrains.annotations.Nullable;
018:        import org.pentaho.reportdesigner.crm.report.lineal.HorizontalLinealComponent;
019:        import org.pentaho.reportdesigner.crm.report.lineal.LinealModel;
020:        import org.pentaho.reportdesigner.crm.report.model.ReportElement;
021:        import org.pentaho.reportdesigner.crm.report.zoom.ZoomModel;
022:
023:        import javax.swing.*;
024:        import java.awt.*;
025:        import java.awt.event.AdjustmentEvent;
026:        import java.awt.event.AdjustmentListener;
027:        import java.awt.event.MouseAdapter;
028:        import java.awt.event.MouseEvent;
029:        import java.awt.event.MouseMotionAdapter;
030:        import java.awt.event.MouseWheelEvent;
031:        import java.awt.event.MouseWheelListener;
032:        import java.util.ArrayList;
033:
034:        /**
035:         * User: Martin
036:         * Date: 26.01.2006
037:         * Time: 08:00:56
038:         */
039:        public class SideLinealComponent extends JComponent {
040:            @NotNull
041:            private BandsComponent bandsComponent;
042:            @NotNull
043:            private JScrollPane scrollPane;
044:
045:            @NotNull
046:            private HorizontalLinealComponent horizontalLineal;
047:            @NotNull
048:            private JLabel percentageLabel;
049:            @NotNull
050:            private ReportDialog reportDialog;
051:
052:            private int lastScaleFactor;
053:
054:            public SideLinealComponent(@NotNull
055:            ReportDialog reportDialog, @NotNull
056:            LinealModel horizontalLinealModel) {
057:                this .reportDialog = reportDialog;
058:                setLayout(new LM());
059:
060:                horizontalLineal = new HorizontalLinealComponent(reportDialog,
061:                        horizontalLinealModel);
062:
063:                bandsComponent = new BandsComponent();
064:                scrollPane = new JScrollPane();
065:
066:                percentageLabel = new JLabel(" ");
067:            }
068:
069:            @NotNull
070:            public BandsComponent getBandsComponent() {
071:                return bandsComponent;
072:            }
073:
074:            public void updateReportBorderPanels(@NotNull
075:            ArrayList<ReportBorderPanel> reportBorderPanels) {
076:                removeAll();
077:
078:                bandsComponent.updateReportBorderPanels(reportBorderPanels);
079:
080:                scrollPane.setViewportView(bandsComponent);
081:
082:                scrollPane.setColumnHeaderView(horizontalLineal);
083:                scrollPane.setRowHeaderView(bandsComponent
084:                        .getBandsComponentHelper());
085:
086:                scrollPane.getHorizontalScrollBar().addAdjustmentListener(
087:                        new AdjustmentListener() {
088:                            public void adjustmentValueChanged(@NotNull
089:                            AdjustmentEvent e) {
090:                                horizontalLineal.revalidate();
091:                                horizontalLineal.repaint();
092:                            }
093:                        });
094:
095:                JPanel panel = new JPanel(new BorderLayout());
096:                percentageLabel = new JLabel(" ");
097:                percentageLabel.setHorizontalAlignment(JLabel.CENTER);
098:                panel.add(percentageLabel, BorderLayout.CENTER);
099:
100:                percentageLabel.addMouseListener(new MouseAdapter() {
101:                    public void mouseClicked(@NotNull
102:                    MouseEvent e) {
103:                        if (e.getClickCount() == 2) {
104:                            ZoomModel zoomModel = reportDialog.getZoomModel();
105:                            if (zoomModel != null) {
106:                                zoomModel.setZoomFactor(1000);
107:                            }
108:                        }
109:                    }
110:                });
111:
112:                final int[] x = new int[1];
113:                percentageLabel.addMouseListener(new MouseAdapter() {
114:                    public void mousePressed(@NotNull
115:                    MouseEvent e) {
116:                        x[0] = e.getX();
117:                    }
118:                });
119:
120:                percentageLabel
121:                        .addMouseMotionListener(new MouseMotionAdapter() {
122:                            public void mouseDragged(@NotNull
123:                            MouseEvent e) {
124:                                ZoomModel zoomModel = reportDialog
125:                                        .getZoomModel();
126:                                if (zoomModel != null) {
127:                                    int diff = x[0] - e.getX();
128:                                    int zoomFactor = zoomModel.getZoomFactor();
129:                                    zoomModel.setZoomFactor(Math.min(5000, Math
130:                                            .max(100, zoomFactor - diff * 10)));
131:                                    x[0] = e.getX();
132:                                }
133:                            }
134:                        });
135:
136:                percentageLabel.addMouseWheelListener(new MouseWheelListener() {
137:                    public void mouseWheelMoved(@NotNull
138:                    MouseWheelEvent e) {
139:                        ZoomModel zoomModel = reportDialog.getZoomModel();
140:                        if (zoomModel != null) {
141:                            int diff = e.getWheelRotation() * 100;
142:                            int zoomFactor = zoomModel.getZoomFactor();
143:                            int newZoomFactor = Math.min(5000, Math.max(100,
144:                                    zoomFactor + diff));
145:                            newZoomFactor = newZoomFactor / 100 * 100;
146:                            zoomModel.setZoomFactor(newZoomFactor);
147:                        }
148:                    }
149:                });
150:
151:                panel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1,
152:                        Color.LIGHT_GRAY));
153:                scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, panel);
154:
155:                add(scrollPane);
156:
157:                setScaleFactor(lastScaleFactor);
158:
159:                revalidate();
160:                repaint();
161:            }
162:
163:            public void setScaleFactor(int sf) {
164:                lastScaleFactor = sf;
165:
166:                percentageLabel.setText(sf / 10 + "%");
167:                horizontalLineal.setScaleFactor(sf / 1000.);
168:                bandsComponent.setScaleFactor(sf / 1000.);
169:            }
170:
171:            @NotNull
172:            public HorizontalLinealComponent getHorizontalLineal() {
173:                return horizontalLineal;
174:            }
175:
176:            public void adjustToPerfectSize() {
177:                ArrayList<ReportBorderPanel> reportBorderPanels = bandsComponent
178:                        .getReportBorderPanels();
179:                for (ReportBorderPanel reportBorderPanel : reportBorderPanels) {
180:                    double height = getOptimalHeight(reportBorderPanel
181:                            .getReportPanel().getBandToplevelReportElement());
182:                    height += reportBorderPanel.getReportPanel()
183:                            .getBandToplevelReportElement().getElementBorder()
184:                            .getTopSide().getWidth();
185:                    reportBorderPanel.getReportPanel()
186:                            .getBandToplevelReportElement().setVisualHeight(
187:                                    Math.max(height, reportBorderPanel
188:                                            .isShowTopBorder() ? 0 : 5));
189:                }
190:
191:                revalidate();
192:                repaint();
193:            }
194:
195:            private double getOptimalHeight(@NotNull
196:            ReportElement reportElement) {
197:                double m = reportElement.getMinimumSize().getHeight()
198:                        + reportElement.getPosition().y;
199:                double b = reportElement.getPreferredSize().getHeight()
200:                        + reportElement.getPosition().y;
201:
202:                m = Math.max(m, b);
203:
204:                for (ReportElement element : reportElement.getChildren()) {
205:                    m = Math.max(m, getOptimalHeight(element));
206:                }
207:
208:                if (reportElement.getMaximumSize().getHeight() > 0) {
209:                    m = Math.min(m, reportElement.getMaximumSize().getHeight());
210:                }
211:
212:                return m;
213:            }
214:
215:            private class LM implements  LayoutManager2 {
216:                public void addLayoutComponent(@NotNull
217:                Component comp, @Nullable
218:                Object constraints) {
219:                }
220:
221:                @NotNull
222:                public Dimension maximumLayoutSize(@NotNull
223:                Container target) {
224:                    return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
225:                }
226:
227:                public float getLayoutAlignmentX(@NotNull
228:                Container target) {
229:                    return 0;
230:                }
231:
232:                public float getLayoutAlignmentY(@NotNull
233:                Container target) {
234:                    return 0;
235:                }
236:
237:                public void invalidateLayout(@NotNull
238:                Container target) {
239:                }
240:
241:                public void addLayoutComponent(@NotNull
242:                String name, @NotNull
243:                Component comp) {
244:                }
245:
246:                public void removeLayoutComponent(@NotNull
247:                Component comp) {
248:                }
249:
250:                @NotNull
251:                public Dimension preferredLayoutSize(@NotNull
252:                Container parent) {
253:                    return new Dimension(100,
254:                            bandsComponent.getPreferredSize().height + 8 + 20);
255:                }
256:
257:                @NotNull
258:                public Dimension minimumLayoutSize(@NotNull
259:                Container parent) {
260:                    return new Dimension(100, 100);
261:                }
262:
263:                public void layoutContainer(@NotNull
264:                Container parent) {
265:                    int topLinealHeight = 0;
266:                    int leftLinealWidth = 0;
267:                    int grabberWidth = 0;
268:
269:                    scrollPane.setBounds(grabberWidth + leftLinealWidth,
270:                            topLinealHeight, getWidth()
271:                                    - (leftLinealWidth + grabberWidth),
272:                            getHeight() - topLinealHeight);
273:                }
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.