Example usage for org.jfree.chart.axis NumberAxis setTickLabelPaint

List of usage examples for org.jfree.chart.axis NumberAxis setTickLabelPaint

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis setTickLabelPaint.

Prototype

public void setTickLabelPaint(Paint paint) 

Source Link

Document

Sets the paint used to draw tick labels (if they are showing) and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:no.met.jtimeseries.chart.ChartPlotter.java

/**
 * Add normal bars in to the chart//from  w  ww. java 2 s .  com
 * 
 * @param dataset
 *            The dataset to visualise
 * @param title
 * @param color
 * @param margin
 *            Define the space between two bars
 */

public void addBarChart(XYDataset dataset, String title, Color color, double margin, double maxValue) {

    if (dataset.getItemCount(0) > 0) {

        XYBarRenderer renderer = new XYBarRenderer(margin);
        renderer.setSeriesPaint(0, color);
        renderer.setShadowVisible(false);
        renderer.setBaseItemLabelsVisible(false);
        renderer.setBarPainter(new StandardXYBarPainter());
        renderer.setSeriesVisibleInLegend(0, false);
        renderer.setDrawBarOutline(true);

        plot.mapDatasetToRangeAxis(plotIndex, rangeAxisIndex);
        plot.setDataset(plotIndex, dataset);
        plot.setRenderer(plotIndex, renderer);

        if (!title.equals("")) {
            // if title is not null then show the legend and label of the
            // bar
            NumberAxis numberAxis = new NumberAxis(title);
            numberAxis.setLowerMargin(LOWER_PLOT_MARGIN);
            double maxRange = calculateRangeMax(maxValue);
            numberAxis.setRangeWithMargins(new Range(0, maxRange), true, true);
            numberAxis.setLabelPaint(color);
            numberAxis.setTickLabelPaint(color);
            plot.setRangeAxis(rangeAxisIndex, numberAxis);

        }

        plotIndex++;
        rangeAxisIndex++;
    }
}

From source file:com.chart.SwingChart.java

/**
 * Background edition//from   ww  w  .j  a va 2s  .  c  o  m
 */
final public void backgroundEdition() {
    final ColorPicker colorPickerChartBackground = new ColorPicker(
            javafx.scene.paint.Color.web(strChartBackgroundColor));
    colorPickerChartBackground.setMaxWidth(Double.MAX_VALUE);
    final ColorPicker colorPickerGridline = new ColorPicker(javafx.scene.paint.Color.web(strGridlineColor));
    colorPickerGridline.setMaxWidth(Double.MAX_VALUE);
    final ColorPicker colorPickerBackground = new ColorPicker(javafx.scene.paint.Color.web(strBackgroundColor));
    colorPickerBackground.setMaxWidth(Double.MAX_VALUE);
    final ColorPicker colorPickerTick = new ColorPicker(javafx.scene.paint.Color.web(strTickColor));
    colorPickerTick.setMaxWidth(Double.MAX_VALUE);
    final TextField tfFontSize = new TextField();
    tfFontSize.setMaxWidth(Double.MAX_VALUE);

    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(0, 10, 0, 10));

    grid.add(new Label("Background color"), 0, 0);
    grid.add(colorPickerChartBackground, 1, 0);
    grid.add(new Label("Gridline color"), 0, 1);
    grid.add(colorPickerGridline, 1, 1);
    grid.add(new Label("Frame color"), 0, 2);
    grid.add(colorPickerBackground, 1, 2);
    grid.add(new Label("Tick color"), 0, 3);
    grid.add(colorPickerTick, 1, 3);
    grid.add(new Label("Font size"), 0, 4);
    grid.add(tfFontSize, 1, 4);
    tfFontSize.setText(String.valueOf(fontSize));

    new PseudoModalDialog(skeleton, grid, true) {

        @Override
        public boolean validation() {
            fontSize = Float.valueOf(tfFontSize.getText().replace(",", "."));
            strBackgroundColor = colorPickerBackground.getValue().toString().replace("0x", "#");
            for (Node le : legendFrame.getChildren()) {
                if (le instanceof LegendAxis) {
                    le.setStyle("-fx-background-color:" + strBackgroundColor);
                    ((LegendAxis) le).selected = false;
                }
            }
            chart.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor)));
            chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
                    BorderFactory.createLineBorder(
                            scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor)))));
            chartPanel.setBackground(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor)));

            legendFrame.setStyle("marco: " + colorPickerBackground.getValue().toString().replace("0x", "#")
                    + ";-fx-background-color: marco;");

            strChartBackgroundColor = colorPickerChartBackground.getValue().toString().replace("0x", "#");
            plot.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strChartBackgroundColor)));

            for (Node le : legendFrame.getChildren()) {
                if (le instanceof LegendAxis) {
                    le.setStyle("-fx-background-color:" + strBackgroundColor);
                    ((LegendAxis) le).selected = false;
                    for (Node nn : ((LegendAxis) le).getChildren()) {
                        if (nn instanceof Label) {
                            ((Label) nn).setStyle("fondo: "
                                    + colorPickerChartBackground.getValue().toString().replace("0x", "#")
                                    + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: "
                                    + String.valueOf(fontSize) + "px");
                        }
                    }
                }
            }

            strGridlineColor = colorPickerGridline.getValue().toString().replace("0x", "#");
            plot.setDomainGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor)));
            plot.setRangeGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor)));

            strTickColor = colorPickerTick.getValue().toString().replace("0x", "#");
            abcissaAxis.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
            abcissaAxis.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
            abcissaAxis.setLabelFont(abcissaAxis.getLabelFont().deriveFont(fontSize));
            abcissaAxis.setTickLabelFont(abcissaAxis.getLabelFont().deriveFont(fontSize));

            for (NumberAxis ejeOrdenada : AxesList) {
                ejeOrdenada.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
                ejeOrdenada.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
                ejeOrdenada.setLabelFont(ejeOrdenada.getLabelFont().deriveFont(fontSize));
                ejeOrdenada.setTickLabelFont(ejeOrdenada.getLabelFont().deriveFont(fontSize));
            }
            return true;
        }
    }.show();

}

From source file:no.met.jtimeseries.chart.ChartPlotter.java

/**
 * Add a line chart in the plot/*www . jav a 2 s.c o m*/
 * 
 * @param timeBase
 *            The base time of the data: second, minute, hour, year or auto
 * @param phenomenon
 *            Phenomenon to plot.
 * @param plotStyle
 *            The style preference for the plot
 * 
 */
public void addLineChart(TimeBase timeBase, NumberPhenomenon ph, PlotStyle plotStyle) {
    NumberPhenomenon phenomenon = ph.clone();
    if (phenomenon.getItems().size() > 0) {
        XYItemRenderer renderer = RendererFactory.createRenderer(SplineStyle.STANDARD);
        // if using hybrid spline
        if (plotStyle.getSplineStyle().equalsIgnoreCase(SplineStyle.HYBRID)) {
            phenomenon.doHybridSpline(0.5d, 4);
            renderer = RendererFactory.createRenderer(SplineStyle.NONE);
        }

        if (plotStyle.getNonNegative()) {
            phenomenon.removeNegativeValues();
        }

        XYDataset dataset = phenomenon.getTimeSeries(plotStyle.getTitle(), timeBase);

        renderer.setSeriesPaint(0, plotStyle.getSeriesColor());
        renderer.setSeriesStroke(0, plotStyle.getStroke());

        // hidden the legend by default
        renderer.setSeriesVisibleInLegend(0, false);

        plot.setDataset(plotIndex, dataset);
        plot.setRenderer(plotIndex, renderer);

        // render the range axis
        NumberAxis numberAxis;
        // null check for number axis
        if (plotStyle.getNumberAxis() == null) {
            numberAxis = new NumberAxis(plotStyle.getTitle());
            numberAxis.setAutoRangeIncludesZero(false);
            numberAxis.setLabelPaint(plotStyle.getLabelColor());
            numberAxis.setTickLabelPaint(plotStyle.getLabelColor());

            // ugly calculation
            double max = phenomenon.getMaxValue();
            double min = phenomenon.getMinValue();
            // increase and decrease max, min respectiivly to get the
            // difference pf atleast 50
            while ((max - min) <= plotStyle.getDifference()) {
                max++;
                min--;
            }
            int tUnit = (int) ((max - min) / plotStyle.getTotalTicks());
            if (tUnit <= 1) {
                tUnit = 2;
            }
            int[] range = calculateAxisMaxMin(phenomenon, tUnit, plotStyle.getTotalTicks());

            NumberTickUnit ntu = new NumberTickUnit(tUnit);
            numberAxis.setTickUnit(ntu);
            numberAxis.setRangeWithMargins(range[1], range[0]);
        } else {
            numberAxis = plotStyle.getNumberAxis();
        }
        plot.setRangeAxis(rangeAxisIndex, numberAxis);

        Date minDate = phenomenon.getStartTime();
        Date maxDate = phenomenon.getEndTime();

        DateAxis domainAxis = (DateAxis) plot.getDomainAxis();
        domainAxis.setRange(minDate, maxDate);

        plot.mapDatasetToRangeAxis(plotIndex, rangeAxisIndex);

        plotIndex++;
        rangeAxisIndex++;
    }
}

