Example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer XYLineAndShapeRenderer

List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer XYLineAndShapeRenderer

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer XYLineAndShapeRenderer.

Prototype

public XYLineAndShapeRenderer(boolean lines, boolean shapes) 

Source Link

Document

Creates a new renderer.

Usage

From source file:de.bund.bfr.knime.pmm.common.chart.ChartCreator.java

private void plotFunctionSample(XYPlot plot, Plotable plotable, String id, Color defaultColor,
        Shape defaultShape, double minX, double maxX, List<String> warnings) throws ConvertException {
    double[][] functionPoints = plotable.getFunctionPoints(paramX, paramY, unitX, unitY, transformX, transformY,
            minX, maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    double[][] samplePoints;

    if (!inverse) {
        samplePoints = plotable.getFunctionSamplePoints(paramX, paramY, unitX, unitY, transformX, transformY,
                minX, maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, warnings);
    } else {/*from w  w w.  j  a  v a2  s  . c om*/
        samplePoints = plotable.getInverseFunctionSamplePoints(paramX, paramY, unitX, unitY, transformX,
                transformY, minX, maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, warnings);
    }

    double[][] functionErrors = null;
    String legend = shortLegend.get(id);
    Color color = colors.get(id);
    Shape shape = shapes.get(id);

    if (showConfidenceInterval) {
        functionErrors = plotable.getFunctionErrors(paramX, paramY, unitX, unitY, transformX, transformY, minX,
                maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    }

    if (addInfoInLegend) {
        legend = longLegend.get(id);
    }

    if (color == null) {
        color = defaultColor;
    }

    if (shape == null) {
        shape = defaultShape;
    }

    if (functionPoints != null) {
        int i;

        if (plot.getDataset(0) == null) {
            i = 0;
        } else {
            i = plot.getDatasetCount();
        }

        if (functionErrors != null) {
            YIntervalSeriesCollection functionDataset = new YIntervalSeriesCollection();
            DeviationRenderer functionRenderer = new DeviationRenderer(true, false);
            YIntervalSeries series = new YIntervalSeries(legend);

            for (int j = 0; j < functionPoints[0].length; j++) {
                double error = Double.isNaN(functionErrors[1][j]) ? 0.0 : functionErrors[1][j];

                series.add(functionPoints[0][j], functionPoints[1][j], functionPoints[1][j] - error,
                        functionPoints[1][j] + error);
            }

            functionDataset.addSeries(series);
            functionRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            functionRenderer.setSeriesPaint(0, color);
            functionRenderer.setSeriesFillPaint(0, color);
            functionRenderer.setSeriesShape(0, shape);

            if (samplePoints != null) {
                functionRenderer.setBaseSeriesVisibleInLegend(false);
            }

            plot.setDataset(i, functionDataset);
            plot.setRenderer(i, functionRenderer);
        } else {
            DefaultXYDataset functionDataset = new DefaultXYDataset();
            XYLineAndShapeRenderer functionRenderer = new XYLineAndShapeRenderer(true, false);

            functionDataset.addSeries(legend, functionPoints);
            functionRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            functionRenderer.setSeriesPaint(0, color);
            functionRenderer.setSeriesShape(0, shape);

            if (samplePoints != null) {
                functionRenderer.setBaseSeriesVisibleInLegend(false);
            }

            plot.setDataset(i, functionDataset);
            plot.setRenderer(i, functionRenderer);
        }

        if (samplePoints != null) {
            DefaultXYDataset sampleDataset = new DefaultXYDataset();
            XYLineAndShapeRenderer sampleRenderer = new XYLineAndShapeRenderer(false, true);

            sampleDataset.addSeries(legend, samplePoints);
            sampleRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            sampleRenderer.setSeriesPaint(0, color);
            sampleRenderer.setSeriesShape(0, shape);

            plot.setDataset(i + 1, sampleDataset);
            plot.setRenderer(i + 1, sampleRenderer);
        }
    }
}

From source file:whitebox.stats.Kriging.java

/**
 * Draw Semivariogram surface map and also draw the search are if
 * Anisotropic//w  ww. j av a2s. c  o m
 *
 * @param Radius
 * @param AnIsotropic
 */
public void DrawSemivariogramSurface(double Radius, boolean AnIsotropic) {
    double[][] data = new double[3][BinSurface.length * BinSurface[0].length];
    int n = 0;
    double max = Double.MIN_VALUE;
    for (int i = 0; i < BinSurface.length; i++) {
        for (int j = 0; j < BinSurface[i].length; j++) {
            data[0][n] = BinSurface[i][j].GridHorDistance;
            data[1][n] = BinSurface[i][j].GridVerDistance;
            if ((Math.pow(data[0][n], 2) + Math.pow(data[1][n], 2)) <= Radius * Radius
                    && !Double.isNaN(BinSurface[i][j].Value)) {
                data[2][n] = BinSurface[i][j].Value;
                if (max < data[2][n]) {
                    max = data[2][n];
                }
            } else {
                data[2][n] = -1;
            }
            n++;
        }
    }
    DefaultXYZDataset dataset = new DefaultXYZDataset();
    dataset.addSeries("Value", data);
    NumberAxis xAxis = new NumberAxis();

    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    NumberAxis yAxis = new NumberAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setBlockWidth(LagSize);
    renderer.setBlockHeight(LagSize);
    renderer.setBlockAnchor(RectangleAnchor.CENTER);

    LookupPaintScale paintScale = new LookupPaintScale(0, max, Color.white);
    double colorRange = max / 6;
    //double colorRange = 23013;
    paintScale.add(0.0, Color.blue);
    paintScale.add(1 * colorRange, Color.green);
    paintScale.add(2 * colorRange, Color.cyan);
    paintScale.add(3 * colorRange, Color.yellow);
    paintScale.add(4 * colorRange, Color.ORANGE);
    paintScale.add(5 * colorRange, Color.red);

    renderer.setPaintScale(paintScale);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinePaint(Color.white);

    if (AnIsotropic) {
        CombinedRangeXYPlot combinedrangexyplot = new CombinedRangeXYPlot();
        XYSeries seriesT1 = new XYSeries("1");
        XYSeriesCollection AngleCollct = new XYSeriesCollection();

        double bw = BandWidth;
        double r = bw / Math.sin(Tolerance);
        if (r > Radius) {
            bw = Radius * Math.sin(Tolerance);
            r = Radius;
        }
        seriesT1.add(r * Math.cos(Angle + Tolerance), r * Math.sin(Angle + Tolerance));

        if ((double) Math.round(Math.sin(Angle) * 10000) / 10000 != 0) {
            if ((double) Math.round(Math.cos(Angle) * 10000) / 10000 != 0) {
                double a = (1 + Math.pow(Math.tan(Angle), 2));
                double b = 2 * bw / Math.sin(Angle) * Math.pow(Math.tan(Angle), 2);
                double c = Math.pow(Math.tan(Angle), 2) * Math.pow(bw / Math.sin(Angle), 2)
                        - Math.pow(Radius, 2);
                double x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
                double y1 = Math.tan(Angle) * (x1 + bw / Math.sin(Angle));
                double x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
                double y2 = Math.tan(Angle) * (x2 + bw / Math.sin(Angle));
                double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));
                double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y2), 2)));
                if (d1 < d2) {
                    seriesT1.add(x1, y1);
                } else {
                    seriesT1.add(x2, y2);
                }
            } else {
                double x1 = -bw * Math.sin(Angle);
                double y1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2));
                double y2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2));
                double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));
                double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y2), 2)));

                if (d1 < d2) {
                    seriesT1.add(x1, y1);
                } else {
                    seriesT1.add(x1, y2);
                }
            }
        } else {
            double y1 = bw * Math.cos(Angle);
            double x1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2));
            double x2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2));
            double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                    + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));
            double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2))
                    + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));

            if (d1 < d2) {
                seriesT1.add(x1, y1);
            } else {
                seriesT1.add(x2, y1);
            }
        }

        AngleCollct.addSeries(seriesT1);

        XYSeries seriesT2 = new XYSeries("2");
        seriesT2.add(r * Math.cos(Angle + Tolerance), r * Math.sin(Angle + Tolerance));
        seriesT2.add(0.0, 0.0);
        AngleCollct.addSeries(seriesT2);

        XYSeries seriesT3 = new XYSeries("3");
        seriesT3.add(Radius * Math.cos(Angle), Radius * Math.sin(Angle));
        seriesT3.add(0, 0);
        AngleCollct.addSeries(seriesT3);

        XYSeries seriesT4 = new XYSeries("4");
        seriesT4.add(r * Math.cos(Angle - Tolerance), r * Math.sin(Angle - Tolerance));
        seriesT4.add(0, 0);
        AngleCollct.addSeries(seriesT4);

        XYSeries seriesT5 = new XYSeries("5");

        seriesT5.add(r * Math.cos(Angle - Tolerance), r * Math.sin(Angle - Tolerance));
        if ((double) Math.round(Math.sin(Angle) * 10000) / 10000 != 0) {
            if ((double) Math.round(Math.cos(Angle) * 10000) / 10000 != 0) {
                double a = (1 + Math.pow(Math.tan(Angle), 2));
                double b = -2 * bw / Math.sin(Angle) * Math.pow(Math.tan(Angle), 2);
                double c = Math.pow(Math.tan(Angle), 2) * Math.pow(bw / Math.sin(Angle), 2)
                        - Math.pow(Radius, 2);
                double x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
                double y1 = Math.tan(Angle) * (x1 - bw / Math.sin(Angle));
                double x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
                double y2 = Math.tan(Angle) * (x2 - bw / Math.sin(Angle));
                double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));
                double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y2), 2)));
                if (d1 < d2) {
                    seriesT5.add(x1, y1);
                } else {
                    seriesT5.add(x2, y2);
                }
            } else {
                double x1 = bw * Math.sin(Angle);
                double y1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2));
                double y2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2));
                double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));
                double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                        + (Math.pow((Radius * Math.sin(Angle) - y2), 2)));

                if (d1 < d2) {
                    seriesT5.add(x1, y1);
                } else {
                    seriesT5.add(x1, y2);
                }
            }
        } else {
            double y1 = -bw * Math.cos(Angle);
            double x1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2));
            double x2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2));
            double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2))
                    + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));
            double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2))
                    + (Math.pow((Radius * Math.sin(Angle) - y1), 2)));

            if (d1 < d2) {
                seriesT5.add(x1, y1);
            } else {
                seriesT5.add(x2, y1);
            }
        }
        AngleCollct.addSeries(seriesT5);
        plot.setDataset(1, AngleCollct);
        XYLineAndShapeRenderer lineshapRend = new XYLineAndShapeRenderer(true, false);
        for (int i = 0; i < AngleCollct.getSeriesCount(); i++) {
            //plot.getRenderer().setSeriesPaint(i , Color.BLUE);
            lineshapRend.setSeriesPaint(i, Color.BLACK);
        }
        plot.setRenderer(1, lineshapRend);
        combinedrangexyplot.add(plot);
    }
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    JFreeChart chart = new JFreeChart("Semivariogram Surface", plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);

    // create and display a frame...
    ChartFrame frame = new ChartFrame("", chart);
    frame.pack();
    //frame.setSize(100, 50);
    frame.setVisible(true);
}

