Subversion Repositories bacoAlunos

Rev

Rev 1571 | Rev 1576 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1571 Rev 1574
1
package pt.estgp.estgweb.services.questionarios.utils;
1
package pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils;
2
 
2
 
3
import org.apache.log4j.Logger;
3
import org.apache.log4j.Logger;
4
import org.jfree.chart.ChartFactory;
4
import org.jfree.chart.ChartFactory;
5
import org.jfree.chart.ChartRenderingInfo;
5
import org.jfree.chart.ChartRenderingInfo;
6
import org.jfree.chart.ChartUtilities;
6
import org.jfree.chart.ChartUtilities;
7
import org.jfree.chart.JFreeChart;
7
import org.jfree.chart.JFreeChart;
8
import org.jfree.chart.axis.*;
8
import org.jfree.chart.axis.*;
9
import org.jfree.chart.entity.StandardEntityCollection;
9
import org.jfree.chart.entity.StandardEntityCollection;
10
import org.jfree.chart.labels.*;
10
import org.jfree.chart.labels.*;
11
import org.jfree.chart.plot.*;
11
import org.jfree.chart.plot.*;
12
import org.jfree.chart.renderer.category.BarRenderer;
12
import org.jfree.chart.renderer.category.BarRenderer;
13
import org.jfree.chart.renderer.xy.XYDifferenceRenderer;
13
import org.jfree.chart.renderer.xy.XYDifferenceRenderer;
14
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
14
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
15
import org.jfree.chart.title.TextTitle;
15
import org.jfree.chart.title.TextTitle;
16
import org.jfree.chart.title.Title;
16
import org.jfree.chart.title.Title;
17
import org.jfree.data.category.CategoryDataset;
17
import org.jfree.data.category.CategoryDataset;
18
import org.jfree.data.category.DefaultCategoryDataset;
18
import org.jfree.data.category.DefaultCategoryDataset;
19
import org.jfree.data.general.DefaultPieDataset;
19
import org.jfree.data.general.DefaultPieDataset;
20
import org.jfree.data.general.DefaultValueDataset;
20
import org.jfree.data.general.DefaultValueDataset;
21
import org.jfree.data.time.Day;
21
import org.jfree.data.time.Day;
22
import org.jfree.data.time.TimeSeries;
22
import org.jfree.data.time.TimeSeries;
23
import org.jfree.data.time.TimeSeriesCollection;
23
import org.jfree.data.time.TimeSeriesCollection;
24
import org.jfree.data.time.Week;
24
import org.jfree.data.time.Week;
25
import org.jfree.data.xy.XYDataset;
25
import org.jfree.data.xy.XYDataset;
26
import org.jfree.ui.HorizontalAlignment;
26
import org.jfree.ui.HorizontalAlignment;
27
import org.jfree.ui.TextAnchor;
27
import org.jfree.ui.TextAnchor;
28
import org.jfree.util.ShapeUtilities;
28
import org.jfree.util.ShapeUtilities;
29
import pt.estgp.estgweb.Globals;
29
import pt.estgp.estgweb.Globals;
30
import pt.estgp.estgweb.services.questionarios.pedagogico.QuestionariosAlunosReport;
30
import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.reportsdomain.QuestionariosAlunosReport;
31
import pt.estgp.estgweb.services.questionarios.pedagogico.QuestionariosReport;
31
import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.reportsdomain.QuestionariosReport;
32
 
32
 
33
import javax.imageio.ImageIO;
33
import javax.imageio.ImageIO;
34
import java.awt.*;
34
import java.awt.*;
35
import java.awt.image.BufferedImage;
35
import java.awt.image.BufferedImage;
36
import java.io.File;
36
import java.io.File;
37
import java.io.FileOutputStream;
37
import java.io.FileOutputStream;
38
import java.io.IOException;
38
import java.io.IOException;
39
import java.text.DecimalFormat;
39
import java.text.DecimalFormat;
40
import java.text.NumberFormat;
40
import java.text.NumberFormat;
41
import java.text.SimpleDateFormat;
41
import java.text.SimpleDateFormat;
42
import java.util.ArrayList;
42
import java.util.ArrayList;
43
import java.util.Date;
43
import java.util.Date;
44
 
44
 
45
/**
45
/**
46
 * Created by jorgemachado on 28/11/16.
46
 * Created by jorgemachado on 28/11/16.
47
 */
47
 */
48
public class ChartBuilderUtil
48
public class ChartBuilderUtil
49
{
49
{
50
 
50
 
51
    private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(ChartBuilderUtil.class);
51
    private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(ChartBuilderUtil.class);
52
 
52
 
53
    public static 1.5.0/docs/api/java/awt/Color.html">Color GREEN_OK = new 1.5.0/docs/api/java/awt/Color.html">Color(223,253,184);
53
    public static 1.5.0/docs/api/java/awt/Color.html">Color GREEN_OK = new 1.5.0/docs/api/java/awt/Color.html">Color(223,253,184);
54
    public static 1.5.0/docs/api/java/awt/Color.html">Color RED_NOT_OK = new 1.5.0/docs/api/java/awt/Color.html">Color(255,200, 164);
54
    public static 1.5.0/docs/api/java/awt/Color.html">Color RED_NOT_OK = new 1.5.0/docs/api/java/awt/Color.html">Color(255,200, 164);
55
    public static 1.5.0/docs/api/java/awt/Color.html">Color NEUTRAL_TOTAL = new 1.5.0/docs/api/java/awt/Color.html">Color(83,83,84);
55
    public static 1.5.0/docs/api/java/awt/Color.html">Color NEUTRAL_TOTAL = new 1.5.0/docs/api/java/awt/Color.html">Color(83,83,84);
56
 
56
 
57
 
57
 
58
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_BLUE = new 1.5.0/docs/api/java/awt/Color.html">Color(178,230,254);
58
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_BLUE = new 1.5.0/docs/api/java/awt/Color.html">Color(178,230,254);
59
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_BLUE_DARK = new 1.5.0/docs/api/java/awt/Color.html">Color(82, 162,254);
59
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_BLUE_DARK = new 1.5.0/docs/api/java/awt/Color.html">Color(82, 162,254);
60
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_GREEN = new 1.5.0/docs/api/java/awt/Color.html">Color(221,253,177);
60
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_GREEN = new 1.5.0/docs/api/java/awt/Color.html">Color(221,253,177);
61
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_GREEN_DARK = new 1.5.0/docs/api/java/awt/Color.html">Color(130,253, 89);
61
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_GREEN_DARK = new 1.5.0/docs/api/java/awt/Color.html">Color(130,253, 89);
62
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_ROSE = new 1.5.0/docs/api/java/awt/Color.html">Color(255, 157, 169);
62
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_ROSE = new 1.5.0/docs/api/java/awt/Color.html">Color(255, 157, 169);
63
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_ROSE_DARK = new 1.5.0/docs/api/java/awt/Color.html">Color(223, 116, 128);
63
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_ROSE_DARK = new 1.5.0/docs/api/java/awt/Color.html">Color(223, 116, 128);
64
 
64
 
65
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_DIM = new 1.5.0/docs/api/java/awt/Color.html">Color(255, 200, 237);
65
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_DIM = new 1.5.0/docs/api/java/awt/Color.html">Color(255, 200, 237);
66
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_DIM_DARK = new 1.5.0/docs/api/java/awt/Color.html">Color(255, 86, 241);
66
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_SECTION_DIM_DARK = new 1.5.0/docs/api/java/awt/Color.html">Color(255, 86, 241);
67
 
67
 
68
 
68
 
69
    public static 1.5.0/docs/api/java/awt/Color.html">Color TRANSPARENT = new 1.5.0/docs/api/java/awt/Color.html">Color(0xFF, 0xFF, 0xFF, 0);
69
    public static 1.5.0/docs/api/java/awt/Color.html">Color TRANSPARENT = new 1.5.0/docs/api/java/awt/Color.html">Color(0xFF, 0xFF, 0xFF, 0);
70
 
70
 
71
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_1 = new 1.5.0/docs/api/java/awt/Color.html">Color(253, 11, 0);
71
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_1 = new 1.5.0/docs/api/java/awt/Color.html">Color(253, 11, 0);
72
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_2 = new 1.5.0/docs/api/java/awt/Color.html">Color(255, 190, 0);
72
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_2 = new 1.5.0/docs/api/java/awt/Color.html">Color(255, 190, 0);
73
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_3 = new 1.5.0/docs/api/java/awt/Color.html">Color(255, 254, 0);
73
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_3 = new 1.5.0/docs/api/java/awt/Color.html">Color(255, 254, 0);
74
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_4 = new 1.5.0/docs/api/java/awt/Color.html">Color(188, 255, 0);
74
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_4 = new 1.5.0/docs/api/java/awt/Color.html">Color(188, 255, 0);
75
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_5 = new 1.5.0/docs/api/java/awt/Color.html">Color(32, 255, 5);
75
    public static 1.5.0/docs/api/java/awt/Color.html">Color COLOR_5 = new 1.5.0/docs/api/java/awt/Color.html">Color(32, 255, 5);
76
 
76
 
77
    public static 1.5.0/docs/api/java/lang/String.html">String COLOR_1_HEX = 1.5.0/docs/api/java/lang/String.html">String.format("#%02x%02x%02x", 253, 11, 0);
77
    public static 1.5.0/docs/api/java/lang/String.html">String COLOR_1_HEX = 1.5.0/docs/api/java/lang/String.html">String.format("#%02x%02x%02x", 253, 11, 0);
78
    public static 1.5.0/docs/api/java/lang/String.html">String COLOR_2_HEX = 1.5.0/docs/api/java/lang/String.html">String.format("#%02x%02x%02x", 255, 190, 0);
78
    public static 1.5.0/docs/api/java/lang/String.html">String COLOR_2_HEX = 1.5.0/docs/api/java/lang/String.html">String.format("#%02x%02x%02x", 255, 190, 0);
79
    public static 1.5.0/docs/api/java/lang/String.html">String COLOR_3_HEX = 1.5.0/docs/api/java/lang/String.html">String.format("#%02x%02x%02x", 255, 254, 0);
79
    public static 1.5.0/docs/api/java/lang/String.html">String COLOR_3_HEX = 1.5.0/docs/api/java/lang/String.html">String.format("#%02x%02x%02x", 255, 254, 0);
80
    public static 1.5.0/docs/api/java/lang/String.html">String COLOR_4_HEX = 1.5.0/docs/api/java/lang/String.html">String.format("#%02x%02x%02x", 188, 255, 0);
80
    public static 1.5.0/docs/api/java/lang/String.html">String COLOR_4_HEX = 1.5.0/docs/api/java/lang/String.html">String.format("#%02x%02x%02x", 188, 255, 0);
81
    public static 1.5.0/docs/api/java/lang/String.html">String COLOR_5_HEX = 1.5.0/docs/api/java/lang/String.html">String.format("#%02x%02x%02x", 32, 255, 5);
81
    public static 1.5.0/docs/api/java/lang/String.html">String COLOR_5_HEX = 1.5.0/docs/api/java/lang/String.html">String.format("#%02x%02x%02x", 32, 255, 5);
82
 
82
 
83
    /**
83
    /**
84
     * Util to create Bar Charts
84
     * Util to create Bar Charts
85
     *
85
     *
86
     * @param pergunta
86
     * @param pergunta
87
     * @param respostas
87
     * @param respostas
88
     * @param pathTmp
88
     * @param pathTmp
89
     * @return
89
     * @return
90
     * @throws java.io.IOException
90
     * @throws java.io.IOException
91
     */
91
     */
92
    public static PerguntaStats createChartRespostasPergunta(1.5.0/docs/api/java/lang/String.html">String pergunta,java.util.List<String> subtitles, int[] respostas, 1.5.0/docs/api/java/lang/String.html">String pathTmp,int maxValue) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
92
    public static PerguntaStats createChartRespostasPergunta(1.5.0/docs/api/java/lang/String.html">String pergunta,java.util.List<String> subtitles, int[] respostas, 1.5.0/docs/api/java/lang/String.html">String pathTmp,int maxValue) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
93
        //TESTE BARRAS LATERAIS
93
        //TESTE BARRAS LATERAIS
94
 
94
 
95
        DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();
95
        DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();
96
 
96
 
97
 
97
 
98
        categoryDataset.addValue(respostas[0]," 1    ",pergunta);
98
        categoryDataset.addValue(respostas[0]," 1    ",pergunta);
99
        categoryDataset.addValue(respostas[1]," 2    ",pergunta);
99
        categoryDataset.addValue(respostas[1]," 2    ",pergunta);
100
        categoryDataset.addValue(respostas[2]," 3    ",pergunta);
100
        categoryDataset.addValue(respostas[2]," 3    ",pergunta);
101
        categoryDataset.addValue(respostas[3]," 4    ",pergunta);
101
        categoryDataset.addValue(respostas[3]," 4    ",pergunta);
102
        categoryDataset.addValue(respostas[4]," 5    ",pergunta);
102
        categoryDataset.addValue(respostas[4]," 5    ",pergunta);
103
 
103
 
104
 
104
 
105
 
105
 
106
        JFreeChart chart = ChartFactory.createBarChart(pergunta, "", "Respostas", categoryDataset, PlotOrientation.VERTICAL, true, false, false);
106
        JFreeChart chart = ChartFactory.createBarChart(pergunta, "", "Respostas", categoryDataset, PlotOrientation.VERTICAL, true, false, false);
107
        chart.setBorderVisible(false);
107
        chart.setBorderVisible(false);
108
 
108
 
109
        chart.setTitle(new TextTitle(pergunta,new 1.5.0/docs/api/java/awt/Font.html">Font("Helvetica",1.5.0/docs/api/java/awt/Font.html">Font.BOLD, 40)));
109
        chart.setTitle(new TextTitle(pergunta,new 1.5.0/docs/api/java/awt/Font.html">Font("Helvetica",1.5.0/docs/api/java/awt/Font.html">Font.BOLD, 40)));
110
 
110
 
111
        java.util.List<Title> subTitles = new ArrayList<Title>();
111
        java.util.List<Title> subTitles = new ArrayList<Title>();
112
        for(1.5.0/docs/api/java/lang/String.html">String subtitle: subtitles)
112
        for(1.5.0/docs/api/java/lang/String.html">String subtitle: subtitles)
113
        {
113
        {
114
            TextTitle t = new TextTitle(subtitle,new 1.5.0/docs/api/java/awt/Font.html">Font(
114
            TextTitle t = new TextTitle(subtitle,new 1.5.0/docs/api/java/awt/Font.html">Font(
115
                    "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 40));
115
                    "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 40));
116
            t.setHorizontalAlignment(HorizontalAlignment.LEFT);
116
            t.setHorizontalAlignment(HorizontalAlignment.LEFT);
117
            chart.addSubtitle(t);
117
            chart.addSubtitle(t);
118
        }
118
        }
119
 
119
 
120
 
120
 
121
 
121
 
122
        chart.setAntiAlias(true);
122
        chart.setAntiAlias(true);
123
        chart.setTextAntiAlias(true);
123
        chart.setTextAntiAlias(true);
124
        CategoryPlot barChartPlot = (CategoryPlot) chart.getPlot();
124
        CategoryPlot barChartPlot = (CategoryPlot) chart.getPlot();
125
 
125
 
126
 
126
 
127
        //barChartPlot.getRangeAxis().setRange(0,100);
127
        //barChartPlot.getRangeAxis().setRange(0,100);
128
        //barChartPlot.setDrawingSupplier(new ChartDrawingSupplier());
128
        //barChartPlot.setDrawingSupplier(new ChartDrawingSupplier());
129
        barChartPlot.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 255, 255));
129
        barChartPlot.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 255, 255));
130
        //barChartPlot.setOutlineVisible(false);
130
        //barChartPlot.setOutlineVisible(false);
131
 
131
 
132
 
132
 
