Java 类javafx.scene.effect.ColorInput 实例源码

项目:openjfx-8u-dev-tests    文件:CanvasEffects2App.java   
@Override
public Node drawNode() {

    Group group = new Group();
    final Canvas canvas = new Canvas(120, 120);
    GraphicsContext gc = canvas.getGraphicsContext2D();
    group.getChildren().add(canvas);

    gc.setFill(Color.GREEN);
    gc.fillRect(10,10, 70, 70);

    ColorInput effect = new ColorInput();
    effect.setPaint(Color.RED);
    effect.setX(15);
    effect.setY(15);
    effect.setWidth(70);
    effect.setHeight(70);

    gc.applyEffect(effect);
    return group;
}
项目:openjfx-8u-dev-tests    文件:CanvasEffects2App.java   
@Override
public Node drawNode() {

    Group group = new Group();
    final Canvas canvas = new Canvas(120, 120);
    GraphicsContext gc = canvas.getGraphicsContext2D();
    group.getChildren().add(canvas);

    gc.setFill(Color.GREEN);
    gc.fillRect(10,10, 70, 70);

    ColorInput effect = new ColorInput();
    effect.setPaint(new LinearGradient(0, 0, 0.5f, 0.1f, true, CycleMethod.REPEAT, new Stop[] {
                    new Stop(0, Color.RED),
                    new Stop(1, Color.GREEN),
                }));
    effect.setX(15);
    effect.setY(15);
    effect.setWidth(70);
    effect.setHeight(70);

    gc.applyEffect(effect);
    return group;

}
项目:metastone    文件:GameToken.java   
private void createTargetButton() {
    target = (StackPane) lookup("#targetAnchor");
    Image image = IconFactory.getTargetIcon();
    ImageView targetIcon = new ImageView(image);
    targetIcon.setClip(new ImageView(image));
    ColorAdjust monochrome = new ColorAdjust();
    monochrome.setSaturation(-1.0);

    Blend red = new Blend(BlendMode.MULTIPLY, monochrome,
            new ColorInput(0, 0, targetIcon.getImage().getWidth(), targetIcon.getImage().getHeight(), Color.RED));

    Blend green = new Blend(BlendMode.MULTIPLY, monochrome,
            new ColorInput(0, 0, targetIcon.getImage().getWidth(), targetIcon.getImage().getHeight(), new Color(0, 1, 0, 0.5)));

    targetButton = targetIcon;

    targetIcon.effectProperty().bind(Bindings.when(targetButton.hoverProperty()).then((Effect) green).otherwise((Effect) red));
    targetButton.setId("target_button");
    hideTargetMarker();
    target.getChildren().add(targetButton);
}
项目:metastone    文件:DigitFactory.java   
private static void applyFontColor(ImageView image, Color color) {
    ColorAdjust monochrome = new ColorAdjust();
    monochrome.setSaturation(-1.0);
    Effect colorInput = new ColorInput(0, 0, image.getImage().getWidth(), image.getImage().getHeight(), color);
    Blend blend = new Blend(BlendMode.MULTIPLY, new ImageInput(image.getImage()), colorInput);
    image.setClip(new ImageView(image.getImage()));
    image.setEffect(blend);
    image.setCache(true);
}
项目:StreamSis    文件:CuteGraphicValidationDecoration.java   
/**
 * {@inheritDoc}
 */
@Override
protected Collection<Decoration> createRequiredDecorations(Control target) {
    ImageView imageView = new ImageView(REQUIRED_IMAGE);
    // The following code will transform REQUIRED_IMAGE from red to blue.
    ColorAdjust adjust = new ColorAdjust();
    adjust.setSaturation(-1);
    Blend bluemaker = new Blend(BlendMode.SRC_ATOP, adjust,
            new ColorInput(0, 0, imageView.getImage().getWidth(),
                    imageView.getImage().getHeight(), Color.DEEPSKYBLUE));
    imageView.setEffect(bluemaker);
    return Arrays.asList(new GraphicDecoration(imageView, Pos.TOP_LEFT,
            REQUIRED_IMAGE.getWidth() / 2, REQUIRED_IMAGE.getHeight() / 2));
}
项目:jfx-torrent    文件:ImageUtils.java   
/**
 * Given a monochrome image, apply a color to it
 * 
 * @param imageView A view to the target monochrome image
 * @param color Target new image color
 */
