Ejemplo n.º 1
0
  /**
   * Sets colors for path gradient. Values are used on next update().
   *
   * @param pathColor Path Color
   * @param bendStartColor Starting path color
   * @param bendEndColor Ending path color
   */
  public void setColors(Color pathColor, Color bendStartColor, Color bendEndColor) {
    this.pathColor = pathColor;
    this.bendEndColor = bendEndColor;
    this.bendStartColor = bendStartColor;

    Paint fill = p.getFill();
    if (fill instanceof LinearGradient) {
      LinearGradient lg = (LinearGradient) fill;
      if (lg.getStops().size() >= 3) {
        p.setFill(
            new LinearGradient(
                lg.getStartX(),
                lg.getStartY(),
                lg.getEndX(),
                lg.getEndY(),
                false,
                CycleMethod.NO_CYCLE,
                new Stop(lg.getStops().get(0).getOffset(), pathColor),
                new Stop(lg.getStops().get(1).getOffset(), bendStartColor),
                new Stop(lg.getStops().get(2).getOffset(), bendEndColor)));
      }
    }
  }