Source Code Cross Referenced for ChartProxy.java in  » Test-Coverage » salome-tmf » salomeTMF_plug » requirements » data » 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 » Test Coverage » salome tmf » salomeTMF_plug.requirements.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package salomeTMF_plug.requirements.data;
002:
003:        import java.io.File;
004:        import java.io.IOException;
005:        import java.util.Enumeration;
006:        import java.util.Hashtable;
007:        import java.util.Vector;
008:
009:        import org.jfree.chart.ChartFactory;
010:        import org.jfree.chart.ChartUtilities;
011:        import org.jfree.chart.JFreeChart;
012:        import org.jfree.chart.plot.PiePlot3D;
013:        import org.jfree.data.general.DefaultPieDataset;
014:        import org.jfree.util.Rotation;
015:        import org.objectweb.salome_tmf.api.ApiConstants;
016:        import org.objectweb.salome_tmf.data.Campaign;
017:        import org.objectweb.salome_tmf.data.ExecutionResult;
018:        import org.objectweb.salome_tmf.ihm.languages.Language;
019:
020:        import salomeTMF_plug.requirements.sqlWrapper.ReqWrapper;
021:        import salomeTMF_plug.requirements.sqlWrapper.SQLWrapper;
022:
023:        public class ChartProxy {
024:
025:            static public void saveChartAsJPEG(JFreeChart chart, File file) {
026:                try {
027:                    ChartUtilities.saveChartAsJPEG(file, chart, 500, 300);
028:                } catch (IOException e) {
029:
030:                }
031:            }
032:
033:            /**
034:             * Provide a chart representing a pie of requirements covered by Tests
035:             * @param filtre 
036:             * @return
037:             */
038:            public static JFreeChart getCoveredReqChart(int filtre) {
039:                PiePlot3D plot;
040:                DefaultPieDataset dataset;
041:                dataset = new DefaultPieDataset();
042:                JFreeChart chart = ChartFactory.createPieChart3D(Language
043:                        .getInstance().getText("Exigence_couverte"), // chart title
044:                        dataset, // data
045:                        true, // include legend
046:                        true, false);
047:
048:                plot = (PiePlot3D) chart.getPlot();
049:                plot.setStartAngle(290);
050:                plot.setDirection(Rotation.CLOCKWISE);
051:                plot.setForegroundAlpha(0.5f);
052:
053:                try {
054:                    int nbTotalReq = 1;
055:                    int nbCoveredReq = 0;
056:                    if (filtre > 0) {
057:                        Vector leafInCurrentProject = Requirement
058:                                .getReqWrapperLeafInCurrentProject();
059:                        nbTotalReq = leafInCurrentProject.size();
060:
061:                        Vector reqWrapperCovered = Requirement
062:                                .getReqWrapperCovered();
063:                        nbCoveredReq = reqWrapperCovered.size();
064:                        if (filtre != 111) {
065:                            int nbTotalReq2 = 0;
066:                            for (int i = 0; i < nbTotalReq; i++) {
067:                                int reqP = ((ReqWrapper) leafInCurrentProject
068:                                        .elementAt(i)).getPriority();
069:                                if ((reqP & filtre) > 0) {
070:                                    nbTotalReq2++;
071:                                }
072:                            }
073:                            int nbCoveredReq2 = 0;
074:                            for (int i = 0; i < nbCoveredReq; i++) {
075:                                int reqP = ((ReqWrapper) reqWrapperCovered
076:                                        .elementAt(i)).getPriority();
077:                                if ((reqP & filtre) > 0) {
078:                                    nbCoveredReq2++;
079:                                }
080:                            }
081:                            nbTotalReq = nbTotalReq2;
082:                            nbCoveredReq = nbCoveredReq2;
083:                        }
084:                    }
085:                    if (nbTotalReq > 0) {
086:                        Double nbCovered = new Double((nbCoveredReq * 100)
087:                                / nbTotalReq);
088:                        Double nbNotCovered = new Double(100
089:                                - (nbCoveredReq * 100) / nbTotalReq);
090:                        dataset.setValue(Language.getInstance().getText(
091:                                "Exigence_non_couverte"), nbNotCovered);
092:                        dataset.setValue(Language.getInstance().getText(
093:                                "Exigence_couverte"), nbCovered);
094:                        plot.setDataset(dataset);
095:                    }
096:
097:                } catch (Exception e) {
098:
099:                }
100:
101:                return chart;
102:            }
103:
104:            /**
105:             * Provide a chart representing a pie of requirements covered by a campaing
106:             * @param pCamp
107:             * @param filtre
108:             * @return
109:             */
110:            public static JFreeChart getCoveredCampChart(Campaign pCamp,
111:                    int filtre) {
112:                PiePlot3D plot;
113:                DefaultPieDataset dataset = new DefaultPieDataset();
114:                JFreeChart chart = ChartFactory.createPieChart3D(Language
115:                        .getInstance().getText("Exigence_couverte"), // chart title
116:                        dataset, // data
117:                        true, // include legend
118:                        true, false);
119:                plot = (PiePlot3D) chart.getPlot();
120:                plot.setStartAngle(290);
121:                plot.setDirection(Rotation.CLOCKWISE);
122:                plot.setForegroundAlpha(0.5f);
123:
124:                Vector reqCoveredWrapper;
125:                Vector filtredreqCovered = new Vector();
126:                int nbReqTotal = 0;
127:                int transNumber = -1;
128:                try {
129:                    transNumber = SQLWrapper.beginTransaction();
130:                    reqCoveredWrapper = Requirement
131:                            .getReqWrapperCoveredByCamp(pCamp.getIdBdd());
132:                    int size = reqCoveredWrapper.size();
133:                    for (int j = 0; j < size; j++) {
134:                        ReqWrapper pReqWrapper = (ReqWrapper) reqCoveredWrapper
135:                                .elementAt(j);
136:                        if (pReqWrapper.getType() == 1) {
137:                            if (!filtredreqCovered.contains(pReqWrapper)) {
138:                                int reqP = pReqWrapper.getPriority();
139:                                if ((reqP & filtre) > 0) {
140:                                    filtredreqCovered.add(pReqWrapper);
141:                                }
142:                            }
143:                        }
144:                    }
145:                    int nbReqCovered = filtredreqCovered.size();
146:                    try {
147:                        nbReqTotal = Requirement
148:                                .getReqWrapperLeafInCurrentProject().size();
149:
150:                    } catch (Exception e) {
151:                        nbReqTotal = 0;
152:                    }
153:
154:                    dataset = new DefaultPieDataset();
155:                    if (nbReqTotal > 0) {
156:                        Double nbCovered = new Double((nbReqCovered * 100)
157:                                / nbReqTotal);
158:                        Double nbNotCovered = new Double(100
159:                                - (nbReqCovered * 100) / nbReqTotal);
160:                        dataset.setValue(Language.getInstance().getText(
161:                                "Exigence_non_couverte"), nbNotCovered);
162:                        dataset.setValue(Language.getInstance().getText(
163:                                "Exigence_couverte"), nbCovered);
164:                    }
165:                    plot.setDataset(dataset);
166:
167:                    SQLWrapper.commitTrans(transNumber);
168:                } catch (Exception e) {
169:                    try {
170:                        SQLWrapper.rollBackTrans(transNumber);
171:                    } catch (Exception e1) {
172:                    }
173:                    return null;
174:                }
175:                return chart;
176:            }
177:
178:            /**
179:             * Provide a chart representing a pie of requirements satisfaction in a execution result
180:             * @param executionResult
181:             * @param filtre
182:             * @return
183:             */
184:            public static JFreeChart getExecutionResultChart(
185:                    ExecutionResult executionResult, int filtre) {
186:                Hashtable allReq = new Hashtable();
187:                PiePlot3D plot;
188:                DefaultPieDataset dataset = new DefaultPieDataset();
189:                JFreeChart chart = ChartFactory.createPieChart3D(Language
190:                        .getInstance().getText("Exigence_Pass"), // chart title
191:                        dataset, // data
192:                        true, // include legend
193:                        true, false);
194:
195:                plot = (PiePlot3D) chart.getPlot();
196:                plot.setStartAngle(290);
197:                plot.setDirection(Rotation.CLOCKWISE);
198:                plot.setForegroundAlpha(0.5f);
199:
200:                try {
201:                    Vector reqPass = new Vector();
202:                    Vector reqFail = new Vector();
203:                    Vector reqInco = new Vector();
204:
205:                    reqPass = Requirement.getReqWrapperInExecByStatus(
206:                            executionResult.getIdBdd(), ApiConstants.SUCCESS);
207:                    reqFail = Requirement.getReqWrapperInExecByStatus(
208:                            executionResult.getIdBdd(), ApiConstants.FAIL);
209:                    reqInco = Requirement.getReqWrapperInExecByStatus(
210:                            executionResult.getIdBdd(), ApiConstants.UNKNOWN);
211:                    int sizePass = reqPass.size();
212:                    int sizeFail = reqFail.size();
213:                    int sizeInco = reqInco.size();
214:
215:                    allReq.clear();
216:
217:                    for (int i = 0; i < sizePass; i++) {
218:                        ReqWrapper pReqWrapper = (ReqWrapper) reqPass
219:                                .elementAt(i);
220:                        allReq.put(pReqWrapper, ApiConstants.SUCCESS);
221:
222:                    }
223:                    for (int i = 0; i < sizeInco; i++) {
224:                        ReqWrapper pReqWrapper = (ReqWrapper) reqInco
225:                                .elementAt(i);
226:                        allReq.put(pReqWrapper, ApiConstants.UNKNOWN);
227:
228:                    }
229:                    for (int i = 0; i < sizeFail; i++) {
230:                        ReqWrapper pReqWrapper = (ReqWrapper) reqFail
231:                                .elementAt(i);
232:                        allReq.put(pReqWrapper, ApiConstants.FAIL);
233:                    }
234:                    Enumeration enumReq = allReq.keys();
235:                    int nbFail = 0;
236:                    int nbPass = 0;
237:                    int nbInco = 0;
238:
239:                    while (enumReq.hasMoreElements()) {
240:                        ReqWrapper pReqWrapper = (ReqWrapper) enumReq
241:                                .nextElement();
242:                        int reqP = pReqWrapper.getPriority();
243:                        if ((reqP & filtre) > 0) {
244:                            String status = (String) allReq.get(pReqWrapper);
245:                            if (status.equals(ApiConstants.SUCCESS)) {
246:                                nbPass++;
247:                            } else if (status.equals(ApiConstants.FAIL)) {
248:                                nbFail++;
249:                            } else {
250:                                nbInco++;
251:                            }
252:
253:                        }
254:                    }
255:
256:                    int nbReqTotal = nbFail + nbPass + nbInco;
257:
258:                    dataset = new DefaultPieDataset();
259:                    if (nbReqTotal > 0) {
260:                        Double percentPass = new Double((nbPass * 100)
261:                                / nbReqTotal);
262:                        Double percentFail = new Double((nbFail * 100)
263:                                / nbReqTotal);
264:                        Double percentInco = new Double((nbInco * 100)
265:                                / nbReqTotal);
266:                        dataset.setValue(Language.getInstance().getText(
267:                                "Exigence_Fail"), percentFail);
268:                        dataset.setValue(Language.getInstance().getText(
269:                                "Exigence_Inco"), percentInco);
270:                        dataset.setValue(Language.getInstance().getText(
271:                                "Exigence_Pass"), percentPass);
272:                    }
273:                    plot.setDataset(dataset);
274:
275:                } catch (Exception e) {
276:                    e.printStackTrace();
277:                }
278:                return chart;
279:            }
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.