Example usage for java.awt Color getHSBColor

List of usage examples for java.awt Color getHSBColor

Introduction

In this page you can find the example usage for java.awt Color getHSBColor.

Prototype

public static Color getHSBColor(float h, float s, float b) 

Source Link

Document

Creates a Color object based on the specified values for the HSB color model.

Usage

From source file:Interface.ResultadoJanela.java

public JFreeChart gerarGrafico(CategoryDataset dataSet) {
    JFreeChart chart = ChartFactory.createBarChart3D("Resultado da Localizao de Defeitos", //Titulo
            " ", // Eixo X
            "Probabilidade (%)", //Eixo Y
            dataSet, // Dados para o grafico
            PlotOrientation.VERTICAL, //Orientacao do grafico
            true, true, true); // exibir: legendas, tooltips, url
    chart.setBackgroundPaint(Color.getHSBColor(0, 0, (float) 0.835)); // Set the background colour of the chart

    CategoryPlot p = chart.getCategoryPlot(); // Get the Plot object for a bar graph
    p.setBackgroundPaint(Color.white); // Modify the plot background 
    p.setRangeGridlinePaint(Color.BLACK);

    CategoryAxis axis = p.getDomainAxis();
    axis.setTickLabelFont(new Font("Helvetica", Font.PLAIN, 10));
    axis.setMaximumCategoryLabelWidthRatio(1.0f);
    axis.setMaximumCategoryLabelLines(2);
    p.setDomainAxis(axis);//  w  ww . j a va 2 s  .  c o  m

    return chart;
}

From source file:org.matsim.counts.algorithms.graphs.CountsLoadCurveGraph.java

@Override
public JFreeChart createChart(final int nbr) {
    String title = this.getChartTitle() + ", Iteration: " + this.iteration_;
    this.chart_ = ChartFactory.createBarChart(title, "Hour", "Volumes [veh/h]", this.dataset0,
            PlotOrientation.VERTICAL, true, // legend?
            true, // tooltips?
            false // URLs?
    );/* w w  w  . j av a  2  s  . co m*/
    CategoryPlot plot = this.chart_.getCategoryPlot();
    //      plot.getRangeAxis().setRange(0.0, 10000.0); // do not set a fixed range for the single link graphs
    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    // BarRenderer renderer=(BarRenderer) plot.getRenderer();
    BarRenderer renderer = new BarRenderer();
    renderer.setSeriesOutlinePaint(0, Color.black);
    renderer.setSeriesOutlinePaint(1, Color.black);
    renderer.setSeriesPaint(0, Color.getHSBColor((float) 0.62, (float) 0.56, (float) 0.93));
    // Color.orange gives a dirty yellow!
    renderer.setSeriesPaint(1, Color.getHSBColor((float) 0.1, (float) 0.79, (float) 0.89));
    renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());
    renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator());
    renderer.setItemMargin(0.0);

    // configure plot with light colors instead of the default 3D
    renderer.setShadowVisible(false);
    renderer.setBarPainter(new StandardBarPainter());
    this.chart_.setBackgroundPaint(Color.getHSBColor((float) 0.0, (float) 0.0, (float) 0.93));
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeGridlinesVisible(true);

    plot.setRenderer(0, renderer);
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    // TRRE:  plot.setDataset(1, this.dataset1);
    plot.mapDatasetToRangeAxis(1, 1);

    final CategoryAxis axis1 = plot.getDomainAxis();
    axis1.setCategoryMargin(0.25); // leave a gap of 25% between categories

    /*  TRRE: 
    final ValueAxis axis2 = new NumberAxis("Signed Rel. Error [%]");
    plot.setRangeAxis(1, axis2);
            
    final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
    renderer2.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());
    renderer2.setSeriesShape(0, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0));
    renderer2.setSeriesPaint(0, Color.black);
    renderer2.setBaseStroke(new BasicStroke(2.5f));
    plot.setRenderer(1, renderer2);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    */

    return this.chart_;
}

From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PaintScaleFactory.java

public static Color[] generateColors(int n) {
    Color[] cols = new Color[n];
    for (int i = 0; i < n; i++) {
        cols[i] = Color.getHSBColor((float) i / (float) n, 0.85f, 1.0f);
    }// www. java  2s  .c o m
    return cols;
}