133
        barChartPlot.setRenderer(new BarRenderer()
133
        barChartPlot.setRenderer(new BarRenderer()
134
        {
134
        {
135
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemPaint(int row, int col) {
135
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemPaint(int row, int col) {
136
                switch (row){
136
                switch (row){
137
                    case 0:return COLOR_1 ;
137
                    case 0:return COLOR_1 ;
138
                    case 1: return COLOR_2;
138
                    case 1: return COLOR_2;
139
                    case 2:return COLOR_3 ;
139
                    case 2:return COLOR_3 ;
140
                    case 3:return COLOR_4 ;
140
                    case 3:return COLOR_4 ;
141
                    case 4:return COLOR_5 ;
141
                    case 4:return COLOR_5 ;
142
                    default: return NEUTRAL_TOTAL;
142
                    default: return NEUTRAL_TOTAL;
143
                }
143
                }
144
 
144
 
145
            }
145
            }
146
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemLabelPaint(int row, int col)
146
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemLabelPaint(int row, int col)
147
            {
147
            {
148
                switch (col){
148
                switch (col){
149
                    case 0:return 1.5.0/docs/api/java/awt/Color.html">Color.black ;
149
                    case 0:return 1.5.0/docs/api/java/awt/Color.html">Color.black ;
150
                    case 1:return 1.5.0/docs/api/java/awt/Color.html">Color.black ;
150
                    case 1:return 1.5.0/docs/api/java/awt/Color.html">Color.black ;
151
                    case 2:return 1.5.0/docs/api/java/awt/Color.html">Color.black ;
151
                    case 2:return 1.5.0/docs/api/java/awt/Color.html">Color.black ;
152
                    case 3:return 1.5.0/docs/api/java/awt/Color.html">Color.black ;
152
                    case 3:return 1.5.0/docs/api/java/awt/Color.html">Color.black ;
153
                    case 4: return 1.5.0/docs/api/java/awt/Color.html">Color.black;
153
                    case 4: return 1.5.0/docs/api/java/awt/Color.html">Color.black;
154
                    default: return 1.5.0/docs/api/java/awt/Color.html">Color.black;
154
                    default: return 1.5.0/docs/api/java/awt/Color.html">Color.black;
155
                }
155
                }
156
            }
156
            }
157
 
157
 
158
 
158
 
159
        }
159
        }
160
        );
160
        );
161
        barChartPlot.getRenderer().setSeriesPaint(0,COLOR_1);
161
        barChartPlot.getRenderer().setSeriesPaint(0,COLOR_1);
162
        barChartPlot.getRenderer().setSeriesPaint(1,COLOR_2);
162
        barChartPlot.getRenderer().setSeriesPaint(1,COLOR_2);
163
        barChartPlot.getRenderer().setSeriesPaint(2,COLOR_3);
163
        barChartPlot.getRenderer().setSeriesPaint(2,COLOR_3);
164
        barChartPlot.getRenderer().setSeriesPaint(3,COLOR_4);
164
        barChartPlot.getRenderer().setSeriesPaint(3,COLOR_4);
165
        barChartPlot.getRenderer().setSeriesPaint(4,COLOR_5);
165
        barChartPlot.getRenderer().setSeriesPaint(4,COLOR_5);
166
 
166
 
167
 
167
 
168
 
168
 
169
        java.util.5+0%2Fdocs%2Fapi+List">List categories = barChartPlot.getCategories();
169
        java.util.5+0%2Fdocs%2Fapi+List">List categories = barChartPlot.getCategories();
170
        barChartPlot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}({3})", 1.5.0/docs/api/java/text/NumberFormat.html">NumberFormat.getInstance(),1.5.0/docs/api/java/text/NumberFormat.html">NumberFormat.getPercentInstance()));
170
        barChartPlot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}({3})", 1.5.0/docs/api/java/text/NumberFormat.html">NumberFormat.getInstance(),1.5.0/docs/api/java/text/NumberFormat.html">NumberFormat.getPercentInstance()));
171
 
171
 
172
 
172
 
173
        (((CategoryPlot) chart.getPlot()).getRangeAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
173
        (((CategoryPlot) chart.getPlot()).getRangeAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
174
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 40));
174
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 40));
175
        (((CategoryPlot) chart.getPlot()).getDomainAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
175
        (((CategoryPlot) chart.getPlot()).getDomainAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
176
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 40));
176
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 40));
177
        ((BarRenderer)((CategoryPlot) chart.getPlot()).getRenderer()).setBaseLegendTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
177
        ((BarRenderer)((CategoryPlot) chart.getPlot()).getRenderer()).setBaseLegendTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
178
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 40));
178
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 40));
179
        ((CategoryPlot) chart.getPlot()).getRenderer().setBaseItemLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
179
        ((CategoryPlot) chart.getPlot()).getRenderer().setBaseItemLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
180
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 43));
180
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 43));
181
 
181
 
182
        ((BarRenderer)((CategoryPlot) chart.getPlot()).getRenderer()).setBaseLegendTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
182
        ((BarRenderer)((CategoryPlot) chart.getPlot()).getRenderer()).setBaseLegendTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
183
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 40));
183
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 40));
184
 
184
 
185
        //barChartPlot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
185
        //barChartPlot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
186
 
186
 
187
 
187
 
188
        //((BarRenderer) barChartPlot.getRenderer()).setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.TOP_CENTER));
188
        //((BarRenderer) barChartPlot.getRenderer()).setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.TOP_CENTER));
189
        barChartPlot.getRenderer().setBaseItemLabelsVisible(true);
189
        barChartPlot.getRenderer().setBaseItemLabelsVisible(true);
190
        barChartPlot.getRenderer().setItemLabelsVisible(true);
190
        barChartPlot.getRenderer().setItemLabelsVisible(true);
191
 
191
 
192
        //barChartPlot.getDomainAxis().setLabel("d");
192
        //barChartPlot.getDomainAxis().setLabel("d");
193
 
193
 
194
 
194
 
195
 
195
 
196
 
196
 
197
        //((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1.0);
197
        //((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1.0);
198
        ((BarRenderer)barChartPlot.getRenderer()).setItemMargin(0);
198
        ((BarRenderer)barChartPlot.getRenderer()).setItemMargin(0);
199
        ((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1);
199
        ((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1);
200
        ((BarRenderer)barChartPlot.getRenderer()).setMinimumBarLength(10);
200
        ((BarRenderer)barChartPlot.getRenderer()).setMinimumBarLength(10);
201
        //System.out.println(((BarRenderer)barChartPlot.getRenderer()).getMaximumBarWidth());
201
        //System.out.println(((BarRenderer)barChartPlot.getRenderer()).getMaximumBarWidth());
202
        //System.out.println(((BarRenderer)barChartPlot.getRenderer()).getMinimumBarLength());
202
        //System.out.println(((BarRenderer)barChartPlot.getRenderer()).getMinimumBarLength());
203
 
203
 
204
        //NOVO
204
        //NOVO
205
 
205
 
206
        NumberAxis rangeAxis = (NumberAxis) barChartPlot.getRangeAxis();
206
        NumberAxis rangeAxis = (NumberAxis) barChartPlot.getRangeAxis();
207
        rangeAxis.setUpperMargin(0.15);
207
        rangeAxis.setUpperMargin(0.15);
208
        rangeAxis.setRange(0,maxValue);
208
        rangeAxis.setRange(0,maxValue);
209
        org.jfree.chart.axis.CategoryAxis categoryAxis = barChartPlot.getDomainAxis();
209
        org.jfree.chart.axis.CategoryAxis categoryAxis = barChartPlot.getDomainAxis();
210
        categoryAxis.setVisible(false);
210
        categoryAxis.setVisible(false);
211
        //categoryAxis.setTickLabelsVisible(true);
211
        //categoryAxis.setTickLabelsVisible(true);
212
 
212
 
213
 
213
 
214
 
214
 
215
        ((BarRenderer)barChartPlot.getRenderer()).setShadowVisible(false);
215
        ((BarRenderer)barChartPlot.getRenderer()).setShadowVisible(false);
216
 
216
 
217
        ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
217
        ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
218
 
218
 
219
 
219
 
220
        1.5.0/docs/api/java/lang/String.html">String pathGraficoRespostas = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + "graficoRespostas" + pathTmp + ".png";
220
        1.5.0/docs/api/java/lang/String.html">String pathGraficoRespostas = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + "graficoRespostas" + pathTmp + ".png";
221
        //String pathGraficoRespostas = "/Volumes/Home/jorgemachado/Desktop/graficoRespostas.png";
221
        //String pathGraficoRespostas = "/Volumes/Home/jorgemachado/Desktop/graficoRespostas.png";
222
        ChartUtilities.saveChartAsPNG(new 1.5.0/docs/api/java/io/File.html">File(pathGraficoRespostas), chart, 1200, 1000, info);
222
        ChartUtilities.saveChartAsPNG(new 1.5.0/docs/api/java/io/File.html">File(pathGraficoRespostas), chart, 1200, 1000, info);
223
        PerguntaStats respostasChart = new PerguntaStats();
223
        PerguntaStats respostasChart = new PerguntaStats();
224
        respostasChart.setTempFile(pathGraficoRespostas);
224
        respostasChart.setTempFile(pathGraficoRespostas);
225
        respostasChart.setPergunta(pergunta);
225
        respostasChart.setPergunta(pergunta);
226
        return respostasChart;
226
        return respostasChart;
227
    }
227
    }
228
 
228
 
229
    public static void createRespostasDispersao()
229
    public static void createRespostasDispersao()
230
    {
230
    {
231
 
231
 
232
        /*****
232
        /*****
233
         *
233
         *
234
         *
234
         *
235
         *
235
         *
236
         */
236
         */
237
        /*
237
        /*
238
        BufferedImage image = null;
238
        BufferedImage image = null;
239
        try {
239
        try {
240
 
240
 
241
            image = ImageIO.read(Thread.currentThread().getContextClassLoader().getResource("pt/estgp/estgweb/services/questionarios/utils/fundoDispersao.png"));
241
            image = ImageIO.read(Thread.currentThread().getContextClassLoader().getResource("pt/estgp/estgweb/services/questionarios/utils/fundoDispersao.png"));
242
        } catch (MalformedURLException e) {
242
        } catch (MalformedURLException e) {
243
            // TODO Auto-generated catch block
243
            // TODO Auto-generated catch block
244
            e.printStackTrace();
244
            e.printStackTrace();
245
        } catch (IOException e) {
245
        } catch (IOException e) {
246
            // TODO Auto-generated catch block
246
            // TODO Auto-generated catch block
247
            e.printStackTrace();
247
            e.printStackTrace();
248
        }
248
        }
249
        barChartPlot.setBackgroundImage(image);*/
249
        barChartPlot.setBackgroundImage(image);*/
250
        /****
250
        /****
251
         *
251
         *
252
         */
252
         */
253
    }
253
    }
254
 
254
 
255
    /**
255
    /**
256
     *
256
     *
257
     * @param questionariosReport
257
     * @param questionariosReport
258
     * @throws IOException
258
     * @throws IOException
259
     */
259
     */
260
    public static void createChartTiposAlunos(QuestionariosAlunosReport questionariosReport, 1.5.0/docs/api/java/lang/String.html">String pathTemplate) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
260
    public static void createChartTiposAlunos(QuestionariosAlunosReport questionariosReport, 1.5.0/docs/api/java/lang/String.html">String pathTemplate) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
261
        DefaultPieDataset data = new DefaultPieDataset();
261
        DefaultPieDataset data = new DefaultPieDataset();
262
        if(questionariosReport.getTipoAlunosNormalComResposta() > 0)
262
        if(questionariosReport.getTipoAlunosNormalComResposta() > 0)
263
            data.setValue("Regime Normal " + questionariosReport.getTipoAlunosNormalComResposta() + " = " + questionariosReport.getTipoAlunosNormalComRespostaPercent()  + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(questionariosReport.getTipoAlunosNormalComResposta()));
263
            data.setValue("Regime Normal " + questionariosReport.getTipoAlunosNormalComResposta() + " = " + questionariosReport.getTipoAlunosNormalComRespostaPercent()  + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(questionariosReport.getTipoAlunosNormalComResposta()));
264
        if(questionariosReport.getTipoAlunosTrabalhadorEstudanteComResposta() > 0)
264
        if(questionariosReport.getTipoAlunosTrabalhadorEstudanteComResposta() > 0)
265
            data.setValue("Trabalhador Estudante " + questionariosReport.getTipoAlunosTrabalhadorEstudanteComResposta() + " = " + questionariosReport.getTipoAlunosTrabalhadorEstudanteComRespostaPercent()  + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(questionariosReport.getTipoAlunosTrabalhadorEstudanteComResposta()));
265
            data.setValue("Trabalhador Estudante " + questionariosReport.getTipoAlunosTrabalhadorEstudanteComResposta() + " = " + questionariosReport.getTipoAlunosTrabalhadorEstudanteComRespostaPercent()  + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(questionariosReport.getTipoAlunosTrabalhadorEstudanteComResposta()));
266
        if(questionariosReport.getTipoAlunosErasmusComResposta() > 0)
266
        if(questionariosReport.getTipoAlunosErasmusComResposta() > 0)
267
            data.setValue("Erasmus " + questionariosReport.getTipoAlunosErasmusComResposta() + " = " + questionariosReport.getTipoAlunosErasmusComRespostaPercent()  + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(questionariosReport.getTipoAlunosErasmusComResposta()));
267
            data.setValue("Erasmus " + questionariosReport.getTipoAlunosErasmusComResposta() + " = " + questionariosReport.getTipoAlunosErasmusComRespostaPercent()  + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(questionariosReport.getTipoAlunosErasmusComResposta()));
268
        JFreeChart chart = ChartFactory.createPieChart3D(null, data, false, true, false);
268
        JFreeChart chart = ChartFactory.createPieChart3D(null, data, false, true, false);
269
        chart.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255,255,255));
269
        chart.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255,255,255));
270
        PiePlot plot = (PiePlot) chart.getPlot();
270
        PiePlot plot = (PiePlot) chart.getPlot();
271
        plot.setLabelBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 249, 235));
271
        plot.setLabelBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 249, 235));
272
        plot.setLabelPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(88, 88, 90));
272
        plot.setLabelPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(88, 88, 90));
273
        plot.setDrawingSupplier(new ChartDrawingSupplier());
273
        plot.setDrawingSupplier(new ChartDrawingSupplier());
274
        //CategoryItemRenderer render = chart.getCategoryPlot().getRenderer();
274
        //CategoryItemRenderer render = chart.getCategoryPlot().getRenderer();
275
        //render.setSeriesPaint(0,new Color(255,201,92));
275
        //render.setSeriesPaint(0,new Color(255,201,92));
276
        plot.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 255, 255));
276
        plot.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 255, 255));
277
        plot.setOutlineVisible(false);
277
        plot.setOutlineVisible(false);
278
 
278
 
279
 
279
 
280
 
280
 
281
        plot.setLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
281
        plot.setLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
282
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 50));
282
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 50));
283
 
283
 
284
 
284
 
285
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( 300*4, 200*4);
285
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( 300*4, 200*4);
286
        1.5.0/docs/api/java/lang/String.html">String pathGraficoTiposAlunos = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate + "graficoTiposAlunos.png";
286
        1.5.0/docs/api/java/lang/String.html">String pathGraficoTiposAlunos = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate + "graficoTiposAlunos.png";
287
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathGraficoTiposAlunos));
287
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathGraficoTiposAlunos));
288
        questionariosReport.setPathGraficoTiposAlunosComResposta(pathGraficoTiposAlunos);
288
        questionariosReport.setPathGraficoTiposAlunosComResposta(pathGraficoTiposAlunos);
289
    }
289
    }
290
 
290
 
291
 
291
 
292
    /**
292
    /**
293
     *
293
     *
294
     * @param questionariosReport
294
     * @param questionariosReport
295
     * @throws IOException
295
     * @throws IOException
296
     *
296
     *
297
     */
297
     */
298
    public static void createChartUnidadesContribuicao(QuestionariosAlunosReport questionariosReport, 1.5.0/docs/api/java/lang/String.html">String pathTemplate) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
298
    public static void createChartUnidadesContribuicao(QuestionariosAlunosReport questionariosReport, 1.5.0/docs/api/java/lang/String.html">String pathTemplate) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
299
        DefaultPieDataset data = new DefaultPieDataset();
299
        DefaultPieDataset data = new DefaultPieDataset();
300
 
300
 
301
 
301
 
302
        for(QuestionariosAlunosReport.ParticipacaoUnidade p: questionariosReport.getParticipacoesUnidades())
302
        for(QuestionariosAlunosReport.ParticipacaoUnidade p: questionariosReport.getParticipacoesUnidades())
303
        {
303
        {
304
            if(p.getPercentagemContribuicaoDaUnidadeNoUniversoUnidades() > 0)
304
            if(p.getPercentagemContribuicaoDaUnidadeNoUniversoUnidades() > 0)
305
                data.setValue(p.getNomeUnidade() + " " + p.getPercentagemContribuicaoDaUnidadeNoUniversoUnidadesPrint() + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(p.getParticiparam()));
305
                data.setValue(p.getNomeUnidade() + " " + p.getPercentagemContribuicaoDaUnidadeNoUniversoUnidadesPrint() + "%", new 1.5.0/docs/api/java/lang/Double.html">Double(p.getParticiparam()));
306
        }
306
        }
307
 
307
 
308
        JFreeChart chart = ChartFactory.createRingChart(null, data, false, true, false);
308
        JFreeChart chart = ChartFactory.createRingChart(null, data, false, true, false);
309
        chart.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255,255,255));
309
        chart.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255,255,255));