public static void colorize(final ImageView imageView, final Paint color) {     
    final ColorAdjust monochrome = new ColorAdjust();
       monochrome.setSaturation(-1.0);
       monochrome.setBrightness(0.75);

    final Blend selectionColorBlend = new Blend(BlendMode.SRC_ATOP,
            monochrome, new ColorInput(0, 0, imageView.getFitWidth(),
                    imageView.getFitHeight(), color));          
    imageView.setEffect(selectionColorBlend);           
}
项目:Augendiagnose    文件:ImageUtil.java   
/**
 * Retrieve an overlay image.
 *
 * @param overlayType
 *            The overlay type.
 * @param side
 *            The side of the eye.
 * @param color
 *            The overlay color.
 *
 * @return The overlay image.
 */
private static Image getOverlayImage(final int overlayType, final RightLeft side, final Color color) {
    URL imageUrl = ClassLoader.getSystemResource("overlay/" + getOverlayFileName(overlayType, side));

    Image image = new Image(imageUrl.toExternalForm());

    Canvas canvas = new Canvas(OVERLAY_SIZE, OVERLAY_SIZE);
    Color colorNoAlpha = new Color(color.getRed(), color.getGreen(), color.getBlue(), 1);

    Blend effect = new Blend(
            BlendMode.SRC_ATOP,
            null,
            new ColorInput(
                    0,
                    0,
                    OVERLAY_SIZE,
                    OVERLAY_SIZE,
                    colorNoAlpha));

    // Type 2 is not changed in color.
    if (overlayType != 2) {
        canvas.getGraphicsContext2D().setEffect(effect);
    }
    canvas.getGraphicsContext2D().setGlobalAlpha(color.getOpacity());
    canvas.getGraphicsContext2D().drawImage(image, 0, 0, OVERLAY_SIZE, OVERLAY_SIZE);
    SnapshotParameters parameters = new SnapshotParameters();
    parameters.setFill(Color.TRANSPARENT);

    return canvas.snapshot(parameters, null);
}
项目:MacroIIDiscrete    文件:HasLocationPortrait.java   
protected HasLocationPortrait(EconomicAgent agent, DoubleProperty xLocationProperty,
                              DoubleProperty yLocationProperty)
{
    this.agent =agent;
    this.xLocationProperty = xLocationProperty;
    this.yLocationProperty = yLocationProperty;

    nodeDelegate = new GUINodeSimple();

    //load the image
    icon = new ImageView();
    icon.setImage(initImage(agent));
    this.getChildren().add(icon);
    //bind icon height to pref-height. The idea here is that when they resize this region, we resize the location portrait as well
    icon.fitWidthProperty().bind(prefWidthProperty());
    icon.fitHeightProperty().bind(prefHeightProperty());


    //this is to keep it with the right color
    ColorAdjust monochrome = new ColorAdjust(); //this is the first effect
    //monochrome.setBrightness(-1.0);
    //keep the color
    color= new SimpleObjectProperty<>(Color.BLACK);


    ColorInput input = new ColorInput(); //this is the second effect, the coloring proper
    input.setX(0); input.setY(0);
    input.widthProperty().bind(prefWidthProperty());
    input.heightProperty().bind(prefHeightProperty());

    input.paintProperty().bind(color);

    //bind the color adjust
    Blend coloring = new Blend(BlendMode.SRC_ATOP,monochrome,input);
    icon.effectProperty().setValue(coloring);

    setCache(true);
    setCacheHint(CacheHint.SPEED);


    //now set the text
    priceText = new Text();
    this.getChildren().add(priceText );
    priceText.setFont(Font.font("Verdana", 10));

    priceText.setFill(Color.BLACK);



}