From source file:org.matsim.counts.algorithms.graphs.CountsGEHCurveGraph.java

@Override
public JFreeChart createChart(final int nbr) {
    String title = this.getChartTitle() + ", Iteration: " + this.iteration_;
    this.chart_ = ChartFactory.createBarChart(title, "Hour", "GEH", this.dataset, PlotOrientation.VERTICAL,
            false, // legend?
            false, // tooltips?
            false // URLs?
    );/*from  ww  w. jav  a2  s. co m*/
    CategoryPlot plot = this.chart_.getCategoryPlot();
    //      plot.getRangeAxis().setRange(0.0, 10000.0); // do not set a fixed range for the single link graphs
    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    // BarRenderer renderer=(BarRenderer) plot.getRenderer();
    //      BarRenderer renderer = new BarRenderer();
    /*
     * Chooses the color adaptive based on the value to be shown by a bar.
     * Values <= 5.0 are green, values >= 10 are red. In between the color is interpolated. 
     */
    BarRenderer renderer = new BarRenderer() {
        @Override
        public Paint getItemPaint(final int row, final int column) {
            double value = dataset.getValue(row, column).doubleValue();

            if (value <= 5.0)
                return Color.green;
            else if (value >= 10)
                return Color.red;
            else {
                if (value < 7.5) {
                    int mixed = mix(Color.yellow.getRGB(), Color.green.getRGB(), (7.5 - value) / 2.5);
                    return new Color(mixed);
                } else {
                    int mixed = mix(Color.red.getRGB(), Color.yellow.getRGB(), (10.0 - value) / 2.5);
                    return new Color(mixed);
                }
            }

            //            if (value <= 5.0) return Color.green;
            //            else if (value >= 10) return Color.red;
            //            else {
            //               int mixed = mix(Color.red.getRGB(), Color.green.getRGB(), (10.0 - value) / 5.0);
            //               return new Color(mixed);
            //            }
        }
    };
    renderer.setSeriesOutlinePaint(0, Color.black);
    renderer.setSeriesPaint(0, Color.getHSBColor((float) 0.62, (float) 0.56, (float) 0.93));
    renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());
    renderer.setItemMargin(0.0);

    // configure plot with light colors instead of the default 3D
    renderer.setShadowVisible(false);
    renderer.setBarPainter(new StandardBarPainter());
    this.chart_.setBackgroundPaint(Color.getHSBColor((float) 0.0, (float) 0.0, (float) 0.93));
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeGridlinesVisible(true);

    plot.setRenderer(0, renderer);
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    plot.mapDatasetToRangeAxis(1, 1);

    final CategoryAxis axis1 = plot.getDomainAxis();
    axis1.setCategoryMargin(0.25); // leave a gap of 25% between categories

    return this.chart_;
}

From source file:mavn.network.view.JUNGPanelAdapter.java

/**
 * Create an instance of a simple graph with popup controls to
 * create a graph.//from w w w . j a  v  a  2s. co  m
 *
 */
public JUNGPanelAdapter(double[][] w2, double[][] w1, double[][] w0) {
    this.w2 = w2;
    this.w1 = w1;
    this.w0 = w0;
    this.setPreferredSize(new Dimension(600, 400));
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    // create a simple graph for the demo
    graph = new DirectedSparseMultigraph<Number, Number>();

    this.layout = new StaticLayout<Number, Number>(graph, new Dimension(600, 600));

    if (w2.length > 0) {
        findIndicies();
        createVerticies();
        drawEdges();
        drawVerticies();
    }

    vv = new VisualizationViewer<Number, Number>(layout);

    vv.setBackground(Color.getColor("#333333"));

    vv.getRenderContext().setVertexLabelTransformer(MapTransformer.<Number, String>getInstance(
            LazyMap.<Number, String>decorate(new HashMap<Number, String>(), new ToStringLabeller<Number>())));

    vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer());

    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());

    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    this.add(panel);

    final EditingModalGraphMouse<Number, Number> graphMouse = new EditingModalGraphMouse<Number, Number>(
            vv.getRenderContext(), vertexFactory, edgeFactory);

    Transformer<Number, Paint> vertexPaint = new Transformer<Number, Paint>() {
        @Override
        public Paint transform(Number i) {
            return Color.getHSBColor(0, 0.73f, 1);
        }
    };

    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);

    // the EditingGraphMouse will pass mouse event coordinates to the
    // vertexLocations function to set the locations of the vertices as
    // they are created
    // graphMouse.setVertexLocations(vertexLocations);
    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();
    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JPanel controls = new JPanel();
    controls.add(plus);
    controls.add(minus);
    this.add(controls);
    this.setVisible(true);
}

