Ejemplo n.º 1
0
    @Override
    public void apply(Rule r) {
      for (RenderStyle style : r.styles) {

        if (modifyLine && style instanceof LineStyle) {
          LineStyle s = (LineStyle) style;

          s.set(
              lineBuilder
                  .set(s)
                  .color(saturate(s.color, saturation, relative))
                  .stippleColor(saturate(s.stippleColor, saturation, relative))
                  .build());
          continue;
        }

        if (modifyArea && style instanceof AreaStyle) {
          AreaStyle s = (AreaStyle) style;

          s.set(
              areaBuilder
                  .set(s)
                  .color(saturate(s.color, saturation, relative))
                  .blendColor(saturate(s.blendColor, saturation, relative))
                  .build());
        }
      }

      super.apply(r);
    }
Ejemplo n.º 2
0
  static class SaturateLineStyles extends RuleVisitor {
    private final LineBuilder<?> lineBuilder = LineStyle.builder();
    private final AreaBuilder<?> areaBuilder = AreaStyle.builder();

    private final double saturation;
    private final boolean modifyArea;
    private final boolean modifyLine;
    private final boolean relative;

    public SaturateLineStyles(
        double saturation, boolean relative, boolean modArea, boolean modLine) {
      this.saturation = saturation;
      this.modifyArea = modArea;
      this.modifyLine = modLine;
      this.relative = relative;
    }

    @Override
    public void apply(Rule r) {
      for (RenderStyle style : r.styles) {

        if (modifyLine && style instanceof LineStyle) {
          LineStyle s = (LineStyle) style;

          s.set(
              lineBuilder
                  .set(s)
                  .color(saturate(s.color, saturation, relative))
                  .stippleColor(saturate(s.stippleColor, saturation, relative))
                  .build());
          continue;
        }

        if (modifyArea && style instanceof AreaStyle) {
          AreaStyle s = (AreaStyle) style;

          s.set(
              areaBuilder
                  .set(s)
                  .color(saturate(s.color, saturation, relative))
                  .blendColor(saturate(s.blendColor, saturation, relative))
                  .build());
        }
      }

      super.apply(r);
    }
  }