310
        RingPlot plot = (RingPlot) chart.getPlot();
310
        RingPlot plot = (RingPlot) chart.getPlot();
311
 
311
 
312
        plot.setLabelBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 249, 235));
312
        plot.setLabelBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 249, 235));
313
        plot.setLabelPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(88, 88, 90));
313
        plot.setLabelPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(88, 88, 90));
314
        plot.setDrawingSupplier(new ChartDrawingSupplier());
314
        plot.setDrawingSupplier(new ChartDrawingSupplier());
315
        //CategoryItemRenderer render = chart.getCategoryPlot().getRenderer();
315
        //CategoryItemRenderer render = chart.getCategoryPlot().getRenderer();
316
        //render.setSeriesPaint(0,new Color(255,201,92));
316
        //render.setSeriesPaint(0,new Color(255,201,92));
317
        plot.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 255, 255));
317
        plot.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 255, 255));
318
        plot.setOutlineVisible(false);
318
        plot.setOutlineVisible(false);
319
 
319
 
320
        plot.setCenterTextMode(CenterTextMode.FIXED);
320
        plot.setCenterTextMode(CenterTextMode.FIXED);
321
        plot.setCenterText("" + questionariosReport.getQuestionariosReqRespondidos() + " Resp.");
321
        plot.setCenterText("" + questionariosReport.getQuestionariosReqRespondidos() + " Resp.");
322
        plot.setCenterTextColor(1.5.0/docs/api/java/awt/Color.html">Color.black);
322
        plot.setCenterTextColor(1.5.0/docs/api/java/awt/Color.html">Color.black);
323
        plot.setCenterTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.SANS_SERIF, 1.5.0/docs/api/java/awt/Font.html">Font.BOLD, 24));
323
        plot.setCenterTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.SANS_SERIF, 1.5.0/docs/api/java/awt/Font.html">Font.BOLD, 24));
324
 
324
 
325
        plot.setLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
325
        plot.setLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
326
        plot.setCenterTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 100));
326
        plot.setCenterTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 100));
327
 
327
 
328
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage(  500*4, 300*4);
328
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage(  500*4, 300*4);
329
        1.5.0/docs/api/java/lang/String.html">String pathGraficoTiposAlunos = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate + "graficoContribuicaoUnidades.png";
329
        1.5.0/docs/api/java/lang/String.html">String pathGraficoTiposAlunos = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate + "graficoContribuicaoUnidades.png";
330
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathGraficoTiposAlunos));
330
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathGraficoTiposAlunos));
331
        questionariosReport.setPathGraficoContribuicaoUnidades(pathGraficoTiposAlunos);
331
        questionariosReport.setPathGraficoContribuicaoUnidades(pathGraficoTiposAlunos);
332
    }
332
    }
333
 
333
 
334
 
334
 
335
    /**
335
    /**
336
     *
336
     *
337
     * @param questionariosReport
337
     * @param questionariosReport
338
     * @throws IOException
338
     * @throws IOException
339
     */
339
     */
340
    public static void createChartTaxaRespostas(QuestionariosReport questionariosReport, 1.5.0/docs/api/java/lang/String.html">String pathTemplate) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
340
    public static void createChartTaxaRespostas(QuestionariosReport questionariosReport, 1.5.0/docs/api/java/lang/String.html">String pathTemplate) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
341
        //TESTE BARRAS LATERAIS
341
        //TESTE BARRAS LATERAIS
342
 
342
 
343
        DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();
343
        DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();
344
        DefaultValueDataset a = new DefaultValueDataset();
344
        DefaultValueDataset a = new DefaultValueDataset();
345
 
345
 
346
        //categoryDataset.addValue(1,"Alunos","Respostas1");
346
        //categoryDataset.addValue(1,"Alunos","Respostas1");
347
        categoryDataset.addValue(questionariosReport.questionariosReqRespondidos,"Questionarios","Respondidos");
347
        categoryDataset.addValue(questionariosReport.questionariosReqRespondidos,"Questionarios","Respondidos");
348
        categoryDataset.addValue(questionariosReport.questionariosReqNaoRespondidos,"Questionarios","S/Resposta");
348
        categoryDataset.addValue(questionariosReport.questionariosReqNaoRespondidos,"Questionarios","S/Resposta");
349
        categoryDataset.addValue(questionariosReport.questionariosReqTotal,"Questionarios","Questionarios");
349
        categoryDataset.addValue(questionariosReport.questionariosReqTotal,"Questionarios","Questionarios");
350
 
350
 
351
 
351
 
352
        JFreeChart chart = ChartFactory.createBarChart(null, null, null, categoryDataset, PlotOrientation.HORIZONTAL, false, true, false);
352
        JFreeChart chart = ChartFactory.createBarChart(null, null, null, categoryDataset, PlotOrientation.HORIZONTAL, false, true, false);
353
        chart.setAntiAlias(true);
353
        chart.setAntiAlias(true);
354
        chart.setTextAntiAlias(false);
354
        chart.setTextAntiAlias(false);
355
        CategoryPlot barChartPlot = (CategoryPlot) chart.getPlot();
355
        CategoryPlot barChartPlot = (CategoryPlot) chart.getPlot();
356
 
356
 
357
 
357
 
358
        barChartPlot.setDrawingSupplier(new ChartBuilderUtil.ChartDrawingSupplier());
358
        barChartPlot.setDrawingSupplier(new ChartBuilderUtil.ChartDrawingSupplier());
359
        barChartPlot.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 255, 255));
359
        barChartPlot.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 255, 255));
360
        barChartPlot.setOutlineVisible(false);
360
        barChartPlot.setOutlineVisible(false);
361
        barChartPlot.setRenderer(new BarRenderer() {
361
        barChartPlot.setRenderer(new BarRenderer() {
362
            @1.5.0/docs/api/java/lang/Override.html">Override
362
            @1.5.0/docs/api/java/lang/Override.html">Override
363
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemPaint(int row, int col) {
363
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemPaint(int row, int col) {
364
                switch (col) {
364
                switch (col) {
365
                    case 0:
365
                    case 0:
366
                        return GREEN_OK;
366
                        return GREEN_OK;
367
                    case 1:
367
                    case 1:
368
                        return RED_NOT_OK;
368
                        return RED_NOT_OK;
369
                    default:
369
                    default:
370
                        return NEUTRAL_TOTAL;
370
                        return NEUTRAL_TOTAL;
371
                }
371
                }
372
 
372
 
373
            }
373
            }
374
 
374
 
375
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemLabelPaint(int row, int col) {
375
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemLabelPaint(int row, int col) {
376
                switch (col) {
376
                switch (col) {
377
                    case 0:
377
                    case 0:
378
                        return 1.5.0/docs/api/java/awt/Color.html">Color.black;
378
                        return 1.5.0/docs/api/java/awt/Color.html">Color.black;
379
                    case 1:
379
                    case 1:
380
                        return 1.5.0/docs/api/java/awt/Color.html">Color.black;
380
                        return 1.5.0/docs/api/java/awt/Color.html">Color.black;
381
                    default:
381
                    default:
382
                        return 1.5.0/docs/api/java/awt/Color.html">Color.white;
382
                        return 1.5.0/docs/api/java/awt/Color.html">Color.white;
383
                }
383
                }
384
            }
384
            }
385
        }
385
        }
386
        );
386
        );
387
 
387
 
388
        (((CategoryPlot) chart.getPlot()).getRangeAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
388
        (((CategoryPlot) chart.getPlot()).getRangeAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
389
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
389
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
390
        (((CategoryPlot) chart.getPlot()).getDomainAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
390
        (((CategoryPlot) chart.getPlot()).getDomainAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
391
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
391
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
392
        ((BarRenderer)((CategoryPlot) chart.getPlot()).getRenderer()).setBaseLegendTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
392
        ((BarRenderer)((CategoryPlot) chart.getPlot()).getRenderer()).setBaseLegendTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
393
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
393
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
394
        ((CategoryPlot) chart.getPlot()).getRenderer().setBaseItemLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
394
        ((CategoryPlot) chart.getPlot()).getRenderer().setBaseItemLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
395
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
395
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
396
        barChartPlot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
396
        barChartPlot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
397
        //barChartPlot.getRendererForDataset(barChartPlot.getDataset(0)).setSeriesPaint(0,Color.red);
397
        //barChartPlot.getRendererForDataset(barChartPlot.getDataset(0)).setSeriesPaint(0,Color.red);
398
        //barChartPlot.getRendererForDataset(barChartPlot.getDataset(0)).setSeriesPaint(1,Color.blue);
398
        //barChartPlot.getRendererForDataset(barChartPlot.getDataset(0)).setSeriesPaint(1,Color.blue);
399
        //     barChartPlot.getRendererForDataset(barChartPlot.getDataset(1)).setSeriesPaint(0,Color.blue);
399
        //     barChartPlot.getRendererForDataset(barChartPlot.getDataset(1)).setSeriesPaint(0,Color.blue);
400
 
400
 
401
        ((BarRenderer)barChartPlot.getRenderer()).setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT));
401
        ((BarRenderer)barChartPlot.getRenderer()).setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT));
402
        barChartPlot.getRenderer().setBaseItemLabelsVisible(true);
402
        barChartPlot.getRenderer().setBaseItemLabelsVisible(true);
403
        barChartPlot.getRenderer().setItemLabelsVisible(true);
403
        barChartPlot.getRenderer().setItemLabelsVisible(true);
404
        //((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1.0);
404
        //((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1.0);
405
 
405
 
406
        ((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1);
406
        ((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1);
407
        ((BarRenderer)barChartPlot.getRenderer()).setMinimumBarLength(10);
407
        ((BarRenderer)barChartPlot.getRenderer()).setMinimumBarLength(10);
408
 
408
 
409
        //CategoryItemLabelGenerator generator = new StandardCategoryItemLabelGenerator(
409
        //CategoryItemLabelGenerator generator = new StandardCategoryItemLabelGenerator(
410
        //        "{2}", new DecimalFormat("0.00"));
410
        //        "{2}", new DecimalFormat("0.00"));
411
       ((BarRenderer)barChartPlot.getRenderer()).setItemLabelPaint(null);
411
       ((BarRenderer)barChartPlot.getRenderer()).setItemLabelPaint(null);
412
        // add settings for individual series...
412
        // add settings for individual series...
413
 
413
 
414
 
414
 
415
        ((BarRenderer)barChartPlot.getRenderer()).setShadowVisible(false);
415
        ((BarRenderer)barChartPlot.getRenderer()).setShadowVisible(false);
416
        barChartPlot.getRangeAxis().setVisible(false);
416
        barChartPlot.getRangeAxis().setVisible(false);
417
        barChartPlot.getRangeAxis().setUpperMargin(0.15);
417
        barChartPlot.getRangeAxis().setUpperMargin(0.15);
418
        ((BarRenderer)barChartPlot.getRenderer()).setItemMargin(0.2);
418
        ((BarRenderer)barChartPlot.getRenderer()).setItemMargin(0.2);
419
 
419
 
420
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( 550*4, 300*4);
420
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( 550*4, 300*4);
421
        1.5.0/docs/api/java/lang/String.html">String pathGraficoRespostas = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate  + "graficoRespostas.png";
421
        1.5.0/docs/api/java/lang/String.html">String pathGraficoRespostas = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate  + "graficoRespostas.png";
422
        //String pathGraficoRespostas = "/Volumes/Home/jorgemachado/Desktop/graficoRespostas.png";
422
        //String pathGraficoRespostas = "/Volumes/Home/jorgemachado/Desktop/graficoRespostas.png";
423
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathGraficoRespostas));
423
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathGraficoRespostas));
424
 
424
 
425
        questionariosReport.setPathGraficoTaxaRespostaQuestionarios(pathGraficoRespostas);
425
        questionariosReport.setPathGraficoTaxaRespostaQuestionarios(pathGraficoRespostas);
426
    }
426
    }
427
 
427
 
428
 
428
 
429
    /**
429
    /**
430
     *
430
     *
431
     * @param questionariosReport
431
     * @param questionariosReport
432
     * @throws IOException
432
     * @throws IOException
433
     */
433
     */
434
    public static void createChartTaxaParticipacao(QuestionariosAlunosReport questionariosReport, 1.5.0/docs/api/java/lang/String.html">String pathTemplate) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
434
    public static void createChartTaxaParticipacao(QuestionariosAlunosReport questionariosReport, 1.5.0/docs/api/java/lang/String.html">String pathTemplate) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
435
        //TESTE BARRAS LATERAIS
435
        //TESTE BARRAS LATERAIS
436
 
436
 
437
        DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();
437
        DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();
438
        DefaultValueDataset a = new DefaultValueDataset();
438
        DefaultValueDataset a = new DefaultValueDataset();
439
 
439
 
440
        //categoryDataset.addValue(1,"Alunos","Respostas1");
440
        //categoryDataset.addValue(1,"Alunos","Respostas1");
441
        categoryDataset.addValue(questionariosReport.getInquiridosComResposta(),"Alunos","Participaram");
441
        categoryDataset.addValue(questionariosReport.getInquiridosComResposta(),"Alunos","Participaram");
442
        categoryDataset.addValue(questionariosReport.getInquiridosNaoResponderam(),"Alunos","N/Participaram");
442
        categoryDataset.addValue(questionariosReport.getInquiridosNaoResponderam(),"Alunos","N/Participaram");
443
        categoryDataset.addValue(questionariosReport.getInquiridosTotal(),"Alunos","Alunos");
443
        categoryDataset.addValue(questionariosReport.getInquiridosTotal(),"Alunos","Alunos");
444
 
444
 
445
 
445
 
446
        JFreeChart chart = ChartFactory.createBarChart(null, null, null, categoryDataset, PlotOrientation.HORIZONTAL, false, true, false);
446
        JFreeChart chart = ChartFactory.createBarChart(null, null, null, categoryDataset, PlotOrientation.HORIZONTAL, false, true, false);
447
        chart.setAntiAlias(true);
447
        chart.setAntiAlias(true);
448
        chart.setTextAntiAlias(true);
448
        chart.setTextAntiAlias(true);
449
        CategoryPlot barChartPlot = (CategoryPlot) chart.getPlot();
449
        CategoryPlot barChartPlot = (CategoryPlot) chart.getPlot();
450
 
450
 
451
 
451
 
452
        barChartPlot.setDrawingSupplier(new ChartDrawingSupplier());
452
        barChartPlot.setDrawingSupplier(new ChartDrawingSupplier());
453
        barChartPlot.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 255, 255));