From source file:osh.comdriver.simulation.cruisecontrol.ScheduleDrawer.java

/**
 * Creates a chart./*from   w  w  w  .  j av a 2 s  .  c  om*/
 *
 * @param dataset1  a dataset.
 * @return A chart.
 */
private static JFreeChart createChart(XYDataset dataset1, //power
        XYDataset dataset2, //costs
        XYDataset dataset3, long time) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart("schedule", // title
            "time", // x-axis label
            "power", // y-axis label
            dataset1, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

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

    NumberAxis axis1 = new NumberAxis("power");
    NumberAxis axis2 = new NumberAxis("costs");
    axis1.setAutoRangeIncludesZero(true);
    axis1.setUpperBound(5000);
    axis1.setLowerBound(-5000);
    axis2.setAutoRangeIncludesZero(true);
    axis2.setUpperBound(50);
    axis2.setLowerBound(0);
    plot.setRangeAxis(0, axis1);
    plot.setRangeAxis(1, axis2);

    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);

    plot.setDataset(2, dataset3);
    plot.mapDatasetToRangeAxis(2, 0);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    //TODO: SHADOWS OFF

    final StandardXYItemRenderer r1 = new StandardXYItemRenderer();
    final StandardXYItemRenderer r2 = new StandardXYItemRenderer();
    final StandardXYItemRenderer r3 = new StandardXYItemRenderer();
    final StandardXYItemRenderer r4 = new StandardXYItemRenderer();
    plot.setRenderer(0, r1);
    plot.setRenderer(1, r2);
    plot.setRenderer(2, r3);
    plot.setRenderer(3, r4);

    int numberOfSeries = 0;
    numberOfSeries += dataset1.getSeriesCount();
    numberOfSeries += dataset2.getSeriesCount();
    numberOfSeries += dataset3.getSeriesCount();

    Color[] color = new Color[numberOfSeries];

    for (int i = 0; i < numberOfSeries / 2; i++) {
        color[i] = Color.getHSBColor(i * 1.0f / (numberOfSeries / 2), 1.0f, 1.0f);
    }

    int i = 0;

    for (int j = 0; j < dataset1.getSeriesCount() / 2; j++) {
        float[] rgbcolor = Color.RGBtoHSB(color[i].getRed(), color[i].getGreen(), color[i].getBlue(), null);
        plot.getRendererForDataset(dataset1).setSeriesPaint(2 * j, Color.getHSBColor(rgbcolor[0], 1.0f, 1.0f));
        plot.getRendererForDataset(dataset1).setSeriesPaint(2 * j + 1,
                Color.getHSBColor(rgbcolor[0], 1.0f, 0.6f));
        i++;
    }
    for (int j = 0; j < dataset2.getSeriesCount() / 2; j++) {
        float[] rgbcolor = Color.RGBtoHSB(color[i].getRed(), color[i].getGreen(), color[i].getBlue(), null);
        plot.getRendererForDataset(dataset2).setSeriesPaint(2 * j, Color.getHSBColor(rgbcolor[0], 1.0f, 1.0f));
        plot.getRendererForDataset(dataset2).setSeriesPaint(2 * j + 1,
                Color.getHSBColor(rgbcolor[0], 1.0f, 0.6f));
        i++;
    }
    for (int j = 0; j < dataset3.getSeriesCount() / 2; j++) {
        float[] rgbcolor = Color.RGBtoHSB(color[i].getRed(), color[i].getGreen(), color[i].getBlue(), null);
        plot.getRendererForDataset(dataset3).setSeriesPaint(2 * j, Color.getHSBColor(rgbcolor[0], 1.0f, 1.0f));
        plot.getRendererForDataset(dataset3).setSeriesPaint(2 * j + 1,
                Color.getHSBColor(rgbcolor[0], 1.0f, 0.6f));
        i++;
    }

    // NOW line
    double upperBound = plot.getRangeAxis(1).getUpperBound();
    double lowerBound = plot.getRangeAxis(1).getLowerBound();

    XYSeries nowLine = new XYSeries("now");
    nowLine.add(time * 1000, lowerBound);
    nowLine.add(time * 1000, upperBound);
    XYSeriesCollection nowColl = new XYSeriesCollection(); //power axis
    nowColl.addSeries(nowLine);
    XYDataset nowSet = nowColl;

    plot.setDataset(3, nowSet);
    plot.mapDatasetToRangeAxis(3, 1);

    plot.getRendererForDataset(nowSet).setSeriesPaint(0, Color.DARK_GRAY);
    plot.getRendererForDataset(nowSet).setSeriesStroke(0, (Stroke) new BasicStroke(2.0f, BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f));

    plot.setDomainAxis(new DateAxis());
    plot.getDomainAxis().setAutoRange(false);

    long begin = (time / 86400) * 86400 * 1000; //beginning of day
    long end = begin + 86400 * 2 * 1000;

    plot.getDomainAxis().setRange(begin, end);

    return chart;

}

