Changeset 515


Ignore:
Timestamp:
02/07/11 18:25:10 (2 years ago)
Author:
philsmart
Message:
 
Location:
raptor-web/trunk/src/main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/engine/ChartProcessor.java

    r511 r515  
    4848/** 
    4949 * @author philsmart 
    50  *  
     50 * 
    5151 *         Takes a chart from the MUA, and wraps it inside the current graph view technologies (trinidad, JFreeChart) graph model 
    5252 */ 
     
    6565    /* options for how the graph is displayed */ 
    6666    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    } 
    7474 
    7575    public String getRootDirectory(String user) { 
     
    116116    /** 
    117117     * Outputs into the users home directory in the parent graph directory 
    118      *  
     118     * 
    119119     * @param gmodel 
    120120     * @param session 
     
    128128    /** 
    129129     * Will output into the root graphs directory 
    130      *  
     130     * 
    131131     * @param gmodel 
    132132     * @return 
     
    138138    /** 
    139139     * Requires websession, as charts stored on file system specific to the current users home directory 
    140      *  
     140     * 
    141141     * @param gmodel 
    142142     * @param session 
     
    144144     */ 
    145145    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 }); 
    147147        RaptorJFreeChartModel chartmodel = new RaptorJFreeChartModel(); 
    148148 
    149149        // construct the graph 
    150150        DefaultCategoryDataset dataset = new DefaultCategoryDataset(); 
    151  
     151        log.info("Creating dataset with {} series and {} groups", gmodel.getSeriesLabels().size(), gmodel.getGroupLabels().size()); 
    152152        for (int j = 0; j < gmodel.getSeriesLabels().size(); j++) { 
    153153            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)); 
    155155            } 
    156156        } 
    157157        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 }); 
    159171        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); 
    161173        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); 
    163175        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); 
    165177        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); 
    167179        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 
    171182        // setup the graph output 
    172183        if (graphPresentation == GraphPresentation.FANCY) 
     
    175186            simpleGraphOutput(chart); 
    176187 
    177          
    178188        // save the graph 
    179189        File chartLocation = new File(getRootDirectory(user) + "/raptor-graphs-main.svg"); 
     
    205215        return chartmodel; 
    206216    } 
    207      
    208     private void fancyGraphOutput(JFreeChart chart){ 
     217 
     218    private void fancyGraphOutput(JFreeChart chart) { 
    209219        CategoryPlot plot = (CategoryPlot) chart.getPlot(); 
    210220        CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); 
     
    220230        plot.setRangeGridlinePaint(Color.black); 
    221231        plot.setDomainGridlinePaint(Color.black); 
    222          
    223         //axis 
     232 
     233        // axis 
    224234        CategoryAxis rangeAxis = (CategoryAxis) plot.getDomainAxis(); 
    225235        rangeAxis.setUpperMargin(0.0); 
    226236        rangeAxis.setLowerMargin(0.0); 
    227          
    228     } 
    229      
    230     private void simpleGraphOutput(JFreeChart chart){ 
     237 
     238    } 
     239 
     240    private void simpleGraphOutput(JFreeChart chart) { 
    231241        CategoryPlot plot = (CategoryPlot) chart.getPlot(); 
    232242        CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); 
    233243        xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); 
    234         //chart.setBackgroundPaint(new Color(255, 255, 255, 0)); 
     244        // chart.setBackgroundPaint(new Color(255, 255, 255, 0)); 
    235245        chart.setPadding(new RectangleInsets(10, 5, 5, 5)); 
    236246        plot.setBackgroundPaint(new Color(222, 222, 222, 125)); 
     
    239249        plot.setRangeGridlinePaint(Color.black); 
    240250        plot.setDomainGridlinePaint(Color.black); 
    241          
    242         //axis 
     251 
     252        // axis 
    243253        CategoryAxis rangeAxis = (CategoryAxis) plot.getDomainAxis(); 
    244254        rangeAxis.setUpperMargin(0.0); 
    245255        rangeAxis.setLowerMargin(0.0); 
    246          
    247          
    248256 
    249257    } 
     
    251259    /** 
    252260     * Exports a JFreeChart to a SVG file. 
    253      *  
     261     * 
    254262     * @param chart 
    255263     *            JFreeChart to export 
     
    283291    /** 
    284292     * Exports a JFreeChart to a jpg file. 
    285      *  
     293     * 
    286294     * @param chart 
    287295     *            JFreeChart to export 
     
    311319        RaptorTableChartModel tableModel = new RaptorTableChartModel(); 
    312320 
    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 is 
    318             * 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        // } 
    323331 
    324332        return tableModel; 
  • raptor-web/trunk/src/main/webapp/WEB-INF/config/web-setup.xml

    r511 r515  
    7575                <property name="triggers"> 
    7676                        <list> 
    77                         <ref local="SystemStatsQuickTrigger"/> 
     77                        <!-- <ref local="SystemStatsQuickTrigger"/>--> 
    7878                        </list> 
    7979                </property> 
Note: See TracChangeset for help on using the changeset viewer.