List of usage examples for org.jfree.chart.renderer.category GanttRenderer setSeriesPaint
public void setSeriesPaint(int series, Paint paint)
From source file:graficos.GraficoGantt.java
private static JFreeChart crearGrafico(IntervalCategoryDataset cjto_datos) { JFreeChart grafico = ChartFactory.createGanttChart("Diagrama de Gantt", // Ttulo "Actividad", // Ttulo eje x "Fecha", // Ttulo eje y cjto_datos, // Datos true, // Incluir leyenda true, // Incluir tooltips false // Incluir URLs );// w ww .j a v a 2s .c om grafico.setBackgroundPaint(new Color(240, 240, 240)); grafico.getPlot().zoom(0.0); CategoryPlot categoriaPlot = (CategoryPlot) grafico.getPlot(); GanttRenderer renderer = (GanttRenderer) categoriaPlot.getRenderer(); renderer.setDrawBarOutline(true); // GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, new Color(102, 255, 102), 0.0f, 0.0f, new Color(102, 255, 102)); renderer.setSeriesPaint(0, new Color(48, 239, 48)); renderer.setSeriesPaint(1, Color.RED); grafico.getPlot().setOutlineVisible(true); return grafico; }
From source file:org.metacsp.utility.UI.PlotActivityNetworkGantt.java
/** * Create a new Gantt JFrame//from www.j ava 2s. 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); }