From source file:com.syncleus.dann.graph.jung.BrainPanel.java

@Override
protected void initVis(VisualizationViewer<N, S> vis) {
    vis.getRenderContext().setVertexLabelTransformer(new NeuronLabeller());
    vis.getRenderContext().setEdgeLabelTransformer(new SynapseLabeller());
    vis.getRenderContext().setVertexFillPaintTransformer(new Transformer<N, Paint>() {

        public Paint transform(N n) {
            if (n instanceof InputNeuron) {
                return Color.MAGENTA;
            } else if (n instanceof OutputNeuron) {
                return Color.GREEN;
            } else {
                return Color.GRAY;
            }/*  w  w  w  . j a  v  a2  s  .c o m*/
        }
    });
    vis.getRenderContext().setVertexShapeTransformer(new Transformer<N, Shape>() {

        public Shape transform(N n) {
            float s = 0.5f;
            if (n instanceof OutputNeuron) {
                OutputNeuron aan = (OutputNeuron) n;
                s = (float) Math.abs(aan.getOutput());
            } else if (n instanceof InputNeuron) {
                InputNeuron aan = (InputNeuron) n;
                s = (float) Math.abs(aan.getInput());
            }
            int w = (int) (s * 44.0);
            int h = (int) (s * 44.0);
            int x = -w / 2;
            int y = -h / 2;
            return new Rectangle2D.Float(x, y, w, h);
        }
    });
    vis.getRenderContext().setEdgeStrokeTransformer(new Transformer<S, Stroke>() {

        public Stroke transform(S i) {
            return new BasicStroke((int) ((Math.abs(i.getWeight())) * 8.0));
        }
    });
    vis.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<S, Paint>() {

        public Paint transform(S syn) {
            float b = (float) Math.abs(syn.getWeight());
            float s = 0.8f;
            float h = syn.getWeight() < 0 ? 0.6f : 0.9f;
            return Color.getHSBColor(h, s, b);
        }
    });

}

From source file:GeMSE.GS.Analysis.Stats.OneSampleCovariancePanel.java

private void Plot(double[][] matrix) {
    HeatChart heatChart = new HeatChart(matrix);
    heatChart.setBackgroundColour(Color.getHSBColor(bColor[0], bColor[1], bColor[2]));
    heatChart.setChartMargin(10);//from ww w. ja  v  a 2s  .  c  o m

    Dimension dimension = new Dimension(HeatmapL.getSize().width - 50, HeatmapL.getSize().height - 50);
    dimension.height = (int) Math
            .round((dimension.height - (heatChart.getChartMargin() * 5.0)) / matrix.length);
    dimension.width = (int) Math
            .round((dimension.width - (heatChart.getChartMargin() * 5.0)) / matrix[0].length);
    if (dimension.height < 1)
        dimension.height = 1;
    if (dimension.width < 1)
        dimension.width = 1;

    String[] xValues = new String[matrix.length];
    for (int i = 0; i < xValues.length; i++)
        xValues[i] = "";
    heatChart.setXValues(xValues);

    String[] yValues = new String[matrix[0].length];
    for (int i = 0; i < yValues.length; i++)
        yValues[i] = "";
    heatChart.setYValues(yValues);

    heatChart.setHighValueColour(GlobalVariables.hightValueColor);
    heatChart.setLowValueColour(GlobalVariables.lowValueColor);

    heatChart.setCellSize(dimension);

    HeatmapL.setText("");
    HeatmapL.setIcon(new javax.swing.ImageIcon(heatChart.getChartImage(false)));
}

