Subversion Repositories bacoAlunos

Rev

Rev 1887 | Rev 1974 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1887 Rev 1927
Line 1... Line 1...
1
package pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components;
1
package pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.components;
2
 
2
 
3
import jomm.utils.BytesUtils;
3
import jomm.utils.BytesUtils;
4
import jomm.utils.MimeTypeGuesser;
4
import jomm.utils.MimeTypeGuesser;
-
 
5
import org.apache.log4j.Category;
5
import org.jfree.chart.ChartFactory;
6
import org.jfree.chart.ChartFactory;
-
 
7
import org.jfree.chart.ChartFrame;
6
import org.jfree.chart.JFreeChart;
8
import org.jfree.chart.JFreeChart;
-
 
9
import org.jfree.chart.axis.ValueAxis;
-
 
10
import org.jfree.chart.plot.CategoryPlot;
7
import org.jfree.chart.plot.PiePlot;
11
import org.jfree.chart.plot.PiePlot;
-
 
12
import org.jfree.chart.plot.PlotOrientation;
8
import org.jfree.chart.plot.RingPlot;
13
import org.jfree.chart.plot.RingPlot;
-
 
14
import org.jfree.data.category.DefaultCategoryDataset;
9
import org.jfree.data.general.DefaultPieDataset;
15
import org.jfree.data.general.DefaultPieDataset;
10
import pt.estgp.estgweb.services.courses.coursereport.documentmodel.CourseReportDocument;
16
import pt.estgp.estgweb.services.courses.coursereport.documentmodel.CourseReportDocument;
11
import pt.estgp.estgweb.utils.Globals;
17
import pt.estgp.estgweb.utils.Globals;
12
import pt.estgp.estgweb.utils.documentBuilder.ImageComponent;
18
import pt.estgp.estgweb.utils.documentBuilder.ImageComponent;
13
import pt.estgp.estgweb.web.controllers.utils.FileUploaded;
19
import pt.estgp.estgweb.web.controllers.utils.FileUploaded;
Line 16... Line 22...
16
import java.awt.*;
22
import java.awt.*;
17
import java.awt.image.BufferedImage;
23
import java.awt.image.BufferedImage;
18
import java.io.FileOutputStream;
24
import java.io.FileOutputStream;
19
import java.io.IOException;
25
import java.io.IOException;
20
 
26
 
-
 
27
 
21
/**
28
/**
22
 * Created by jorgemachado on 31/10/17.
29
 * Created by jorgemachado on 31/10/17.
23
 */
30
 */
24
public class GlobalLearningResultsChartImg extends ImageComponent
31
public class GlobalLearningResultsChartImg extends ImageComponent
25
{
32
{
Line 38... Line 45...
38
        double reprovadosPercent = ((int)(results.getReprovadosPercent()*100.0))/100.0;
45
        double reprovadosPercent = ((int)(results.getReprovadosPercent()*100.0))/100.0;
39
        double semElementosPercent = ((int)(results.getSemElementosPercent()*100.0))/100.0;
46
        double semElementosPercent = ((int)(results.getSemElementosPercent()*100.0))/100.0;
40
 
47
 
41
        1.5.0/docs/api/java/lang/String.html">String tempName = BytesUtils.generateHexKey() + ".png";
48
        1.5.0/docs/api/java/lang/String.html">String tempName = BytesUtils.generateHexKey() + ".png";
42
 
49
 
43
        DefaultPieDataset data = new DefaultPieDataset();
50
        DefaultCategoryDataset data = new DefaultCategoryDataset();
44
        if(reprovados > 0)
51
        if(reprovados > 0)
45
            data.setValue("Reprovados " + reprovadosPercent + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(reprovados));
52
            data.setValue(new 1.5.0/docs/api/java/lang/Double.html">Double(reprovados), "Reprovados " + reprovadosPercent + "%","Reprovados " + reprovadosPercent + "%" );
46
        if(aprovados > 0)
53
        if(aprovados > 0)
47
            data.setValue("Aprovados " + aprovadosPercent  + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(aprovados));
54
            data.setValue(new 1.5.0/docs/api/java/lang/Double.html">Double(aprovados),"Aprovados " + aprovadosPercent  + "%","Aprovados " + aprovadosPercent  + "%");
48
        if(semElementos > 0)
55
        if(semElementos > 0)
49
            data.setValue("Sem Elementos "  + semElementosPercent  + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(semElementos));
56
            data.setValue(new 1.5.0/docs/api/java/lang/Double.html">Double(semElementos),"Sem Elementos "  + semElementosPercent  + "%", "Sem Elementos "  + semElementosPercent  + "%");
-
 
57
 
-
 
58
        //Grafico Barras
50
        JFreeChart chart = ChartFactory.createRingChart(null, data, false, true, false);
59
        JFreeChart chart = ChartFactory.createBarChart(null, null,null,data, PlotOrientation.VERTICAL, true,true,false);
-
 
60
 
51
        chart.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255,255,255));
61
        chart.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255,255,255));
52
        PiePlot plot = (RingPlot) chart.getPlot();
-
 
53
        plot.setLabelBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 249, 235));