From source file:de.bund.bfr.knime.pmm.common.chart.ChartCreator.java

private void plotBoth(XYPlot plot, Plotable plotable, String id, Color defaultColor, Shape defaultShape,
        double minX, double maxX) throws ConvertException {
    double[][] modelPoints = plotable.getFunctionPoints(paramX, paramY, unitX, unitY, transformX, transformY,
            minX, maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    double[][] dataPoints = plotable.getPoints(paramX, paramY, unitX, unitY, transformX, transformY);
    double[][] functionErrors = null;
    String legend = shortLegend.get(id);
    Color color = colors.get(id);
    Shape shape = shapes.get(id);

    if (showConfidenceInterval) {
        functionErrors = plotable.getFunctionErrors(paramX, paramY, unitX, unitY, transformX, transformY, minX,
                maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
    }/*from  w  w  w .j a  v a2s  . c o  m*/

    if (addInfoInLegend) {
        legend = longLegend.get(id);
    }

    if (color == null) {
        color = defaultColor;
    }

    if (shape == null) {
        shape = defaultShape;
    }

    if (modelPoints != null) {
        int i;

        if (plot.getDataset(0) == null) {
            i = 0;
        } else {
            i = plot.getDatasetCount();
        }

        if (functionErrors != null) {
            YIntervalSeriesCollection functionDataset = new YIntervalSeriesCollection();
            DeviationRenderer functionRenderer = new DeviationRenderer(true, false);
            YIntervalSeries series = new YIntervalSeries(legend);

            for (int j = 0; j < modelPoints[0].length; j++) {
                double error = Double.isNaN(functionErrors[1][j]) ? 0.0 : functionErrors[1][j];

                series.add(modelPoints[0][j], modelPoints[1][j], modelPoints[1][j] - error,
                        modelPoints[1][j] + error);
            }

            functionDataset.addSeries(series);
            functionRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            functionRenderer.setSeriesPaint(0, color);
            functionRenderer.setSeriesFillPaint(0, color);
            functionRenderer.setSeriesShape(0, shape);

            if (dataPoints != null) {
                functionRenderer.setBaseSeriesVisibleInLegend(false);
            }

            plot.setDataset(i, functionDataset);
            plot.setRenderer(i, functionRenderer);
        } else {
            DefaultXYDataset functionDataset = new DefaultXYDataset();
            XYLineAndShapeRenderer functionRenderer = new XYLineAndShapeRenderer(true, false);

            functionDataset.addSeries(legend, modelPoints);
            functionRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            functionRenderer.setSeriesPaint(0, color);
            functionRenderer.setSeriesShape(0, shape);

            if (dataPoints != null) {
                functionRenderer.setBaseSeriesVisibleInLegend(false);
            }

            plot.setDataset(i, functionDataset);
            plot.setRenderer(i, functionRenderer);
        }
    }

    if (dataPoints != null) {
        DefaultXYDataset dataSet = new DefaultXYDataset();
        XYLineAndShapeRenderer dataRenderer = new XYLineAndShapeRenderer(drawLines, true);

        dataSet.addSeries(legend, dataPoints);
        dataRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
        dataRenderer.setSeriesPaint(0, color);
        dataRenderer.setSeriesShape(0, shape);

        int i;

        if (plot.getDataset(0) == null) {
            i = 0;
        } else {
            i = plot.getDatasetCount();
        }

        plot.setDataset(i, dataSet);
        plot.setRenderer(i, dataRenderer);
    }
}

From source file:de.bund.bfr.knime.pmm.common.chart.ChartCreator.java

private void plotBothStrict(XYPlot plot, Plotable plotable, String id, double minX, double maxX)
        throws ConvertException {
    String legend = shortLegend.get(id);
    List<Color> colorList = colorLists.get(id);
    List<Shape> shapeList = shapeLists.get(id);
    ColorAndShapeCreator creator = new ColorAndShapeCreator(plotable.getNumberOfCombinations());
    int index = 0;

    if (addInfoInLegend) {
        legend = longLegend.get(id);/*from w w  w.java2  s.  c o m*/
    }

    if (colorList == null || colorList.isEmpty()) {
        colorList = creator.getColorList();
    }

    if (shapeList == null || shapeList.isEmpty()) {
        shapeList = creator.getShapeList();
    }

    for (Map<String, Integer> choiceMap : plotable.getAllChoices()) {
        double[][] dataPoints = plotable.getPoints(paramX, paramY, unitX, unitY, transformX, transformY,
                choiceMap);

        if (dataPoints == null) {
            continue;
        }

        double[][] modelPoints = plotable.getFunctionPoints(paramX, paramY, unitX, unitY, transformX,
                transformY, minX, maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, choiceMap);

        if (modelPoints == null) {
            continue;
        }

        double[][] modelErrors = null;

        if (showConfidenceInterval) {
            modelErrors = plotable.getFunctionErrors(paramX, paramY, unitX, unitY, transformX, transformY, minX,
                    maxX, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, choiceMap);
        }

        int i;

        if (plot.getDataset(0) == null) {
            i = 0;
        } else {
            i = plot.getDatasetCount();
        }

        String addLegend = "";

        for (String arg : choiceMap.keySet()) {
            if (!arg.equals(paramX)) {
                addLegend += " (" + arg + "=" + plotable.getFunctionArguments().get(arg).get(choiceMap.get(arg))
                        + ")";
            }
        }

        if (modelErrors != null) {
            YIntervalSeriesCollection modelSet = new YIntervalSeriesCollection();
            DeviationRenderer modelRenderer = new DeviationRenderer(true, false);
            YIntervalSeries series = new YIntervalSeries(legend);

            for (int j = 0; j < modelPoints[0].length; j++) {
                double error = Double.isNaN(modelErrors[1][j]) ? 0.0 : modelErrors[1][j];

                series.add(modelPoints[0][j], modelPoints[1][j], modelPoints[1][j] - error,
                        modelPoints[1][j] + error);
            }

            modelSet.addSeries(series);
            modelRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            modelRenderer.setSeriesPaint(0, colorList.get(index));
            modelRenderer.setSeriesFillPaint(0, colorList.get(index));
            modelRenderer.setSeriesShape(0, shapeList.get(index));

            if (dataPoints != null) {
                modelRenderer.setBaseSeriesVisibleInLegend(false);
            }

            plot.setDataset(i, modelSet);
            plot.setRenderer(i, modelRenderer);
        } else {
            DefaultXYDataset modelSet = new DefaultXYDataset();
            XYLineAndShapeRenderer modelRenderer = new XYLineAndShapeRenderer(true, false);

            modelSet.addSeries(legend + addLegend, modelPoints);
            modelRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            modelRenderer.setBaseSeriesVisibleInLegend(false);
            modelRenderer.setSeriesPaint(0, colorList.get(index));
            modelRenderer.setSeriesShape(0, shapeList.get(index));

            plot.setDataset(i, modelSet);
            plot.setRenderer(i, modelRenderer);
        }

        DefaultXYDataset dataSet = new DefaultXYDataset();
        XYLineAndShapeRenderer dataRenderer = new XYLineAndShapeRenderer(drawLines, true);

        dataSet.addSeries(legend + addLegend, dataPoints);
        dataRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
        dataRenderer.setSeriesPaint(0, colorList.get(index));
        dataRenderer.setSeriesShape(0, shapeList.get(index));
        plot.setDataset(i + 1, dataSet);
        plot.setRenderer(i + 1, dataRenderer);

        index++;
    }
}

From source file:com.chart.SwingChart.java

/**
 * Add axis/*from  w  w w .j a  va2 s .c om*/
 * @param name new axis name 
 */
@Override
public final void addAxis(String name) {
    boolean encontrado = false;
    for (AxisChart categoria : axes) {
        if (categoria.getName().equals(name)) {
            encontrado = true;
            break;
        }
    }
    if (!encontrado) {
        axes.add(new AxisChart((name)));
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    NumberAxis ejeOrdenada = new NumberAxis(name);

    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));

    int i = datasetList.size();

    datasetList.add(dataset);
    AxesList.add(ejeOrdenada);
    plot.setDataset(i, dataset);
    plot.setRangeAxis(i, ejeOrdenada);
    plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_LEFT);
    plot.mapDatasetToRangeAxis(i, i);
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, true);
    if (i == 0) {
        plot.setRenderer(renderer);
    } else {
        plot.setRenderer(i, renderer);
    }

    final LegendAxis le;
    final int indiceLeyenda = legendFrame.getChildren().size();

    legendFrame.getChildren().add(le = new LegendAxis(name));

    le.setOnMouseClicked((MouseEvent t) -> {
        if (le.selected && t.getClickCount() == 2) {
            setOrdinateRange(AxesList.get(indiceLeyenda));
        }
    });

    le.setOnMouseEntered((MouseEvent t) -> {
        le.setStyle("-fx-background-color:blue");
        le.selected = true;
        AxesList.get(indiceLeyenda).setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web("blue")));
        AxesList.get(indiceLeyenda).setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web("blue")));
    });

    le.setOnMouseExited((MouseEvent t) -> {
        le.setStyle("-fx-background-color:" + strBackgroundColor);
        le.selected = false;
        AxesList.get(indiceLeyenda).setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
        AxesList.get(indiceLeyenda)
                .setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
    });
}

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

