1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| public class TestApplet extends JApplet {
boolean isNewChart = false;
public void init() {
final IntervalCategoryDataset dataset;
if(isNewChart != true){
dataset = createDataset();
}else{
dataset = createDatasetTest();
}
final JFreeChart chart = createChart(dataset);
// add the chart to a panel...
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new Dimension(900,600));
chartPanel.setPopupMenu(null);
//add the chartPanel to the container (getContentPane is inherited from JApplet which TestApplet extends).
Container content = getContentPane();
content.removeAll();
//content.add(new JLabel("Test Applet : " + isNewChart));
content.add(chartPanel);
}
public static IntervalCategoryDataset createDataset() {
final TaskSeries s1 = new TaskSeries("Scheduled");
...
final TaskSeriesCollection collection = new TaskSeriesCollection();
collection.add(s1);
return collection;
}
private JFreeChart createChart(final IntervalCategoryDataset dataset) {
final JFreeChart chart = ChartFactory.createGanttChart(
"Diagramme de Gantt", // chart title
"Task", // domain axis label
"Date", // range axis label
dataset, // data
true, // include legend
true, // tooltips
false // urls
);
// chart.getCategoryPlot().getDomainAxis().setMaxCategoryLabelWidthRatio(10.0f);
return chart;
}
public void testDate(String dateDebut, String dateFin) {
isNewChart = true;
init();
}
private JFreeChart createChartTest(final IntervalCategoryDataset datasetTest) {
final JFreeChart chartTest = ChartFactory.createGanttChart(
"Diagramme de Gantt", // chart title
"Task", // domain axis label
"Date", // range axis label
datasetTest, // data
true, // include legend
true, // tooltips
false // urls
);
// chart.getCategoryPlot().getDomainAxis().setMaxCategoryLabelWidthRatio(10.0f);
return chartTest;
}
public static IntervalCategoryDataset createDatasetTest() {
final TaskSeries s1Test = new TaskSeries("Scheduled");
...
final TaskSeriesCollection collectionTest = new TaskSeriesCollection();
collectionTest.add(s1Test);
return collectionTest; |
Partager