Changeset 515
- Timestamp:
- 02/07/11 18:25:10 (2 years ago)
- Location:
- raptor-web/trunk/src/main
- Files:
-
- 2 edited
-
java/uk/ac/cardiff/raptorweb/engine/ChartProcessor.java (modified) (13 diffs)
-
webapp/WEB-INF/config/web-setup.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/engine/ChartProcessor.java
r511 r515 48 48 /** 49 49 * @author philsmart 50 * 50 * 51 51 * Takes a chart from the MUA, and wraps it inside the current graph view technologies (trinidad, JFreeChart) graph model 52 52 */ … … 65 65 /* options for how the graph is displayed */ 66 66 public enum GraphPresentation { 67 FANCY(true), SIMPLE (false);68 private boolean legend;69 GraphPresentation(boolean legend){ 70 this.legend=legend;71 }72 } 73 67 FANCY(true), SIMPLE(false); 68 private boolean legend; 69 70 GraphPresentation(boolean legend) { 71 this.legend = legend; 72 } 73 } 74 74 75 75 public String getRootDirectory(String user) { … … 116 116 /** 117 117 * Outputs into the users home directory in the parent graph directory 118 * 118 * 119 119 * @param gmodel 120 120 * @param session … … 128 128 /** 129 129 * Will output into the root graphs directory 130 * 130 * 131 131 * @param gmodel 132 132 * @return … … 138 138 /** 139 139 * Requires websession, as charts stored on file system specific to the current users home directory 140 * 140 * 141 141 * @param gmodel 142 142 * @param session … … 144 144 */ 145 145 private RaptorJFreeChartModel doConstructJFreeGraphBar(GraphPresentation graphPresentation, GraphType graphType, AggregatorGraphModel gmodel, String user, int width, int height) { 146 log.info("Creating graph {} with presentation {} (legend {}), width={} height={}", new Object[]{graphType,graphPresentation,graphPresentation.legend,width,height});146 log.info("Creating graph {} with presentation {} (legend {}), width={} height={}", new Object[] { graphType, graphPresentation, graphPresentation.legend, width, height }); 147 147 RaptorJFreeChartModel chartmodel = new RaptorJFreeChartModel(); 148 148 149 149 // construct the graph 150 150 DefaultCategoryDataset dataset = new DefaultCategoryDataset(); 151 151 log.info("Creating dataset with {} series and {} groups", gmodel.getSeriesLabels().size(), gmodel.getGroupLabels().size()); 152 152 for (int j = 0; j < gmodel.getSeriesLabels().size(); j++) { 153 153 for (int i = 0; i < gmodel.getGroupLabels().size(); i++) { 154 dataset.setValue(gmodel.getYValues().get( i).get(j), gmodel.getSeriesLabels().get(j), gmodel.getGroupLabels().get(i));154 dataset.setValue(gmodel.getYValues().get(j).get(i), gmodel.getSeriesLabels().get(j), gmodel.getGroupLabels().get(i)); 155 155 } 156 156 } 157 157 JFreeChart chart = null; 158 158 String chartTitle = ""; 159 String xAxisLabel = ""; 160 String yAxisLabel = ""; 161 if (gmodel.getPresentation() != null) { 162 if (gmodel.getPresentation().getGraphTitle() != null) 163 chartTitle = gmodel.getPresentation().getGraphTitle(); 164 if (gmodel.getPresentation().getxAxisLabel() != null) 165 xAxisLabel = gmodel.getPresentation().getxAxisLabel(); 166 if (gmodel.getPresentation().getyAxisLabel() != null) 167 yAxisLabel = gmodel.getPresentation().getyAxisLabel(); 168 } 169 170 log.debug("Graph Setup with Title {}, xAxisLabel {}, yAxisLabel {}", new Object[] { chartTitle, xAxisLabel, yAxisLabel }); 159 171 if (graphType == GraphType.BAR3D) 160 chart = ChartFactory.createBarChart3D( gmodel.getPresentation().getGraphTitle(), gmodel.getPresentation().getxAxisLabel(), gmodel.getPresentation().getyAxisLabel(), dataset, PlotOrientation.VERTICAL, graphPresentation.legend, true, false);172 chart = ChartFactory.createBarChart3D(chartTitle, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, graphPresentation.legend, true, false); 161 173 else if (graphType == GraphType.AREA) 162 chart = ChartFactory.createAreaChart( gmodel.getPresentation().getGraphTitle(), gmodel.getPresentation().getxAxisLabel(), gmodel.getPresentation().getyAxisLabel(), dataset, PlotOrientation.VERTICAL, graphPresentation.legend, true, false);174 chart = ChartFactory.createAreaChart(chartTitle, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, graphPresentation.legend, true, false); 163 175 else if (graphType == GraphType.LINE3D) 164 chart = ChartFactory.createLineChart3D( gmodel.getPresentation().getGraphTitle(), gmodel.getPresentation().getxAxisLabel(), gmodel.getPresentation().getyAxisLabel(), dataset, PlotOrientation.VERTICAL, graphPresentation.legend, true, false);176 chart = ChartFactory.createLineChart3D(chartTitle, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, graphPresentation.legend, true, false); 165 177 else if (graphType == GraphType.BAR) 166 chart = ChartFactory.createBarChart( gmodel.getPresentation().getGraphTitle(), gmodel.getPresentation().getxAxisLabel(), gmodel.getPresentation().getyAxisLabel(), dataset, PlotOrientation.VERTICAL, graphPresentation.legend, true, false);178 chart = ChartFactory.createBarChart(chartTitle, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, graphPresentation.legend, true, false); 167 179 else if (graphType == GraphType.LINE) 168 chart = ChartFactory.createLineChart(gmodel.getPresentation().getGraphTitle(), gmodel.getPresentation().getxAxisLabel(), gmodel.getPresentation().getyAxisLabel(), dataset, PlotOrientation.VERTICAL, graphPresentation.legend, true, false); 169 170 180 chart = ChartFactory.createLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, graphPresentation.legend, true, false); 181 171 182 // setup the graph output 172 183 if (graphPresentation == GraphPresentation.FANCY) … … 175 186 simpleGraphOutput(chart); 176 187 177 178 188 // save the graph 179 189 File chartLocation = new File(getRootDirectory(user) + "/raptor-graphs-main.svg"); … … 205 215 return chartmodel; 206 216 } 207 208 private void fancyGraphOutput(JFreeChart chart) {217 218 private void fancyGraphOutput(JFreeChart chart) { 209 219 CategoryPlot plot = (CategoryPlot) chart.getPlot(); 210 220 CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); … … 220 230 plot.setRangeGridlinePaint(Color.black); 221 231 plot.setDomainGridlinePaint(Color.black); 222 223 // axis232 233 // axis 224 234 CategoryAxis rangeAxis = (CategoryAxis) plot.getDomainAxis(); 225 235 rangeAxis.setUpperMargin(0.0); 226 236 rangeAxis.setLowerMargin(0.0); 227 228 } 229 230 private void simpleGraphOutput(JFreeChart chart) {237 238 } 239 240 private void simpleGraphOutput(JFreeChart chart) { 231 241 CategoryPlot plot = (CategoryPlot) chart.getPlot(); 232 242 CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); 233 243 xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); 234 // chart.setBackgroundPaint(new Color(255, 255, 255, 0));244 // chart.setBackgroundPaint(new Color(255, 255, 255, 0)); 235 245 chart.setPadding(new RectangleInsets(10, 5, 5, 5)); 236 246 plot.setBackgroundPaint(new Color(222, 222, 222, 125)); … … 239 249 plot.setRangeGridlinePaint(Color.black); 240 250 plot.setDomainGridlinePaint(Color.black); 241 242 // axis251 252 // axis 243 253 CategoryAxis rangeAxis = (CategoryAxis) plot.getDomainAxis(); 244 254 rangeAxis.setUpperMargin(0.0); 245 255 rangeAxis.setLowerMargin(0.0); 246 247 248 256 249 257 } … … 251 259 /** 252 260 * Exports a JFreeChart to a SVG file. 253 * 261 * 254 262 * @param chart 255 263 * JFreeChart to export … … 283 291 /** 284 292 * Exports a JFreeChart to a jpg file. 285 * 293 * 286 294 * @param chart 287 295 * JFreeChart to export … … 311 319 RaptorTableChartModel tableModel = new RaptorTableChartModel(); 312 320 313 for (int i = 0; i < gmodel.getGroupLabels().size(); i++) {314 Row<Double> row = new Row<Double>();315 row.setSeries(gmodel.getGroupLabels().get(i));316 /*317 * important, as currently we only operate with one group, the second list of Doubles in the YValues will only have a List of size 1, which is318 * assumed here, hence get(0).319 */320 row.setValue(gmodel.getYValues().get(i).get(0));321 tableModel.addRow(row);322 }321 // for (int i = 0; i < gmodel.getGroupLabels().size(); i++) { 322 // Row<Double> row = new Row<Double>(); 323 // row.setSeries(gmodel.getGroupLabels().get(i)); 324 // /* 325 // * important, as currently we only operate with one group, the second list of Doubles in the YValues will only have a List of size 1, which is 326 // * assumed here, hence get(0). 327 // */ 328 // row.setValue(gmodel.getYValues().get(i).get(0)); 329 // tableModel.addRow(row); 330 // } 323 331 324 332 return tableModel; -
raptor-web/trunk/src/main/webapp/WEB-INF/config/web-setup.xml
r511 r515 75 75 <property name="triggers"> 76 76 <list> 77 < ref local="SystemStatsQuickTrigger"/>77 <!-- <ref local="SystemStatsQuickTrigger"/>--> 78 78 </list> 79 79 </property>
Note: See TracChangeset
for help on using the changeset viewer.