From source file:no.met.jtimeseries.chart.ChartPlotter.java

public void addThresholdLineChart(TimeBase timeBase, NumberPhenomenon ph, PlotStyle plotStyle) {
    NumberPhenomenon phenomenon = ph.clone();
    if (phenomenon.getItems().size() > 0) {
        XYItemRenderer renderer = RendererFactory.createRenderer(SplineStyle.STANDARD);
        // if using hybrid
        if (plotStyle.getSplineStyle().equalsIgnoreCase(SplineStyle.HYBRID)) {
            phenomenon.doHybridSpline(0.5d, 4);
            renderer = RendererFactory.createRenderer(SplineStyle.NONE);
        }//w  w w  .ja va 2 s. c o m

        if (plotStyle.getNonNegative()) {
            phenomenon.removeNegativeValues();
        }

        // add threshold point into the dataset
        phenomenon.addThresholdPoints(plotStyle.getThreshold());
        // create threshold data set with specified threshold value
        XYDataset dataset = phenomenon.getTimeSeriesWithThreshold(plotStyle.getTitle(), timeBase,
                plotStyle.getThreshold());

        // render even series lines with color1 and odd series lines with
        // color2
        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            if (i % 2 == 0)
                renderer.setSeriesPaint(i, plotStyle.getPlusDegreeColor());
            else
                renderer.setSeriesPaint(i, plotStyle.getMinusDegreeColor());
            renderer.setSeriesStroke(i, plotStyle.getStroke());
            // hidden legend
            renderer.setSeriesVisibleInLegend(i, false);
        }

        plot.setDataset(plotIndex, dataset);
        plot.setRenderer(plotIndex, renderer);

        NumberAxis numberAxis;
        // null check for number axis
        if (plotStyle.getNumberAxis() == null) {
            numberAxis = new NumberAxis(plotStyle.getTitle());
            numberAxis.setAutoRangeIncludesZero(false);
            numberAxis.setLabelPaint(plotStyle.getLabelColor());
            numberAxis.setTickLabelPaint(plotStyle.getLabelColor());

            // ugly calculation
            double max = phenomenon.getMaxValue();
            double min = phenomenon.getMinValue();
            int tUnit = getTemperatureTicksUnit(max, min);
            int[] range = calculateAxisMaxMin(phenomenon, tUnit, plotStyle.getTotalTicks());

            NumberTickUnit ntu = new NumberTickUnit(tUnit);
            numberAxis.setTickUnit(ntu);
            numberAxis.setLowerMargin(LOWER_PLOT_MARGIN);
            numberAxis.setRangeWithMargins(range[1], range[0]);
        } else {
            numberAxis = plotStyle.getNumberAxis();
        }

        plot.setRangeAxis(rangeAxisIndex, numberAxis);

        Date minDate = phenomenon.getStartTime();
        Date maxDate = phenomenon.getEndTime();

        DateAxis domainAxis = (DateAxis) plot.getDomainAxis();
        domainAxis.setRange(minDate, maxDate);

        plot.mapDatasetToRangeAxis(plotIndex, rangeAxisIndex);

        plotIndex++;
        rangeAxisIndex++;
    }
}

From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java

/**
 * Temperaturgraph machen Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui
 * /*  ww  w . j  a v a2s.c  om*/
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 02.08.2012
 * @param labels
 * @param thePlot
 * @param diveList
 */
