Example usage for org.jfree.chart ChartFactory createGanttChart

List of usage examples for org.jfree.chart ChartFactory createGanttChart

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createGanttChart.

Prototype

public static JFreeChart createGanttChart(String title, String categoryAxisLabel, String dateAxisLabel,
        IntervalCategoryDataset dataset, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a Gantt chart using the supplied attributes plus default values where required.

Usage

From source file:org.jfree.chart.demo.GanttDemo2.java

/**
 * Creates a new demo./*from w w w.  j a v  a  2 s .c o  m*/
 *
 * @param title  the frame title.
 */
public GanttDemo2(final String title) {

    super(title);

    final IntervalCategoryDataset dataset = createSampleDataset();

    // create the chart...
    final JFreeChart chart = ChartFactory.createGanttChart("Gantt Chart Demo", // chart title
            "Task", // domain axis label
            "Date", // range axis label
            dataset, // data
            true, // include legend
            true, // tooltips
            false // urls
    );
    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    //      plot.getDomainAxis().setMaxCategoryLabelWidthRatio(10.0f);
    final CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.blue);

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:com.thecoderscorner.groovychart.chart.GanttChart.java

public JFreeChart createChart() {

    JFreeChart chart = ChartFactory.createGanttChart(getTitle(), getCategoryAxisLabel(), getDateAxisLabel(),
            (IntervalCategoryDataset) getDataset(), isLegend(), isTooltips(), isUrls());
    return setExtraProperties(chart);

}

From source file:org.metacsp.utility.UI.PlotActivityNetworkGantt.java

/**
 * Create a new Gantt JFrame/*from ww w. java 2  s . co m*/
 * @param s {@link ActivityNetworkSolver} to be plotted as Gantt
 * @param selectedVariables {@link Vector} of {@link ActivityNetworkSolver}'s component names (variable names) that will be plotted.
 * @param n {@link JFrame} title
 */
public PlotActivityNetworkGantt(ActivityNetworkSolver s, Vector<String> selectedVariables, String n) {
    super(n);
    this.solver = s;
    this.selectedVariables = selectedVariables;

    GanttRenderer renderer = new GanttRenderer();
    renderer.setBaseItemLabelFont(new Font("Tahoma", Font.PLAIN, 11));

    JFreeChart chart = ChartFactory.createGanttChart(null, // "Channel", //
            "Activities & Resources", // domain axis label
            null, // "Time", // range axis label
            createDataset(), // data
            false, // do not include legend
            false, // no tooltips
            false // urls
    );

    chart.getCategoryPlot().setRenderer(renderer);
    renderer.setSeriesPaint(0, Color.green.darker());
    renderer.setSeriesPaint(1, Color.red.darker());
    renderer.setItemMargin(-0.5);

    chart.getCategoryPlot().setRangeAxis(new NumberAxis());

    chart.getCategoryPlot().getRangeAxis().setLabelFont(new Font("Arial", Font.PLAIN, 14));
    chart.getCategoryPlot().getDomainAxis().setLabelFont(new Font("Arial", Font.PLAIN, 14));
    chart.getCategoryPlot().getDomainAxis().setTickLabelsVisible(true);
    chart.getCategoryPlot().getRangeAxis().setAutoRange(false);

    chartPanel = new ChartPanel(chart);
    chartPanel.setDomainZoomable(true);
    chartPanel.setRangeZoomable(true);

    setContentPane(new JScrollPane(chartPanel));
    this.setPreferredSize(new Dimension(800, 600));
    this.setSize(new Dimension(800, 600));
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    this.setVisible(true);
}

From source file:Negocio.Produccion.Planificacion.GanttManager.java

/**
 * Creates a chart./*  w ww .  ja  va2  s.c  o m*/
 *
 * @param dataset  the dataset.
 *
 * @return The chart.
 */
private static JFreeChart createChart(final IntervalCategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createGanttChart("", // 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;
}

From source file:netmason.support.graphics.GanttDisplay.java

public GanttDisplay(String title) {

    super(title);

    collection.add(s1);//from w w  w  . jav a 2  s.  c o  m

    // create the chart...
    chart = ChartFactory.createGanttChart("Gantt Chart", // chart title
            "Agent", // domain axis label
            "Date", // range axis label
            collection, // data
            false, // include legend
            true, // tooltips
            false // urls
    );

    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    CategoryItemRenderer renderer = plot.getRenderer();
    plot.setDomainGridlinePosition(CategoryAnchor.START);
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelPaint(Color.blue);
    domainAxis.setAxisLineVisible(false);

    domainAxis.setCategoryLabelPositionOffset(0);
    domainAxis.setMaximumCategoryLabelLines(2);
    domainAxis.setMaximumCategoryLabelWidthRatio(0.3f);

    renderer.setSeriesPaint(0, Color.blue);

    // add the chart to a panel...
    ChartPanel chartPanel = new ChartPanel(chart);
    setContentPane(chartPanel);

}

From source file:pt.lsts.neptus.plugins.trex.TrexTimelinePanel.java

@Override
public void initSubPanel() {
    chart = ChartFactory.createGanttChart("", "", "", tsc, true, true, false);
    panel = new ChartPanel(chart);
    setLayout(new BorderLayout());
    add(panel, BorderLayout.CENTER);
}

From source file:pt.lsts.neptus.plugins.trex.TrexTimelinePanel.java

public JFreeChart getChart(String title, String xlabel, String ylabel) {
    if (chart != null)
        chart = ChartFactory.createGanttChart(title, xlabel, ylabel, tsc, true, true, false);
    return chart;
}

From source file:org.ietr.preesm.mapper.ui.GanttPlotter.java

/**
 * Creates a chart.//from  w ww.  java  2  s  . c om
 * 
 * @param dataset
 *            a dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(IntervalCategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createGanttChart("Solution Gantt", // title
            "Operators", // x-axis label
            "Time", // y-axis label
            null, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    Paint p = getBackgroundColorGradient();
    chart.setBackgroundPaint(p);

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.black);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setOrientation(PlotOrientation.HORIZONTAL);

    DateAxis xaxis = (DateAxis) plot.getRangeAxis();
    xaxis.setDateFormatOverride(new VertexDateFormat());
    xaxis.setPositiveArrowVisible(true);

    DefaultDrawingSupplier d = new DefaultDrawingSupplier();

    plot.setDrawingSupplier(d);
    MyGanttRenderer ren = new MyGanttRenderer();
    // ren.setRepaintedListener(new RefreshRepaintedListener(this));

    ren.setSeriesItemLabelsVisible(0, false);
    ren.setSeriesVisibleInLegend(0, false);
    ren.setSeriesItemLabelGenerator(0, new IntervalCategoryItemLabelGenerator());
    ren.setSeriesToolTipGenerator(0, new MapperGanttToolTipGenerator());

    ren.setAutoPopulateSeriesShape(false);

    plot.setRenderer(ren);

    plot.setDataset(dataset);
    return chart;

}

From source file:ch.zhaw.init.walj.projectmanagement.util.chart.GanttChart.java

/**
 * creates a gantt chart with all workpackages and tasks
 * @throws NumberFormatException//ww  w . j a v a  2 s. c  o m
 */
public void createChart() throws NumberFormatException, IOException {

    // get data
    IntervalCategoryDataset dataset = createDataset();

    // create chart
    JFreeChart chart = ChartFactory.createGanttChart("", // chart title
            "", // domain axis label
            "", // range axis label
            dataset, // data
            false, // include legend
            false, // tooltips
            false // urls
    );

    // set white background
    chart.setBackgroundPaint(new Color(255, 255, 255));

    // set color of bars
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(0, 62, 102));

    // set size of the chart
    int width = 1200;
    int height = (40 * nbrOfObjects) + 200;

    // save picture as JPEG
    File gantChart = new File(path + "/Charts/GanttProject" + project.getID() + ".jpg");
    ChartUtilities.saveChartAsJPEG(gantChart, chart, width, height);
}

From source file:graphview_components.GanttChart.java

/**
 * Creates a chart./*from   w w  w  .  ja v  a2s  . c o  m*/
 * 
 * @param dataset
 *            the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final IntervalCategoryDataset dataset, String title) {
    final JFreeChart chart = ChartFactory.createGanttChart(title, // chart
            // title
            "Activities", // domain axis label
            "Date", // range axis label
            dataset, // data
            true, // include legend
            true, // tooltips
            false // urls
    );

    return chart;
}