in kit/src/main/java/com/oracle/javafx/scenebuilder/kit/util/control/effectpicker/Utils.java [103:241]
public static Effect clone(Effect effect) {
final Effect clone;
if (effect == null) {
clone = null;
} else if (effect instanceof Blend) {
final Blend blend = (Blend) effect;
clone = new Blend(blend.getMode());
((Blend) clone).setOpacity(blend.getOpacity());
((Blend) clone).setBottomInput(clone(blend.getBottomInput()));
((Blend) clone).setTopInput(clone(blend.getTopInput()));
} else if (effect instanceof Bloom) {
final Bloom bloom = (Bloom) effect;
clone = new Bloom(bloom.getThreshold());
((Bloom) clone).setInput(clone(bloom.getInput()));
} else if (effect instanceof BoxBlur) {
final BoxBlur boxBlur = (BoxBlur) effect;
clone = new BoxBlur(
boxBlur.getWidth(),
boxBlur.getHeight(),
boxBlur.getIterations());
((BoxBlur) clone).setInput(clone(boxBlur.getInput()));
} else if (effect instanceof ColorAdjust) {
final ColorAdjust colorAdjust = (ColorAdjust) effect;
clone = new ColorAdjust(
colorAdjust.getHue(),
colorAdjust.getSaturation(),
colorAdjust.getBrightness(),
colorAdjust.getContrast());
((ColorAdjust) clone).setInput(clone(colorAdjust.getInput()));
} else if (effect instanceof ColorInput) {
final ColorInput colorInput = (ColorInput) effect;
clone = new ColorInput(
colorInput.getX(),
colorInput.getY(),
colorInput.getWidth(),
colorInput.getHeight(),
colorInput.getPaint());
} else if (effect instanceof DisplacementMap) {
final DisplacementMap displacementMap = (DisplacementMap) effect;
clone = new DisplacementMap(
displacementMap.getMapData(),
displacementMap.getOffsetX(),
displacementMap.getOffsetY(),
displacementMap.getScaleX(),
displacementMap.getScaleY());
((DisplacementMap) clone).setWrap(displacementMap.isWrap());
((DisplacementMap) clone).setInput(clone(displacementMap.getInput()));
} else if (effect instanceof DropShadow) {
final DropShadow dropShadow = (DropShadow) effect;
clone = new DropShadow(
dropShadow.getBlurType(),
dropShadow.getColor(),
dropShadow.getRadius(),
dropShadow.getSpread(),
dropShadow.getOffsetX(),
dropShadow.getOffsetY());
((DropShadow) clone).setHeight(dropShadow.getHeight());
((DropShadow) clone).setWidth(dropShadow.getWidth());
((DropShadow) clone).setInput(clone(dropShadow.getInput()));
} else if (effect instanceof GaussianBlur) {
final GaussianBlur gaussianBlur = (GaussianBlur) effect;
clone = new GaussianBlur(gaussianBlur.getRadius());
((GaussianBlur) clone).setInput(clone(gaussianBlur.getInput()));
} else if (effect instanceof Glow) {
final Glow glow = (Glow) effect;
clone = new Glow(glow.getLevel());
((Glow) clone).setInput(clone(glow.getInput()));
} else if (effect instanceof ImageInput) {
final ImageInput imageInput = (ImageInput) effect;
clone = new ImageInput(
imageInput.getSource(),
imageInput.getX(),
imageInput.getY());
} else if (effect instanceof InnerShadow) {
final InnerShadow innerShadow = (InnerShadow) effect;
clone = new InnerShadow(
innerShadow.getBlurType(),
innerShadow.getColor(),
innerShadow.getRadius(),
innerShadow.getChoke(),
innerShadow.getOffsetX(),
innerShadow.getOffsetY());
((InnerShadow) clone).setHeight(innerShadow.getHeight());
((InnerShadow) clone).setWidth(innerShadow.getWidth());
((InnerShadow) clone).setInput(clone(innerShadow.getInput()));
} else if (effect instanceof Lighting) {
final Lighting lighting = (Lighting) effect;
clone = new Lighting(lighting.getLight());
((Lighting) clone).setDiffuseConstant(lighting.getDiffuseConstant());
((Lighting) clone).setSpecularConstant(lighting.getSpecularConstant());
((Lighting) clone).setSpecularExponent(lighting.getSpecularExponent());
((Lighting) clone).setSurfaceScale(lighting.getSurfaceScale());
((Lighting) clone).setBumpInput(clone(lighting.getBumpInput()));
((Lighting) clone).setContentInput(clone(lighting.getContentInput()));
} else if (effect instanceof MotionBlur) {
final MotionBlur motionBlur = (MotionBlur) effect;
clone = new MotionBlur(
motionBlur.getAngle(),
motionBlur.getRadius());
((MotionBlur) clone).setInput(clone(motionBlur.getInput()));
} else if (effect instanceof PerspectiveTransform) {
final PerspectiveTransform perspectiveTransform = (PerspectiveTransform) effect;
clone = new PerspectiveTransform(
perspectiveTransform.getUlx(),
perspectiveTransform.getUly(),
perspectiveTransform.getUrx(),
perspectiveTransform.getUry(),
perspectiveTransform.getLrx(),
perspectiveTransform.getLry(),
perspectiveTransform.getLlx(),
perspectiveTransform.getLly());
((PerspectiveTransform) clone).setInput(clone(perspectiveTransform.getInput()));
} else if (effect instanceof Reflection) {
final Reflection reflection = (Reflection) effect;
clone = new Reflection(
reflection.getTopOffset(),
reflection.getFraction(),
reflection.getTopOpacity(),
reflection.getBottomOpacity());
((Reflection) clone).setInput(clone(reflection.getInput()));
} else if (effect instanceof SepiaTone) {
final SepiaTone sepiaTone = (SepiaTone) effect;
clone = new SepiaTone(sepiaTone.getLevel());
((SepiaTone) clone).setInput(clone(sepiaTone.getInput()));
} else if (effect instanceof Shadow) {
final Shadow shadow = (Shadow) effect;
clone = new Shadow(
shadow.getBlurType(),
shadow.getColor(),
shadow.getRadius());
((Shadow) clone).setHeight(shadow.getHeight());
((Shadow) clone).setWidth(shadow.getWidth());
((Shadow) clone).setInput(clone(shadow.getInput()));
} else {
assert false;
clone = null;
}
return clone;
}