/**
 * Graph fr Anteil Inertgas machen Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui
 * //from   w  w w  .  j  av  a  2 s.  c om
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 02.08.2012
 * @param diveList
 * @param thePlot
 * @param string
 */
private void makeInnertGasGraph(Vector<Integer[]> diveList, XYPlot thePlot, String gasName) {
    XYDataset percentDataSet;
    int graphPos;
    int lRenderColor;
    //
    lg.debug("create percent dataset (" + gasName + ")");
    final XYLineAndShapeRenderer setpointRenderer = new XYLineAndShapeRenderer(true, true);
    if (0 == gasName.indexOf("he")) {
        percentDataSet = createXYDataset(gasName, diveList, showingUnitSystem, 0,
                LogDerbyDatabaseUtil.HEPERCENT);
        graphPos = GRAPH_HE;
        lRenderColor = ProjectConst.GRAPH_HE_RCOLOR;
    } else {
        percentDataSet = createXYDataset(gasName, diveList, showingUnitSystem, 0,
                LogDerbyDatabaseUtil.N2PERCENT);
        graphPos = GRAPH_N2;
        lRenderColor = ProjectConst.GRAPH_N2_RCOLOR;
    }
    // die Achse sollte schon erstellt sein
    thePlot.setDataset(graphPos, percentDataSet);
    thePlot.mapDatasetToRangeAxis(graphPos, GRAPH_HE);
    setpointRenderer.setSeriesPaint(0, new Color(lRenderColor));
    setpointRenderer.setSeriesShapesVisible(0, false);
    setpointRenderer.setDrawSeriesLineAsPath(true);
    thePlot.setRenderer(graphPos, setpointRenderer);
}

