Source Code Cross Referenced for EllipseReportElement.java in  » Report » pentaho-report » org » pentaho » reportdesigner » crm » report » model » 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.model 
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.model;
015:
016:        import org.gjt.xpp.XmlPullNode;
017:        import org.jetbrains.annotations.NotNull;
018:        import org.jetbrains.annotations.Nullable;
019:        import org.pentaho.reportdesigner.crm.report.GraphicsContext;
020:        import org.pentaho.reportdesigner.crm.report.PropertyKeys;
021:        import org.pentaho.reportdesigner.crm.report.model.functions.ExpressionRegistry;
022:        import org.pentaho.reportdesigner.crm.report.reportexporter.ReportCreationException;
023:        import org.pentaho.reportdesigner.crm.report.reportexporter.ReportVisitor;
024:        import org.pentaho.reportdesigner.lib.client.undo.Undo;
025:        import org.pentaho.reportdesigner.lib.client.undo.UndoEntry;
026:        import org.pentaho.reportdesigner.lib.client.util.MathUtils;
027:        import org.pentaho.reportdesigner.lib.common.xml.ObjectConverterFactory;
028:        import org.pentaho.reportdesigner.lib.common.xml.XMLConstants;
029:        import org.pentaho.reportdesigner.lib.common.xml.XMLContext;
030:        import org.pentaho.reportdesigner.lib.common.xml.XMLUtils;
031:        import org.pentaho.reportdesigner.lib.common.xml.XMLWriter;
032:
033:        import java.awt.*;
034:        import java.awt.geom.Ellipse2D;
035:        import java.awt.geom.Rectangle2D;
036:        import java.io.IOException;
037:
038:        /**
039:         * User: Martin
040:         * Date: 08.02.2006
041:         * Time: 11:07:45
042:         */
043:        public class EllipseReportElement extends ReportElement {
044:            private boolean drawBorder;
045:
046:            @NotNull
047:            private BorderDefinition borderDefinition;
048:
049:            @Nullable
050:            private Color color;
051:            private boolean fill;
052:
053:            public EllipseReportElement() {
054:                borderDefinition = new BorderDefinition();
055:                drawBorder = false;
056:                fill = true;
057:            }
058:
059:            public void accept(@Nullable
060:            Object parent, @NotNull
061:            ReportVisitor reportVisitor) throws ReportCreationException {
062:                /*Object newParent = */
063:                reportVisitor.visit(parent, this );
064:            }
065:
066:            @Nullable
067:            public Color getColor() {
068:                return color;
069:            }
070:
071:            public void setColor(@Nullable
072:            final Color color) {
073:                final Color oldColor = this .color;
074:                this .color = color;
075:
076:                Undo undo = getUndo();
077:                if (undo != null && !undo.isInProgress()) {
078:                    undo.startTransaction(PropertyKeys.COLOR);
079:                    undo.add(new UndoEntry() {
080:                        public void undo() {
081:                            setColor(oldColor);
082:                        }
083:
084:                        public void redo() {
085:                            setColor(color);
086:                        }
087:                    });
088:                    undo.endTransaction();
089:                }
090:                firePropertyChange(PropertyKeys.COLOR, oldColor, color);
091:            }
092:
093:            @NotNull
094:            public BorderDefinition getBorderDefinition() {
095:                return borderDefinition;
096:            }
097:
098:            public void setBorderDefinition(@NotNull
099:            final BorderDefinition borderDefinition) {
100:                //noinspection ConstantConditions
101:                if (borderDefinition == null) {
102:                    throw new IllegalArgumentException(
103:                            "borderDefinition must not be null");
104:                }
105:
106:                final BorderDefinition oldBorderDefinition = this .borderDefinition;
107:                this .borderDefinition = borderDefinition;
108:                setElementRepaintBorder(borderDefinition.getWidth()
109:                        * MathUtils.SQRT_OF_2 / 2 + 1);
110:
111:                Undo undo = getUndo();
112:                if (undo != null && !undo.isInProgress()) {
113:                    undo.startTransaction(PropertyKeys.BORDER_DEFINITION);
114:                    undo.add(new UndoEntry() {
115:                        public void undo() {
116:                            setBorderDefinition(oldBorderDefinition);
117:                        }
118:
119:                        public void redo() {
120:                            setBorderDefinition(borderDefinition);
121:                        }
122:                    });
123:                    undo.endTransaction();
124:                }
125:                firePropertyChange(PropertyKeys.BORDER_DEFINITION,
126:                        oldBorderDefinition, borderDefinition);
127:            }
128:
129:            public boolean isFill() {
130:                return fill;
131:            }
132:
133:            public void setFill(final boolean fill) {
134:                final boolean oldFill = this .fill;
135:                this .fill = fill;
136:
137:                Undo undo = getUndo();
138:                if (undo != null && !undo.isInProgress()) {
139:                    undo.startTransaction(PropertyKeys.FILL);
140:                    undo.add(new UndoEntry() {
141:                        public void undo() {
142:                            setFill(oldFill);
143:                        }
144:
145:                        public void redo() {
146:                            setFill(fill);
147:                        }
148:                    });
149:                    undo.endTransaction();
150:                }
151:
152:                firePropertyChange(PropertyKeys.FILL, Boolean.valueOf(oldFill),
153:                        Boolean.valueOf(fill));
154:            }
155:
156:            public boolean isDrawBorder() {
157:                return drawBorder;
158:            }
159:
160:            public void setDrawBorder(final boolean drawBorder) {
161:                final boolean oldDrawBorder = this .drawBorder;
162:                this .drawBorder = drawBorder;
163:
164:                Undo undo = getUndo();
165:                if (undo != null && !undo.isInProgress()) {
166:                    undo.startTransaction(PropertyKeys.DRAW_BORDER);
167:                    undo.add(new UndoEntry() {
168:                        public void undo() {
169:                            setDrawBorder(oldDrawBorder);
170:                        }
171:
172:                        public void redo() {
173:                            setDrawBorder(drawBorder);
174:                        }
175:                    });
176:                    undo.endTransaction();
177:                }
178:
179:                firePropertyChange(PropertyKeys.DRAW_BORDER, Boolean
180:                        .valueOf(oldDrawBorder), Boolean.valueOf(drawBorder));
181:            }
182:
183:            public void paint(@NotNull
184:            GraphicsContext graphicsContext, @NotNull
185:            Graphics2D g2d) {
186:                Shape origClip = g2d.getClip();
187:                Color origColor = g2d.getColor();
188:                Stroke origStroke = g2d.getStroke();
189:                Composite origComposite = g2d.getComposite();
190:
191:                Rectangle2D.Double rect = getRectangle();
192:
193:                paintBackroundAndBorder(g2d);
194:
195:                Ellipse2D.Double ellipse;
196:                ellipse = new Ellipse2D.Double(rect.x, rect.y, rect.width,
197:                        rect.height);
198:
199:                Color bgColor = color;
200:                if (bgColor != null) {
201:                    if (fill) {
202:                        g2d.setColor(bgColor);
203:                        g2d.fill(ellipse);
204:                    }
205:                    if (drawBorder) {
206:                        g2d.setColor(borderDefinition.getColor());
207:                        g2d.setStroke(borderDefinition.getBasicStroke());
208:                        g2d.draw(ellipse);
209:                    }
210:                }
211:
212:                g2d.setComposite(origComposite);
213:                g2d.setStroke(origStroke);
214:                g2d.setColor(origColor);
215:                g2d.setClip(origClip);
216:            }
217:
218:            protected void externalizeElements(@NotNull
219:            XMLWriter xmlWriter, @NotNull
220:            XMLContext xmlContext) throws IOException {
221:                super .externalizeElements(xmlWriter, xmlContext);
222:
223:                Color color = this .color;
224:                if (color != null) {
225:                    xmlWriter.writeProperty(PropertyKeys.COLOR,
226:                            ObjectConverterFactory.getInstance()
227:                                    .getColorConverter().getString(color));
228:                }
229:
230:                xmlWriter.writeProperty(PropertyKeys.DRAW_BORDER, String
231:                        .valueOf(drawBorder));
232:                xmlWriter
233:                        .writeProperty(PropertyKeys.FILL, String.valueOf(fill));
234:
235:                xmlWriter.startElement(PropertyKeys.BORDER_DEFINITION);
236:                borderDefinition.externalizeObject(xmlWriter, xmlContext);
237:                xmlWriter.closeElement(PropertyKeys.BORDER_DEFINITION);
238:            }
239:
240:            protected void readElement(@NotNull
241:            ExpressionRegistry expressions, @NotNull
242:            XmlPullNode node, @NotNull
243:            XMLContext xmlContext) throws Exception {
244:                super .readElement(expressions, node, xmlContext);
245:
246:                if (XMLConstants.PROPERTY.equals(node.getRawName())
247:                        && PropertyKeys.COLOR
248:                                .equals(node
249:                                        .getAttributeValueFromRawName(XMLConstants.NAME))) {
250:                    color = ObjectConverterFactory.getInstance()
251:                            .getColorConverter().getObject(
252:                                    XMLUtils.readProperty(PropertyKeys.COLOR,
253:                                            node));
254:                } else if (XMLConstants.PROPERTY.equals(node.getRawName())
255:                        && PropertyKeys.DRAW_BORDER
256:                                .equals(node
257:                                        .getAttributeValueFromRawName(XMLConstants.NAME))) {
258:                    drawBorder = Boolean.parseBoolean(XMLUtils.readProperty(
259:                            PropertyKeys.DRAW_BORDER, node));
260:                } else if (XMLConstants.PROPERTY.equals(node.getRawName())
261:                        && PropertyKeys.FILL
262:                                .equals(node
263:                                        .getAttributeValueFromRawName(XMLConstants.NAME))) {
264:                    fill = Boolean.parseBoolean(XMLUtils.readProperty(
265:                            PropertyKeys.FILL, node));
266:                } else if (PropertyKeys.BORDER_DEFINITION.equals(node
267:                        .getRawName())) {
268:                    borderDefinition = new BorderDefinition();
269:                    borderDefinition.readObject(node, xmlContext);
270:                }
271:            }
272:
273:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.