-
 
54
        plot.setLabelPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(88, 88, 90));
-
 
55
        //plot.setDrawingSupplier(new ChartBuilderUtil.ChartDrawingSupplier());
-
 
56
 
62
 
-
 
63
        CategoryPlot plot = chart.getCategoryPlot();
-
 
64
 
-
 
65
        plot.setRangeGridlinePaint(1.5.0/docs/api/java/awt/Color.html">Color.black);
-
 
66
 
-
 
67
        //plot.setDrawingSupplier(new ChartBuilderUtil.ChartDrawingSupplier());
-
 
68
        /*
57
        plot.setSectionPaint(0, new 1.5.0/docs/api/java/awt/Color.html">Color(255, 0, 0));
69
        plot.setSectionPaint(0, new Color(255, 0, 0));
58
        plot.setSectionPaint(1, new 1.5.0/docs/api/java/awt/Color.html">Color(15, 218, 10));
70
        plot.setSectionPaint(1, new Color(15, 218, 10));
59
        plot.setSectionPaint(2, new 1.5.0/docs/api/java/awt/Color.html">Color(200, 200, 200));
71
        plot.setSectionPaint(2, new Color(200, 200, 200));
60
        plot.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 255, 255));
72
        plot.setBackgroundPaint(new Color(255, 255, 255));
61
        plot.setOutlineVisible(false);
73
        plot.setOutlineVisible(false);
62
 
74
 
63
 
-
 
64
 
-
 
65
        plot.setLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
75
        plot.setLabelFont(new Font(
66
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 30));
76
                "Helvetica", Font.PLAIN, 30));
-
 
77
        */
67
 
78
 
-
 
79
        plot.getDomainAxis().setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 30));
68
 
80
 
69
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( 300*4, 200*4);
81
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( 300*4, 200*4);
70
        1.5.0/docs/api/java/lang/String.html">String pathGraficoTiposAlunos = Globals.TMP_DIR + java.io.1.5.0/docs/api/java/io/File.html">File.separator + tempName;
82
        1.5.0/docs/api/java/lang/String.html">String pathGraficoTiposAlunos = Globals.TMP_DIR + java.io.1.5.0/docs/api/java/io/File.html">File.separator + tempName;
71
        java.io.1.5.0/docs/api/java/io/File.html">File output = new java.io.1.5.0/docs/api/java/io/File.html">File(pathGraficoTiposAlunos);
83
        java.io.1.5.0/docs/api/java/io/File.html">File output = new java.io.1.5.0/docs/api/java/io/File.html">File(pathGraficoTiposAlunos);
72
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(output));
84
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(output));
Line 89... Line 101...
89
        double reprovadosPercent = ((int)2/16*100.0)/100.0;
101
        double reprovadosPercent = ((int)2/16*100.0)/100.0;
90
        double semElementosPercent = ((int)4/16*100.0)/100.0;
102
        double semElementosPercent = ((int)4/16*100.0)/100.0;
91
 
103
 
92
        1.5.0/docs/api/java/lang/String.html">String tempName = BytesUtils.generateHexKey() + ".png";