private void makeTemperatureGraph(Vector<Integer[]> diveList, XYPlot thePlot, String[] labels) {
    XYDataset tempDataSet;
    Color axisColor = new Color(ProjectConst.GRAPH_TEMPERATURE_ACOLOR);
    Color renderColor = new Color(ProjectConst.GRAPH_TEMPERATURE_RCOLOR);
    //
    lg.debug("create temp dataset");
    if (showingUnitSystem == savedUnitSystem || showingUnitSystem == ProjectConst.UNITS_DEFAULT) {
        // Keine nderung norwendig!
        tempDataSet = createXYDataset(LangStrings.getString("spx42LogGraphPanel.graph.tempScalaTitle"),
                diveList, ProjectConst.UNITS_DEFAULT, 0, LogDerbyDatabaseUtil.TEMPERATURE);
    } else {
        // bitte konvertiere die Einheiten ins gewnschte Format!
        tempDataSet = createXYDataset(LangStrings.getString("spx42LogGraphPanel.graph.tempScalaTitle"),
                diveList, showingUnitSystem, 0, LogDerbyDatabaseUtil.TEMPERATURE);
    }
    final XYLineAndShapeRenderer lineTemperatureRenderer = new XYLineAndShapeRenderer(true, true);
    final NumberAxis tempAxis = new NumberAxis(
            LangStrings.getString("spx42LogGraphPanel.graph.tempAxisTitle") + " " + labels[1]);
    tempAxis.setLabelPaint(axisColor);
    tempAxis.setTickLabelPaint(axisColor);
    tempAxis.setNumberFormatOverride(new DecimalFormat("###.##"));
    lineTemperatureRenderer.setSeriesPaint(0, renderColor);
    lineTemperatureRenderer.setSeriesShapesVisible(0, false);
    lineTemperatureRenderer.setDrawSeriesLineAsPath(true);
    tempAxis.setAutoRangeIncludesZero(true);
    thePlot.setRangeAxis(GRAPH_DEPTH, tempAxis);
    thePlot.mapDatasetToRangeAxis(GRAPH_DEPTH, 0);
    thePlot.setDataset(GRAPH_TEMPERATURE, tempDataSet);
    thePlot.setRenderer(GRAPH_TEMPERATURE, lineTemperatureRenderer);
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.CombinedCategoryBar.java

public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");

    // recover the datasets
    DefaultCategoryDataset datasetBarFirstAxis = (DefaultCategoryDataset) datasets.getDatasets().get("1-bar");
    DefaultCategoryDataset datasetBarSecondAxis = (DefaultCategoryDataset) datasets.getDatasets().get("2-bar");
    DefaultCategoryDataset datasetLineFirstAxis = (DefaultCategoryDataset) datasets.getDatasets().get("1-line");
    DefaultCategoryDataset datasetLineSecondAxis = (DefaultCategoryDataset) datasets.getDatasets()
            .get("2-line");

    // create the two subplots
    CategoryPlot subPlot1 = new CategoryPlot();
    CategoryPlot subPlot2 = new CategoryPlot();
    CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot();

    subPlot1.setDataset(0, datasetBarFirstAxis);
    subPlot2.setDataset(0, datasetBarSecondAxis);

    subPlot1.setDataset(1, datasetLineFirstAxis);
    subPlot2.setDataset(1, datasetLineSecondAxis);

    // localize numbers on y axis
    NumberFormat nf = (NumberFormat) NumberFormat.getNumberInstance(locale);

    // Range Axis 1
    NumberAxis rangeAxis = new NumberAxis(getValueLabel());
    rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setLabelPaint(styleXaxesLabels.getColor());
    rangeAxis/* w ww .j av a2s.  co  m*/
            .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor());
    rangeAxis.setUpperMargin(0.10);
    rangeAxis.setNumberFormatOverride(nf);
    subPlot1.setRangeAxis(rangeAxis);
    if (rangeIntegerValues == true) {
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    // Range Axis 2
    NumberAxis rangeAxis2 = new NumberAxis(secondAxisLabel);
    rangeAxis2.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis2.setLabelPaint(styleXaxesLabels.getColor());
    rangeAxis2
            .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis2.setTickLabelPaint(styleXaxesLabels.getColor());
    rangeAxis2.setUpperMargin(0.10);
    rangeAxis2.setNumberFormatOverride(nf);
    subPlot2.setRangeAxis(rangeAxis2);
    if (rangeIntegerValues == true) {
        rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    // Category Axis
    CategoryAxis domainAxis = new CategoryAxis(getCategoryLabel());
    domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setLabelPaint(styleYaxesLabels.getColor());
    domainAxis
            .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setTickLabelPaint(styleYaxesLabels.getColor());
    domainAxis.setUpperMargin(0.10);
    plot.setDomainAxis(domainAxis);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);

    // Add subplots to main plot
    plot.add(subPlot1, 1);
    plot.add(subPlot2, 2);

    MyStandardCategoryItemLabelGenerator generator = null;

    // value labels and additional values are mutually exclusive
    if (showValueLabels == true)
        additionalLabels = false;

    if (additionalLabels) {
        generator = new MyStandardCategoryItemLabelGenerator(catSerLabels, "{1}", NumberFormat.getInstance());
    }

    //      Create Renderers!
    CategoryItemRenderer barRenderer1 = new BarRenderer();
    CategoryItemRenderer barRenderer2 = new BarRenderer();
    LineAndShapeRenderer lineRenderer1 = (useLinesRenderers == true) ? new LineAndShapeRenderer() : null;
    LineAndShapeRenderer lineRenderer2 = (useLinesRenderers == true) ? new LineAndShapeRenderer() : null;

    subPlot1.setRenderer(0, barRenderer1);
    subPlot2.setRenderer(0, barRenderer2);

    if (useLinesRenderers == true) {
        subPlot1.setRenderer(1, lineRenderer1);
        subPlot2.setRenderer(1, lineRenderer2);

        // no shapes for line_no_shapes  series
        for (Iterator iterator = lineNoShapeSeries1.iterator(); iterator.hasNext();) {
            String ser = (String) iterator.next();
            // if there iS a abel associated search for that
            String label = null;
            if (seriesLabelsMap != null) {
                label = (String) seriesLabelsMap.get(ser);
            }
            if (label == null)
                label = ser;
            int index = datasetLineFirstAxis.getRowIndex(label);
            if (index != -1) {
                lineRenderer1.setSeriesShapesVisible(index, false);
            }
        }
        for (Iterator iterator = lineNoShapeSeries2.iterator(); iterator.hasNext();) {
            String ser = (String) iterator.next();
            // if there iS a abel associated search for that

            String label = null;
            if (seriesLabelsMap != null) {
                label = (String) seriesLabelsMap.get(ser);
            }
            if (label == null)
                label = ser;
            int index = datasetLineSecondAxis.getRowIndex(label);
            if (index != -1) {
                lineRenderer2.setSeriesShapesVisible(index, false);
            }
        }

    }

    // add tooltip if enabled
    if (enableToolTips) {
        MyCategoryToolTipGenerator generatorToolTip = new MyCategoryToolTipGenerator(freeToolTips,
                seriesTooltip, categoriesTooltip, seriesCaptions);
        barRenderer1.setToolTipGenerator(generatorToolTip);
        barRenderer2.setToolTipGenerator(generatorToolTip);
        if (useLinesRenderers) {
            lineRenderer1.setToolTipGenerator(generatorToolTip);
            lineRenderer2.setToolTipGenerator(generatorToolTip);
        }
    }

    subPlot1.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    subPlot2.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    // COnfigure renderers: I do in extensive way so will be easier to add customization in the future

    if (maxBarWidth != null) {
        ((BarRenderer) barRenderer1).setMaximumBarWidth(maxBarWidth.doubleValue());
        ((BarRenderer) barRenderer2).setMaximumBarWidth(maxBarWidth.doubleValue());
    }

    // Values or addition Labels for first BAR Renderer
    if (showValueLabels) {
        barRenderer1.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
        barRenderer1.setBaseItemLabelsVisible(true);
        barRenderer1.setBaseItemLabelFont(
                new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
        barRenderer1.setBaseItemLabelPaint(styleValueLabels.getColor());

        barRenderer1.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

        barRenderer1.setBaseNegativeItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

        barRenderer2.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
        barRenderer2.setBaseItemLabelsVisible(true);
        barRenderer2.setBaseItemLabelFont(
                new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
        barRenderer2.setBaseItemLabelPaint(styleValueLabels.getColor());

        barRenderer2.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

        barRenderer2.setBaseNegativeItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

    } else if (additionalLabels) {
        barRenderer1.setBaseItemLabelGenerator(generator);
        barRenderer2.setBaseItemLabelGenerator(generator);

        double orient = (-Math.PI / 2.0);
        if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) {
            orient = 0.0;
        }

        barRenderer1.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient));
        barRenderer1.setBaseNegativeItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient));
        barRenderer2.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient));
        barRenderer2.setBaseNegativeItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient));

    }

    // Values or addition Labels for line Renderers if requested
    if (useLinesRenderers == true) {
        if (showValueLabels) {
            lineRenderer1.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
            lineRenderer1.setBaseItemLabelsVisible(true);
            lineRenderer1.setBaseItemLabelFont(
                    new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
            lineRenderer1.setBaseItemLabelPaint(styleValueLabels.getColor());
            lineRenderer1.setBasePositiveItemLabelPosition(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
            lineRenderer1.setBaseNegativeItemLabelPosition(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
            lineRenderer2.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
            lineRenderer2.setBaseItemLabelsVisible(true);
            lineRenderer2.setBaseItemLabelFont(
                    new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
            lineRenderer2.setBaseItemLabelPaint(styleValueLabels.getColor());
            lineRenderer2.setBasePositiveItemLabelPosition(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
            lineRenderer2.setBaseNegativeItemLabelPosition(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

        } else if (additionalLabels) {
            lineRenderer1.setBaseItemLabelGenerator(generator);
            lineRenderer2.setBaseItemLabelGenerator(generator);
            double orient = (-Math.PI / 2.0);
            if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) {
                orient = 0.0;
            }
            lineRenderer1.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));
            lineRenderer1.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));
            lineRenderer2.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));
            lineRenderer2.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));

        }
    }

    // Bar Dataset Colors!
    if (colorMap != null) {
        int idx = -1;
        for (Iterator iterator = datasetBarFirstAxis.getRowKeys().iterator(); iterator.hasNext();) {
            idx++;
            String serName = (String) iterator.next();
            String labelName = "";
            int index = -1;

            if (seriesCaptions != null && seriesCaptions.size() > 0) {
                labelName = serName;
                serName = (String) seriesCaptions.get(serName);
                index = datasetBarFirstAxis.getRowIndex(labelName);
            } else
                index = datasetBarFirstAxis.getRowIndex(serName);

            Color color = (Color) colorMap.get(serName);
            if (color != null) {
                barRenderer1.setSeriesPaint(index, color);
            }
        }

        for (Iterator iterator = datasetBarSecondAxis.getRowKeys().iterator(); iterator.hasNext();) {
            idx++;
            String serName = (String) iterator.next();
            String labelName = "";
            int index = -1;

            if (seriesCaptions != null && seriesCaptions.size() > 0) {
                labelName = serName;
                serName = (String) seriesCaptions.get(serName);
                index = datasetBarSecondAxis.getRowIndex(labelName);
            } else
                index = datasetBarSecondAxis.getRowIndex(serName);

            Color color = (Color) colorMap.get(serName);
            if (color != null) {
                barRenderer2.setSeriesPaint(index, color);
            }
        }
    }

    // LINE Dataset Colors!
    if (useLinesRenderers == true) {
        if (colorMap != null) {
            int idx = -1;
            for (Iterator iterator = datasetLineFirstAxis.getRowKeys().iterator(); iterator.hasNext();) {
                idx++;
                String serName = (String) iterator.next();
                String labelName = "";
                int index = -1;

                if (seriesCaptions != null && seriesCaptions.size() > 0) {
                    labelName = serName;
                    serName = (String) seriesCaptions.get(serName);
                    index = datasetLineFirstAxis.getRowIndex(labelName);
                } else
                    index = datasetLineFirstAxis.getRowIndex(serName);

                Color color = (Color) colorMap.get(serName);
                if (color != null) {
                    lineRenderer1.setSeriesPaint(index, color);
                }
            }

            for (Iterator iterator = datasetLineSecondAxis.getRowKeys().iterator(); iterator.hasNext();) {
                idx++;
                String serName = (String) iterator.next();
                String labelName = "";
                int index = -1;

                if (seriesCaptions != null && seriesCaptions.size() > 0) {
                    labelName = serName;
                    serName = (String) seriesCaptions.get(serName);
                    index = datasetLineSecondAxis.getRowIndex(labelName);
                } else
                    index = datasetLineSecondAxis.getRowIndex(serName);

                Color color = (Color) colorMap.get(serName);
                if (color != null) {
                    lineRenderer2.setSeriesPaint(index, color);
                }
            }
        }
    }

    //defines url for drill
    boolean document_composition = false;
    if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION))
        document_composition = true;

    logger.debug("Calling Url Generation");

    MyCategoryUrlGenerator mycatUrl = null;
    if (super.rootUrl != null) {
        logger.debug("Set MycatUrl");
        mycatUrl = new MyCategoryUrlGenerator(super.rootUrl);

        mycatUrl.setDocument_composition(document_composition);
        mycatUrl.setCategoryUrlLabel(super.categoryUrlName);
        mycatUrl.setSerieUrlLabel(super.serieUrlname);
        mycatUrl.setDrillDocTitle(drillDocTitle);
        mycatUrl.setTarget(target);
    }
    if (mycatUrl != null) {
        barRenderer1.setItemURLGenerator(mycatUrl);
        barRenderer2.setItemURLGenerator(mycatUrl);
        if (useLinesRenderers) {
            lineRenderer1.setItemURLGenerator(mycatUrl);
            lineRenderer2.setItemURLGenerator(mycatUrl);
        }

    }

    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    JFreeChart chart = new JFreeChart(plot);
    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }
    chart.setBackgroundPaint(Color.white);

    //      I want to re order the legend
    LegendItemCollection legends = plot.getLegendItems();
    // legend Temp 
    HashMap<String, LegendItem> legendTemp = new HashMap<String, LegendItem>();
    Vector<String> alreadyInserted = new Vector<String>();
    for (int i = 0; i < legends.getItemCount(); i++) {
        LegendItem item = legends.get(i);
        String label = item.getLabel();
        legendTemp.put(label, item);
    }
    LegendItemCollection newLegend = new LegendItemCollection();
    // force the order of the ones specified
    for (Iterator iterator = seriesOrder.iterator(); iterator.hasNext();) {
        String serie = (String) iterator.next();
        if (legendTemp.keySet().contains(serie)) {
            newLegend.add(legendTemp.get(serie));
            alreadyInserted.add(serie);
        }
    }
    // check that there are no serie not specified, otherwise add them
    for (Iterator iterator = legendTemp.keySet().iterator(); iterator.hasNext();) {
        String serie = (String) iterator.next();
        if (!alreadyInserted.contains(serie)) {
            newLegend.add(legendTemp.get(serie));
        }
    }

    plot.setFixedLegendItems(newLegend);

    if (legend == true)
        drawLegend(chart);
    logger.debug("OUT");

    return chart;

}