From source file:gov.nih.nci.caintegrator.common.Cai2Util.java

/**
 * Used by classes to create a palette of unique colors.
 * @param totalNumberOfUniqueColors - total number of unique colors to be created in the palette.
 *//*from w ww  . j  av a2 s  . c  o m*/
public static void setColorPalette(int totalNumberOfUniqueColors) {
    for (int i = 0; i < MAX_ANGLE_CONSTANT; i += MAX_ANGLE_CONSTANT / totalNumberOfUniqueColors) {
        double colorNumberAsAngle = i * GOLDEN_ANGLE;
        double hue = colorNumberAsAngle - Math.floor(colorNumberAsAngle);
        COLOR_PALETTE.add(Color.getHSBColor((float) hue, (float) COLOR_SATURATION, (float) COLOR_BRIGHTNESS));
    }
}

From source file:csds60analyzer.csds60analyzerGUI.java

public BufferedImage creaImagen() {
    BufferedImage imagen = null;/*from  ww  w.java  2  s.  c o  m*/
    try {
        SAXBuilder builder = new SAXBuilder(false);
        Document doc = null;
        TimeSeriesCollection datos = new TimeSeriesCollection();
        if (fichero != null) {
            doc = builder.build(fichero);
            Element raiz = doc.getRootElement();
            List<Element> dias = raiz.getChildren("dia");
            Iterator<Element> diasIT = dias.iterator();
            TimeSeries desayunoAntes = new TimeSeries("Desayuno antes");
            TimeSeries desayunoDespues = new TimeSeries("Desayuno despus");
            TimeSeries almuerzoAntes = new TimeSeries("Almuerzo antes");
            TimeSeries almuerzoDespues = new TimeSeries("Almuerzo despus");
            TimeSeries cenaAntes = new TimeSeries("Cena antes");
            TimeSeries cenaDespues = new TimeSeries("Cena despus");

            pdesayuno = 0;
            pdesant = 0;
            pdesdes = 0;
            palmuerzo = 0;
            palmant = 0;
            palmdes = 0;
            pcena = 0;
            pcenant = 0;
            pcendes = 0;

            contdesant = 0;
            contdesdes = 0;
            contalmant = 0;
            contalmdes = 0;
            contcenant = 0;
            contcendes = 0;

            while (diasIT.hasNext()) {
                Element diaActual = diasIT.next();
                Integer fechaActual = Integer.parseInt(diaActual.getChildText("fecha").substring(0, 10));

                Calendar fad = GregorianCalendar.getInstance();
                fad.setTimeInMillis(fechaActual.longValue() * 1000);

                int dia = fad.get(Calendar.DAY_OF_MONTH);
                int mes = fad.get(Calendar.MONTH) + 1;
                int ano = fad.get(Calendar.YEAR);

                if (diaActual.getChildren().toString().contains("desayunoantes")) {
                    int desayunoAntesActual = Integer.parseInt(diaActual.getChildText("desayunoantes"));
                    desayunoAntes.add(new Day(dia, mes, ano), desayunoAntesActual);
                    pdesant = pdesant + desayunoAntesActual;
                    contdesant++;
                }
                if (diaActual.getChildren().toString().contains("desayunodespues")) {
                    int desayunoDespuesActual = Integer.parseInt(diaActual.getChildText("desayunodespues"));
                    desayunoDespues.add(new Day(dia, mes, ano), desayunoDespuesActual);
                    pdesdes = pdesdes + desayunoDespuesActual;
                    contdesdes++;
                }
                if (diaActual.getChildren().toString().contains("almuerzoantes")) {
                    int almuerzoAntesActual = Integer.parseInt(diaActual.getChildText("almuerzoantes"));
                    almuerzoAntes.add(new Day(dia, mes, ano), almuerzoAntesActual);
                    palmant = palmant + almuerzoAntesActual;
                    contalmant++;
                }
                if (diaActual.getChildren().toString().contains("almuerzodespues")) {
                    int almuerzoDespuesActual = Integer.parseInt(diaActual.getChildText("almuerzodespues"));
                    almuerzoDespues.add(new Day(dia, mes, ano), almuerzoDespuesActual);
                    palmdes = palmdes + almuerzoDespuesActual;
                    contalmdes++;
                }
                if (diaActual.getChildren().toString().contains("cenaantes")) {
                    int cenaAntesActual = Integer.parseInt(diaActual.getChildText("cenaantes"));
                    cenaAntes.add(new Day(dia, mes, ano), cenaAntesActual);
                    pcenant = pcenant + cenaAntesActual;
                    contcenant++;
                }
                if (diaActual.getChildren().toString().contains("cenadespues")) {
                    int cenaDespuesActual = Integer.parseInt(diaActual.getChildText("cenadespues"));
                    cenaDespues.add(new Day(dia, mes, ano), cenaDespuesActual);
                    pcendes = pcendes + cenaDespuesActual;
                    contcendes++;
                }
            }
            //controlar la division por cero
            if ((contdesant + contdesdes) > 0)
                pdesayuno = (pdesant + pdesdes) / (contdesant + contdesdes);
            if (contdesant > 0)
                pdesant = pdesant / contdesant;
            if (contdesdes > 0)
                pdesdes = pdesdes / contdesdes;
            if ((contalmant + contalmdes) > 0)
                palmuerzo = (palmant + palmdes) / (contalmant + contalmdes);
            if (contalmant > 0)
                palmant = palmant / contalmant;
            if (contalmdes > 0)
                palmdes = palmdes / contalmdes;
            if ((contcenant + contcendes) > 0)
                pcena = (pcenant + pcendes) / (contcenant + contcendes);
            if (contcenant > 0)
                pcenant = pcenant / contcenant;
            if (contcendes > 0)
                pcendes = pcendes / contcendes;
            datos.addSeries(desayunoAntes);
            datos.addSeries(desayunoDespues);
            datos.addSeries(almuerzoAntes);
            datos.addSeries(almuerzoDespues);
            datos.addSeries(cenaAntes);
            datos.addSeries(cenaDespues);
        }
        JFreeChart graficaJfree = ChartFactory.createTimeSeriesChart("Anlisis", " ", "Glucosa (mg)", datos,
                true, true, false);
        XYPlot plot = (XYPlot) graficaJfree.getPlot();
        plot.setBackgroundPaint(Color.getHSBColor(0f, 0f, .88f));
        plot.setDomainGridlinePaint(Color.getHSBColor(0f, 0f, .35f));
        plot.setDomainTickBandPaint(Color.getHSBColor(0f, 0f, .93f));
        plot.setOutlinePaint(Color.getHSBColor(0f, 0f, 0.35f));
        plot.setRangeGridlinePaint(Color.getHSBColor(0f, 0f, 0.35f));
        XYLineAndShapeRenderer plot2 = (XYLineAndShapeRenderer) plot.getRenderer();
        if (!CBdesayunoantes.getState())
            plot2.setSeriesLinesVisible(0, false);
        plot2.setSeriesPaint(0, Color.getHSBColor(.3f, 1f, .5f));
        //plot2.setSeriesStroke(0,new BasicStroke(2.0f,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND,1.0f));
        if (!CBdesayunodespues.getState())
            plot2.setSeriesLinesVisible(1, false);
        plot2.setSeriesPaint(1, Color.getHSBColor(.2f, 1f, .9f));
        if (!CBalmuerzoantes.getState())
            plot2.setSeriesLinesVisible(2, false);
        plot2.setSeriesPaint(2, Color.getHSBColor(.0f, 1f, .6f));
        if (!CBalmuerzodespues.getState())
            plot2.setSeriesLinesVisible(3, false);
        plot2.setSeriesPaint(3, Color.getHSBColor(.0f, 1f, .9f));
        if (!CBcenaantes.getState())
            plot2.setSeriesLinesVisible(4, false);
        plot2.setSeriesPaint(4, Color.getHSBColor(.6f, 1f, .4f));
        if (!CBcenadespues.getState())
            plot2.setSeriesLinesVisible(5, false);
        plot2.setSeriesPaint(5, Color.getHSBColor(.6f, 1f, 1f));
        imagen = graficaJfree.createBufferedImage(800, 600);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return imagen;
}