453
        barChartPlot.setBackgroundPaint(new 1.5.0/docs/api/java/awt/Color.html">Color(255, 255, 255));
454
        barChartPlot.setOutlineVisible(false);
454
        barChartPlot.setOutlineVisible(false);
455
        barChartPlot.setRenderer(new BarRenderer() {
455
        barChartPlot.setRenderer(new BarRenderer() {
456
            @1.5.0/docs/api/java/lang/Override.html">Override
456
            @1.5.0/docs/api/java/lang/Override.html">Override
457
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemPaint(int row, int col) {
457
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemPaint(int row, int col) {
458
                switch (col) {
458
                switch (col) {
459
                    case 0:
459
                    case 0:
460
                        return GREEN_OK;
460
                        return GREEN_OK;
461
                    case 1:
461
                    case 1:
462
                        return RED_NOT_OK;
462
                        return RED_NOT_OK;
463
                    default:
463
                    default:
464
                        return NEUTRAL_TOTAL;
464
                        return NEUTRAL_TOTAL;
465
                }
465
                }
466
 
466
 
467
            }
467
            }
468
 
468
 
469
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemLabelPaint(int row, int col) {
469
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemLabelPaint(int row, int col) {
470
                switch (col) {
470
                switch (col) {
471
                    case 0:
471
                    case 0:
472
                        return 1.5.0/docs/api/java/awt/Color.html">Color.black;
472
                        return 1.5.0/docs/api/java/awt/Color.html">Color.black;
473
                    case 1:
473
                    case 1:
474
                        return 1.5.0/docs/api/java/awt/Color.html">Color.black;
474
                        return 1.5.0/docs/api/java/awt/Color.html">Color.black;
475
                    default:
475
                    default:
476
                        return 1.5.0/docs/api/java/awt/Color.html">Color.white;
476
                        return 1.5.0/docs/api/java/awt/Color.html">Color.white;
477
 
477
 
478
                }
478
                }
479
            }
479
            }
480
        }
480
        }
481
        );
481
        );
482
 
482
 
483
        (((CategoryPlot) chart.getPlot()).getRangeAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
483
        (((CategoryPlot) chart.getPlot()).getRangeAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
484
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
484
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
485
        (((CategoryPlot) chart.getPlot()).getDomainAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
485
        (((CategoryPlot) chart.getPlot()).getDomainAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
486
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
486
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
487
        ((BarRenderer)((CategoryPlot) chart.getPlot()).getRenderer()).setBaseLegendTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
487
        ((BarRenderer)((CategoryPlot) chart.getPlot()).getRenderer()).setBaseLegendTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
488
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
488
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
489
        ((CategoryPlot) chart.getPlot()).getRenderer().setBaseItemLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
489
        ((CategoryPlot) chart.getPlot()).getRenderer().setBaseItemLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
490
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
490
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
491
        barChartPlot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
491
        barChartPlot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
492
 
492
 
493
        ((BarRenderer)barChartPlot.getRenderer()).setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT));
493
        ((BarRenderer)barChartPlot.getRenderer()).setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT));
494
        barChartPlot.getRenderer().setBaseItemLabelsVisible(true);
494
        barChartPlot.getRenderer().setBaseItemLabelsVisible(true);
495
        barChartPlot.getRenderer().setItemLabelsVisible(true);
495
        barChartPlot.getRenderer().setItemLabelsVisible(true);
496
        //((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1.0);
496
        //((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1.0);
497
        ((BarRenderer)barChartPlot.getRenderer()).setItemMargin(0.2);
497
        ((BarRenderer)barChartPlot.getRenderer()).setItemMargin(0.2);
498
        ((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1);
498
        ((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1);
499
        ((BarRenderer)barChartPlot.getRenderer()).setMinimumBarLength(10);
499
        ((BarRenderer)barChartPlot.getRenderer()).setMinimumBarLength(10);
500
 
500
 
501
 
501
 
502
        ((BarRenderer)barChartPlot.getRenderer()).setShadowVisible(false);
502
        ((BarRenderer)barChartPlot.getRenderer()).setShadowVisible(false);
503
        barChartPlot.getRangeAxis().setVisible(false);
503
        barChartPlot.getRangeAxis().setVisible(false);
504
        barChartPlot.getRangeAxis().setUpperMargin(0.15);
504
        barChartPlot.getRangeAxis().setUpperMargin(0.15);
505
        ((BarRenderer)barChartPlot.getRenderer()).setItemMargin(0.2);
505
        ((BarRenderer)barChartPlot.getRenderer()).setItemMargin(0.2);
506
 
506
 
507
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( 550*4, 300*4);
507
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( 550*4, 300*4);
508
        1.5.0/docs/api/java/lang/String.html">String pathGraficoRespostas = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate +  "graficoTaxaParticipacao.png";
508
        1.5.0/docs/api/java/lang/String.html">String pathGraficoRespostas = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate +  "graficoTaxaParticipacao.png";
509
        //String pathGraficoRespostas = "/Volumes/Home/jorgemachado/Desktop/graficoTaxaParticipacao.png";
509
        //String pathGraficoRespostas = "/Volumes/Home/jorgemachado/Desktop/graficoTaxaParticipacao.png";
510
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathGraficoRespostas));
510
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathGraficoRespostas));
511
 
511
 
512
        questionariosReport.setPathGraficoTaxaRespostaAlunos(pathGraficoRespostas);
512
        questionariosReport.setPathGraficoTaxaRespostaAlunos(pathGraficoRespostas);
513
    }
513
    }
514
 
514
 
515
    public static 1.5.0/docs/api/java/lang/String.html">String getRgbXslColor(1.5.0/docs/api/java/awt/Color.html">Color color)
515
    public static 1.5.0/docs/api/java/lang/String.html">String getRgbXslColor(1.5.0/docs/api/java/awt/Color.html">Color color)
516
    {
516
    {
517
        return "rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")";
517
        return "rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")";
518
    }
518
    }
519
 
519
 
520
 
520
 
521
    /**
521
    /**
522
     * Gerador de Cores para as Barras
522
     * Gerador de Cores para as Barras
523
     */
523
     */
524
 
524
 
525
    public static class ChartDrawingSupplier extends DefaultDrawingSupplier {
525
    public static class ChartDrawingSupplier extends DefaultDrawingSupplier {
526
 
526
 
527
        public 1.5.0/docs/api/java/awt/Paint.html">Paint[] paintSequence;
527
        public 1.5.0/docs/api/java/awt/Paint.html">Paint[] paintSequence;
528
        public int paintIndex;
528
        public int paintIndex;
529
        public int fillPaintIndex;
529
        public int fillPaintIndex;
530
 
530
 
531
        {
531
        {
532
            paintSequence =  new 1.5.0/docs/api/java/awt/Paint.html">Paint[] {
532
            paintSequence =  new 1.5.0/docs/api/java/awt/Paint.html">Paint[] {
533
                    new 1.5.0/docs/api/java/awt/Color.html">Color(255, 235, 166),
533
                    new 1.5.0/docs/api/java/awt/Color.html">Color(255, 235, 166),
534
                    new 1.5.0/docs/api/java/awt/Color.html">Color(141,141, 144),
534
                    new 1.5.0/docs/api/java/awt/Color.html">Color(141,141, 144),
535
                    new 1.5.0/docs/api/java/awt/Color.html">Color(255,200, 164),
535
                    new 1.5.0/docs/api/java/awt/Color.html">Color(255,200, 164),
536
                    new 1.5.0/docs/api/java/awt/Color.html">Color(198,198,202),
536
                    new 1.5.0/docs/api/java/awt/Color.html">Color(198,198,202),
537
                    new 1.5.0/docs/api/java/awt/Color.html">Color(197,130,107),
537
                    new 1.5.0/docs/api/java/awt/Color.html">Color(197,130,107),
538
                    new 1.5.0/docs/api/java/awt/Color.html">Color(217,199,140),
538
                    new 1.5.0/docs/api/java/awt/Color.html">Color(217,199,140),
539
                    new 1.5.0/docs/api/java/awt/Color.html">Color(172,164,140),
539
                    new 1.5.0/docs/api/java/awt/Color.html">Color(172,164,140),
540
                    new 1.5.0/docs/api/java/awt/Color.html">Color(155,91,58),
540
                    new 1.5.0/docs/api/java/awt/Color.html">Color(155,91,58),
541
                    new 1.5.0/docs/api/java/awt/Color.html">Color(83,83,84),
541
                    new 1.5.0/docs/api/java/awt/Color.html">Color(83,83,84),
542
                    new 1.5.0/docs/api/java/awt/Color.html">Color(255,196,76),
542
                    new 1.5.0/docs/api/java/awt/Color.html">Color(255,196,76),
543
                    new 1.5.0/docs/api/java/awt/Color.html">Color(40,40,40),
543
                    new 1.5.0/docs/api/java/awt/Color.html">Color(40,40,40),
544
                    new 1.5.0/docs/api/java/awt/Color.html">Color(255,108,51),
544
                    new 1.5.0/docs/api/java/awt/Color.html">Color(255,108,51),
545
                    new 1.5.0/docs/api/java/awt/Color.html">Color(229,229,223),
545
                    new 1.5.0/docs/api/java/awt/Color.html">Color(229,229,223),
546
                    new 1.5.0/docs/api/java/awt/Color.html">Color(167,120,51),
546
                    new 1.5.0/docs/api/java/awt/Color.html">Color(167,120,51),
547
            };
547
            };
548
        }
548
        }
549
 
549
 
550
        public ChartDrawingSupplier() {
550
        public ChartDrawingSupplier() {
551
 
551
 
552
        }
552
        }
553
 
553
 
554
        public ChartDrawingSupplier(1.5.0/docs/api/java/awt/Paint.html">Paint[] paintSequence) {
554
        public ChartDrawingSupplier(1.5.0/docs/api/java/awt/Paint.html">Paint[] paintSequence) {
555
            this.paintSequence = paintSequence;
555
            this.paintSequence = paintSequence;
556
        }
556
        }
557
 
557
 
558
        @1.5.0/docs/api/java/lang/Override.html">Override
558
        @1.5.0/docs/api/java/lang/Override.html">Override
559
        public 1.5.0/docs/api/java/awt/Paint.html">Paint getNextPaint() {
559
        public 1.5.0/docs/api/java/awt/Paint.html">Paint getNextPaint() {
560
            1.5.0/docs/api/java/awt/Paint.html">Paint result
560
            1.5.0/docs/api/java/awt/Paint.html">Paint result
561
                    = paintSequence[paintIndex % paintSequence.length];
561
                    = paintSequence[paintIndex % paintSequence.length];
562
            paintIndex++;
562
            paintIndex++;
563
            return result;
563
            return result;
564
        }
564
        }
565
 
565
 
566
 
566
 
567
        @1.5.0/docs/api/java/lang/Override.html">Override
567
        @1.5.0/docs/api/java/lang/Override.html">Override
568
        public 1.5.0/docs/api/java/awt/Paint.html">Paint getNextFillPaint() {
568
        public 1.5.0/docs/api/java/awt/Paint.html">Paint getNextFillPaint() {
569
            1.5.0/docs/api/java/awt/Paint.html">Paint result
569
            1.5.0/docs/api/java/awt/Paint.html">Paint result
570
                    = paintSequence[fillPaintIndex % paintSequence.length];
570
                    = paintSequence[fillPaintIndex % paintSequence.length];
571
            fillPaintIndex++;
571
            fillPaintIndex++;
572
            return result;
572
            return result;
573
        }
573
        }
574
    }
574
    }
575
 
575
 
576
 
576
 
577
    private static class CustomToolTipGenerator implements CategoryToolTipGenerator {
577
    private static class CustomToolTipGenerator implements CategoryToolTipGenerator {
578
        CategoryDataset dataset;
578
        CategoryDataset dataset;
579
        java.util.5+0%2Fdocs%2Fapi+List">List categories;
579
        java.util.5+0%2Fdocs%2Fapi+List">List categories;
580
 
580
 
581
        public CustomToolTipGenerator(CategoryDataset dataset, java.util.5+0%2Fdocs%2Fapi+List">List categories) {
581
        public CustomToolTipGenerator(CategoryDataset dataset, java.util.5+0%2Fdocs%2Fapi+List">List categories) {
582
            this.dataset = dataset;
582
            this.dataset = dataset;
583
            this.categories = categories;
583
            this.categories = categories;
584
        }
584
        }
585
 
585
 
586
        @1.5.0/docs/api/java/lang/Override.html">Override
586
        @1.5.0/docs/api/java/lang/Override.html">Override
587
        public 1.5.0/docs/api/java/lang/String.html">String generateToolTip(CategoryDataset arg0, int arg1, int arg2) {
587
        public 1.5.0/docs/api/java/lang/String.html">String generateToolTip(CategoryDataset arg0, int arg1, int arg2) {
588
            1.5.0/docs/api/java/lang/String.html">String categoryName = (1.5.0/docs/api/java/lang/String.html">String) categories.get(arg2);
588
            1.5.0/docs/api/java/lang/String.html">String categoryName = (1.5.0/docs/api/java/lang/String.html">String) categories.get(arg2);
589
            return categoryName + " = " + arg0.getValue(arg1, arg2);
589
            return categoryName + " = " + arg0.getValue(arg1, arg2);
590
        }
590
        }
591
    }
591
    }
592
 
592
 
593
    static 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat df2 = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.##");
593
    static 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat df2 = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.##");
594
    static 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat df1 = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.#");
594
    static 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat df1 = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.#");
595
    public static double getPercentagem(int parcela, int total)
595
    public static double getPercentagem(int parcela, int total)
596
    {
596
    {
597
        if(total == 0)
597
        if(total == 0)
598
            return 0;
598
            return 0;
599
        return 100.0 * ((double)((double)parcela/(double)total));
599
        return 100.0 * ((double)((double)parcela/(double)total));
600
    }
600
    }
601
 
601
 
602
    public static double getPercentagem(double parcela, int total)
602
    public static double getPercentagem(double parcela, int total)
603
    {
603
    {
604
        if(total == 0)
604
        if(total == 0)
605
            return 0;
605
            return 0;
606
        return 100.0 * ((double)(parcela/(double)total));
606
        return 100.0 * ((double)(parcela/(double)total));
607
    }
607
    }
608
 
608
 
609
    public static 1.5.0/docs/api/java/lang/String.html">String getPercentagemPrint0Slots(double parcela, int total)
609
    public static 1.5.0/docs/api/java/lang/String.html">String getPercentagemPrint0Slots(double parcela, int total)
610
    {
610
    {
611
        double percent = getPercentagem(parcela,total);
611
        double percent = getPercentagem(parcela,total);
612
        return "" + (int) percent;
612
        return "" + (int) percent;
613
    }
613
    }
614
    public static 1.5.0/docs/api/java/lang/String.html">String getPercentagemPrint2Slots(double parcela, int total)
614
    public static 1.5.0/docs/api/java/lang/String.html">String getPercentagemPrint2Slots(double parcela, int total)
615
    {
615
    {
616
        double percent = getPercentagem(parcela,total);
616
        double percent = getPercentagem(parcela,total);
617
        return df2.format(percent);
617
        return df2.format(percent);
618
    }
618
    }
619
    public static 1.5.0/docs/api/java/lang/String.html">String getPercentagemPrint2Slots(int parcela, int total)
619
    public static 1.5.0/docs/api/java/lang/String.html">String getPercentagemPrint2Slots(int parcela, int total)
620
    {
620
    {
621
        double percent = getPercentagem(parcela,total);
621
        double percent = getPercentagem(parcela,total);
622
        return df2.format(percent);
622
        return df2.format(percent);
623
    }
623
    }
624
 
624
 
625
    public static 1.5.0/docs/api/java/lang/String.html">String getPercentagemPrint1Slots(int parcela, int total)
625
    public static 1.5.0/docs/api/java/lang/String.html">String getPercentagemPrint1Slots(int parcela, int total)
626
    {
626
    {
627
        double percent = getPercentagem(parcela,total);
627
        double percent = getPercentagem(parcela,total);
628
        return df1.format(percent);
628
        return df1.format(percent);
629
    }
629
    }
630
 
630
 
631
 
631
 
632
 
632
 
633
 
633
 
634
    public static 1.5.0/docs/api/java/lang/String.html">String createBarChartTwoBars(1.5.0/docs/api/java/lang/String.html">String name1, 1.5.0/docs/api/java/lang/String.html">String name2,final 1.5.0/docs/api/java/awt/Color.html">Color color1, final 1.5.0/docs/api/java/awt/Color.html">Color color2, double value1, double value2, double max, 1.5.0/docs/api/java/lang/String.html">String pathTemplate) throws 1.5.0/docs/api/java/io/IOException.html">IOException
634
    public static 1.5.0/docs/api/java/lang/String.html">String createBarChartTwoBars(1.5.0/docs/api/java/lang/String.html">String name1, 1.5.0/docs/api/java/lang/String.html">String name2,final 1.5.0/docs/api/java/awt/Color.html">Color color1, final 1.5.0/docs/api/java/awt/Color.html">Color color2, double value1, double value2, double max, 1.5.0/docs/api/java/lang/String.html">String pathTemplate) throws 1.5.0/docs/api/java/io/IOException.html">IOException
