示例#1
0
  private static JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart =
        ChartFactory.createXYLineChart(
            "Ratings by Age", // Title
            "Age", // X label
            "Average Rating", // Y label
            dataset, // data
            PlotOrientation.VERTICAL, // Orientation
            false, // legend
            false, // tooltips
            false); // urls
    chart.setBorderPaint(Color.white);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return chart;
  }
示例#2
0
 private void configureRendererForCorrelativeData(XYLineAndShapeRenderer renderer) {
   renderer.setSeriesLinesVisible(1, false);
   renderer.setSeriesShapesVisible(1, true);
   renderer.setSeriesStroke(1, new BasicStroke(1.0f));
   renderer.setSeriesPaint(1, StatisticChartStyling.CORRELATIVE_POINT_PAINT);
   renderer.setSeriesFillPaint(1, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT);
   renderer.setSeriesShape(1, StatisticChartStyling.CORRELATIVE_POINT_SHAPE);
 }
示例#3
0
  private JFreeChart createChart(XYDataset dataset, String title) {

    // create the chart...
    final JFreeChart chart =
        ChartFactory.createXYLineChart(
            title, // chart title
            "x", // domain axis label
            "y", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
            );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);
    //    legend.setShapeScaleX(1.5);
    //  legend.setShapeScaleY(1.5);
    // legend.setDisplaySeriesLines(true);

    chart.setBackgroundPaint(Color.white);
    chart.setAntiAlias(false);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    //    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, false);
    plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.
    return chart;
  }
  private static void configureXYLineAndShapeRenderer(
      XYLineAndShapeRenderer renderer, ValueSource valueSource, PlotInstance plotInstance) {
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    SeriesFormat seriesFormat = valueSource.getSeriesFormat();
    DimensionConfig domainConfig = valueSource.getDomainConfig();
    DimensionConfig colorDimensionConfig =
        plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(PlotDimension.COLOR);
    DimensionConfig shapeDimensionConfig =
        plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(PlotDimension.SHAPE);
    ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource);

    int seriesCount = valueSourceData.getSeriesDataForAllGroupCells().groupCellCount();

    // Loop all series and set series format.
    // Format based on dimension configs will be set later on in initFormatDelegate().
    for (int seriesIdx = 0; seriesIdx < seriesCount; ++seriesIdx) {
      // configure linestyle
      if (seriesFormat.getLineStyle() == LineStyle.NONE) {
        renderer.setSeriesLinesVisible(seriesIdx, false);
      } else {
        renderer.setSeriesLinesVisible(seriesIdx, true);
        renderer.setSeriesStroke(seriesIdx, seriesFormat.getStroke(), false);
      }

      // configure series shape if necessary
      if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, shapeDimensionConfig)) {
        if (seriesFormat.getItemShape() != ItemShape.NONE) {
          renderer.setSeriesShapesVisible(seriesIdx, true);
          renderer.setSeriesShape(seriesIdx, seriesFormat.getItemShape().getShape());
        } else {
          renderer.setSeriesShapesVisible(seriesIdx, false);
        }
      }

      // configure series color if necessary
      if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, colorDimensionConfig)) {
        Color itemColor = seriesFormat.getItemColor();
        renderer.setSeriesPaint(seriesIdx, itemColor);
        renderer.setSeriesFillPaint(seriesIdx, itemColor);
      }
      renderer.setSeriesOutlinePaint(seriesIdx, PlotConfiguration.DEFAULT_SERIES_OUTLINE_PAINT);
      renderer.setUseOutlinePaint(true);
    }
  }
示例#5
0
  public static void generateXYScatterPlot(
      String fileName, double[] x, double[] y, String title, String xLabel, String yLabel) {

    if (x.length != y.length) {
      DebugLib.stopSystemAndReportInconsistency("dimensions of arrays do not match");
    }

    final XYSeries series1 = new XYSeries(title);

    for (int i = 0; i < x.length; i++) {
      series1.add(x[i], y[i]);
    }

    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);

    final JFreeChart chart =
        ChartFactory.createXYLineChart(
            title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    int width = 500;
    int height = 300;

    try {
      ChartUtilities.saveChartAsPNG(new File(fileName), chart, width, height);
    } catch (IOException e) {

    }
  }