From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java

private byte[] createMonthlyLoginChart(int width, int height) {
    IntervalXYDataset dataset1 = getMonthlyLoginsDataSet();
    IntervalXYDataset dataset3 = getMonthlySiteUserDataSet();

    if ((dataset1 == null) || (dataset3 == null)) {
        return generateNoDataChart(width, height);
    }/*from   w w w . j  ava  2  s  .  c  o  m*/

    // create plot ...
    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
    renderer1.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesPaint(0, Color.RED);

    DateAxis domainAxis = new DateAxis("");
    domainAxis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1, new SimpleDateFormat("yyyy-MM")));
    domainAxis.setTickMarkPosition(DateTickMarkPosition.START);
    domainAxis.setVerticalTickLabels(true);
    domainAxis.setLowerMargin(0.01);
    domainAxis.setUpperMargin(0.01);

    NumberAxis axis1 = new NumberAxis("Total Logins");
    axis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    axis1.setLabelPaint(Color.RED);
    axis1.setTickLabelPaint(Color.RED);

    XYPlot plot1 = new XYPlot(dataset1, null, axis1, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);

    // AXIS 2
    /*
    NumberAxis axis2 = new NumberAxis("Total Unique Users");
    axis2.setStandardTickUnits (NumberAxis.createIntegerTickUnits ());
    axis2.setLabelPaint(Color.BLUE);
    axis2.setTickLabelPaint(Color.BLUE);
    plot1.setRangeAxis(1, axis2);
            
    plot1.setDataset(1, dataset2);
    plot1.mapDatasetToRangeAxis(1, 1);
    XYItemRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
    renderer2.setSeriesStroke(0, new BasicStroke(2.0f, 
        BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer2.setSeriesPaint (0, Color.BLUE);
    plot1.setRenderer(1, renderer2);
    */

    // add a third dataset and renderer...
    XYItemRenderer renderer3 = new XYLineAndShapeRenderer(true, false);
    renderer3.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer3.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer3.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer3.setSeriesPaint(0, Color.GREEN);
    renderer3.setSeriesPaint(1, Color.BLACK);
    renderer3.setSeriesPaint(2, Color.CYAN);

    axis1 = new NumberAxis("count");
    axis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYPlot plot2 = new XYPlot(dataset3, null, axis1, renderer3);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);

    CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis);
    cplot.add(plot1, 3);
    cplot.add(plot2, 2);
    cplot.setGap(8.0);
    cplot.setDomainGridlinePaint(Color.white);
    cplot.setDomainGridlinesVisible(true);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
    LegendTitle legend = new LegendTitle(cplot);
    chart.addSubtitle(legend);

    // set background
    chart.setBackgroundPaint(parseColor(statsManager.getChartBackgroundColor()));

    // set chart border
    chart.setPadding(new RectangleInsets(10, 5, 5, 5));
    chart.setBorderVisible(true);
    chart.setBorderPaint(parseColor("#cccccc"));

    // set anti alias
    chart.setAntiAlias(true);

    BufferedImage img = chart.createBufferedImage(width, height);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        ImageIO.write(img, "png", out);
    } catch (IOException e) {
        log.warn("Error occurred while generating SiteStats chart image data", e);
    }
    return out.toByteArray();
}

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