635
    {
635
    {
636
 
636
 
637
        DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();
637
        DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();
638
        DefaultValueDataset a = new DefaultValueDataset();
638
        DefaultValueDataset a = new DefaultValueDataset();
639
 
639
 
640
        categoryDataset.addValue(value1,"Valor",name1);
640
        categoryDataset.addValue(value1,"Valor",name1);
641
        categoryDataset.addValue(value2,"Valor",name2);
641
        categoryDataset.addValue(value2,"Valor",name2);
642
 
642
 
643
 
643
 
644
        JFreeChart chart = ChartFactory.createBarChart(null, null, null, categoryDataset, PlotOrientation.HORIZONTAL, false, true, false);
644
        JFreeChart chart = ChartFactory.createBarChart(null, null, null, categoryDataset, PlotOrientation.HORIZONTAL, false, true, false);
645
        chart.setAntiAlias(true);
645
        chart.setAntiAlias(true);
646
        chart.setTextAntiAlias(true);
646
        chart.setTextAntiAlias(true);
647
        chart.setBackgroundPaint(TRANSPARENT);
647
        chart.setBackgroundPaint(TRANSPARENT);
648
        CategoryPlot barChartPlot = (CategoryPlot) chart.getPlot();
648
        CategoryPlot barChartPlot = (CategoryPlot) chart.getPlot();
649
 
649
 
650
 
650
 
651
        barChartPlot.setDrawingSupplier(new ChartBuilderUtil.ChartDrawingSupplier());
651
        barChartPlot.setDrawingSupplier(new ChartBuilderUtil.ChartDrawingSupplier());
652
        barChartPlot.setBackgroundPaint(TRANSPARENT);
652
        barChartPlot.setBackgroundPaint(TRANSPARENT);
653
        barChartPlot.setOutlineVisible(false);
653
        barChartPlot.setOutlineVisible(false);
654
        barChartPlot.setRenderer(new BarRenderer() {
654
        barChartPlot.setRenderer(new BarRenderer() {
655
            @1.5.0/docs/api/java/lang/Override.html">Override
655
            @1.5.0/docs/api/java/lang/Override.html">Override
656
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemPaint(int row, int col) {
656
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemPaint(int row, int col) {
657
                switch (col) {
657
                switch (col) {
658
                    case 0:
658
                    case 0:
659
                        return color1;
659
                        return color1;
660
                    case 1:
660
                    case 1:
661
                        return color2;
661
                        return color2;
662
                    default:
662
                    default:
663
                        return NEUTRAL_TOTAL;
663
                        return NEUTRAL_TOTAL;
664
                }
664
                }
665
 
665
 
666
            }
666
            }
667
 
667
 
668
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemLabelPaint(int row, int col) {
668
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemLabelPaint(int row, int col) {
669
                switch (col) {
669
                switch (col) {
670
                    case 0:
670
                    case 0:
671
                        return 1.5.0/docs/api/java/awt/Color.html">Color.black;
671
                        return 1.5.0/docs/api/java/awt/Color.html">Color.black;
672
                    case 1:
672
                    case 1:
673
                        return 1.5.0/docs/api/java/awt/Color.html">Color.black;
673
                        return 1.5.0/docs/api/java/awt/Color.html">Color.black;
674
                    default:
674
                    default:
675
                        return 1.5.0/docs/api/java/awt/Color.html">Color.white;
675
                        return 1.5.0/docs/api/java/awt/Color.html">Color.white;
676
                }
676
                }
677
            }
677
            }
678
        }
678
        }
679
        );
679
        );
680
 
680
 
681
        barChartPlot.getRangeAxis().setUpperMargin(0.3);
681
        barChartPlot.getRangeAxis().setUpperMargin(0.3);
682
        barChartPlot.getRangeAxis().setRange(0,7);
682
        barChartPlot.getRangeAxis().setRange(0,7);
683
        barChartPlot.getRangeAxis().setVisible(false);
683
        barChartPlot.getRangeAxis().setVisible(false);
684
 
684
 
685
        (((CategoryPlot) chart.getPlot()).getRangeAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
685
        (((CategoryPlot) chart.getPlot()).getRangeAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
686
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 55));
686
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 55));
687
        (((CategoryPlot) chart.getPlot()).getDomainAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
687
        (((CategoryPlot) chart.getPlot()).getDomainAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
688
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 55));
688
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 55));
689
        ((BarRenderer)((CategoryPlot) chart.getPlot()).getRenderer()).setBaseLegendTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
689
        ((BarRenderer)((CategoryPlot) chart.getPlot()).getRenderer()).setBaseLegendTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
690
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.BOLD, 55));
690
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.BOLD, 55));
691
        ((CategoryPlot) chart.getPlot()).getRenderer().setBaseItemLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
691
        ((CategoryPlot) chart.getPlot()).getRenderer().setBaseItemLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
692
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 55));
692
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 55));
693
        1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat dfKey = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.##");
693
        1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat dfKey = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.##");
694
        barChartPlot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}",dfKey));
694
        barChartPlot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}",dfKey));
695
 
695
 
696
        ((BarRenderer)barChartPlot.getRenderer()).setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT));
696
        ((BarRenderer)barChartPlot.getRenderer()).setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT));
697
        ((BarRenderer)barChartPlot.getRenderer()).setShadowVisible(false);
697
        ((BarRenderer)barChartPlot.getRenderer()).setShadowVisible(false);
698
        barChartPlot.getRenderer().setBaseItemLabelsVisible(true);
698
        barChartPlot.getRenderer().setBaseItemLabelsVisible(true);
699
        barChartPlot.getRenderer().setItemLabelsVisible(true);
699
        barChartPlot.getRenderer().setItemLabelsVisible(true);
700
        //((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1.0);
700
        //((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1.0);
701
        ((BarRenderer)barChartPlot.getRenderer()).setItemMargin(0.7);
701
        ((BarRenderer)barChartPlot.getRenderer()).setItemMargin(0.7);
702
        ((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(0.5);
702
        ((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(0.5);
703
        ((BarRenderer)barChartPlot.getRenderer()).setMinimumBarLength(5);
703
        ((BarRenderer)barChartPlot.getRenderer()).setMinimumBarLength(5);
704
        ((BarRenderer)barChartPlot.getRenderer()).setItemLabelPaint(null);
704
        ((BarRenderer)barChartPlot.getRenderer()).setItemLabelPaint(null);
705
        // add settings for individual series...
705
        // add settings for individual series...
706
 
706
 
707
        //PINTAR LETRAS DAS LABELS POR CATGORIA SE FOR APENAS UMA CATEGORIA PINTA TUDO IGUAL com red
707
        //PINTAR LETRAS DAS LABELS POR CATGORIA SE FOR APENAS UMA CATEGORIA PINTA TUDO IGUAL com red
708
        //((BarRenderer)barChartPlot.getRenderer()).setSeriesItemLabelPaint(0, Color.red);
708
        //((BarRenderer)barChartPlot.getRenderer()).setSeriesItemLabelPaint(0, Color.red);
709
        //((BarRenderer)barChartPlot.getRenderer()) .setSeriesItemLabelPaint(1, Color.green);
709
        //((BarRenderer)barChartPlot.getRenderer()) .setSeriesItemLabelPaint(1, Color.green);
710
        //((BarRenderer)barChartPlot.getRenderer()) .setSeriesItemLabelPaint(1, Color.blue);
710
        //((BarRenderer)barChartPlot.getRenderer()) .setSeriesItemLabelPaint(1, Color.blue);
711
 
711
 
712
        //((BarRenderer)barChartPlot.getRenderer()).set;
712
        //((BarRenderer)barChartPlot.getRenderer()).set;
713
 
713
 
714
 
714
 
715
        //chart2.getCategoryPlot().getRangeAxis().setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0, 0, 25, 25));
715
        //chart2.getCategoryPlot().getRangeAxis().setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0, 0, 25, 25));
716
 
716
 
717
 
717
 
718
 
718
 
719
 
719
 
720
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( 300*4, 150*4);
720
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( 300*4, 150*4);
721
        1.5.0/docs/api/java/lang/String.html">String pathGraficoRespostas = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate  + "twoBars.png";
721
        1.5.0/docs/api/java/lang/String.html">String pathGraficoRespostas = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate  + "twoBars.png";
722
        //String pathGraficoRespostas = "/Volumes/Home/jorgemachado/Desktop/graficoRespostas.png";
722
        //String pathGraficoRespostas = "/Volumes/Home/jorgemachado/Desktop/graficoRespostas.png";
723
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathGraficoRespostas));
723
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathGraficoRespostas));
724
 
724
 
725
        return pathGraficoRespostas;
725
        return pathGraficoRespostas;
726
 
726
 
727
    }
727
    }
728
 
728
 
729
 
729
 
730
    public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) throws 1.5.0/docs/api/java/io/IOException.html">IOException
730
    public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) throws 1.5.0/docs/api/java/io/IOException.html">IOException
731
    {
731
    {
732
        //createTimeSeries();
732
        //createTimeSeries();
733
       /* for(int i = 1; i < 100;i++)
733
       /* for(int i = 1; i < 100;i++)
734
        {
734
        {
735
            createChartRingOneDimension(i, 100, true, true,true,"ring" + i);
735
            createChartRingOneDimension(i, 100, true, true,true,"ring" + i);
736
        }
736
        }
737
 
737
 
738
        createBarChartTwoBars("Docente","Curso",COLOR_SECTION_BLUE_DARK, COLOR_SECTION_GREEN,4.2,3.8,5,"mediaDoc");*/
738
        createBarChartTwoBars("Docente","Curso",COLOR_SECTION_BLUE_DARK, COLOR_SECTION_GREEN,4.2,3.8,5,"mediaDoc");*/
739
 
739
 
740
        1.5.0/docs/api/java/lang/String.html">String[] categories = new 1.5.0/docs/api/java/lang/String.html">String[]{"Engenharia do Software","Teoria da Computação","Analise e Concepção de Sistemas","Programação WEB com Bases de Dados"};
740
        1.5.0/docs/api/java/lang/String.html">String[] categories = new 1.5.0/docs/api/java/lang/String.html">String[]{"Engenharia do Software","Teoria da Computação","Analise e Concepção de Sistemas","Programação WEB com Bases de Dados"};
741
        1.5.0/docs/api/java/lang/String.html">String[] series = new 1.5.0/docs/api/java/lang/String.html">String[]{"Média Docente","Média Unidade"};
741
        1.5.0/docs/api/java/lang/String.html">String[] series = new 1.5.0/docs/api/java/lang/String.html">String[]{"Média Docente","Média Unidade"};
742
        1.5.0/docs/api/java/awt/Color.html">Color[] colors = new 1.5.0/docs/api/java/awt/Color.html">Color[]{COLOR_SECTION_BLUE_DARK,COLOR_SECTION_BLUE};
742
        1.5.0/docs/api/java/awt/Color.html">Color[] colors = new 1.5.0/docs/api/java/awt/Color.html">Color[]{COLOR_SECTION_BLUE_DARK,COLOR_SECTION_BLUE};
743
        1.5.0/docs/api/java/awt/Color.html">Color[] colorsLabels = new 1.5.0/docs/api/java/awt/Color.html">Color[]{1.5.0/docs/api/java/awt/Color.html">Color.black,1.5.0/docs/api/java/awt/Color.html">Color.black};
743
        1.5.0/docs/api/java/awt/Color.html">Color[] colorsLabels = new 1.5.0/docs/api/java/awt/Color.html">Color[]{1.5.0/docs/api/java/awt/Color.html">Color.black,1.5.0/docs/api/java/awt/Color.html">Color.black};
744
        double[][] values = new double[][]{
744
        double[][] values = new double[][]{
745
                new double[]{4.6,4.2},
745
                new double[]{4.6,4.2},
746
                new double[]{3.4,3.5},
746
                new double[]{3.4,3.5},
747
                new double[]{4.2,3.8},
747
                new double[]{4.2,3.8},
748
                new double[]{4.5,5.0},
748
                new double[]{4.5,5.0},
749
        };
749
        };
750
        createBarChartBarsCategories(series,categories,colors,colorsLabels,values,0,5,"testeBarras",300,40);
750
        createBarChartBarsCategories(series,categories,colors,colorsLabels,values,0,5,"testeBarras",300,40);
751
    }
751
    }
752
 
752
 
753
    /**
753
    /**
754
     *
754
     *
755
     * @param series valores a considerar, exemplo Media Docente, Media Unidade
755
     * @param series valores a considerar, exemplo Media Docente, Media Unidade
756
     * @param categories objectos a considerar exemplo Cadeiras
756
     * @param categories objectos a considerar exemplo Cadeiras
757
     * @param seriesColors cores das series nas series
757
     * @param seriesColors cores das series nas series
758
     * @param seriesLabelColors cores das letras nas series
758
     * @param seriesLabelColors cores das letras nas series
759
     * @param values matrix de valores exemplo double[10][2] para dois valores em 10 objectos
759
     * @param values matrix de valores exemplo double[10][2] para dois valores em 10 objectos
760
     * @param min minimo da escala
760
     * @param min minimo da escala
761
     * @param max máximo da escala
761
     * @param max máximo da escala
762
     * @param pathTemplate caminho prefixo para o grafico gerado
762
     * @param pathTemplate caminho prefixo para o grafico gerado
763
     * @return devolve caminho final do grafico gerado
763
     * @return devolve caminho final do grafico gerado
764
     * @throws IOException
764
     * @throws IOException
765
     */
765
     */
766
    public static 1.5.0/docs/api/java/lang/String.html">String createBarChartBarsCategories(1.5.0/docs/api/java/lang/String.html">String[]series, 1.5.0/docs/api/java/lang/String.html">String[] categories,final 1.5.0/docs/api/java/awt/Color.html">Color[] seriesColors,final 1.5.0/docs/api/java/awt/Color.html">Color[] seriesLabelColors,double[][] values, double min, double max, 1.5.0/docs/api/java/lang/String.html">String pathTemplate,int width,int heightPerCategory) throws 1.5.0/docs/api/java/io/IOException.html">IOException
766
    public static 1.5.0/docs/api/java/lang/String.html">String createBarChartBarsCategories(1.5.0/docs/api/java/lang/String.html">String[]series, 1.5.0/docs/api/java/lang/String.html">String[] categories,final 1.5.0/docs/api/java/awt/Color.html">Color[] seriesColors,final 1.5.0/docs/api/java/awt/Color.html">Color[] seriesLabelColors,double[][] values, double min, double max, 1.5.0/docs/api/java/lang/String.html">String pathTemplate,int width,int heightPerCategory) throws 1.5.0/docs/api/java/io/IOException.html">IOException
767
    {
767
    {
768
 
768
 
769
        //Exemplo Series são as unidades
769
        //Exemplo Series são as unidades
770
        //categorias é a media docente, media unidade, media curso
770
        //categorias é a media docente, media unidade, media curso
771
        DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();
771
        DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset();
772
 
772
 
773
        for(int s = 0; s< series.length; s++)
773
        for(int s = 0; s< series.length; s++)
774
        {
774
        {
775
            1.5.0/docs/api/java/lang/String.html">String serie = series[s];
775
            1.5.0/docs/api/java/lang/String.html">String serie = series[s];
776
            for(int c = 0; c< categories.length; c++)
776
            for(int c = 0; c< categories.length; c++)
777
            {
777
            {
778
                1.5.0/docs/api/java/lang/String.html">String category = categories[c];
778
                1.5.0/docs/api/java/lang/String.html">String category = categories[c];
779
                double value = values[c][s];
779
                double value = values[c][s];
780
                categoryDataset.addValue(value,serie,category);
780
                categoryDataset.addValue(value,serie,category);
781
            }
781
            }
782
        }
782
        }
783
 
783
 
784
        JFreeChart chart = ChartFactory.createBarChart(null, null, null, categoryDataset, PlotOrientation.HORIZONTAL, true, true, false);
784
        JFreeChart chart = ChartFactory.createBarChart(null, null, null, categoryDataset, PlotOrientation.HORIZONTAL, true, true, false);
785
        chart.setAntiAlias(true);
785
        chart.setAntiAlias(true);
786
        chart.setTextAntiAlias(true);
786
        chart.setTextAntiAlias(true);
787
        chart.setBackgroundPaint(TRANSPARENT);
787
        chart.setBackgroundPaint(TRANSPARENT);
788
        CategoryPlot barChartPlot = (CategoryPlot) chart.getPlot();
788
        CategoryPlot barChartPlot = (CategoryPlot) chart.getPlot();
789
 
789
 
790
 
790
 
791
 
791
 
792
 
792
 
793
 
793
 
794
        //PARA BATER CERTO TEMOS DE DAR AS CORES EM DOIS SITIOS, AQUI E NO METODO DO RENDER
794
        //PARA BATER CERTO TEMOS DE DAR AS CORES EM DOIS SITIOS, AQUI E NO METODO DO RENDER
795
        barChartPlot.setDrawingSupplier(new ChartBuilderUtil.ChartDrawingSupplier(
795
        barChartPlot.setDrawingSupplier(new ChartBuilderUtil.ChartDrawingSupplier(
796
                seriesColors
796
                seriesColors
797
        ));
797
        ));
798
 
798
 
799
 
799
 
800
        barChartPlot.setBackgroundPaint(TRANSPARENT);
800
        barChartPlot.setBackgroundPaint(TRANSPARENT);
801
        barChartPlot.setOutlineVisible(false);
801
        barChartPlot.setOutlineVisible(false);
802
        barChartPlot.setRenderer(new BarRenderer() {
802
        barChartPlot.setRenderer(new BarRenderer() {
803
            @1.5.0/docs/api/java/lang/Override.html">Override
803
            @1.5.0/docs/api/java/lang/Override.html">Override
804
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemPaint(int row, int col) {
804
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemPaint(int row, int col) {
805
                return seriesColors[row];
805
                return seriesColors[row];
806
            }
806
            }
807
 
807
 
808
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemLabelPaint(int row, int col) {
808
            public 1.5.0/docs/api/java/awt/Paint.html">Paint getItemLabelPaint(int row, int col) {
809
                return seriesLabelColors[row];
809
                return seriesLabelColors[row];
810
            }
810
            }
811
        }
811
        }
812
        );
812
        );
813
        ((BarRenderer)barChartPlot.getRenderer()).setLegendShape(0,new 1.5.0/docs/api/java/awt/Rectangle.html">Rectangle(60,60));
813
        ((BarRenderer)barChartPlot.getRenderer()).setLegendShape(0,new 1.5.0/docs/api/java/awt/Rectangle.html">Rectangle(60,60));
814
        ((BarRenderer)barChartPlot.getRenderer()).setLegendShape(1,new 1.5.0/docs/api/java/awt/Rectangle.html">Rectangle(60,60));
814
        ((BarRenderer)barChartPlot.getRenderer()).setLegendShape(1,new 1.5.0/docs/api/java/awt/Rectangle.html">Rectangle(60,60));
815
 
815
 
816
 
816
 
817
        barChartPlot.getDomainAxis().setMaximumCategoryLabelLines(2);
817
        barChartPlot.getDomainAxis().setMaximumCategoryLabelLines(2);
818
        barChartPlot.getRangeAxis().setUpperMargin(0.15);
818
        barChartPlot.getRangeAxis().setUpperMargin(0.15);
819
        barChartPlot.getRangeAxis().setRange(min, max);
819
        barChartPlot.getRangeAxis().setRange(min, max);
820
        barChartPlot.getRangeAxis().setVisible(false);
820
        barChartPlot.getRangeAxis().setVisible(false);
821
 
821
 
822
 
822
 
823
        1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat dfKey = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.##");
823
        1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat dfKey = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.##");
824
        barChartPlot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}",dfKey));
824
        barChartPlot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}",dfKey));
825
        (((CategoryPlot) chart.getPlot()).getRangeAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
825
        (((CategoryPlot) chart.getPlot()).getRangeAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
826
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 65));
826
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 65));
827
        (((CategoryPlot) chart.getPlot()).getDomainAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
827
        (((CategoryPlot) chart.getPlot()).getDomainAxis()).setTickLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
828
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 60));
828
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 60));
829
        ((BarRenderer)((CategoryPlot) chart.getPlot()).getRenderer()).setBaseLegendTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