示例#6
0
  private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart =
        ChartFactory.createXYLineChart(
            Setting.getString("/bat/isotope/graph/bg/title"), // chart title
            Setting.getString("/bat/isotope/graph/bg/x_axes"), // x axis label
            Setting.getString("/bat/isotope/graph/bg/y_axes"), // y axis label
            dataset, // data
            PlotOrientation.VERTICAL,
            false, // include legend
            true, // tooltips
            false // urls
            );

    chart.setBackgroundPaint(Setting.getColor("/bat/isotope/graph/background"));
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Setting.getColor("/bat/isotope/graph/background"));
    plot.setRangeGridlinePaint(Setting.getColor("/bat/isotope/graph/background"));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    plot.getDomainAxis().getUpperBound();
    plot.setDataset(1, Func.xYSlope(slope, plot.getDomainAxis().getUpperBound()));

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseSeriesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setSeriesItemLabelFont(0, fText);
    renderer.setBaseItemLabelFont(fText);
    chart.getTitle().setFont(fTitel);

    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, true);

    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(true);
    axis.setLabelFont(fAxes);
    plot.getDomainAxis().setLabelFont(fAxes);

    return chart;
  }
  private JFreeChart createChart(String titulo, String eixoX, String eixoY, XYDataset dados) {

    // create the chart...
    final JFreeChart chart =
        ChartFactory.createXYLineChart(
            titulo, // chart title\
            eixoX, // x axis label
            eixoY, // y axis label
            dados, // data
            PlotOrientation.VERTICAL,
            true, // include legend
            true, // tooltips
            false // urls
            );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    // final StandardLegend legend = (StandardLegend) chart.getLegend();
    // legend.setDisplaySeriesShapes(true);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);

    plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
  }
  // --- GET HEIGTH GRAPH ------------------------------------------------------------------------
  private JFreeChart getHeightGraph() throws Exception {
    // get dataset
    String sGender = checkString(req.getParameter("gender"));
    final XYSeriesCollection dataset =
        getDataSet((sGender.equalsIgnoreCase("m") ? 1 : 2), "height-age-05-20.txt");

    // add patient data
    XYSeries patientSeries = new XYSeries("Patient", true, false);
    double height, lastPatientHeight = 0;
    float age;
    for (int i = 60; i < 240; i++) {
      height = getPatientHeightForAge(i);

      if (height > 0) {
        age = new Float(i).floatValue();
        patientSeries.add(age, new Float(height).floatValue());
        lastPatientHeight = height;
      }
    }

    dataset.addSeries(patientSeries);

    // create chart
    final JFreeChart chart =
        createChart(
            dataset,
            getTran("web", "heightForAgePercentiles"),
            getTran("web", "heightInCentimeter"));

    // add annotations
    XYPlot plot = chart.getXYPlot();
    java.awt.Font font = new java.awt.Font("SansSerif", Font.NORMAL, 9);

    int xPosAnnotation = 245;
    if (sGender.equalsIgnoreCase("m")) {
      // *** male ***
      addAnnotation("3rd", font, plot, xPosAnnotation, 163.00);
      addAnnotation("5th", font, plot, xPosAnnotation, 166.00);
      addAnnotation("25th", font, plot, xPosAnnotation, 172.00);
      addAnnotation("50th", font, plot, xPosAnnotation, 177.00);
      addAnnotation("75th", font, plot, xPosAnnotation, 182.00);
      addAnnotation("95th", font, plot, xPosAnnotation, 188.00);
      addAnnotation("97th", font, plot, xPosAnnotation, 191.00);
    } else {
      // *** female ***
      addAnnotation("3rd", font, plot, xPosAnnotation, 151.00);
      addAnnotation("5th", font, plot, xPosAnnotation, 154.00);
      addAnnotation("25th", font, plot, xPosAnnotation, 159.00);
      addAnnotation("50th", font, plot, xPosAnnotation, 163.00);
      addAnnotation("75th", font, plot, xPosAnnotation, 168.00);
      addAnnotation("95th", font, plot, xPosAnnotation, 174.00);
      addAnnotation("97th", font, plot, xPosAnnotation, 176.35);
    }

    // patient annotation
    XYTextAnnotation annotation =
        new XYTextAnnotation("Patient", xPosAnnotation, lastPatientHeight);
    annotation.setFont(font);
    annotation.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT);
    annotation.setPaint(Color.BLUE);
    plot.addAnnotation(annotation);

    // visual customization
    chart.setBackgroundPaint(Color.WHITE);

    // series colors
    int idx = 0;
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(idx, Color.red); //  3rd
    renderer.setSeriesShapesVisible(idx++, false);
    renderer.setSeriesPaint(idx, Color.orange); //  5th
    renderer.setSeriesShapesVisible(idx++, false);
    renderer.setSeriesPaint(idx, Color.orange); // 25th
    renderer.setSeriesShapesVisible(idx++, false);
    renderer.setSeriesPaint(idx, Color.green); // 50th
    renderer.setSeriesShapesVisible(idx++, false);
    renderer.setSeriesPaint(idx, Color.orange); // 75th
    renderer.setSeriesShapesVisible(idx++, false);
    renderer.setSeriesPaint(idx, Color.orange); // 95th
    renderer.setSeriesShapesVisible(idx++, false);
    renderer.setSeriesPaint(idx, Color.red); // 97th
    renderer.setSeriesShapesVisible(idx++, false);
    renderer.setSeriesPaint(idx, Color.blue); // patient
    renderer.setSeriesShapesVisible(idx, true);

    // only dots for patient values
    renderer.setSeriesLinesVisible(idx, false); // no curve
    int dotSize = 3;
    renderer.setSeriesShape(
        idx, new Ellipse2D.Double(dotSize / 2.0 * (-1), dotSize / 2.0 * (-1), dotSize, dotSize));

    // labels
    renderer.setSeriesItemLabelGenerator(
        idx,
        new StandardXYItemLabelGenerator(
            "{2}", new DecimalFormat("0.00"), new DecimalFormat("0.00")));
    renderer.setSeriesItemLabelsVisible(idx, true);
    plot.setRenderer(renderer);

    return chart;
  }
  /** Displays the data in a graph. */
  private void showPlot() {
    // Create a data series containing the heading error data...
    XYSeries headingErrorSeries = new XYSeries("Heading Error");
    Enumeration<HeadingDivergenceState> e = divergenceData.elements();
    while (e.hasMoreElements()) {
      HeadingDivergenceState currState = e.nextElement();
      headingErrorSeries.add(
          (currState.time - robotData.getExpStartTime()) / 1000, currState.headingError);
    }

    // Create two data series one containing the times when the robot starts heading
    // towards a waypoint, and another containing the times when the robot arrives at
    // a waypoint
    final XYSeries beginEdgeSeries = new XYSeries("Begin Edge Traveral");
    final XYSeries waypointArrivalSeries = new XYSeries("Waypoint Arrival");
    Vector<PathEdge> pathEdges = robotData.getPathEdges();
    Enumeration<PathEdge> e2 = pathEdges.elements();
    while (e2.hasMoreElements()) {
      PathEdge currEdge = e2.nextElement();
      double beginEdgeTime = (currEdge.getStartTime() - robotData.getExpStartTime()) / 1000.0;
      beginEdgeSeries.add(beginEdgeTime, 0);
      double wayPointArrivalTime = (currEdge.getEndTime() - robotData.getExpStartTime()) / 1000.0;
      waypointArrivalSeries.add(wayPointArrivalTime, 0);
    }

    // Create a dataset out of the data series
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(headingErrorSeries);
    dataset.addSeries(beginEdgeSeries);
    dataset.addSeries(waypointArrivalSeries);

    // Create the chart
    JFreeChart chart =
        ChartFactory.createXYLineChart(
            "Heading Error vs. Time", // chart title
            "Time (s)", // x axis label
            "Heading Error (radians)", // y axis label
            dataset, // the data
            PlotOrientation.VERTICAL, // plot orientation (y axis is vertical)
            true, // include legend
            true, // tooltips
            false // urls
            );

    // Place the legend on top of the chart just below the title.
    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.TOP);

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    //        plot.setBackgroundPaint(Color.lightGray);
    //    //    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    //        plot.setDomainGridlinePaint(Color.white);
    //        plot.setRangeGridlinePaint(Color.white);

    // Display the points and not the lines connecting the points
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true); // display the heading errors as a line
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesLinesVisible(
        1, false); // display the begin edge traversal points as blue dots
    renderer.setSeriesShapesVisible(1, true);
    renderer.setSeriesPaint(1, Color.BLUE);
    renderer.setSeriesShape(1, new java.awt.geom.Ellipse2D.Double(-3, -3, 6, 6));
    renderer.setSeriesLinesVisible(
        2, false); // display the begin edge traversal points as green dots
    renderer.setSeriesShapesVisible(2, true);
    renderer.setSeriesPaint(2, Color.GREEN.darker());
    renderer.setSeriesShape(2, new java.awt.geom.Ellipse2D.Double(-5, -5, 10, 10));
    plot.setRenderer(renderer);

    //        final NumberAxis domainAxis = (NumberAxis)plot.getDomainAxis();
    //        domainAxis.setRange(new Range(0,140));

    //        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    //     // change the auto tick unit selection to integer units only...
    ////        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    //        rangeAxis.setRange(new Range(-Math.PI, Math.PI));

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(1000, 600));

    // Create a frame for the chart, then display it.
    ApplicationFrame appFrame = new ApplicationFrame("Heading Error for " + logFileName);
    appFrame.setContentPane(chartPanel);
    appFrame.pack();
    RefineryUtilities.centerFrameOnScreen(appFrame);
    appFrame.setVisible(true);
  }
