Source Code Cross Referenced for RequisitionsChartDataModel.java in  » Science » Cougaar12_4 » org » cougaar » logistics » ui » inventory » 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 » Science » Cougaar12_4 » org.cougaar.logistics.ui.inventory 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 1997-2004 BBNT Solutions, LLC
005:         *  under sponsorship of the Defense Advanced Research Projects
006:         *  Agency (DARPA).
007:         * 
008:         *  You can redistribute this software and/or modify it under the
009:         *  terms of the Cougaar Open Source License as published on the
010:         *  Cougaar Open Source Website (www.cougaar.org).
011:         * 
012:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015:         *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016:         *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017:         *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018:         *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019:         *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020:         *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021:         *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022:         *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023:         *  
024:         * </copyright>
025:         */
026:
027:        package org.cougaar.logistics.ui.inventory;
028:
029:        import java.util.ArrayList;
030:        import java.util.Date;
031:
032:        import com.klg.jclass.chart.ChartDataModel;
033:        import com.klg.jclass.chart.LabelledChartDataModel;
034:        import com.klg.jclass.chart.ChartDataSupport;
035:        import com.klg.jclass.chart.ChartDataEvent;
036:        import com.klg.jclass.chart.ChartDataManageable;
037:        import com.klg.jclass.chart.ChartDataManager;
038:
039:        import org.cougaar.util.log.Logging;
040:        import org.cougaar.util.log.Logger;
041:
042:        import org.cougaar.logistics.plugin.inventory.LogisticsInventoryFormatter;
043:
044:        import org.cougaar.logistics.ui.inventory.data.InventoryData;
045:        import org.cougaar.logistics.ui.inventory.data.InventoryTask;
046:        import org.cougaar.logistics.ui.inventory.data.InventoryAR;
047:        import org.cougaar.logistics.ui.inventory.data.InventoryScheduleHeader;
048:        import org.cougaar.logistics.ui.inventory.data.InventoryScheduleElement;
049:
050:        import org.cougaar.util.TimeSpanSet;
051:
052:        /**
053:         * <pre>
054:         *
055:         * The RequisitionsChartDataModel is the ChartDataModel for the
056:         * all non projection tasks.   A Schedule of actuals and their
057:         * corresponding allocation results are given as the
058:         * values to compute into the x and y coordinates for the
059:         * chart.
060:         *
061:         *
062:         * @see InventoryBaseChartDataModel
063:         *
064:         **/
065:
066:        public class RequisitionsChartDataModel extends
067:                InventoryBaseChartDataModel {
068:
069:            protected String reqScheduleName;
070:            protected String reqARScheduleName;
071:
072:            public static final String REQUISITION_SERIES_LABEL = "Requisition";
073:            public static final String REQUISITION_ALLOCATION_SERIES_LABEL = "Requisition Response";
074:            public static final String REQUISITION_LEGEND = "";
075:
076:            public RequisitionsChartDataModel(String aReqScheduleName,
077:                    String aReqARScheduleName) {
078:                this (REQUISITION_LEGEND, aReqScheduleName, aReqARScheduleName);
079:            }
080:
081:            public RequisitionsChartDataModel(String legendTitle,
082:                    String reqSchedule, String reqARSchedule) {
083:                this (null, reqSchedule, reqARSchedule, legendTitle);
084:            }
085:
086:            public RequisitionsChartDataModel(InventoryData data,
087:                    String reqSchedule, String reqARSchedule,
088:                    String theLegendTitle) {
089:                inventory = data;
090:                legendTitle = theLegendTitle;
091:                reqScheduleName = reqSchedule;
092:                reqARScheduleName = reqARSchedule;
093:                nSeries = 2;
094:                scheduleNames = new String[2];
095:                scheduleNames[0] = reqScheduleName;
096:                scheduleNames[1] = reqARScheduleName;
097:                seriesLabels = new String[2];
098:                seriesLabels[0] = REQUISITION_SERIES_LABEL;
099:                seriesLabels[1] = REQUISITION_ALLOCATION_SERIES_LABEL;
100:                logger = Logging.getLogger(this );
101:                initValues();
102:            }
103:
104:            public void setValues() {
105:                if (valuesSet)
106:                    return;
107:                setRequisitionValues();
108:                valuesSet = true;
109:            }
110:
111:            public void setRequisitionValues() {
112:
113:                if (inventory == null) {
114:                    xvalues = new double[nSeries][0];
115:                    yvalues = new double[nSeries][0];
116:                    return;
117:                }
118:
119:                InventoryScheduleHeader schedHeader = (InventoryScheduleHeader) inventory
120:                        .getSchedules().get(reqScheduleName);
121:                ArrayList requisitions = schedHeader.getSchedule();
122:                schedHeader = (InventoryScheduleHeader) inventory
123:                        .getSchedules().get(reqARScheduleName);
124:                ArrayList reqARs = schedHeader.getSchedule();
125:
126:                computeCriticalNValues();
127:
128:                xvalues = new double[nSeries][nValues];
129:                yvalues = new double[nSeries][nValues];
130:                //initZeroYVal(nValues);
131:
132:                for (int i = 0; i < nSeries; i++) {
133:                    for (int j = 0; j < nValues; j++) {
134:                        xvalues[i][j] = minBucket + (j * bucketDays);
135:                        yvalues[i][j] = 0;
136:                    }
137:                }
138:
139:                for (int i = 0; i < requisitions.size(); i++) {
140:                    InventoryTask task = (InventoryTask) requisitions.get(i);
141:                    long endTime = task.getEndTime();
142:                    int endBucket = (int) computeBucketFromTime(endTime);
143:                    try {
144:                        yvalues[0][endBucket - minBucket] += (task.getQty() * unitFactor);
145:                    } catch (java.lang.ArrayIndexOutOfBoundsException ex) {
146:                        if (logger.isErrorEnabled()) {
147:                            logger.error("Whoa! endBucket is " + endBucket
148:                                    + " and minBucket is " + minBucket
149:                                    + " and maxBucket is " + maxBucket
150:                                    + " and the task at the " + i
151:                                    + "th place is " + task + " - startTime "
152:                                    + new Date(task.getStartTime())
153:                                    + " and the fatal end time is "
154:                                    + new Date(endTime));
155:                        }
156:                        throw ex;
157:                    }
158:                }
159:
160:                for (int i = 0; i < reqARs.size(); i++) {
161:                    InventoryAR ar = (InventoryAR) reqARs.get(i);
162:                    if (ar.isSuccess()) {
163:                        long endTime = ar.getEndTime();
164:                        int endBucket = (int) computeBucketFromTime(endTime);
165:                        yvalues[1][endBucket - minBucket] += (ar.getQty() * unitFactor);
166:                    }
167:                }
168:
169:                //MWD this is more expensive than it needs to be.
170:                //Cheaper to go through through all InventoryTasks
171:                //take the end time figure which day it goes into
172:                //and sum the value in the array bucket - same for
173:                //ARs - fix tommorow.  Probably don't even need
174:                //schedules for this.
175:
176:                /***
177:                 ** MWD Remove
178:
179:                 TimeSpanSet reqSchedule = new TimeSpanSet(requisitions);
180:                 TimeSpanSet reqARSchedule = new TimeSpanSet(reqARs);
181:
182:                 for(int i=minDay; i<=maxDay ; i+=bucketDays) {
183:                 long startTime = ((i * MILLIS_IN_DAY) + baseTime);
184:                 long endTime = (startTime + (bucketDays * MILLIS_IN_DAY)) - 1;
185:                 Collection reqs = reqSchdule.encapsulatedSet(startTime,endTime);
186:                 Collection reqARs = reqARSchdule.encapsulatedSet(startTime,endTime);
187:                 double totalReqs=0;
188:                 double totalARs=0;
189:                 Iterator it = reqs.iterator();
190:                 while(it.hasNext()) {
191:                 totalReqs+=(((InventoryTask) it.next()).getQty());
192:                 }
193:                 it = reqARs.iterator();
194:                 while(it.hasNext()) {
195:                 InventoryAR ar = ((InventoryAR) it.next());
196:                 if(ar.isSuccess()) {
197:                 totalARs+=ar.getQty();
198:                 }
199:                 }
200:                 yvalues[0][i-minDay] = totalReqs;
201:                 yvalues[1][i-minDay] = totalARs;
202:                 }
203:
204:                 ***/
205:            }
206:
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.