From source file:com.vgi.mafscaling.LogView.java

private void createGraghPanel() {
    JFreeChart chart = ChartFactory.createXYLineChart(null, null, null, null, PlotOrientation.VERTICAL, false,
            true, false);// w w  w .j  av  a2  s . c o m
    chartPanel = new ChartPanel(chart, true, true, true, true, true);
    chartPanel.setAutoscrolls(true);
    chartPanel.setPopupMenu(null);
    chart.setBackgroundPaint(new Color(60, 60, 65));

    rpmDataset = new XYSeriesCollection();
    rpmPlotRenderer = new XYLineAndShapeRenderer();
    dataset = new XYSeriesCollection();
    plotRenderer = new XYLineAndShapeRenderer();

    NumberAxis xAxis = new NumberAxis();
    xAxis.setTickLabelsVisible(false);
    xAxis.setTickLabelPaint(Color.WHITE);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis();
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickLabelPaint(Color.WHITE);
    yAxis.setAutoRangeIncludesZero(false);
    NumberAxis y2Axis = new NumberAxis();
    y2Axis.setTickLabelsVisible(false);
    y2Axis.setTickLabelPaint(Color.WHITE);
    y2Axis.setAutoRangeIncludesZero(false);

    plot = chartPanel.getChart().getXYPlot();
    plot.setRangePannable(true);
    plot.setDomainPannable(true);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setBackgroundPaint(new Color(80, 80, 85));

    plot.setDataset(0, rpmDataset);
    plot.setRenderer(0, rpmPlotRenderer);
    plot.setDomainAxis(0, xAxis);
    plot.setRangeAxis(0, yAxis);
    plot.mapDatasetToDomainAxis(0, 0);
    plot.mapDatasetToRangeAxis(0, 0);

    plot.setDataset(1, dataset);
    plot.setRenderer(1, plotRenderer);
    plot.setRangeAxis(1, y2Axis);
    plot.mapDatasetToDomainAxis(1, 0);
    plot.mapDatasetToRangeAxis(1, 1);

    LegendTitle legend = new LegendTitle(plot);
    legend.setItemFont(new Font("Arial", 0, 10));
    legend.setPosition(RectangleEdge.TOP);
    legend.setItemPaint(Color.WHITE);
    chart.addLegend(legend);

    xyMarker = new XYDomainMutilineAnnotation();
    plot.addAnnotation(xyMarker);

    chartMouseListener = new ChartMouseListener() {
        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            try {
                Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea();
                Point2D p = chartPanel.translateScreenToJava2D(event.getTrigger().getPoint());
                double x = plot.getDomainAxis().java2DToValue(p.getX(), dataArea, plot.getDomainAxisEdge());
                boolean isLeft = (p.getX() < (dataArea.getMaxX() - dataArea.getMinX()) / 2) ? true : false;
                if (setMarkers(x, isLeft)) {
                    try {
                        int selectedCol = logDataTable.getTable().getSelectedColumn();
                        if (selectedCol < 0)
                            selectedCol = 0;
                        if (logPlayWindow == null || startMarker != null || endMarker != null) {
                            logDataTable.getTable().setRowSelectionInterval((int) x, (int) x);
                            logDataTable.getTable().changeSelection((int) x, selectedCol, false, false);
                        } else {
                            logPlayWindow.setProgressBar((int) x);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            if (logPlayWindow == null)
                return;
            if (xyMarker.count() == 0)
                return;
            Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea();
            Point2D p = chartPanel.translateScreenToJava2D(event.getTrigger().getPoint());
            double x = plot.getDomainAxis().java2DToValue(p.getX(), dataArea, plot.getDomainAxisEdge());
            if (x < 0 || (int) x >= logDataTable.getRowCount())
                return;
            if (SwingUtilities.isLeftMouseButton(event.getTrigger())) {
                if (startMarker == null) {
                    startMarker = new ValueMarker(x);
                    startMarker.setPaint(Color.GREEN);
                    startMarker.setStroke(new BasicStroke(1.5f));
                    plot.addDomainMarker(startMarker);
                } else {
                    plot.removeDomainMarker(startMarker);
                    startMarker = null;
                }
            } else if (SwingUtilities.isRightMouseButton(event.getTrigger())) {
                if (endMarker == null) {
                    endMarker = new ValueMarker(x);
                    endMarker.setPaint(Color.GREEN);
                    endMarker.setStroke(new BasicStroke(1.5f));
                    plot.addDomainMarker(endMarker);
                } else {
                    plot.removeDomainMarker(endMarker);
                    endMarker = null;
                }
            }
            chartPanel.repaint();
            logPlayWindow.setStartEndArea(startMarker, endMarker);
        }
    };

    chartPanel.addChartMouseListener(chartMouseListener);
}

From source file:v800_trainer.JUebersicht.java

public JPanel Update_Uebersicht(JCicloTronic JTronicHandle) {

    int i;/*from  w w w . jav  a  2s.  c o  m*/
    Day xTime[];
    Today = new GregorianCalendar();
    double y1Werte[];
    double y2Werte[];
    double y3Werte[];
    double y4Werte[];
    double y5Werte[];
    double y6Werte[];
    double y7Werte[];
    double y8Werte[];
    double y9Werte[];
    double y10Werte[];
    double SummeZeit = 0;
    double Summekm = 0;
    double Summehm = 0;
    double SummeZeit12Mon = 0;
    double Summekm12Mon = 0;
    double Summehm12Mon = 0;
    int AnzahlJahre = 0;
    int Selektiert = 0;
    int SelektiertVergl = 0;
    int Jahr;
    int Linecount = 0;
    boolean Vergleich = false;
    XYItemRenderer renderer;
    XYBarRenderer rendererb;

    JFreeChart chart;

    AnzahlJahre = JTronicHandle.Auswahl_bersicht.getItemCount();
    Selektiert = JTronicHandle.Auswahl_bersicht.getSelectedIndex();
    SelektiertVergl = JTronicHandle.JahrVergleich.getSelectedIndex();
    if (SelektiertVergl == 0 || Selektiert == SelektiertVergl - 1)
        Vergleich = false;
    else
        Vergleich = true;

    xTime = new Day[366];

    y1Werte = new double[366];
    y2Werte = new double[366];
    y3Werte = new double[366];
    y4Werte = new double[366];
    y5Werte = new double[366];
    y6Werte = new double[366];
    y7Werte = new double[366];
    y8Werte = new double[366];
    y9Werte = new double[366];
    y10Werte = new double[366];
    TimeSeries dataset;

    dataset = new TimeSeries("dummy");

    dataset.add(new Day(1, 1, 1900), 1);

    TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset);

    chart = ChartFactory.createTimeSeriesChart(
            "Jahresbersicht " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString(), "Zeit", "",
            dataset1, true, true, true);

    XYToolTipGenerator ToolTip = new StandardXYToolTipGenerator("{0}: ({1}, {2})",
            (DateFormat) new SimpleDateFormat("dd.MM"), NumberFormat.getInstance());

    if (SelektiertVergl != 0)
        chart.addSubtitle(new TextTitle(
                "Vergleich mit Jahr " + JTronicHandle.JahrVergleich.getSelectedItem().toString()));
    chart.setBackgroundPaint(Color.white);

    JTronicHandle.applyChartTheme(chart);

    XYPlot plot = chart.getXYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.setRangeCrosshairLockedOnData(false);
    plot.setDomainCrosshairLockedOnData(false);
    if (!JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
        DateAxis MyAxis = new DateAxis();
        MyAxis = (DateAxis) plot.getDomainAxis();
        MyAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
        MyAxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

        plot.setDomainGridlinesVisible(false);

    }

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.getRangeAxis().setFixedDimension(15.0);

    plot.getDomainAxis().setTickLabelInsets(new RectangleInsets(2.0, 1.0, 2.0, 1.0));

    Jahr = Integer.parseInt(JTronicHandle.Auswahl_bersicht.getSelectedItem().toString());

    for (i = 0; i < 366; i++) {
        SummeZeit12Mon += (double) Zeit[Selektiert + 1][i];
        Summekm12Mon += (double) kmJahr[Selektiert + 1][i];
        Summehm12Mon += (double) HmJahr[Selektiert + 1][i];

    }

    y4Werte[0] = SummeZeit12Mon;
    y5Werte[0] = Summekm12Mon;
    y6Werte[0] = Summehm12Mon;

    xTime[0] = new Day(31, 12, Jahr - 1);
    for (i = 1; i < 366; i++) {
        try {
            xTime[i] = new Day(xTime[i - 1].next().getStart());

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Exception GregorianCalender  " + e, "Achtung!",
                    JOptionPane.ERROR_MESSAGE);
        }

        if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
            SummeZeit += (double) Zeit[Selektiert][i];
            Summekm += (double) kmJahr[Selektiert][i];
            Summehm += (double) HmJahr[Selektiert][i];
            y1Werte[i] = SummeZeit;
            y2Werte[i] = Summekm;
            y3Werte[i] = Summehm;

            y4Werte[i] = y4Werte[i - 1] - (double) Zeit[Selektiert + 1][i] + (double) Zeit[Selektiert][i];
            y5Werte[i] = y5Werte[i - 1] - (double) kmJahr[Selektiert + 1][i] + (double) kmJahr[Selektiert][i];
            y6Werte[i] = y6Werte[i - 1] - (double) HmJahr[Selektiert + 1][i] + (double) HmJahr[Selektiert][i];

        } else {
            Day n = new Day(1, xTime[i].getMonth(), xTime[i].getYear());
            try {
                Kalender = new GregorianCalendar(xTime[i].getYear(), xTime[i].getMonth() - 1, 1);

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Exception GregorianCalender  " + e, "Achtung!",
                        JOptionPane.ERROR_MESSAGE);

            }
            int j = (int) Kalender.get(Kalender.DAY_OF_YEAR);
            for (int m = 0; m < 6; m++) {
                y1Werte[j + m + 1] += (double) Zeit[Selektiert][i];
                y2Werte[j + m + 11] += (double) kmJahr[Selektiert][i];
                y3Werte[j + m + 21] += (double) HmJahr[Selektiert][i];

            }
        }

    }

    dataset = new TimeSeries("Trainingszeit " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString());
    for (i = 0; i < 366; i++) {
        dataset.add(xTime[i], y1Werte[i]);
    }

    dataset1 = new TimeSeriesCollection(dataset);
    NumberAxis axis = new NumberAxis();
    try {
        axis = (NumberAxis) plot.getRangeAxis().clone();
    } catch (Exception e) {
    }
    axis.setLabel("Stunden");
    axis.setAutoRangeIncludesZero(true);
    axis.setLabelPaint(Color.BLACK);
    axis.setTickLabelPaint(Color.BLACK);
    plot.setRangeAxis(0, axis);
    plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT);

    plot.setDataset(Linecount, dataset1);
    plot.mapDatasetToRangeAxis(Linecount, 0);

    if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
        renderer = new StandardXYItemRenderer(2, ToolTip);
        renderer.setSeriesPaint(0, getColour(Linecount, 255));

        plot.setRenderer(Linecount, renderer);
    } else {
        rendererb = new XYBarRenderer();
        rendererb.setSeriesPaint(0, getColour(Linecount, 150));
        rendererb.setShadowVisible(false);
        rendererb.setDrawBarOutline(false);
        rendererb.setBarPainter(new StandardXYBarPainter());

        plot.setRenderer(Linecount, rendererb);
    }

    Linecount++;

    dataset = new TimeSeries(
            "Trainingskilometer " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString());
    for (i = 0; i < 366; i++) {
        dataset.add(xTime[i], y2Werte[i]);

    }

    TimeSeriesCollection dataset2 = new TimeSeriesCollection(dataset);

    NumberAxis axis2 = new NumberAxis();
    try {
        axis2 = (NumberAxis) plot.getRangeAxis().clone();
    } catch (Exception e) {
    }
    ;
    axis2.setLabel("Kilometer");
    axis2.setAutoRangeIncludesZero(true);
    axis2.setLabelPaint(Color.BLACK);
    axis2.setTickLabelPaint(Color.BLACK);

    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);

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

    if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
        renderer = new StandardXYItemRenderer(2, ToolTip);
        renderer.setSeriesPaint(0, getColour(Linecount, 255));

        plot.setRenderer(Linecount, renderer);
    } else {
        rendererb = new XYBarRenderer();
        rendererb.setSeriesPaint(0, getColour(Linecount, 150));
        rendererb.setShadowVisible(false);
        rendererb.setDrawBarOutline(false);
        rendererb.setBarPainter(new StandardXYBarPainter());

        plot.setRenderer(Linecount, rendererb);
    }

    Linecount++;

    dataset = new TimeSeries(
            "Trainingshhenmeter " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString());
    for (i = 0; i < 366; i++) {
        dataset.add(xTime[i], y3Werte[i]);

    }

    TimeSeriesCollection dataset3 = new TimeSeriesCollection(dataset);

    NumberAxis axis3 = new NumberAxis("Hhenmeter");
    try {
        axis3 = (NumberAxis) plot.getRangeAxis().clone();
    } catch (Exception e) {
    }
    ;
    axis3.setLabel("Hhenmeter");
    axis3.setAutoRangeIncludesZero(true);
    axis3.setLabelPaint(Color.BLACK);
    axis3.setTickLabelPaint(Color.BLACK);

    plot.setRangeAxis(2, axis3);
    plot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_RIGHT);

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

    if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
        renderer = new StandardXYItemRenderer(2, ToolTip);
        renderer.setSeriesPaint(0, getColour(Linecount, 255));

        plot.setRenderer(Linecount, renderer);
    } else {
        rendererb = new XYBarRenderer();
        rendererb.setSeriesPaint(0, getColour(Linecount, 150));
        rendererb.setShadowVisible(false);
        rendererb.setDrawBarOutline(false);
        rendererb.setBarPainter(new StandardXYBarPainter());

        plot.setRenderer(Linecount, rendererb);
    }

    Linecount++;

    if (Vergleich == true) {
        SummeZeit = 0;
        Summekm = 0;
        Summehm = 0;

        SummeZeit12Mon = 0;
        Summekm12Mon = 0;
        Summehm12Mon = 0;

        for (i = 0; i < 366; i++) {
            SummeZeit12Mon += (double) Zeit[SelektiertVergl - 1][i];
            Summekm12Mon += (double) kmJahr[SelektiertVergl - 1][i];
            Summehm12Mon += (double) HmJahr[SelektiertVergl - 1][i];
        }

        y4Werte[0] = SummeZeit12Mon;
        y5Werte[0] = Summekm12Mon;
        y6Werte[0] = Summehm12Mon;

        for (i = 1; i < 366; i++) {
            try {

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Exception GregorianCalender  " + e, "Achtung!",
                        JOptionPane.ERROR_MESSAGE);
            }
            ;
            if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
                SummeZeit += (double) Zeit[SelektiertVergl - 1][i];
                Summekm += (double) kmJahr[SelektiertVergl - 1][i];
                Summehm += (double) HmJahr[SelektiertVergl - 1][i];
                y7Werte[i] = SummeZeit;
                y8Werte[i] = Summekm;
                y9Werte[i] = Summehm;

                y4Werte[i] = y4Werte[i - 1] - (double) Zeit[SelektiertVergl - 1][i]
                        + (double) Zeit[Selektiert][i];
                y5Werte[i] = y5Werte[i - 1] - (double) kmJahr[SelektiertVergl - 1][i]
                        + (double) kmJahr[Selektiert][i];
                y6Werte[i] = y6Werte[i - 1] - (double) HmJahr[SelektiertVergl - 1][i]
                        + (double) HmJahr[Selektiert][i];
            } else {
                Day n = new Day(1, xTime[i].getMonth(), xTime[i].getYear());
                try {
                    Kalender = new GregorianCalendar(xTime[i].getYear(), xTime[i].getMonth() - 1, 1);

                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, "Exception GregorianCalender  " + e, "Achtung!",
                            JOptionPane.ERROR_MESSAGE);

                }
                int j = (int) Kalender.get(Kalender.DAY_OF_YEAR);
                for (int m = 0; m < 5; m++) {
                    y7Werte[j + m + 4] += (double) Zeit[SelektiertVergl - 1][i];
                    y8Werte[j + m + 14] += (double) kmJahr[SelektiertVergl - 1][i];
                    y9Werte[j + m + 24] += (double) HmJahr[SelektiertVergl - 1][i];

                }

            }

        }

        if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
            dataset = new TimeSeries("Trainingszeit ber 12 Monate ");
            for (i = 0; i < 366; i++) {
                dataset.add(xTime[i], y4Werte[i]);
            }

            TimeSeriesCollection dataset4 = new TimeSeriesCollection(dataset);

            plot.setDataset(Linecount, dataset4);
            plot.mapDatasetToRangeAxis(Linecount, 0);

            if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
                renderer = new StandardXYItemRenderer(2, ToolTip);
                renderer.setSeriesPaint(0, getColour(Linecount, 255));

                plot.setRenderer(Linecount, renderer);
            } else {
                rendererb = new XYBarRenderer();
                rendererb.setSeriesPaint(0, getColour(Linecount, 150));
                rendererb.setShadowVisible(false);
                rendererb.setBarPainter(new StandardXYBarPainter());

                plot.setRenderer(Linecount, rendererb);
            }

            Linecount++;

            dataset = new TimeSeries("Trainingskilometer ber 12 Monate ");
            for (i = 0; i < 366; i++) {
                dataset.add(xTime[i], y5Werte[i]);
            }

            TimeSeriesCollection dataset5 = new TimeSeriesCollection(dataset);

            plot.setDataset(Linecount, dataset5);
            plot.mapDatasetToRangeAxis(Linecount, 1);

            if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
                renderer = new StandardXYItemRenderer(2, ToolTip);
                renderer.setSeriesPaint(0, getColour(Linecount, 255));

                plot.setRenderer(Linecount, renderer);
            } else {
                rendererb = new XYBarRenderer();
                rendererb.setSeriesPaint(0, getColour(Linecount, 150));
                rendererb.setShadowVisible(false);
                rendererb.setGradientPaintTransformer(null);
                rendererb.setBarPainter(new StandardXYBarPainter());

                plot.setRenderer(Linecount, rendererb);
            }

            Linecount++;

            dataset = new TimeSeries("Trainingshhenmeter ber 12 Monate ");
            for (i = 0; i < 366; i++) {
                dataset.add(xTime[i], y6Werte[i]);
            }

            TimeSeriesCollection dataset6 = new TimeSeriesCollection(dataset);

            plot.setDataset(Linecount, dataset6);
            plot.mapDatasetToRangeAxis(Linecount, 2);

            if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
                renderer = new StandardXYItemRenderer(2, ToolTip);
                renderer.setSeriesPaint(0, getColour(Linecount, 255));

                plot.setRenderer(Linecount, renderer);
            } else {
                rendererb = new XYBarRenderer();
                rendererb.setSeriesPaint(0, getColour(Linecount, 150));
                rendererb.setShadowVisible(false);
                rendererb.setGradientPaintTransformer(null);
                rendererb.setBarPainter(new StandardXYBarPainter());

                plot.setRenderer(Linecount, rendererb);
            }

        }
        Linecount++;

        dataset = new TimeSeries("Trainingszeit " + JTronicHandle.JahrVergleich.getSelectedItem().toString());
        for (i = 0; i < 366; i++) {
            dataset.add(xTime[i], y7Werte[i]);
        }

        TimeSeriesCollection dataset7 = new TimeSeriesCollection(dataset);

        plot.setDataset(Linecount, dataset7);
        plot.mapDatasetToRangeAxis(Linecount, 0);

        if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
            renderer = new StandardXYItemRenderer(2, ToolTip);
            renderer.setSeriesPaint(0, getColour(Linecount, 255));

            plot.setRenderer(Linecount, renderer);
        } else {
            rendererb = new XYBarRenderer();
            rendererb.setSeriesPaint(0, getColour(Linecount, 150));
            rendererb.setShadowVisible(false);
            rendererb.setGradientPaintTransformer(null);
            rendererb.setBarPainter(new StandardXYBarPainter());

            plot.setRenderer(Linecount, rendererb);
        }
        Linecount++;

        dataset = new TimeSeries(
                "Trainingskilometer " + JTronicHandle.JahrVergleich.getSelectedItem().toString());
        for (i = 0; i < 366; i++) {
            dataset.add(xTime[i], y8Werte[i]);
        }

        TimeSeriesCollection dataset8 = new TimeSeriesCollection(dataset);

        plot.setDataset(Linecount, dataset8);
        plot.mapDatasetToRangeAxis(Linecount, 1);

        if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
            renderer = new StandardXYItemRenderer(2, ToolTip);
            renderer.setSeriesPaint(0, getColour(Linecount, 255));

            plot.setRenderer(Linecount, renderer);
        } else {
            rendererb = new XYBarRenderer();
            rendererb.setSeriesPaint(0, getColour(Linecount, 150));
            rendererb.setShadowVisible(false);
            rendererb.setGradientPaintTransformer(null);
            rendererb.setBarPainter(new StandardXYBarPainter());

            plot.setRenderer(Linecount, rendererb);
        }

        Linecount++;

        dataset = new TimeSeries(
                "Trainingshhenmeter " + JTronicHandle.JahrVergleich.getSelectedItem().toString());
        for (i = 0; i < 366; i++) {
            dataset.add(xTime[i], y9Werte[i]);
        }

        TimeSeriesCollection dataset9 = new TimeSeriesCollection(dataset);

        plot.setDataset(Linecount, dataset9);
        plot.mapDatasetToRangeAxis(Linecount, 2);

        if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
            renderer = new StandardXYItemRenderer(2, ToolTip);
            renderer.setSeriesPaint(0, getColour(Linecount, 255));

            plot.setRenderer(Linecount, renderer);
        } else {
            rendererb = new XYBarRenderer();
            rendererb.setSeriesPaint(0, getColour(Linecount, 150));
            rendererb.setShadowVisible(false);
            rendererb.setGradientPaintTransformer(null);
            rendererb.setBarPainter(new StandardXYBarPainter());

            plot.setRenderer(Linecount, rendererb);
        }

    }

    if (!JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {

        double max = axis.getRange().getUpperBound();
        for (i = 0; i < 12; i++) {
            try {
                Kalender = new GregorianCalendar(Integer.parseInt(DataProperty.getProperty("Jahr", "0")), i, 1);

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "JUebersicht\nException GregorianCalender  " + e,
                        "Achtung!", JOptionPane.ERROR_MESSAGE);
            }

            y10Werte[Kalender.get(Kalender.DAY_OF_YEAR)] = max;
            y10Werte[Kalender.get(Kalender.DAY_OF_YEAR) + 1] = 0;
        }
        dataset = new TimeSeries("");

        for (i = 0; i < 366; i++) {

            dataset.add(xTime[i], y10Werte[i]);

        }
        TimeSeriesCollection dataset10 = new TimeSeriesCollection(dataset);
        plot.setDataset(Linecount + 1, dataset10);
        plot.mapDatasetToRangeAxis(Linecount + 1, 0);

        renderer = new StandardXYItemRenderer(2, ToolTip);
        renderer.setSeriesPaint(0, Color.white);

        plot.setRenderer(Linecount + 1, renderer);
        plot.getDomainAxis().setAutoRange(false);
        axis.setRange(0, max);

    }

    if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) {
        axis2.setRange(0, axis2.getRange().getUpperBound() * 1.5);
        axis3.setRange(0, axis3.getRange().getUpperBound() * 2);
        plot.setDomainCrosshairValue(
                (double) new GregorianCalendar(Jahr, Today.get(Today.MONTH), Today.get(Today.DAY_OF_MONTH))
                        .getTimeInMillis());

    }

    chart.setPadding(padding);
    ChartPanel Panel = new ChartPanel(chart);
    Panel.setDismissDelay(100000);

    return Panel;

}

