资源简介

包含SSM的环境配置和里面的增删查改功能,还有JFreeChart的柱状图,饼状图和折线图的实现。JFreeChart已经改成SSM的形式,实现了controller,service的分层,还把复杂的字体设置代码提取到了utils里面,使得controller层代码量大大减少。

资源截图

代码片段和文件信息

package com.jiancheng.controller;  

import javax.servlet.http.HttpServletRequest;  
import javax.servlet.http.HttpServletResponse;  
  
import org.jfree.chart.ChartColor;  
import org.jfree.chart.ChartFactory;  
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;  
import org.jfree.chart.plot.PlotOrientation;  
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.BarRenderer3D;
import org.jfree.chart.servlet.ServletUtilities;    
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.ui.TextAnchor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;  
import org.springframework.ui.ModelMap;  
import org.springframework.web.bind.annotation.RequestMapping;  
import org.springframework.web.servlet.ModelAndView;

import com.jiancheng.service.ChartService;
import com.jiancheng.utils.ChartFont;  
  
@Controller  
public class ChartContoller {  

private ChartFont chartFont = new ChartFont();

@Autowired
ChartService chartService;
      
    @RequestMapping(“/resultmap“)  
    public String resultmap(){  
        return “resultmap“;  
    }  
      
    //显示柱状图  
@RequestMapping(value = “/getColumnChart“)  
    public ModelAndView getColumnChart(HttpServletRequest requestHttpServletResponse response ModelMap modelMap) throws Exception{  
        //1. 获得数据集合  
        CategoryDataset dataset = chartService.getDataSet();  
        //2. 创建柱状图  
        JFreeChart chart = ChartFactory.createBarChart3D(“学生对教师授课满意度“ // 图表标题  
                “课程名“ // 目录轴的显示标签  
                “数目“ // 数值轴的显示标签  
                dataset // 数据集  
                PlotOrientation.VERTICAL // 图表方向:水平、垂直  
                false // 是否显示图例(对于简单的柱状图必须是false)  
                true // 是否生成工具  
                true // 是否生成URL链接  
                );  
        //3. 设置整个柱状图的颜色和文字(char对象的设置是针对整个图形的设置)  
        chart.setBackgroundPaint(ChartColor.WHITE); // 设置总的背景颜色  
        
        //4. 获得图形对象,并通过此对象对图形的颜色文字进行设置  
        CategoryPlot p = chart.getCategoryPlot();// 获得图表对象  
        BarRenderer3D renderer = new BarRenderer3D();//3D属性修改 
        renderer.setbaseItemLabelGenerator(new  StandardCategoryItemLabelGenerator());
        renderer.setbaseItemLabelsVisible( true ); 
        renderer.setbaseItemLabelPaint(ChartColor.DARK_GREEN);
        p.setBackgroundPaint(ChartColor.lightGray);//图形背景颜色  
        p.setRangeGridlinePaint(ChartColor.WHITE);//图形表格颜色  
        renderer.setbasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12 TextAnchor.CENTER_LEFT));
        renderer.setItemLabelAn

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件         586  2018-07-07 23:13  Reader me.txt
     目录           0  2018-06-26 00:18  ssm_demo_maven\
     文件        1445  2018-06-26 00:18  ssm_demo_maven\.classpath
     文件        1090  2018-06-26 00:18  ssm_demo_maven\.project
     目录           0  2018-06-26 00:18  ssm_demo_maven\.settings\
     文件         639  2018-06-26 00:18  ssm_demo_maven\.settings\.jsdtscope
     文件         430  2018-06-26 00:18  ssm_demo_maven\.settings\org.eclipse.jdt.core.prefs
     文件          90  2018-06-26 00:18  ssm_demo_maven\.settings\org.eclipse.m2e.core.prefs
     文件         767  2018-06-26 00:18  ssm_demo_maven\.settings\org.eclipse.wst.common.component
     文件         171  2018-06-26 00:18  ssm_demo_maven\.settings\org.eclipse.wst.common.project.facet.core.prefs.xml
     文件         300  2018-06-26 00:18  ssm_demo_maven\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2018-06-26 00:18  ssm_demo_maven\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2018-06-26 00:18  ssm_demo_maven\.settings\org.eclipse.wst.jsdt.ui.superType.name
     文件          50  2018-06-26 00:18  ssm_demo_maven\.settings\org.eclipse.wst.validation.prefs
     目录           0  2018-06-26 00:18  ssm_demo_maven\.svn\
     文件           3  2018-06-26 00:18  ssm_demo_maven\.svn\entries
     文件           3  2018-06-26 00:18  ssm_demo_maven\.svn\format
     目录           0  2018-07-07 23:07  ssm_demo_maven\.svn\pristine\
     目录           0  2018-06-26 00:18  ssm_demo_maven\.svn\pristine\01\
     文件         430  2018-06-26 00:18  ssm_demo_maven\.svn\pristine\01\01e1c466a5646cb9a6d6df069514558e54ed997f.svn-base
     目录           0  2018-06-26 00:18  ssm_demo_maven\.svn\pristine\13\
     文件        8511  2018-06-26 00:18  ssm_demo_maven\.svn\pristine\13\135842c3b84b78e2524ef6bd968e4d4d5a20f84d.svn-base
     目录           0  2018-06-26 00:18  ssm_demo_maven\.svn\pristine\14\
     文件        4347  2018-06-26 00:18  ssm_demo_maven\.svn\pristine\14\14d99416de9ceaf96da1c76f20234b3d3129e5d8.svn-base
     目录           0  2018-07-05 16:57  ssm_demo_maven\.svn\pristine\16\
     文件        4346  2018-07-05 16:57  ssm_demo_maven\.svn\pristine\16\1658b5901fa5250a08b840574fe97a0b4d133e48.svn-base
     目录           0  2018-07-05 16:57  ssm_demo_maven\.svn\pristine\1c\
     文件      256541  2018-07-05 16:57  ssm_demo_maven\.svn\pristine\1c\1c87fd4cd9e940a72582232ace1836808ce1502b.svn-base
     目录           0  2018-06-26 00:18  ssm_demo_maven\.svn\pristine\21\
     文件        1090  2018-06-26 00:18  ssm_demo_maven\.svn\pristine\21\216cdf672e60d4a280e00a7ffc682c4d5eaf7c5a.svn-base
     目录           0  2018-06-26 00:18  ssm_demo_maven\.svn\pristine\26\
............此处省略183个文件信息

评论

共有 条评论