Source Code Cross Referenced for ChartInfo.java in  » Project-Management » OpenProj » com » projity » pm » graphic » chart » 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 » Project Management » OpenProj » com.projity.pm.graphic.chart 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        The contents of this file are subject to the Common Public Attribution License 
003:        Version 1.0 (the "License"); you may not use this file except in compliance with 
004:        the License. You may obtain a copy of the License at 
005:        http://www.projity.com/license . The License is based on the Mozilla Public 
006:        License Version 1.1 but Sections 14 and 15 have been added to cover use of 
007:        software over a computer network and provide for limited attribution for the 
008:        Original Developer. In addition, Exhibit A has been modified to be consistent 
009:        with Exhibit B.
010:
011:        Software distributed under the License is distributed on an "AS IS" basis, 
012:        WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
013:        specific language governing rights and limitations under the License. The 
014:        Original Code is OpenProj. The Original Developer is the Initial Developer and 
015:        is Projity, Inc. All portions of the code written by Projity are Copyright (c) 
016:        2006, 2007. All Rights Reserved. Contributors Projity, Inc.
017:
018:        Alternatively, the contents of this file may be used under the terms of the 
019:        Projity End-User License Agreeement (the Projity License), in which case the 
020:        provisions of the Projity License are applicable instead of those above. If you 
021:        wish to allow use of your version of this file only under the terms of the 
022:        Projity License and not to allow others to use your version of this file under 
023:        the CPAL, indicate your decision by deleting the provisions above and replace 
024:        them with the notice and other provisions required by the Projity  License. If 
025:        you do not delete the provisions above, a recipient may use your version of this 
026:        file under either the CPAL or the Projity License.
027:
028:        [NOTE: The text of this license may differ slightly from the text of the notices 
029:        in Exhibits A and B of the license at http://www.projity.com/license. You should 
030:        use the latest text at http://www.projity.com/license for your modifications.
031:        You may not remove this license text from the source files.]
032:
033:        Attribution Information: Attribution Copyright Notice: Copyright © 2006, 2007 
034:        Projity, Inc. Attribution Phrase (not exceeding 10 words): Powered by OpenProj, 
035:        an open source solution from Projity. Attribution URL: http://www.projity.com 
036:        Graphic Image as provided in the Covered Code as file:  openproj_logo.png with 
037:        alternatives listed on http://www.projity.com/logo
038:
039:        Display of Attribution Information is required in Larger Works which are defined 
040:        in the CPAL as a work which combines Covered Code or portions thereof with code 
041:        not governed by the terms of the CPAL. However, in addition to the other notice 
042:        obligations, all copies of the Covered Code in Executable and Source Code form 
043:        distributed must, as a form of attribution of the original author, include on 
044:        each user interface screen the "OpenProj" logo visible to all users.  The 
045:        OpenProj logo should be located horizontally aligned with the menu bar and left 
046:        justified on the top left of the screen adjacent to the File menu.  The logo 
047:        must be at least 100 x 25 pixels.  When users click on the "OpenProj" logo it 
048:        must direct them back to http://www.projity.com.  
049:         */
050:        package com.projity.pm.graphic.chart;
051:
052:        import java.io.Serializable;
053:        import java.util.ArrayList;
054:        import java.util.List;
055:
056:        import org.jfree.chart.JFreeChart;
057:
058:        import com.projity.document.ObjectEvent;
059:        import com.projity.graphic.configuration.SpreadSheetFieldArray;
060:        import com.projity.grouping.core.model.NodeModel;
061:        import com.projity.pm.graphic.model.cache.NodeModelCache;
062:        import com.projity.pm.graphic.model.event.CacheListener;
063:        import com.projity.pm.graphic.model.event.CompositeCacheEvent;
064:        import com.projity.pm.graphic.spreadsheet.selection.event.SelectionNodeEvent;
065:        import com.projity.pm.graphic.spreadsheet.selection.event.SelectionNodeListener;
066:        import com.projity.pm.graphic.timescale.CoordinatesConverter;
067:        import com.projity.pm.graphic.views.ChartView;
068:        import com.projity.pm.resource.Resource;
069:        import com.projity.pm.scheduling.ScheduleEvent;
070:        import com.projity.pm.scheduling.ScheduleEventListener;
071:        import com.projity.pm.task.Project;
072:        import com.projity.timescale.TimeScaleEvent;
073:        import com.projity.timescale.TimeScaleListener;
074:        import com.projity.workspace.SavableToWorkspace;
075:        import com.projity.workspace.WorkspaceSetting;
076:
077:        /**
078:         * This class serves as a moderator between the ChartPanel and the ChartLegend
079:         */
080:        public class ChartInfo implements  Serializable, SelectionNodeListener,
081:                ScheduleEventListener, TimeScaleListener, ObjectEvent.Listener,
082:                CacheListener, SavableToWorkspace {
083:            private static final long serialVersionUID = -6593093924980192805L;
084:            Project project;
085:            NodeModel nodeModel;
086:            ChartView chartView;
087:
088:            boolean simple;
089:            List selectedObjects = new ArrayList();
090:            ChartModel model;
091:            ChartLegend chartLegend;
092:            JFreeChart chart;
093:            CoordinatesConverter coord;
094:            List tasks;
095:            List resources;
096:            boolean cumulative = false;
097:            boolean histogram = true;
098:            boolean selectedOnTop = true;
099:            boolean work = true;
100:            Object traces[] = {};
101:            TimeChartPanel chartPanel;
102:            AxisPanel axisPanel;
103:            NodeModelCache cache = null; // for resources
104:            private boolean restoring = false;
105:
106:            /**
107:             * 
108:             */
109:            public ChartInfo() {
110:                super ();
111:            }
112:
113:            /**
114:             * @return Returns the chartView.
115:             */
116:            public ChartView getChartView() {
117:                return chartView;
118:            }
119:
120:            /**
121:             * @param chartView The chartView to set.
122:             */
123:            public void setChartView(ChartView chartView) {
124:                this .chartView = chartView;
125:            }
126:
127:            /**
128:             * @return Returns the coord.
129:             */
130:            public CoordinatesConverter getCoord() {
131:                return coord;
132:            }
133:
134:            /**
135:             * @param coord The coord to set.
136:             */
137:            public void setCoord(CoordinatesConverter coord) {
138:                if (this .coord != null)
139:                    this .coord.removeTimeScaleListener(this );
140:                this .coord = coord;
141:                model = new ChartModel(coord);
142:                coord.addTimeScaleListener(this );
143:            }
144:
145:            /**
146:             * @return Returns the cumulative.
147:             */
148:            public boolean isCumulative() {
149:                return cumulative;
150:            }
151:
152:            public boolean isSelectedOnTop() {
153:                return selectedOnTop;
154:            }
155:
156:            /**
157:             * @return Returns the histogram.
158:             */
159:            public boolean isHistogram() {
160:                return histogram;
161:            }
162:
163:            /**
164:             * @param histogram The histogram to set.
165:             */
166:            public void setHistogram(boolean histogram) {
167:                this .histogram = histogram;
168:                updateChart(tasks, resources);
169:            }
170:
171:            /**
172:             * @return Returns the model.
173:             */
174:            public ChartModel getModel() {
175:                return model;
176:            }
177:
178:            /**
179:             * @param model The model to set.
180:             */
181:            public void setModel(ChartModel model) {
182:                this .model = model;
183:            }
184:
185:            /**
186:             * @return Returns the resources.
187:             */
188:            public List getResources() {
189:                return resources;
190:            }
191:
192:            /**
193:             * @param resources The resources to set.
194:             */
195:            public void setResources(List resources) {
196:                this .resources = resources;
197:            }
198:
199:            /**
200:             * @return Returns the selectedObjects.
201:             */
202:            public List getSelectedObjects() {
203:                return selectedObjects;
204:            }
205:
206:            /**
207:             * @param selectedObjects The selectedObjects to set.
208:             */
209:            public void setSelectedObjects(List selectedObjects) {
210:                this .selectedObjects = selectedObjects;
211:            }
212:
213:            /**
214:             * @return Returns the simple.
215:             */
216:            public boolean isSimple() {
217:                return simple;
218:            }
219:
220:            /**
221:             * @param simple The simple to set.
222:             */
223:            public void setSimple(boolean simple) {
224:                this .simple = simple;
225:            }
226:
227:            /**
228:             * @return Returns the tasks.
229:             */
230:            public List getTasks() {
231:                return tasks;
232:            }
233:
234:            /**
235:             * @param tasks The tasks to set.
236:             */
237:            public void setTasks(List tasks) {
238:                this .tasks = tasks;
239:            }
240:
241:            /**
242:             * @return Returns the traces.
243:             */
244:            public Object[] getTraces() {
245:                return traces;
246:            }
247:
248:            /**
249:             * @return Returns the chart.
250:             */
251:            public JFreeChart getChart() {
252:                return chart;
253:            }
254:
255:            /**
256:             * @param chart The chart to set.
257:             */
258:            public JFreeChart setChart(JFreeChart chart) {
259:                this .chart = chart;
260:                return chart;
261:            }
262:
263:            /**
264:             * @return Returns the chartPanel.
265:             */
266:            public TimeChartPanel getChartPanel() {
267:                return chartPanel;
268:            }
269:
270:            /**
271:             * @param chartPanel The chartPanel to set.
272:             */
273:            public void setChartPanel(TimeChartPanel chartPanel) {
274:                this .chartPanel = chartPanel;
275:            }
276:
277:            /**
278:             * @return Returns the project.
279:             */
280:            public Project getProject() {
281:                return project;
282:            }
283:
284:            /**
285:             * @param project The project to set.
286:             */
287:            public void setProject(Project project) {
288:                if (this .project != null) {
289:                    this .project.removeScheduleListener(this );
290:                    this .project.getResourcePool().removeObjectListener(this );
291:                }
292:                this .project = project;
293:                project.addScheduleListener(this );
294:                project.getResourcePool().addObjectListener(this );
295:                nodeModel = project.getResourcePool().getResourceOutline();
296:            }
297:
298:            /**
299:             * @return Returns the nodeModel.
300:             */
301:            public NodeModel getNodeModel() {
302:                return nodeModel;
303:            }
304:
305:            /**
306:             * @param nodeModel The nodeModel to set.
307:             */
308:            public void setNodeModel(NodeModel nodeModel) {
309:                this .nodeModel = nodeModel;
310:            }
311:
312:            public void selectionChanged(SelectionNodeEvent e) {
313:                if (!isVisible())
314:                    return;
315:                chartLegend.selectionChanged(e); // pass it along
316:            }
317:
318:            /**
319:             * @return Returns the chartLegend.
320:             */
321:            public ChartLegend getChartLegend() {
322:                return chartLegend;
323:            }
324:
325:            /**
326:             * @param chartLegend The chartLegend to set.
327:             */
328:            public void setChartLegend(ChartLegend chartLegend) {
329:                this .chartLegend = chartLegend;
330:            }
331:
332:            public void setTraces(Object[] traces) {
333:                if (traces.length == 0) // will happen if changing from cost to work.  Don't change it
334:                    return;
335:                this .traces = traces;
336:                if (chartPanel != null) // the very first time on histogram we need to set traces before chart panel is created
337:                    updateChart(tasks, resources);
338:            }
339:
340:            public void timeScaleChanged(TimeScaleEvent e) {
341:                if (!isVisible())
342:                    return;
343:
344:                updateChart(tasks, resources);
345:            }
346:
347:            /* (non-Javadoc)
348:             * @see com.projity.pm.scheduling.ScheduleEventListener#scheduleChanged(com.projity.pm.scheduling.ScheduleEvent)
349:             */
350:            public void scheduleChanged(ScheduleEvent evt) {
351:                if (!isVisible())
352:                    return;
353:
354:                updateChart(tasks, resources);
355:            }
356:
357:            public void setCumulative(boolean cumulative) {
358:                this .cumulative = cumulative;
359:                updateChart(tasks, resources);
360:            }
361:
362:            public void setSelectedOnTop(boolean multiproject) {
363:                this .selectedOnTop = multiproject;
364:            }
365:
366:            public double getFooterHeight() {
367:                return chartPanel.getNonPlotHeight();
368:            }
369:
370:            public double getHeaderHeight() {
371:                return chartView.getHeaderComponentHeight();
372:            }
373:
374:            public void updateChart(List tasks, List resources) {
375:                this .tasks = tasks;
376:                this .resources = resources;
377:                if (isSimple())
378:                    model.computeHistogram(getProject(), tasks, resources,
379:                            traces);
380:                else
381:                    model.computeValues(tasks, resources, cumulative, traces,
382:                            histogram);
383:                chart = chartPanel.buildChart();
384:                setChart(chart);
385:                chartPanel.updateChart();
386:                axisPanel.setAxis(getChart().getXYPlot().getRangeAxis());
387:                axisPanel.repaint();
388:            }
389:
390:            /**
391:             * @return Returns the axisPanel.
392:             */
393:            public AxisPanel getAxisPanel() {
394:                return axisPanel;
395:            }
396:
397:            /**
398:             * @param axisPanel The axisPanel to set.
399:             */
400:            public void setAxisPanel(AxisPanel axisPanel) {
401:                this .axisPanel = axisPanel;
402:            }
403:
404:            /* (non-Javadoc)
405:             * @see com.projity.field.ObjectEvent.Listener#objectChanged(com.projity.field.ObjectEvent)
406:             */
407:            public void objectChanged(ObjectEvent objectEvent) {
408:                if (!isVisible())
409:                    return;
410:
411:                if (objectEvent.getObject() instanceof  Resource) {
412:                    chartLegend.rebuildTree(); // take into account different resources
413:                    updateChart(tasks, resources);
414:                }
415:            }
416:
417:            boolean isVisible() {
418:                return chartView.isVisible();
419:            }
420:
421:            public void setCache(NodeModelCache cache) {
422:                if (this .cache == null)
423:                    cache.removeNodeModelListener(this );
424:                this .cache = cache;
425:                cache.update();
426:                cache.addNodeModelListener(this );
427:            }
428:
429:            public final NodeModelCache getCache() {
430:                return cache;
431:            }
432:
433:            public void graphicNodesCompositeEvent(CompositeCacheEvent e) {
434:                if (!isVisible())
435:                    return;
436:                chartLegend.rebuildTree();
437:            }
438:
439:            public void setCumulativeCostMode() {
440:                cumulative = true;
441:                histogram = false;
442:            }
443:
444:            public boolean isWork() {
445:                return work;
446:            }
447:
448:            public void setWork(boolean work) {
449:                this .work = work;
450:            }
451:
452:            public void restoreWorkspace(WorkspaceSetting w, int context) {
453:                Workspace ws = (Workspace) w;
454:                cumulative = ws.cumulative;
455:                histogram = ws.histogram;
456:                selectedOnTop = ws.selectedOnTop;
457:                work = ws.work;
458:                chartPanel.setVerticalScrolling(ws.verticalScroll);
459:                chartPanel.verticalScrollingItem.setSelected(ws.verticalScroll);
460:                if (!simple)
461:                    setTraces(SpreadSheetFieldArray.fromIdArray(ws.traces));
462:            }
463:
464:            public WorkspaceSetting createWorkspace(int context) {
465:                Workspace ws = new Workspace();
466:                ws.cumulative = cumulative;
467:                ws.histogram = histogram;
468:                ws.selectedOnTop = selectedOnTop;
469:                ws.work = work;
470:                ws.verticalScroll = chartPanel.isVerticalScrolling();
471:                if (!simple)
472:                    ws.traces = SpreadSheetFieldArray.toIdArray(traces);
473:                return ws;
474:            }
475:
476:            public static class Workspace implements  WorkspaceSetting {
477:                private static final long serialVersionUID = -1369065811123053002L;
478:                boolean cumulative;
479:                boolean histogram;
480:                boolean selectedOnTop;
481:                boolean work;
482:                Object[] traces;
483:                boolean verticalScroll;
484:
485:                public boolean isCumulative() {
486:                    return cumulative;
487:                }
488:
489:                public void setCumulative(boolean cumulative) {
490:                    this .cumulative = cumulative;
491:                }
492:
493:                public boolean isHistogram() {
494:                    return histogram;
495:                }
496:
497:                public void setHistogram(boolean histogram) {
498:                    this .histogram = histogram;
499:                }
500:
501:                public boolean isSelectedOnTop() {
502:                    return selectedOnTop;
503:                }
504:
505:                public void setSelectedOnTop(boolean selectedOnTop) {
506:                    this .selectedOnTop = selectedOnTop;
507:                }
508:
509:                public boolean isWork() {
510:                    return work;
511:                }
512:
513:                public void setWork(boolean work) {
514:                    this .work = work;
515:                }
516:
517:                public Object[] getTraces() {
518:                    return traces;
519:                }
520:
521:                public void setTraces(Object[] traces) {
522:                    this .traces = traces;
523:                }
524:
525:                public boolean isVerticalScroll() {
526:                    return verticalScroll;
527:                }
528:
529:                public void setVerticalScroll(boolean verticalScroll) {
530:                    this .verticalScroll = verticalScroll;
531:                }
532:            }
533:
534:            public boolean isRestoring() {
535:                return restoring;
536:            }
537:
538:            public void setRestoring(boolean restoring) {
539:                this.restoring = restoring;
540:            }
541:
542:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.