From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java

/**
 * Erzeuge den Graphen fr die Tiefe Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui
 * /*from w ww.j  a va  2  s. com*/
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 07.08.2012
 * @param diveList
 * @param thePlot
 */
private void makeDepthGraph(Vector<Integer[]> diveList, XYPlot thePlot) {
    XYDataset depthDataSet;
    lg.debug("create depth dataset");
    if (showingUnitSystem == savedUnitSystem || showingUnitSystem == ProjectConst.UNITS_DEFAULT) {
        depthDataSet = createXYDataset(
                LangStrings.getString("spx42LogGraphPanel.graph.depthScalaTitle") + " " + depthUnitName,
                diveList, ProjectConst.UNITS_DEFAULT, 0, LogDerbyDatabaseUtil.DEPTH);
    } else {
        depthDataSet = createXYDataset(
                LangStrings.getString("spx42LogGraphPanel.graph.depthScalaTitle") + " " + depthUnitName,
                diveList, showingUnitSystem, 0, LogDerbyDatabaseUtil.DEPTH);
    }
    final NumberAxis depthAxis = new NumberAxis(
            LangStrings.getString("spx42LogGraphPanel.graph.depthAxisTitle") + " " + depthUnitName);
    final XYAreaRenderer areaDepthRenderer = new XYAreaRenderer(XYAreaRenderer.AREA);
    depthAxis.setAutoRangeIncludesZero(true);
    depthAxis.setLabelPaint(new Color(ProjectConst.GRAPH_DEPTH_ACOLOR));
    depthAxis.setTickLabelPaint(new Color(ProjectConst.GRAPH_DEPTH_ACOLOR));
    thePlot.setRangeAxis(0, depthAxis);
    thePlot.setDataset(GRAPH_DEPTH, depthDataSet);
    thePlot.mapDatasetToRangeAxis(0, GRAPH_DEPTH);
    areaDepthRenderer.setSeriesPaint(0, new Color(ProjectConst.GRAPH_DEPTH_RCOLOR));
    thePlot.setRenderer(GRAPH_DEPTH, areaDepthRenderer, true);
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.OverlaidBarLine.java

public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");

    // create the first renderer...

    CategoryPlot plot = new CategoryPlot();

    NumberFormat nf = NumberFormat.getNumberInstance(locale);

    NumberAxis rangeAxis = new NumberAxis(getValueLabel());
    rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setLabelPaint(styleXaxesLabels.getColor());
    rangeAxis/*from   ww w.  j  ava 2  s.  c o m*/
            .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor());
    //      rangeAxis.setLowerBound(600);
    //      rangeAxis.setUpperBound(720);
    if (firstAxisLB != null && firstAxisUB != null) {
        rangeAxis.setLowerBound(firstAxisLB);
        rangeAxis.setUpperBound(firstAxisUB);
    }

    rangeAxis.setUpperMargin(0.10);
    plot.setRangeAxis(0, rangeAxis);
    if (rangeIntegerValues == true) {
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }
    rangeAxis.setNumberFormatOverride(nf);

    CategoryAxis domainAxis = new CategoryAxis(getCategoryLabel());
    domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setLabelPaint(styleYaxesLabels.getColor());
    domainAxis
            .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setTickLabelPaint(styleYaxesLabels.getColor());
    domainAxis.setUpperMargin(0.10);
    plot.setDomainAxis(domainAxis);

    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);

    DefaultCategoryDataset datasetLineFirstAxis = (DefaultCategoryDataset) datasets.getDatasets().get("1-line");
    DefaultCategoryDataset datasetBarFirstAxis = (DefaultCategoryDataset) datasets.getDatasets().get("1-bar");
    DefaultCategoryDataset datasetLineSecondAxis = (DefaultCategoryDataset) datasets.getDatasets()
            .get("2-line");
    DefaultCategoryDataset datasetBarSecondAxis = (DefaultCategoryDataset) datasets.getDatasets().get("2-bar");

    //I create one bar renderer and one line
    MyStandardCategoryItemLabelGenerator generator = null;

    // value labels and additional values are mutually exclusive
    if (showValueLabels == true)
        additionalLabels = false;

    if (additionalLabels) {
        generator = new MyStandardCategoryItemLabelGenerator(catSerLabels, "{1}", NumberFormat.getInstance());
    }

    if (useBars) {

        CategoryItemRenderer barRenderer = null;
        if (stackedBarRenderer_1 == true) {
            barRenderer = new StackedBarRenderer();
        } else {
            barRenderer = new BarRenderer();
        }

        CategoryItemRenderer barRenderer2 = new BarRenderer();

        if (stackedBarRenderer_2 == true) {
            barRenderer2 = new StackedBarRenderer();
        } else {
            barRenderer2 = new BarRenderer();
        }

        if (maxBarWidth != null) {
            ((BarRenderer) barRenderer).setMaximumBarWidth(maxBarWidth.doubleValue());
            ((BarRenderer) barRenderer2).setMaximumBarWidth(maxBarWidth.doubleValue());
        }

        if (showValueLabels) {
            barRenderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
            barRenderer.setBaseItemLabelsVisible(true);
            barRenderer.setBaseItemLabelFont(
                    new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
            barRenderer.setBaseItemLabelPaint(styleValueLabels.getColor());

            //            barRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(
            //                  ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
            //
            //            barRenderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(
            //                  ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

            if (valueLabelsPosition.equalsIgnoreCase("inside")) {
                barRenderer.setBasePositiveItemLabelPosition(
                        new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT));
                barRenderer.setBaseNegativeItemLabelPosition(
                        new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT));
            } else {
                barRenderer.setBasePositiveItemLabelPosition(
                        new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
                barRenderer.setBaseNegativeItemLabelPosition(
                        new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
            }

        } else if (additionalLabels) {
            barRenderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
            barRenderer.setBaseItemLabelGenerator(generator);
            double orient = (-Math.PI / 2.0);
            if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) {
                orient = 0.0;
            }

            barRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));
            barRenderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));
            barRenderer.setBaseItemLabelFont(
                    new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
            barRenderer.setBaseItemLabelPaint(defaultLabelsStyle.getColor());
            barRenderer.setBaseItemLabelsVisible(true);
        }

        if (showValueLabels) {
            barRenderer2.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
            barRenderer2.setBaseItemLabelsVisible(true);
            barRenderer2.setBaseItemLabelFont(
                    new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
            barRenderer2.setBaseItemLabelPaint(styleValueLabels.getColor());

            //            barRenderer2.setBasePositiveItemLabelPosition(new ItemLabelPosition(
            //                  ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
            //
            //            barRenderer2.setBaseNegativeItemLabelPosition(new ItemLabelPosition(
            //                  ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));

            if (valueLabelsPosition.equalsIgnoreCase("inside")) {
                barRenderer2.setBasePositiveItemLabelPosition(
                        new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT));
                barRenderer2.setBaseNegativeItemLabelPosition(
                        new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT));
            } else {
                barRenderer2.setBasePositiveItemLabelPosition(
                        new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
                barRenderer2.setBaseNegativeItemLabelPosition(
                        new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
            }

        } else if (additionalLabels) {
            barRenderer2.setBaseItemLabelGenerator(generator);
            double orient = (-Math.PI / 2.0);
            if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) {
                orient = 0.0;
            }

            barRenderer2.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));
            barRenderer2.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));

            barRenderer2.setBaseItemLabelFont(
                    new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
            barRenderer2.setBaseItemLabelPaint(defaultLabelsStyle.getColor());
            barRenderer2.setBaseItemLabelsVisible(true);

        }

        if (colorMap != null) {
            int idx = -1;
            for (Iterator iterator = datasetBarFirstAxis.getRowKeys().iterator(); iterator.hasNext();) {
                idx++;
                String serName = (String) iterator.next();
                String labelName = "";
                int index = -1;

                if (seriesCaptions != null && seriesCaptions.size() > 0) {
                    labelName = serName;
                    serName = (String) seriesCaptions.get(serName);
                    index = datasetBarFirstAxis.getRowIndex(labelName);
                } else
                    index = datasetBarFirstAxis.getRowIndex(serName);

                Color color = (Color) colorMap.get(serName);
                if (color != null) {
                    barRenderer.setSeriesPaint(index, color);
                }
            }
            for (Iterator iterator = datasetBarSecondAxis.getRowKeys().iterator(); iterator.hasNext();) {
                idx++;
                String serName = (String) iterator.next();
                String labelName = "";
                int index = -1;

                if (seriesCaptions != null && seriesCaptions.size() > 0) {
                    labelName = serName;
                    serName = (String) seriesCaptions.get(serName);
                    index = datasetBarSecondAxis.getRowIndex(labelName);
                } else
                    index = datasetBarSecondAxis.getRowIndex(serName);

                Color color = (Color) colorMap.get(serName);
                if (color != null) {
                    barRenderer2.setSeriesPaint(index, color);
                    /* test con un renderer
                    if (idx > index){
                       index = idx+1;
                    }
                            
                    barRenderer.setSeriesPaint(index, color);*/
                }
            }
        }
        // add tooltip if enabled
        if (enableToolTips) {
            MyCategoryToolTipGenerator generatorToolTip = new MyCategoryToolTipGenerator(freeToolTips,
                    seriesTooltip, categoriesTooltip, seriesCaptions);
            barRenderer.setToolTipGenerator(generatorToolTip);
            barRenderer2.setToolTipGenerator(generatorToolTip);
        }
        //defines url for drill
        boolean document_composition = false;
        if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION))
            document_composition = true;

        logger.debug("Calling Url Generation");

        MyCategoryUrlGenerator mycatUrl = null;
        if (super.rootUrl != null) {
            logger.debug("Set MycatUrl");
            mycatUrl = new MyCategoryUrlGenerator(super.rootUrl);

            mycatUrl.setDocument_composition(document_composition);
            mycatUrl.setCategoryUrlLabel(super.categoryUrlName);
            mycatUrl.setSerieUrlLabel(super.serieUrlname);
            mycatUrl.setDrillDocTitle(drillDocTitle);
            mycatUrl.setTarget(target);
        }
        if (mycatUrl != null
                && (!mycatUrl.getCategoryUrlLabel().equals("") || !mycatUrl.getSerieUrlLabel().equals(""))) {
            barRenderer.setItemURLGenerator(mycatUrl);
            barRenderer2.setItemURLGenerator(mycatUrl);
        }

        plot.setDataset(2, datasetBarFirstAxis);
        plot.setDataset(3, datasetBarSecondAxis);

        plot.setRenderer(2, barRenderer);
        plot.setRenderer(3, barRenderer2);

    }

    if (useLines) {

        LineAndShapeRenderer lineRenderer = new LineAndShapeRenderer();
        LineAndShapeRenderer lineRenderer2 = new LineAndShapeRenderer();

        //lineRenderer.setShapesFilled(false);
        lineRenderer.setShapesFilled(true);
        lineRenderer2.setShapesFilled(true);

        // no shapes for line_no_shapes  series
        for (Iterator iterator = lineNoShapeSeries1.iterator(); iterator.hasNext();) {
            String ser = (String) iterator.next();
            // if there iS a abel associated search for that

            String label = null;
            if (seriesLabelsMap != null) {
                label = (String) seriesLabelsMap.get(ser);
            }
            if (label == null)
                label = ser;
            int index = datasetLineFirstAxis.getRowIndex(label);
            if (index != -1) {
                lineRenderer.setSeriesShapesVisible(index, false);
            }
        }

        for (Iterator iterator = lineNoShapeSeries2.iterator(); iterator.hasNext();) {
            String ser = (String) iterator.next();
            // if there iS a abel associated search for that
            String label = null;
            if (seriesLabelsMap != null) {
                label = (String) seriesLabelsMap.get(ser);
            }
            if (label == null)
                label = ser;
            int index = datasetLineSecondAxis.getRowIndex(label);
            if (index != -1) {
                lineRenderer2.setSeriesShapesVisible(index, false);
            }
        }

        if (enableToolTips) {
            MyCategoryToolTipGenerator generatorToolTip = new MyCategoryToolTipGenerator(freeToolTips,
                    seriesTooltip, categoriesTooltip, seriesCaptions);
            lineRenderer.setToolTipGenerator(generatorToolTip);
            lineRenderer2.setToolTipGenerator(generatorToolTip);
        }

        if (showValueLabels) {
            lineRenderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
            lineRenderer.setBaseItemLabelsVisible(true);
            lineRenderer.setBaseItemLabelFont(
                    new Font(styleValueLabels.getFontName(), Font.ITALIC, styleValueLabels.getSize()));
            lineRenderer.setBaseItemLabelPaint(styleValueLabels.getColor());

            lineRenderer.setBasePositiveItemLabelPosition(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_RIGHT));

            lineRenderer.setBaseNegativeItemLabelPosition(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_RIGHT));

        } else if (additionalLabels) {
            lineRenderer.setBaseItemLabelGenerator(generator);
            lineRenderer.setBaseItemLabelFont(
                    new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
            lineRenderer.setBaseItemLabelPaint(defaultLabelsStyle.getColor());
            lineRenderer.setBaseItemLabelsVisible(true);
        }

        if (showValueLabels) {
            lineRenderer2.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
            lineRenderer2.setBaseItemLabelsVisible(true);
            lineRenderer2.setBaseItemLabelFont(
                    new Font(styleValueLabels.getFontName(), Font.ITALIC, styleValueLabels.getSize()));
            lineRenderer2.setBaseItemLabelPaint(styleValueLabels.getColor());

            lineRenderer2.setBasePositiveItemLabelPosition(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_RIGHT));

            lineRenderer2.setBaseNegativeItemLabelPosition(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_RIGHT));

        } else if (additionalLabels) {
            lineRenderer2.setBaseItemLabelGenerator(generator);
            lineRenderer2.setBaseItemLabelFont(
                    new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
            lineRenderer2.setBaseItemLabelPaint(defaultLabelsStyle.getColor());
            lineRenderer2.setBaseItemLabelsVisible(true);
        }

        //         DefaultCategoryDataset datasetSecondAxis=(DefaultCategoryDataset)datasets.getDatasets().get("2");

        if (colorMap != null) {
            for (Iterator iterator = datasetLineSecondAxis.getRowKeys().iterator(); iterator.hasNext();) {
                String serName = (String) iterator.next();
                String labelName = "";
                int index = -1;

                if (seriesCaptions != null && seriesCaptions.size() > 0) {
                    labelName = serName;
                    serName = (String) seriesCaptions.get(serName);
                    index = datasetLineSecondAxis.getRowIndex(labelName);
                } else
                    index = datasetLineSecondAxis.getRowIndex(serName);

                Color color = (Color) colorMap.get(serName);
                if (color != null) {
                    lineRenderer2.setSeriesPaint(index, color);
                }
            }
            for (Iterator iterator = datasetLineFirstAxis.getRowKeys().iterator(); iterator.hasNext();) {
                String serName = (String) iterator.next();
                String labelName = "";
                int index = -1;

                if (seriesCaptions != null && seriesCaptions.size() > 0) {
                    labelName = serName;
                    serName = (String) seriesCaptions.get(serName);
                    index = datasetLineFirstAxis.getRowIndex(labelName);
                } else
                    index = datasetLineFirstAxis.getRowIndex(serName);

                Color color = (Color) colorMap.get(serName);
                if (color != null) {
                    lineRenderer.setSeriesPaint(index, color);
                }
            }

        }
        plot.setDataset(0, datasetLineFirstAxis);
        plot.setRenderer(0, lineRenderer);
        plot.setDataset(1, datasetLineSecondAxis);
        plot.setRenderer(1, lineRenderer2);

    }

    if (secondAxis) {
        NumberAxis na = new NumberAxis(secondAxisLabel);
        na.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
        na.setLabelPaint(styleXaxesLabels.getColor());
        na.setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
        na.setTickLabelPaint(styleXaxesLabels.getColor());
        na.setUpperMargin(0.10);
        na.setNumberFormatOverride(nf);
        //         rangeAxis.setLowerBound(270);
        //         rangeAxis.setUpperBound(340);
        if (secondAxisLB != null && secondAxisUB != null) {
            rangeAxis.setLowerBound(secondAxisLB);
            rangeAxis.setUpperBound(secondAxisUB);
        }
        plot.setRangeAxis(1, na);
        plot.mapDatasetToRangeAxis(0, 0);
        plot.mapDatasetToRangeAxis(2, 0);
        plot.mapDatasetToRangeAxis(1, 1);
        plot.mapDatasetToRangeAxis(3, 1);
        if (rangeIntegerValues == true) {
            na.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        }

    }

    //plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    JFreeChart chart = new JFreeChart(plot);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }
    chart.setBackgroundPaint(Color.white);

    if (legend == true)
        drawLegend(chart);

    logger.debug("OUT");

    return chart;

}