/**
 * Erzeuge eine Grafik fr die Nullzeitanzeige Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui
 * /*from w  ww .j  a  v  a2s .  c o  m*/
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 02.08.2012
 * @param diveList
 * @param thePlot
 */
private void makeNulltimeGraph(Vector<Integer[]> diveList, XYPlot thePlot) {
    XYDataset nullTimeDataSet;
    //
    lg.debug("create nulltime dataset");
    nullTimeDataSet = createXYDataset(LangStrings.getString("spx42LogGraphPanel.graph.nulltimeScalaTitle"),
            diveList, ProjectConst.UNITS_DEFAULT, 0, LogDerbyDatabaseUtil.NULLTIME);
    final XYLineAndShapeRenderer lineNullTimeRenderer = new XYLineAndShapeRenderer(true, true);
    final LogarithmicAxis nullTimeAxis = new LogarithmicAxis(
            LangStrings.getString("spx42LogGraphPanel.graph.nulltimeAxisTitle"));
    nullTimeAxis.setNumberFormatOverride(new DecimalFormat("#.###"));
    lineNullTimeRenderer.setSeriesPaint(0, new Color(ProjectConst.GRAPH_NULLTIME_ACOLOR));
    lineNullTimeRenderer.setSeriesShapesVisible(0, false);
    lineNullTimeRenderer.setDrawSeriesLineAsPath(true);
    nullTimeAxis.setAutoRange(false);
    nullTimeAxis.setRange(0.0D, 200.0D); // Lege die Nullzeit Axenreichweite auf ein bersichtliches Ma fest
    // nullTimeAxis.setAutoRangeIncludesZero( true );
    thePlot.setRangeAxis(GRAPH_NULLTIME, nullTimeAxis);
    thePlot.mapDatasetToRangeAxis(GRAPH_NULLTIME, GRAPH_NULLTIME);
    thePlot.setDataset(GRAPH_NULLTIME, nullTimeDataSet);
    thePlot.setRenderer(GRAPH_NULLTIME, lineNullTimeRenderer);
}

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