829
        ((BarRenderer)((CategoryPlot) chart.getPlot()).getRenderer()).setBaseLegendTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
830
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.BOLD, 60));
830
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.BOLD, 60));
831
        ((CategoryPlot) chart.getPlot()).getRenderer().setBaseItemLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
831
        ((CategoryPlot) chart.getPlot()).getRenderer().setBaseItemLabelFont(new 1.5.0/docs/api/java/awt/Font.html">Font(
832
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 60));
832
                "Helvetica", 1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 60));
833
        ((BarRenderer)barChartPlot.getRenderer()).setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT));
833
        ((BarRenderer)barChartPlot.getRenderer()).setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT));
834
        ((BarRenderer)barChartPlot.getRenderer()).setShadowVisible(false);
834
        ((BarRenderer)barChartPlot.getRenderer()).setShadowVisible(false);
835
        barChartPlot.getRenderer().setBaseItemLabelsVisible(true);
835
        barChartPlot.getRenderer().setBaseItemLabelsVisible(true);
836
        barChartPlot.getRenderer().setBaseSeriesVisible(true);
836
        barChartPlot.getRenderer().setBaseSeriesVisible(true);
837
        barChartPlot.getRenderer().setItemLabelsVisible(true);
837
        barChartPlot.getRenderer().setItemLabelsVisible(true);
838
        //((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1.0);
838
        //((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(1.0);
839
        ((BarRenderer)barChartPlot.getRenderer()).setItemMargin(0);
839
        ((BarRenderer)barChartPlot.getRenderer()).setItemMargin(0);
840
        ((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(0.5);
840
        ((BarRenderer)barChartPlot.getRenderer()).setMaximumBarWidth(0.5);
841
        ((BarRenderer)barChartPlot.getRenderer()).setMinimumBarLength(5);
841
        ((BarRenderer)barChartPlot.getRenderer()).setMinimumBarLength(5);
842
        ((BarRenderer)barChartPlot.getRenderer()).setItemLabelPaint(null);
842
        ((BarRenderer)barChartPlot.getRenderer()).setItemLabelPaint(null);
843
 
843
 
844
 
844
 
845
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( width*8, categories.length * heightPerCategory * 8);
845
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage( width*8, categories.length * heightPerCategory * 8);
846
        1.5.0/docs/api/java/lang/String.html">String pathGraficoRespostas = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate  + "categoriesBars.png";
846
        1.5.0/docs/api/java/lang/String.html">String pathGraficoRespostas = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate  + "categoriesBars.png";
847
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathGraficoRespostas));
847
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathGraficoRespostas));
848
        return pathGraficoRespostas;
848
        return pathGraficoRespostas;
849
 
849
 
850
    }
850
    }
851
 
851
 
852
    public static 1.5.0/docs/api/java/lang/String.html">String getBackgroundColorDiff(double diff)
852
    public static 1.5.0/docs/api/java/lang/String.html">String getBackgroundColorDiff(double diff)
853
    {
853
    {
854
        if(diff > 0)
854
        if(diff > 0)
855
        {
855
        {
856
            if(diff < 1.0)
856
            if(diff < 1.0)
857
                return COLOR_4_HEX;
857
                return COLOR_4_HEX;
858
            else
858
            else
859
                return COLOR_5_HEX;
859
                return COLOR_5_HEX;
860
        }
860
        }
861
        else {
861
        else {
862
            if(diff > -1.0)
862
            if(diff > -1.0)
863
                return COLOR_3_HEX;
863
                return COLOR_3_HEX;
864
            else if(diff > -2.0)
864
            else if(diff > -2.0)
865
                return COLOR_2_HEX;
865
                return COLOR_2_HEX;
866
            else
866
            else
867
                return COLOR_1_HEX;
867
                return COLOR_1_HEX;
868
        }
868
        }
869
    }
869
    }
870
 
870
 
871
    public static int getGreenComponentGradient(double percentageDecimal)
871
    public static int getGreenComponentGradient(double percentageDecimal)
872
    {
872
    {
873
        return (int) (255.0*(percentageDecimal*2));
873
        return (int) (255.0*(percentageDecimal*2));
874
    }
874
    }
875
    public static int getRedComponentGradient(double percentageDecimal)
875
    public static int getRedComponentGradient(double percentageDecimal)
876
    {//Tirando um numero onde esta 1 e metendo 1 estamos a aprocimar o amarelo mais depressa
876
    {//Tirando um numero onde esta 1 e metendo 1 estamos a aprocimar o amarelo mais depressa
877
        return (int)( 1 + (255.0-1.0)*(-(((percentageDecimal -0.5)*(percentageDecimal -0.5))*4.0)+1.0));
877
        return (int)( 1 + (255.0-1.0)*(-(((percentageDecimal -0.5)*(percentageDecimal -0.5))*4.0)+1.0));
878
    }
878
    }
879
    public static 1.5.0/docs/api/java/lang/String.html">String createChartRingOneDimension(double value, double max,boolean colorsPercent,boolean degrade,boolean putPercentInCenter, 1.5.0/docs/api/java/lang/String.html">String pathTemplate) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
879
    public static 1.5.0/docs/api/java/lang/String.html">String createChartRingOneDimension(double value, double max,boolean colorsPercent,boolean degrade,boolean putPercentInCenter, 1.5.0/docs/api/java/lang/String.html">String pathTemplate) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
880
 
880
 
881
        DefaultPieDataset data = new DefaultPieDataset();
881
        DefaultPieDataset data = new DefaultPieDataset();
882
 
882
 
883
 
883
 
884
        1.5.0/docs/api/java/lang/Number.html">Number n;
884
        1.5.0/docs/api/java/lang/Number.html">Number n;
885
 
885
 
886
        data.setValue("A", value);
886
        data.setValue("A", value);
887
        data.setValue("B", max-value);
887
        data.setValue("B", max-value);
888
 
888
 
889
 
889
 
890
 
890
 
891
 
891
 
892
        JFreeChart chart = ChartFactory.createRingChart(null, data, false, false, false);
892
        JFreeChart chart = ChartFactory.createRingChart(null, data, false, false, false);
893
        chart.setBackgroundPaint(TRANSPARENT);
893
        chart.setBackgroundPaint(TRANSPARENT);
894
 
894
 
895
        RingPlot plot = (RingPlot) chart.getPlot();
895
        RingPlot plot = (RingPlot) chart.getPlot();
896
 
896
 
897
 
897
 
898
        //plot.setLabelBackgroundPaint(new Color(255, 249, 235));
898
        //plot.setLabelBackgroundPaint(new Color(255, 249, 235));
899
        //plot.setLabelPaint(new Color(88, 88, 90));
899
        //plot.setLabelPaint(new Color(88, 88, 90));
900
        plot.setLabelGenerator(null);
900
        plot.setLabelGenerator(null);
901
        plot.setDrawingSupplier(new ChartDrawingSupplier());
901
        plot.setDrawingSupplier(new ChartDrawingSupplier());
902
        //CategoryItemRenderer render = chart.getCategoryPlot().getRenderer();
902
        //CategoryItemRenderer render = chart.getCategoryPlot().getRenderer();
903
        //render.setSeriesPaint(0,new Color(255,201,92));
903
        //render.setSeriesPaint(0,new Color(255,201,92));
904
        plot.setBackgroundPaint(TRANSPARENT);
904
        plot.setBackgroundPaint(TRANSPARENT);
905
        plot.setOutlineVisible(false);
905
        plot.setOutlineVisible(false);
906
        plot.setSectionDepth(0.12);
906
        plot.setSectionDepth(0.12);
907
        if(degrade)
907
        if(degrade)