示例#10
0
  private static BufferedImage getChart(double[] tsData, double redDot) {
    try {

      // making the data
      //
      XYSeries dataset = new XYSeries("Series");
      for (int i = 0; i < tsData.length; i++) {
        dataset.add(i, (float) tsData[i]);
      }
      XYSeriesCollection chartXYSeriesCollection = new XYSeriesCollection(dataset);

      XYSeries dot = new XYSeries("Dot");
      dot.add((float) redDot, 0.0f);
      chartXYSeriesCollection.addSeries(dot);

      // set the renderer
      //
      XYLineAndShapeRenderer xyRenderer = new XYLineAndShapeRenderer(true, false);
      xyRenderer.setBaseStroke(new BasicStroke(3));

      xyRenderer.setSeriesPaint(0, new Color(0, 0, 0));
      xyRenderer.setSeriesLinesVisible(0, true);
      xyRenderer.setSeriesShapesVisible(0, false);

      xyRenderer.setSeriesPaint(1, Color.RED);
      xyRenderer.setSeriesLinesVisible(1, false);
      xyRenderer.setSeriesShapesVisible(1, true);

      // X - the time axis
      //
      NumberAxis timeAxis = new NumberAxis();
      timeAxis.setLabel("Time");

      // Y axis
      //
      NumberAxis valueAxis = new NumberAxis("Values");
      valueAxis.setAutoRangeIncludesZero(false);
      valueAxis.setLabel("Values");

      // put these into collection of dots
      //
      XYPlot timeseriesPlot = new XYPlot(chartXYSeriesCollection, timeAxis, valueAxis, xyRenderer);

      // finally, create the chart
      JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, timeseriesPlot, false);

      BufferedImage objBufferedImage = chart.createBufferedImage(800, 400);
      ByteArrayOutputStream bas = new ByteArrayOutputStream();
      try {
        ImageIO.write(objBufferedImage, "png", bas);
      } catch (IOException e) {
        e.printStackTrace();
      }
      byte[] byteArray = bas.toByteArray();

      InputStream in = new ByteArrayInputStream(byteArray);
      BufferedImage image = ImageIO.read(in);

      return image;
    } catch (IOException e) {
      e.printStackTrace();
    }
    return null;
  }
  /**
   * @param axis Axis name to wich the new series belongs
   * @param cs Series Coinfiguration
   */
  @Override
  public final void addSeries(String axis, SimpleSeriesConfiguration cs) {
    for (int i = 0; i < axes.size(); i++) {
      if (axes.get(i).getName().equals(axis)) {
        String strColor;
        javafx.scene.paint.Color color;
        int indice = seriesList.size();
        if (cs.getColor() == null) {
          color = getColor(indice);
        } else {
          color = cs.getColor();
        }
        strColor = color.toString();

        XYSeriesCollection dataset = datasetList.get(i);
        Series series =
            new Series(
                cs.getName(),
                "color: "
                    + strColor
                    + ";width: "
                    + String.valueOf(cs.getLineWidth())
                    + ";shape: "
                    + cs.getShapeName()
                    + ";",
                i,
                dataset.getSeriesCount());
        dataset.addSeries(series);

        XYItemRenderer renderer = plot.getRenderer(i);
        renderer.setSeriesPaint(dataset.getSeriesCount() - 1, scene2awtColor(color));

        SeriesShape simb =
            new SeriesShape(
                cs.getShapeName(), javafx.scene.paint.Color.web(strColor.replace("#", "0x")));

        if (cs.getLineWidth() > 0) {
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesLinesVisible(dataset.getSeriesCount() - 1, true);
          renderer.setSeriesStroke(
              dataset.getSeriesCount() - 1, new BasicStroke(cs.getLineWidth()));
        } else {
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesLinesVisible(dataset.getSeriesCount() - 1, false);
        }

        if (cs.getShapeName().equals("null")) {
          renderer.setSeriesShape(dataset.getSeriesCount() - 1, null);
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesShapesVisible(dataset.getSeriesCount() - 1, false);
        } else {
          renderer.setSeriesShape(dataset.getSeriesCount() - 1, simb.getShapeAWT());
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesShapesVisible(dataset.getSeriesCount() - 1, true);
          if (cs.getShapeName().contains("empty")) {
            ((XYLineAndShapeRenderer) renderer)
                .setSeriesShapesFilled(dataset.getSeriesCount() - 1, false);
          } else {
            ((XYLineAndShapeRenderer) renderer)
                .setSeriesShapesFilled(dataset.getSeriesCount() - 1, true);
          }
        }

        if (i == 0) {
          plot.setRenderer(renderer);
        } else {
          plot.setRenderer(i, renderer);
        }

        seriesList.add(series);

        final LegendAxis le = getLegendAxis(axis);
        final Label label = new Label(cs.toString());
        Platform.runLater(
            () -> {
              label.setStyle(
                  "fondo: "
                      + strChartBackgroundColor
                      + ";-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");
            });

        label.setOnMouseClicked(
            (MouseEvent t) -> {
              if (t.getClickCount() == 2) {
                for (int i1 = 0; i1 < seriesList.size(); i1++) {
                  if (seriesList.get(i1).getKey().toString().equals(label.getText())) {
                    editSeries(seriesList.get(i1));
                    break;
                  }
                }
              }
            });
        label.setOnMouseExited(
            (MouseEvent t) -> {
              label.setStyle(
                  label
                      .getStyle()
                      .replace("-fx-background-color: blue", "-fx-background-color: fondo"));
            });
        label.setOnMouseEntered(
            (MouseEvent t) -> {
              label.setStyle(
                  label
                      .getStyle()
                      .replace("-fx-background-color: fondo", "-fx-background-color: blue"));
              for (Node le1 : legendFrame.getChildren()) {
                if (le1 instanceof LegendAxis) {
                  le1.setStyle("-fx-background-color:" + strBackgroundColor);
                  ((LegendAxis) le1).selected = false;
                }
              }
            });
        label.setStyle(
            "fondo: "
                + strChartBackgroundColor
                + ";-fx-text-fill: white;-fx-background-color: fondo;-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: "
                + String.valueOf(fontSize)
                + "px");

        le.getChildren().add(label);
        label.setGraphic(simb.getShapeGraphic());

        break;
      }
    }
  }
示例#12
0
 /**
  * Sets the 'lines visible' flag for a series and sends a {@link RendererChangeEvent} to all
  * registered listeners.
  *
  * @param series the series index (zero-based).
  * @param visible the flag.
  * @see #getSeriesLinesVisible(int)
  */
 public void setSeriesLinesVisible(int series, boolean visible) {
   setSeriesLinesVisible(series, Boolean.valueOf(visible));
 }