104
        1.5.0/docs/api/java/lang/String.html">String tempName = BytesUtils.generateHexKey() + ".png";
93
 
105
 
94
        DefaultPieDataset data = new DefaultPieDataset();
106
        DefaultCategoryDataset data = new DefaultCategoryDataset();
95
        if(reprovados > 0)
107
        if(reprovados > 0)
96
            data.setValue("Reprovados " + reprovadosPercent + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(reprovados));
108
            data.setValue(new 1.5.0/docs/api/java/lang/Double.html">Double(reprovados), "Reprovados " + reprovadosPercent + "%","Reprovados2 " + reprovadosPercent + "%" );
97
        if(aprovados > 0)
109
        if(aprovados > 0)
98
            data.setValue("Aprovados " + aprovadosPercent  + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(aprovados));
110
            data.setValue(new 1.5.0/docs/api/java/lang/Double.html">Double(aprovados),"Aprovados " + aprovadosPercent  + "%","Aprovados2 " + aprovadosPercent  + "%");
99
        if(semElementos > 0)
111
        if(semElementos > 0)
100
            data.setValue("Sem Elementos "  + semElementosPercent  + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(semElementos));
112
            data.setValue(new 1.5.0/docs/api/java/lang/Double.html">Double(semElementos),"Sem Elementos "  + semElementosPercent  + "%", "Sem Elementos2 "  + semElementosPercent  + "%");
-
 
113
 
-
 
114
        //Grafico Barras
101
        JFreeChart chart = ChartFactory.createRingChart(null, data, false, true, false);
115
        JFreeChart chart = ChartFactory.createBarChart(null, null,null,data, PlotOrientation.VERTICAL, true,true,false);
-
 
116
 
102
        chart.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255,255,255));
117
        chart.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255,255,255));
-
 
118
 
103
        PiePlot plot = (RingPlot) chart.getPlot();
119
        CategoryPlot plot = chart.getCategoryPlot();
-
 
120
 
-
 
121
        plot.setRangeGridlinePaint(1.5.0/docs/api/java/awt/Color.html">Color.black);
-
 
122
 
-
 
123
        ChartFrame chatFrm = new ChartFrame("APROVADOS",chart,true);
-
 
124
        chatFrm.setVisible(true);
-
 
125
        chatFrm.setSize(500,400);
-
 
126
 
-
 
127
        /*
104
        plot.setLabelBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 249, 235));
128
        plot.setLabelBackgroundPaint(new Color(255, 249, 235));
105
        plot.setLabelPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(88, 88, 90));
129
        plot.setLabelPaint(new Color(88, 88, 90));
106
        //plot.setDrawingSupplier(new ChartBuilderUtil.ChartDrawingSupplier());
130
        //plot.setDrawingSupplier(new ChartBuilderUtil.ChartDrawingSupplier());
107
 
131
 
108
        plot.setSectionPaint(0, new 1.5.0/docs/api/java/awt/Color.html">Color(255, 0, 0));
132
        plot.setSectionPaint(0, new Color(255, 0, 0));
Line 113... Line 137...
113
 
137
 
114
 
138
 
115
 
139
 
116
        plot.setLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
140
        plot.setLabelFont(new Font(
117
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 30));
141
                "Helvetica", Font.PLAIN, 30));
118
 
142
        */
119
 
143
 
120
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( 300*4, 200*4);
144
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( 300*4, 200*4);
121
        1.5.0/docs/api/java/lang/String.html">String pathGraficoTiposAlunos = Globals.TMP_DIR + java.io.1.5.0/docs/api/java/io/File.html">File.separator + tempName;
145
        1.5.0/docs/api/java/lang/String.html">String pathGraficoTiposAlunos = Globals.TMP_DIR + java.io.1.5.0/docs/api/java/io/File.html">File.separator + tempName;
122
        java.io.1.5.0/docs/api/java/io/File.html">File output = new java.io.1.5.0/docs/api/java/io/File.html">File(pathGraficoTiposAlunos);
146
        java.io.1.5.0/docs/api/java/io/File.html">File output = new java.io.1.5.0/docs/api/java/io/File.html">File(pathGraficoTiposAlunos);
123
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(output));
147
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(output));