/**
 * Erzeuge je einen Graphen fr die Sensoren Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui
 * /*from w w  w . j a  va2 s.c  o m*/
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 02.08.2012
 * @param diveList
 * @param thePlot
 * @param sensor
 */
private void makePpoGraph(Vector<Integer[]> diveList, XYPlot thePlot, int sensor) {
    XYDataset ppo2DataSet;
    int indexForCreate;
    int posForGraph;
    int posColor;
    String title;
    //
    lg.debug("create Sensor <" + sensor + "> dataset");
    // Titel schon mal...
    title = String.format(LangStrings.getString("spx42LogGraphPanel.graph.ppo2SensorScalaTitle"), sensor);
    //
    // Dataset Index einstellen
    switch (sensor) {
    case 0:
        indexForCreate = LogDerbyDatabaseUtil.PPO2;
        posForGraph = GRAPH_PPO2ALL;
        posColor = ProjectConst.GRAPH_PPO2ALL_RCOLOR;
        title = LangStrings.getString("spx42LogGraphPanel.graph.ppo2ScalaTitle");
        break;
    case 1:
        indexForCreate = LogDerbyDatabaseUtil.PPO2_01;
        posForGraph = GRAPH_PPO2_01;
        posColor = ProjectConst.GRAPH_PPO2_01_RCOLOR;
        break;
    case 2:
        indexForCreate = LogDerbyDatabaseUtil.PPO2_02;
        posForGraph = GRAPH_PPO2_02;
        posColor = ProjectConst.GRAPH_PPO2_02_RCOLOR;
        break;
    case 3:
        indexForCreate = LogDerbyDatabaseUtil.PPO2_03;
        posForGraph = GRAPH_PPO2_03;
        posColor = ProjectConst.GRAPH_PPO2_02_RCOLOR;
        break;
    default:
        indexForCreate = LogDerbyDatabaseUtil.PPO2_01;
        posForGraph = GRAPH_PPO2_01;
        posColor = ProjectConst.GRAPH_PPO2_01_RCOLOR;
    }
    if (showingUnitSystem == savedUnitSystem || showingUnitSystem == ProjectConst.UNITS_DEFAULT) {
        ppo2DataSet = createXYDataset(title, diveList, ProjectConst.UNITS_DEFAULT, 0, indexForCreate);
    } else {
        ppo2DataSet = createXYDataset(title, diveList, showingUnitSystem, 0, indexForCreate);
    }
    final XYLineAndShapeRenderer ppo2Renderer = new XYLineAndShapeRenderer(true, true);
    // die Achse sollte schon erstellt sein
    thePlot.setDataset(posForGraph, ppo2DataSet);
    thePlot.mapDatasetToRangeAxis(posForGraph, GRAPH_PPO2ALL);
    ppo2Renderer.setSeriesPaint(0, new Color(posColor));
    ppo2Renderer.setSeriesShapesVisible(0, false);
    ppo2Renderer.setDrawSeriesLineAsPath(true);
    thePlot.setRenderer(posForGraph, ppo2Renderer);
}