908
        {
908
        {
909
            double percent = (value/max);
909
            double percent = (value/max);
910
            if(percent < 0.5)
910
            if(percent < 0.5)
911
            {
911
            {
912
                plot.setSectionPaint("A", new 1.5.0/docs/api/java/awt/Color.html">Color(255,getGreenComponentGradient(percent), 0));
912
                plot.setSectionPaint("A", new 1.5.0/docs/api/java/awt/Color.html">Color(255,getGreenComponentGradient(percent), 0));
913
            }
913
            }
914
            else
914
            else
915
            {
915
            {
916
                //plot.setSectionPaint("A", new Color((int) (255.0*((1.0-percent)*2)), 255, 0));
916
                //plot.setSectionPaint("A", new Color((int) (255.0*((1.0-percent)*2)), 255, 0));
917
                plot.setSectionPaint("A", new 1.5.0/docs/api/java/awt/Color.html">Color((int) getRedComponentGradient(percent), 255, 0));
917
                plot.setSectionPaint("A", new 1.5.0/docs/api/java/awt/Color.html">Color((int) getRedComponentGradient(percent), 255, 0));
918
            }
918
            }
919
 
919
 
920
        }
920
        }
921
        else if(colorsPercent)
921
        else if(colorsPercent)
922
        {
922
        {
923
            double fraction = max / 5.0;
923
            double fraction = max / 5.0;
924
            if(value < fraction)
924
            if(value < fraction)
925
                plot.setSectionPaint("A", COLOR_1);
925
                plot.setSectionPaint("A", COLOR_1);
926
            else if(value < fraction*2)
926
            else if(value < fraction*2)
927
                plot.setSectionPaint("A", COLOR_2);
927
                plot.setSectionPaint("A", COLOR_2);
928
            else if(value < fraction*3)
928
            else if(value < fraction*3)
929
                plot.setSectionPaint("A", COLOR_3);
929
                plot.setSectionPaint("A", COLOR_3);
930
            else if(value < fraction*4)
930
            else if(value < fraction*4)
931
                plot.setSectionPaint("A", COLOR_4);
931
                plot.setSectionPaint("A", COLOR_4);
932
            else
932
            else
933
                plot.setSectionPaint("A", COLOR_5);
933
                plot.setSectionPaint("A", COLOR_5);
934
        }
934
        }
935
        else
935
        else
936
            plot.setSectionPaint("A", new 1.5.0/docs/api/java/awt/Color.html">Color(113, 154, 181));
936
            plot.setSectionPaint("A", new 1.5.0/docs/api/java/awt/Color.html">Color(113, 154, 181));
937
        plot.setSectionPaint("B", new 1.5.0/docs/api/java/awt/Color.html">Color(100, 100, 100));
937
        plot.setSectionPaint("B", new 1.5.0/docs/api/java/awt/Color.html">Color(100, 100, 100));
938
 
938
 
939
        plot.setCenterTextMode(CenterTextMode.FIXED);
939
        plot.setCenterTextMode(CenterTextMode.FIXED);
940
        plot.setCenterText("" + df1.format(value) + (putPercentInCenter?" %":""));
940
        plot.setCenterText("" + df1.format(value) + (putPercentInCenter?" %":""));
941
        plot.setCenterTextColor(1.5.0/docs/api/java/awt/Color.html">Color.black);
941
        plot.setCenterTextColor(1.5.0/docs/api/java/awt/Color.html">Color.black);
942
        plot.setCenterTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.SANS_SERIF, 1.5.0/docs/api/java/awt/Font.html">Font.BOLD, 100));
942
        plot.setCenterTextFont(new 1.5.0/docs/api/java/awt/Font.html">Font(1.5.0/docs/api/java/awt/Font.html">Font.SANS_SERIF, 1.5.0/docs/api/java/awt/Font.html">Font.BOLD, 100));
943
 
943
 
944
 
944
 
945
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage(  300*2, 300*2);
945
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage(  300*2, 300*2);
946
        1.5.0/docs/api/java/lang/String.html">String pathRing = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate + "Ring.png";
946
        1.5.0/docs/api/java/lang/String.html">String pathRing = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + pathTemplate + "Ring.png";
947
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathRing));
947
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(pathRing));
948
        return pathRing;
948
        return pathRing;
949
    }
949
    }
950
 
950
 
951
    public static 1.5.0/docs/api/java/lang/String.html">String createTimeSeriesDiffArea(1.5.0/docs/api/java/lang/String.html">String tmpName,1.5.0/docs/api/java/lang/String.html">String serie1Name,1.5.0/docs/api/java/lang/String.html">String serie2Name,java.util.List<Object[]> series1,java.util.List<Object[]> series2) throws 1.5.0/docs/api/java/io/IOException.html">IOException
951
    public static 1.5.0/docs/api/java/lang/String.html">String createTimeSeriesDiffArea(1.5.0/docs/api/java/lang/String.html">String tmpName,1.5.0/docs/api/java/lang/String.html">String serie1Name,1.5.0/docs/api/java/lang/String.html">String serie2Name,java.util.List<Object[]> series1,java.util.List<Object[]> series2) throws 1.5.0/docs/api/java/io/IOException.html">IOException
952
    {
952
    {
953
        final XYDataset dataset = createDataset(serie1Name, serie2Name, series1, series2);
953
        final XYDataset dataset = createDataset(serie1Name, serie2Name, series1, series2);
954
        final JFreeChart chart = createChart(dataset);
954
        final JFreeChart chart = createChart(dataset);
955
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage(  600*4, 400*4);
955
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage(  600*4, 400*4);
956
        1.5.0/docs/api/java/lang/String.html">String path = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + tmpName + "timeSeries.png";
956
        1.5.0/docs/api/java/lang/String.html">String path = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + tmpName + "timeSeries.png";
957
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(path));
957
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(path));
958
        return path;
958
        return path;
959
    }
959
    }
960
 
960
 
961
    private static JFreeChart createChart(final XYDataset dataset) {
961
    private static JFreeChart createChart(final XYDataset dataset) {
962
 
962
 
963
        final JFreeChart chart = ChartFactory.createTimeSeriesChart(
963
        final JFreeChart chart = ChartFactory.createTimeSeriesChart(
964
                "",
964
                "",
965
                "",
965
                "",
966
                "",
966
                "",
967
                dataset,
967
                dataset,
968
                true,
968
                true,
969
                false,
969
                false,
970
                false
970
                false
971
        );
971
        );
972
 
972
 
973
        chart.setBackgroundPaint(1.5.0/docs/api/java/awt/Color.html">Color.white);//light gray
973
        chart.setBackgroundPaint(1.5.0/docs/api/java/awt/Color.html">Color.white);//light gray
974
 
974
 
975
        final XYPlot plot = chart.getXYPlot();
975
        final XYPlot plot = chart.getXYPlot();
976
        plot.setBackgroundPaint(1.5.0/docs/api/java/awt/Color.html">Color.white);
976
        plot.setBackgroundPaint(1.5.0/docs/api/java/awt/Color.html">Color.white);
977
        plot.setDomainGridlinesVisible(true);
977
        plot.setDomainGridlinesVisible(true);
978
        plot.setDomainGridlinePaint(1.5.0/docs/api/java/awt/Color.html">Color.lightGray);
978
        plot.setDomainGridlinePaint(1.5.0/docs/api/java/awt/Color.html">Color.lightGray);
979
        plot.setRangeGridlinesVisible(true);
979
        plot.setRangeGridlinesVisible(true);
980
        plot.setRangeGridlinePaint(1.5.0/docs/api/java/awt/Color.html">Color.lightGray);
980
        plot.setRangeGridlinePaint(1.5.0/docs/api/java/awt/Color.html">Color.lightGray);
981
        plot.setDomainCrosshairVisible(true);
981
        plot.setDomainCrosshairVisible(true);
982
        plot.setRangeCrosshairVisible(false);
982
        plot.setRangeCrosshairVisible(false);
983
 
983
 
984
        //plot.setRenderer(0, new XYDifferenceRenderer(GREEN_OK,COLOR_3,true));
984
        //plot.setRenderer(0, new XYDifferenceRenderer(GREEN_OK,COLOR_3,true));
985
        plot.setRenderer(0, new XYLineAndShapeRenderer(true,true));
985
        plot.setRenderer(0, new XYLineAndShapeRenderer(true,true));
986
        plot.setRenderer(1, new XYLineAndShapeRenderer(true,true));
986
        plot.setRenderer(1, new XYLineAndShapeRenderer(true,true));
987
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
987
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
988
 
988
 
989
        //renderer.setLegendShape(0,new Rectangle(60,60));
989
        //renderer.setLegendShape(0,new Rectangle(60,60));
990
        //renderer.setLegendShape(1,new Rectangle(60,60));
990
        //renderer.setLegendShape(1,new Rectangle(60,60));
991
        renderer.setBaseLegendTextFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
991
        renderer.setBaseLegendTextFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
992
 
992
 
993
        renderer.setBaseItemLabelsVisible(true);
993
        renderer.setBaseItemLabelsVisible(true);
994
        renderer.setItemLabelsVisible(true);
994
        renderer.setItemLabelsVisible(true);
995
 
995
 
996
        renderer.setSeriesPaint(0,COLOR_SECTION_BLUE_DARK);
996
        renderer.setSeriesPaint(0,COLOR_SECTION_BLUE_DARK);
997
        renderer.setSeriesPaint(1,NEUTRAL_TOTAL);
997
        renderer.setSeriesPaint(1,NEUTRAL_TOTAL);
998
        renderer.setSeriesStroke(0,new 1.5.0/docs/api/java/awt/BasicStroke.html">BasicStroke(20.0f));
998
        renderer.setSeriesStroke(0,new 1.5.0/docs/api/java/awt/BasicStroke.html">BasicStroke(20.0f));
999
        renderer.setSeriesStroke(1,new 1.5.0/docs/api/java/awt/BasicStroke.html">BasicStroke(20.0f));
999
        renderer.setSeriesStroke(1,new 1.5.0/docs/api/java/awt/BasicStroke.html">BasicStroke(20.0f));
1000
 
1000
 
1001
 
1001
 
1002
        1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat dfKey = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.##");
1002
        1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat dfKey = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.##");
1003
 
1003
 
1004
        StandardXYItemLabelGenerator labelGenerator = new StandardXYItemLabelGenerator("{2}", dfKey, dfKey);
1004
        StandardXYItemLabelGenerator labelGenerator = new StandardXYItemLabelGenerator("{2}", dfKey, dfKey);
1005
 
1005
 
1006
        /*
1006
        /*
1007
         * {0} - label would be equal to Series expression,
1007
         * {0} - label would be equal to Series expression,
1008
         * {1} - label would be equal to Category expression,
1008
         * {1} - label would be equal to Category expression,
1009
         * {2} - label would be equal to Value expression
1009
         * {2} - label would be equal to Value expression
1010
         *
1010
         *
1011
         */
1011
         */
1012
 
1012
 
1013
 
1013
 
1014
 
1014
 
1015
        renderer.setBaseItemLabelsVisible(true);
1015
        renderer.setBaseItemLabelsVisible(true);
1016
 
1016
 
1017
        renderer.setBaseItemLabelGenerator(labelGenerator);
1017
        renderer.setBaseItemLabelGenerator(labelGenerator);
1018
 
1018
 
1019
        renderer.setBaseItemLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
1019
        renderer.setBaseItemLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
1020
        plot.getDomainAxis().setLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
1020
        plot.getDomainAxis().setLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
1021
        plot.getDomainAxis().setTickLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
1021
        plot.getDomainAxis().setTickLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
1022
        plot.getRangeAxis().setLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
1022
        plot.getRangeAxis().setLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
1023
        plot.getRangeAxis().setTickLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
1023
        plot.getRangeAxis().setTickLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
1024
 
1024
 
1025
        //plot.getRangeAxis().setUpperMargin(0.10);
1025
        //plot.getRangeAxis().setUpperMargin(0.10);
1026
        plot.getDomainAxis().setUpperMargin(0.05);
1026
        plot.getDomainAxis().setUpperMargin(0.05);
1027
        plot.getDomainAxis().setLowerMargin(0.05);
1027
        plot.getDomainAxis().setLowerMargin(0.05);
1028
        /*
1028
        /*
1029
        renderer.setSeriesPositiveItemLabelPosition(0,
1029
        renderer.setSeriesPositiveItemLabelPosition(0,
1030
                                                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
1030
                                                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
1031
                                                                          TextAnchor.BOTTOM_LEFT,
1031
                                                                          TextAnchor.BOTTOM_LEFT,
1032
                                                                          TextAnchor.BOTTOM_LEFT,
1032
                                                                          TextAnchor.BOTTOM_LEFT,
1033
                                                                          Math.PI));*/
1033
                                                                          Math.PI));*/
1034
        renderer.setSeriesShape(0, ShapeUtilities.createDiamond(20F));
1034
        renderer.setSeriesShape(0, ShapeUtilities.createDiamond(20F));
1035
 
1035
 
1036
        DateAxis dateaxis = (DateAxis) plot.getDomainAxis();
1036
        DateAxis dateaxis = (DateAxis) plot.getDomainAxis();
1037
        dateaxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH,1,new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("dd-MMM")));
1037
        dateaxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH,1,new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("dd-MMM")));
1038
 
1038
 
1039
        //plot.setRenderer(1,new XYLineAndShapeRenderer());
1039
        //plot.setRenderer(1,new XYLineAndShapeRenderer());
1040
 
1040
 
1041
        /*final XYItemRenderer xyitemrenderer  = plot.getRenderer();
1041
        /*final XYItemRenderer xyitemrenderer  = plot.getRenderer();
1042
        if (xyitemrenderer  instanceof XYLineAndShapeRenderer) {
1042
        if (xyitemrenderer  instanceof XYLineAndShapeRenderer) {
1043
            final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyitemrenderer;
1043
            final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyitemrenderer;
1044
            renderer.setBaseShapesFilled(true);
1044
            renderer.setBaseShapesFilled(true);
1045
            renderer.setBaseShapesVisible(true);
1045
            renderer.setBaseShapesVisible(true);
1046
            renderer.setShapesVisible( true );
1046
            renderer.setShapesVisible( true );
1047
            renderer.setDrawOutlines( true );
1047
            renderer.setDrawOutlines( true );
1048
 
1048
 
1049
            //sets the joint level size means the dot size which join two points on a graph 2f,3f
1049
            //sets the joint level size means the dot size which join two points on a graph 2f,3f
1050
            Stroke stroke = new BasicStroke(
1050
            Stroke stroke = new BasicStroke(
1051
                    3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
1051
                    3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
1052
            renderer.setBaseOutlineStroke(stroke);
1052
            renderer.setBaseOutlineStroke(stroke);
1053
 
1053
 
1054
        }*/
1054
        }*/
1055
 
1055
 
1056
 
1056
 
1057
        final DateAxis xaxis = (DateAxis) plot.getDomainAxis();
1057
        final DateAxis xaxis = (DateAxis) plot.getDomainAxis();
1058
        //Change domain axis lable by 180/4=45 degree
1058
        //Change domain axis lable by 180/4=45 degree
1059
        //xaxis.setLabelAngle(Math.PI / 4.0);
1059
        //xaxis.setLabelAngle(Math.PI / 4.0);
1060
 
1060
 
1061
        //Sets the Tick Labels means domain value labels by 90 degree
1061
        //Sets the Tick Labels means domain value labels by 90 degree
1062
        xaxis.setVerticalTickLabels(true);
1062
        xaxis.setVerticalTickLabels(true);
1063
 
1063
 
1064
 
1064
 
1065
        //Try to play with it. It will work only in case of  horizontal tick mark
1065
        //Try to play with it. It will work only in case of  horizontal tick mark
1066
 
1066
 
1067
        xaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
1067
        xaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
1068
 
1068
 
1069
        //set date format
1069
        //set date format
1070
        xaxis.setDateFormatOverride(new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("MM-yy"));
1070
        xaxis.setDateFormatOverride(new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("MM-yy"));
1071
 
1071
 
1072
        final NumberAxis yaxis = (NumberAxis) plot.getRangeAxis();
1072
        final NumberAxis yaxis = (NumberAxis) plot.getRangeAxis();
1073
        yaxis.setTickLabelsVisible(true);
1073
        yaxis.setTickLabelsVisible(true);
1074
        yaxis.setVisible(true);
1074
        yaxis.setVisible(true);
1075
        //yaxis.setRange(0,5);
1075
        //yaxis.setRange(0,5);
1076
        yaxis.setUpperMargin(0.15);
1076
        yaxis.setUpperMargin(0.15);
1077
        //To set range values integer only. Default are float
1077
        //To set range values integer only. Default are float
1078
        //yaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
1078
        //yaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
1079
 
1079
 
1080
        return chart;
1080
        return chart;
1081
 
1081
 
1082
    }
1082
    }
1083
 
1083
 
1084
    private static XYDataset createDataset(1.5.0/docs/api/java/lang/String.html">String series1Name, 1.5.0/docs/api/java/lang/String.html">String series2Name, java.util.List<Object[]> series1, java.util.List<Object[]> series2)
1084
    private static XYDataset createDataset(1.5.0/docs/api/java/lang/String.html">String series1Name, 1.5.0/docs/api/java/lang/String.html">String series2Name, java.util.List<Object[]> series1, java.util.List<Object[]> series2)
1085
    {
1085
    {
1086
        final TimeSeriesCollection dataset = new TimeSeriesCollection();
1086
        final TimeSeriesCollection dataset = new TimeSeriesCollection();
1087
        dataset.setDomainIsPointsInTime(true);
1087
        dataset.setDomainIsPointsInTime(true);
1088
 
1088
 
1089
 
1089
 
1090
        final TimeSeries s1 = new TimeSeries(series1Name, Day.class);
1090
        final TimeSeries s1 = new TimeSeries(series1Name, Day.class);
1091
        final TimeSeries s2 = new TimeSeries(series2Name, Day.class);
1091
        final TimeSeries s2 = new TimeSeries(series2Name, Day.class);
1092
 
1092
 
1093
        if(series1.size() == 1 && series2.size() == 1)
1093
        if(series1.size() == 1 && series2.size() == 1)
1094
        {
1094
        {
1095
            5+0%2Fdocs%2Fapi+Date">Date firstDate1 = (5+0%2Fdocs%2Fapi+Date">Date) series1.get(0)[1];
1095
            5+0%2Fdocs%2Fapi+Date">Date firstDate1 = (5+0%2Fdocs%2Fapi+Date">Date) series1.get(0)[1];
1096
            5+0%2Fdocs%2Fapi+Date">Date firstDate2 = (5+0%2Fdocs%2Fapi+Date">Date) series2.get(0)[1];
1096
            5+0%2Fdocs%2Fapi+Date">Date firstDate2 = (5+0%2Fdocs%2Fapi+Date">Date) series2.get(0)[1];
1097
 
1097
 
1098
            long threeMonthsMilis = (long) (60000.0*60.0*24.0*30.0*1.5);
1098
            long threeMonthsMilis = (long) (60000.0*60.0*24.0*30.0*1.5);
1099
            if(firstDate1.getTime() < firstDate2.getTime())
1099
            if(firstDate1.getTime() < firstDate2.getTime())
1100
                firstDate1 = new 5+0%2Fdocs%2Fapi+Date">Date(firstDate1.getTime() - threeMonthsMilis);
1100
                firstDate1 = new 5+0%2Fdocs%2Fapi+Date">Date(firstDate1.getTime() - threeMonthsMilis);
1101
            else
1101
            else
1102
                firstDate1 = new 5+0%2Fdocs%2Fapi+Date">Date(firstDate2.getTime() - threeMonthsMilis);
1102
                firstDate1 = new 5+0%2Fdocs%2Fapi+Date">Date(firstDate2.getTime() - threeMonthsMilis);
1103
 
1103
 
1104
            s1.add(new Day(firstDate1), (1.5.0/docs/api/java/lang/Double.html">Double) series1.get(0)[0]);
1104
            s1.add(new Day(firstDate1), (1.5.0/docs/api/java/lang/Double.html">Double) series1.get(0)[0]);
1105
            s2.add(new Day(firstDate1), (1.5.0/docs/api/java/lang/Double.html">Double) series1.get(0)[0]);
1105
            s2.add(new Day(firstDate1), (1.5.0/docs/api/java/lang/Double.html">Double) series1.get(0)[0]);
1106
 
1106
 
1107
        }
1107
        }
1108
 
1108
 
1109
        for (5+0%2Fdocs%2Fapi+Object">Object[] timeValue : series1) {
1109
        for (5+0%2Fdocs%2Fapi+Object">Object[] timeValue : series1) {
1110
            s1.add(new Day((5+0%2Fdocs%2Fapi+Date">Date) timeValue[1]), (1.5.0/docs/api/java/lang/Double.html">Double) timeValue[0]);
1110
            s1.add(new Day((5+0%2Fdocs%2Fapi+Date">Date) timeValue[1]), (1.5.0/docs/api/java/lang/Double.html">Double) timeValue[0]);
1111
        }
1111
        }
1112
 
1112
 
1113
 
1113
 
1114
        for (5+0%2Fdocs%2Fapi+Object">Object[] timeValue : series2) {
1114
        for (5+0%2Fdocs%2Fapi+Object">Object[] timeValue : series2) {
1115
            s2.add(new Day((5+0%2Fdocs%2Fapi+Date">Date) timeValue[1]), (1.5.0/docs/api/java/lang/Double.html">Double) timeValue[0]);
1115
            s2.add(new Day((5+0%2Fdocs%2Fapi+Date">Date) timeValue[1]), (1.5.0/docs/api/java/lang/Double.html">Double) timeValue[0]);
1116
        }
1116
        }
1117
 
1117
 
1118
 
1118
 
1119
 
1119
 
1120
        dataset.addSeries(s1);
1120
        dataset.addSeries(s1);
1121
        dataset.addSeries(s2);
1121
        dataset.addSeries(s2);
1122
        return dataset;
1122
        return dataset;
1123
    }
1123
    }
1124
 
1124
 
1125
    /**
1125
    /**
1126
     *
1126
     *
1127
     * @param series1Name
1127
     * @param series1Name
1128
     * @param series2Name
1128
     * @param series2Name
1129
     * @param series1 List<Integer count,Integer week Integer year>
1129
     * @param series1 List<Integer count,Integer week Integer year>
1130
     * @param series2 List<Integer count,Integer week, Integer year>
1130
     * @param series2 List<Integer count,Integer week, Integer year>
1131
     * @return
1131
     * @return
1132
     */
1132
     */
1133
    private static XYDataset createWeekDataset(1.5.0/docs/api/java/lang/String.html">String series1Name, 1.5.0/docs/api/java/lang/String.html">String series2Name, java.util.List<Object[]> series1, java.util.List<Object[]> series2)
1133
    private static XYDataset createWeekDataset(1.5.0/docs/api/java/lang/String.html">String series1Name, 1.5.0/docs/api/java/lang/String.html">String series2Name, java.util.List<Object[]> series1, java.util.List<Object[]> series2)
1134
    {
1134
    {
1135
        final TimeSeriesCollection dataset = new TimeSeriesCollection();
1135
        final TimeSeriesCollection dataset = new TimeSeriesCollection();
1136
        dataset.setDomainIsPointsInTime(true);
1136
        dataset.setDomainIsPointsInTime(true);
1137
 
1137
 
1138
 
1138
 
1139
        final TimeSeries s1 = new TimeSeries(series1Name, Week.class);
1139
        final TimeSeries s1 = new TimeSeries(series1Name, Week.class);
1140
        final TimeSeries s2 = new TimeSeries(series2Name, Week.class);
1140
        final TimeSeries s2 = new TimeSeries(series2Name, Week.class);
1141
 
1141
 
1142
        for (5+0%2Fdocs%2Fapi+Object">Object[] timeValue : series1) {
1142
        for (5+0%2Fdocs%2Fapi+Object">Object[] timeValue : series1) {
1143
            s1.add(new Week((1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[1],(1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[2]),(1.5.0/docs/api/java/lang/Long.html">Long) timeValue[0]);
1143
            s1.add(new Week((1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[1],(1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[2]),(1.5.0/docs/api/java/lang/Long.html">Long) timeValue[0]);
1144
        }
1144
        }
1145
        for (5+0%2Fdocs%2Fapi+Object">Object[] timeValue : series2) {
1145
        for (5+0%2Fdocs%2Fapi+Object">Object[] timeValue : series2) {
1146
            s2.add(new Week((1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[1],(1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[2]),(1.5.0/docs/api/java/lang/Long.html">Long) timeValue[0]);
1146
            s2.add(new Week((1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[1],(1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[2]),(1.5.0/docs/api/java/lang/Long.html">Long) timeValue[0]);
1147
        }
1147
        }
1148
        dataset.addSeries(s1);
1148
        dataset.addSeries(s1);
1149
        dataset.addSeries(s2);
1149
        dataset.addSeries(s2);
1150
        return dataset;
1150
        return dataset;
1151
    }
1151
    }
1152
 
1152
 
1153
 
1153
 
1154
 
1154
 
1155
    /**
1155
    /**
1156
     *
1156
     *
1157
     * @param series1Name
1157
     * @param series1Name
1158
     * @param series1 List<Integer count,Integer week Integer year>
1158
     * @param series1 List<Integer count,Integer week Integer year>
1159
     * @return
1159
     * @return
1160
     */
1160
     */
1161
    private static XYDataset createWeekDatasetDiffPercent(1.5.0/docs/api/java/lang/String.html">String series1Name,1.5.0/docs/api/java/lang/String.html">String seriesName2, java.util.List<Object[]> series1,int totalAAtingir)
1161
    private static XYDataset createWeekDatasetDiffPercent(1.5.0/docs/api/java/lang/String.html">String series1Name,1.5.0/docs/api/java/lang/String.html">String seriesName2, java.util.List<Object[]> series1,int totalAAtingir)
1162
    {
1162
    {
1163
        final TimeSeriesCollection dataset = new TimeSeriesCollection();
1163
        final TimeSeriesCollection dataset = new TimeSeriesCollection();
1164
        dataset.setDomainIsPointsInTime(true);
1164
        dataset.setDomainIsPointsInTime(true);
1165
 
1165
 
1166
 
1166
 
1167
        final TimeSeries s1 = new TimeSeries(series1Name, Week.class);
1167
        final TimeSeries s1 = new TimeSeries(series1Name, Week.class);
1168
        final TimeSeries s2 = new TimeSeries(seriesName2, Week.class);
1168
        final TimeSeries s2 = new TimeSeries(seriesName2, Week.class);
1169
 
1169
 
1170
        for (5+0%2Fdocs%2Fapi+Object">Object[] timeValue : series1) {
1170
        for (5+0%2Fdocs%2Fapi+Object">Object[] timeValue : series1) {
1171
            s1.add(new Week((1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[1],(1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[2]),(1.5.0/docs/api/java/lang/Long.html">Long) timeValue[0]);
1171
            s1.add(new Week((1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[1],(1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[2]),(1.5.0/docs/api/java/lang/Long.html">Long) timeValue[0]);
1172
        }
1172
        }
1173
        for (5+0%2Fdocs%2Fapi+Object">Object[] timeValue : series1) {
1173
        for (5+0%2Fdocs%2Fapi+Object">Object[] timeValue : series1) {
1174
            s2.add(new Week((1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[1],(1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[2]),totalAAtingir - (1.5.0/docs/api/java/lang/Long.html">Long) timeValue[0]);
1174
            s2.add(new Week((1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[1],(1.5.0/docs/api/java/lang/Integer.html">Integer)timeValue[2]),totalAAtingir - (1.5.0/docs/api/java/lang/Long.html">Long) timeValue[0]);
1175
        }
1175
        }
1176
        dataset.addSeries(s1);
1176
        dataset.addSeries(s1);
1177
        dataset.addSeries(s2);
1177
        dataset.addSeries(s2);
1178
        return dataset;
1178
        return dataset;
1179
    }
1179
    }
1180
       
1180
       
1181
    public static 1.5.0/docs/api/java/lang/String.html">String createTimeSeriesCursoRepostas(1.5.0/docs/api/java/lang/String.html">String tmpName,1.5.0/docs/api/java/lang/String.html">String nomeCurso,1.5.0/docs/api/java/lang/String.html">String nomeEscola,java.util.List<Object[]> series1,java.util.List<Object[]> series2) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
1181
    public static 1.5.0/docs/api/java/lang/String.html">String createTimeSeriesCursoRepostas(1.5.0/docs/api/java/lang/String.html">String tmpName,1.5.0/docs/api/java/lang/String.html">String nomeCurso,1.5.0/docs/api/java/lang/String.html">String nomeEscola,java.util.List<Object[]> series1,java.util.List<Object[]> series2) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
1182
        XYDataset dataset = createWeekDataset(nomeCurso,nomeEscola,series1,series2);
1182
        XYDataset dataset = createWeekDataset(nomeCurso,nomeEscola,series1,series2);
1183
        return createTimeSeriesLines("Nº Respostas","",dataset,tmpName,nomeCurso,nomeEscola,series1,series2);
1183
        return createTimeSeriesLines("Nº Respostas","",dataset,tmpName,nomeCurso,nomeEscola,series1,series2);
1184
 
1184
 
1185
    }
1185
    }
1186
 
1186
 
1187
    public static 1.5.0/docs/api/java/lang/String.html">String createTimeSeriesLines(1.5.0/docs/api/java/lang/String.html">String vtitle,1.5.0/docs/api/java/lang/String.html">String timetitle, XYDataset dataset,1.5.0/docs/api/java/lang/String.html">String tmpName,1.5.0/docs/api/java/lang/String.html">String serie1Name,1.5.0/docs/api/java/lang/String.html">String serie2Name,java.util.List<Object[]> series1,java.util.List<Object[]> series2) throws 1.5.0/docs/api/java/io/IOException.html">IOException
1187
    public static 1.5.0/docs/api/java/lang/String.html">String createTimeSeriesLines(1.5.0/docs/api/java/lang/String.html">String vtitle,1.5.0/docs/api/java/lang/String.html">String timetitle, XYDataset dataset,1.5.0/docs/api/java/lang/String.html">String tmpName,1.5.0/docs/api/java/lang/String.html">String serie1Name,1.5.0/docs/api/java/lang/String.html">String serie2Name,java.util.List<Object[]> series1,java.util.List<Object[]> series2) throws 1.5.0/docs/api/java/io/IOException.html">IOException
1188
    {
1188
    {
1189
 
1189
 
1190
        final JFreeChart chart = ChartFactory.createTimeSeriesChart(
1190
        final JFreeChart chart = ChartFactory.createTimeSeriesChart(
1191
                "",
1191
                "",
1192
                timetitle,
1192
                timetitle,
1193
                vtitle,
1193
                vtitle,
1194
                dataset,
1194
                dataset,
1195
                true,
1195
                true,
1196
                false,
1196
                false,
1197
                false
1197
                false
1198
        );
1198
        );
1199
 
1199
 
1200
        chart.setBackgroundPaint(1.5.0/docs/api/java/awt/Color.html">Color.white);//light gray
1200
        chart.setBackgroundPaint(1.5.0/docs/api/java/awt/Color.html">Color.white);//light gray
1201
 
1201
 
1202
        final XYPlot plot = chart.getXYPlot();
1202
        final XYPlot plot = chart.getXYPlot();
1203
        plot.setBackgroundPaint(1.5.0/docs/api/java/awt/Color.html">Color.white);
1203
        plot.setBackgroundPaint(1.5.0/docs/api/java/awt/Color.html">Color.white);
1204
        plot.setDomainGridlinesVisible(true);
1204
        plot.setDomainGridlinesVisible(true);
1205
        plot.setDomainGridlinePaint(1.5.0/docs/api/java/awt/Color.html">Color.lightGray);
1205
        plot.setDomainGridlinePaint(1.5.0/docs/api/java/awt/Color.html">Color.lightGray);
1206
        plot.setRangeGridlinesVisible(true);
1206
        plot.setRangeGridlinesVisible(true);
1207
        plot.setRangeGridlinePaint(1.5.0/docs/api/java/awt/Color.html">Color.lightGray);
1207
        plot.setRangeGridlinePaint(1.5.0/docs/api/java/awt/Color.html">Color.lightGray);
1208
        plot.setDomainCrosshairVisible(true);
1208
        plot.setDomainCrosshairVisible(true);
1209
        plot.setRangeCrosshairVisible(false);
1209
        plot.setRangeCrosshairVisible(false);
1210
 
1210
 
1211
        plot.setRenderer(0, new XYDifferenceRenderer(GREEN_OK,COLOR_3,true));
1211
        plot.setRenderer(0, new XYDifferenceRenderer(GREEN_OK,COLOR_3,true));
1212
        plot.setRenderer(0, new XYLineAndShapeRenderer(true,true));
1212
        plot.setRenderer(0, new XYLineAndShapeRenderer(true,true));
1213
        plot.setRenderer(1, new XYLineAndShapeRenderer(true,true));
1213
        plot.setRenderer(1, new XYLineAndShapeRenderer(true,true));
1214
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
1214
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
1215
 
1215
 
1216
        //renderer.setLegendShape(0,new Rectangle(60,60));
1216
        //renderer.setLegendShape(0,new Rectangle(60,60));
1217
        //renderer.setLegendShape(1,new Rectangle(60,60));
1217
        //renderer.setLegendShape(1,new Rectangle(60,60));
1218
        renderer.setBaseLegendTextFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
1218
        renderer.setBaseLegendTextFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
1219
 
1219
 
1220
        renderer.setBaseItemLabelsVisible(true);
1220
        renderer.setBaseItemLabelsVisible(true);
1221
        renderer.setItemLabelsVisible(true);
1221
        renderer.setItemLabelsVisible(true);
1222
 
1222
 
1223
        renderer.setSeriesPaint(0,COLOR_SECTION_BLUE_DARK);
1223
        renderer.setSeriesPaint(0,COLOR_SECTION_BLUE_DARK);
1224
        renderer.setSeriesPaint(1,NEUTRAL_TOTAL);
1224
        renderer.setSeriesPaint(1,NEUTRAL_TOTAL);
1225
        renderer.setSeriesStroke(0,new 1.5.0/docs/api/java/awt/BasicStroke.html">BasicStroke(20.0f));
1225
        renderer.setSeriesStroke(0,new 1.5.0/docs/api/java/awt/BasicStroke.html">BasicStroke(20.0f));
1226
        renderer.setSeriesStroke(1,new 1.5.0/docs/api/java/awt/BasicStroke.html">BasicStroke(20.0f));
1226
        renderer.setSeriesStroke(1,new 1.5.0/docs/api/java/awt/BasicStroke.html">BasicStroke(20.0f));
1227
 
1227
 
1228
 
1228
 
1229
        1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat dfKey = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.##");
1229
        1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat dfKey = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.##");
1230
 
1230
 
1231
        StandardXYItemLabelGenerator labelGenerator = new StandardXYItemLabelGenerator("{2}", dfKey, dfKey);
1231
        StandardXYItemLabelGenerator labelGenerator = new StandardXYItemLabelGenerator("{2}", dfKey, dfKey);
1232
 
1232
 
1233
        renderer.setBaseItemLabelsVisible(true);
1233
        renderer.setBaseItemLabelsVisible(true);
1234
 
1234
 
1235
        renderer.setBaseItemLabelGenerator(labelGenerator);
1235
        renderer.setBaseItemLabelGenerator(labelGenerator);
1236
 
1236
 
1237
        renderer.setBaseItemLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
1237
        renderer.setBaseItemLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
1238
        plot.getDomainAxis().setLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
1238
        plot.getDomainAxis().setLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
1239
        plot.getDomainAxis().setTickLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
1239
        plot.getDomainAxis().setTickLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 70));
1240
        plot.getRangeAxis().setLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
1240
        plot.getRangeAxis().setLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
1241
        plot.getRangeAxis().setTickLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
1241
        plot.getRangeAxis().setTickLabelFont(new java.awt.1.5.0/docs/api/java/awt/Font.html">Font("Helvetica", java.awt.1.5.0/docs/api/java/awt/Font.html">Font.PLAIN, 80));
1242
 
1242
 
1243
        plot.getDomainAxis().setUpperMargin(0.05);
1243
        plot.getDomainAxis().setUpperMargin(0.05);
1244
        plot.getDomainAxis().setLowerMargin(0.05);
1244
        plot.getDomainAxis().setLowerMargin(0.05);
1245
 
1245
 
1246
        renderer.setSeriesShape(0, ShapeUtilities.createDownTriangle(20F));
1246
        renderer.setSeriesShape(0, ShapeUtilities.createDownTriangle(20F));
1247
        renderer.setSeriesShape(1, ShapeUtilities.createDiamond(30F));
1247
        renderer.setSeriesShape(1, ShapeUtilities.createDiamond(30F));
1248
 
1248
 
1249
        DateAxis dateaxis = (DateAxis) plot.getDomainAxis();
1249
        DateAxis dateaxis = (DateAxis) plot.getDomainAxis();
1250
        dateaxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH,1,new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("dd-MMM")));
1250
        dateaxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH,1,new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("dd-MMM")));
1251
 
1251
 
1252
        final DateAxis xaxis = (DateAxis) plot.getDomainAxis();
1252
        final DateAxis xaxis = (DateAxis) plot.getDomainAxis();
1253
        xaxis.setVerticalTickLabels(true);
1253
        xaxis.setVerticalTickLabels(true);
1254
 
1254
 
1255
        xaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
1255
        xaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
1256
 
1256
 
1257
        //set date format
1257
        //set date format
1258
        xaxis.setDateFormatOverride(new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("dd-MMM-yy"));
1258
        xaxis.setDateFormatOverride(new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("dd-MMM-yy"));
1259
 
1259
 
1260
        final NumberAxis yaxis = (NumberAxis) plot.getRangeAxis();
1260
        final NumberAxis yaxis = (NumberAxis) plot.getRangeAxis();
1261
        yaxis.setTickLabelsVisible(true);
1261
        yaxis.setTickLabelsVisible(true);
1262
        yaxis.setVisible(true);
1262
        yaxis.setVisible(true);
1263
        //yaxis.setRange(0,5);
1263
        //yaxis.setRange(0,5);
1264
        yaxis.setUpperMargin(0.15);
1264
        yaxis.setUpperMargin(0.15);
1265
 
1265
 
1266
 
1266
 
1267
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage(  800*4, 400*4);
1267
        1.5.0/docs/api/java/awt/image/BufferedImage.html">BufferedImage image = chart.createBufferedImage(  800*4, 400*4);
1268
        1.5.0/docs/api/java/lang/String.html">String path = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + tmpName + "timeSeries.png";
1268
        1.5.0/docs/api/java/lang/String.html">String path = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + tmpName + "timeSeries.png";
1269
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(path));
1269
        1.5.0/docs/api/javax/imageio/ImageIO.html">ImageIO.write(image, "png", new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(path));
1270
        return path;
1270
        return path;
1271
    }
1271
    }
1272
 
1272
 
1273
 
1273
 
1274
 
1274
 
1275
 
1275
 
1276
}
1276
}
1277
 
1277