From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java

private byte[] createWeeklyLoginChart(int width, int height) {
    IntervalXYDataset dataset1 = getWeeklyLoginsDataSet();
    IntervalXYDataset dataset2 = getWeeklySiteUserDataSet();

    if ((dataset1 == null) || (dataset2 == null)) {
        return generateNoDataChart(width, height);
    }//from  w  w w .j  a  v  a  2 s .com

    // create plot ...
    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
    renderer1.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesPaint(0, Color.RED);
    renderer1.setSeriesPaint(0, Color.BLUE);

    DateAxis domainAxis = new DateAxis("");
    domainAxis.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat("yyyy-MM-dd")));
    domainAxis.setTickMarkPosition(DateTickMarkPosition.START);
    domainAxis.setVerticalTickLabels(true);
    domainAxis.setLowerMargin(0.01);
    domainAxis.setUpperMargin(0.01);

    NumberAxis rangeAxis = new NumberAxis("count");
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYPlot plot1 = new XYPlot(dataset1, null, rangeAxis, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);

    // add a second dataset and renderer...
    XYItemRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
    renderer2.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer2.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer2.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer2.setSeriesPaint(0, Color.GREEN);
    renderer2.setSeriesPaint(1, Color.BLACK);
    renderer2.setSeriesPaint(2, Color.CYAN);

    rangeAxis = new NumberAxis("count");
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYPlot plot2 = new XYPlot(dataset2, null, rangeAxis, renderer2);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);

    CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis);
    cplot.add(plot1, 3);
    cplot.add(plot2, 2);
    cplot.setGap(8.0);
    cplot.setDomainGridlinePaint(Color.white);
    cplot.setDomainGridlinesVisible(true);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
    LegendTitle legend = new LegendTitle(cplot);
    chart.addSubtitle(legend);

    // set background
    chart.setBackgroundPaint(parseColor(statsManager.getChartBackgroundColor()));

    // set chart border
    chart.setPadding(new RectangleInsets(10, 5, 5, 5));
    chart.setBorderVisible(true);
    chart.setBorderPaint(parseColor("#cccccc"));

    // set anti alias
    chart.setAntiAlias(true);

    BufferedImage img = chart.createBufferedImage(width, height);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        ImageIO.write(img, "png", out);
    } catch (IOException e) {
        log.warn("Error occurred while generating SiteStats chart image data", e);
    }
    return out.toByteArray();
}