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

项目:FxEditor    文件:FxIconBuilder.java   
protected Effect setInputEffect(Effect a, Effect b)
{
    // I don't know a better way to chain effects, it's missing in FX
    // https://bugs.openjdk.java.net/browse/JDK-8091895
    // perhaps try Blend:
    // https://community.oracle.com/thread/2337194?tstart=0
    if(b instanceof GaussianBlur)
    {
        ((GaussianBlur)b).setInput(a);
    }
    else if(b instanceof ColorAdjust)
    {
        ((ColorAdjust)b).setInput(a);
    }
    else
    {
        throw new Error("todo: does " + b + " have setInput()?"); 
    }
    return b;
}
项目:openjfx-8u-dev-tests    文件:CanvasEffects2App.java   
private void initFactories() {
    textFactory = new Factory() {

        public Node create(final Effect e) {
            Group group = new Group();
            final Canvas canvas = new Canvas(110, 110);
            GraphicsContext gc = canvas.getGraphicsContext2D();
            gc.setEffect(e);
            gc.setFill(Color.RED);
            gc.setFont(new Font(36));
            gc.fillText("B_Blur", 5, 30);

            group.getChildren().add(canvas);

            return group;
        }
    };
}
项目:ReqTraq    文件:FxIconBuilder.java   
protected Effect setInputEffect(Effect a, Effect b)
{
    // I don't know a better way to chain effects, it's missing in FX
    // https://bugs.openjdk.java.net/browse/JDK-8091895
    // perhaps try Blend:
    // https://community.oracle.com/thread/2337194?tstart=0
    if(b instanceof GaussianBlur)
    {
        ((GaussianBlur)b).setInput(a);
    }
    else if(b instanceof ColorAdjust)
    {
        ((ColorAdjust)b).setInput(a);
    }
    else
    {
        throw new Error("todo: does " + b + " have setInput()?"); 
    }
    return b;
}
项目:livro-javafx-pratico    文件:DigaOlaComJavaFX.java   
@Override
public void start(Stage palco) throws Exception {
    final Effect r = new Reflection();
    final VBox raiz = new VBox(30);
    final HBox hbTopo = new HBox(5);
    final TextField txtNome = new TextField();
    final Button btnAcao = new Button("Enviar");
    final Label lblMensagem = new Label();
    raiz.setTranslateX(10);
    raiz.setTranslateY(10);
    lblMensagem.setText("Digite seu nome e clique no botão");
    hbTopo.getChildren().addAll(txtNome, btnAcao);
    raiz.getChildren().addAll(hbTopo, lblMensagem);
    lblMensagem.setEffect(r);
    Scene cena = new Scene(raiz, 250, 100);
    palco.setTitle("Aplicação usando código Java");
    palco.setScene(cena);
    palco.show();

    btnAcao.setOnAction(e -> lblMensagem.setText("Olá, " + txtNome.getText() + ", bem vindo!"));
}
项目:FxDock    文件:FxIconBuilder.java   
protected Effect setInputEffect(Effect a, Effect b)
{
    // I don't know a better way to chain effects, it's missing in FX
    // https://bugs.openjdk.java.net/browse/JDK-8091895
    // perhaps try Blend:
    // https://community.oracle.com/thread/2337194?tstart=0
    if(b instanceof GaussianBlur)
    {
        ((GaussianBlur)b).setInput(a);
    }
    else if(b instanceof ColorAdjust)
    {
        ((ColorAdjust)b).setInput(a);
    }
    else
    {
        throw new Error("todo: does " + b + " have setInput()?"); 
    }
    return b;
}
项目: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);
}
项目:StreamSis    文件:SisSceneCell.java   
private void refreshSisSceneLook(String primarySisSceneName, boolean isSelected) {
        if (primarySisSceneName != null) {
            if (getItem() != null) {
                Effect effect = null;
                String style;
                Color finalColor;
                boolean isPrimary = primarySisSceneName
                        .equals(getItem().getElementInfo().getName());
//              if (isSelected) {
//                  effect = shadowForSelected;
//              } else {
//                  effect = null;
//              }
                if (isPrimary) {
                    style = "-fx-font-weight: bold;";
                    finalColor = Color.HOTPINK;
                } else {
                    style = "-fx-font-weight: normal;";
                    finalColor = CuteColor.GENTLEPINK;
                }
                applySisSceneLook(effect, style, finalColor);
            }
        }
    }
项目:prishonor    文件:ElementLostAssistant.java   
/**
 * @param sepiaToneLevel
 */
@SuppressWarnings("unused")
public void setSepiaTone(double sepiaToneLevel) {
    // For some reason in some computers setting the SepiaTone effect hide the pane.
    if(true) {
        return;
    }

    Effect effect = getEffect();
    if(effect == null) {
        setEffect(new SepiaTone(sepiaToneLevel));
    }
    else if(effect instanceof SepiaTone) {
        ((SepiaTone) effect).setLevel(sepiaToneLevel);
    }
}
项目:incubator-netbeans    文件:DigitalClock.java   
public Digit(Color onColor, Color offColor, Effect onEffect, Effect offEffect) {
    this.onColor = onColor;
    this.offColor = offColor;
    this.onEffect = onEffect;
    this.offEffect = offEffect;
    getChildren().addAll(polygons);
    getTransforms().add(new Shear(-0.1,0));
    showNumber(0);
}
项目:marathonv5    文件:DigitalClock.java   
public Digit(Color onColor, Color offColor, Effect onEffect, Effect offEffect) {
    this.onColor = onColor;
    this.offColor = offColor;
    this.onEffect = onEffect;
    this.offEffect = offEffect;
    getChildren().addAll(polygons);
    getTransforms().add(new Shear(-0.1,0));
    showNumber(0);
}
项目:marathonv5    文件:DigitalClock.java   
public Digit(Color onColor, Color offColor, Effect onEffect, Effect offEffect) {
    this.onColor = onColor;
    this.offColor = offColor;
    this.onEffect = onEffect;
    this.offEffect = offEffect;
    getChildren().addAll(polygons);
    getTransforms().add(new Shear(-0.1,0));
    showNumber(0);
}
项目:FxEditor    文件:FxIconBuilder.java   
public void addEffect(Effect x)
{
    if(effect == null)
    {
        effect = x;
    }
    else
    {
        effect = setInputEffect(effect, x);
    }
}
项目:openjfx-8u-dev-tests    文件:BindingApp.java   
public NodeAndBindee create() {
    final Effect effect = new DropShadow();
    Rectangle rect = new Rectangle(100,100,100,100)
        {{
            setFill(Color.LIGHTGREEN);
            setStroke(Color.DARKGREEN);
            setArcHeight(20);
            setArcWidth(30);
            setEffect(effect);
        }};
    return new NodeAndBindee(rect, effect);
}
项目:openjfx-8u-dev-tests    文件:EffectTestAction.java   
public static TestAction[] generate(Effect effect, boolean isLCDWork){
    return new TestAction[] {
        new EffectTestAction(),
        new EffectTestAction(effect, isLCDWork),
        new EffectTestAction()
    };
}
项目:ReqTraq    文件:FxIconBuilder.java   
public void addEffect(Effect x)
{
    if(effect == null)
    {
        effect = x;
    }
    else
    {
        effect = setInputEffect(effect, x);
    }
}
项目:FxDock    文件:FxIconBuilder.java   
public void addEffect(Effect x)
{
    if(effect == null)
    {
        effect = x;
    }
    else
    {
        effect = setInputEffect(effect, x);
    }
}
项目: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    文件:SisSceneCell.java   
private void applySisSceneLook(Effect effect, String style, Color finalColor) {
    if (!getStyle().equals(style))
        setStyle(style);
    if (videoCameraGraphic.getEffect() == null
            || !videoCameraGraphic.getEffect().equals(effect))
        videoCameraGraphic.setEffect(effect);
    if (!finalColor.equals(videoCameraGraphic.getFill()))
        videoCameraGraphic.setFill(finalColor);
}
项目:ISAAC    文件:DragRegistry.java   
protected synchronized void conceptDragStarted()
{
    logger.debug("Drag Started");
    // There is a bug in javafx with comboboxs - it seems to fire dragStarted events twice.
    // http://javafx-jira.kenai.com/browse/RT-28778
    if ((System.currentTimeMillis() - dragStartedAt.get()) < 2000)
    {
        logger.debug("Ignoring duplicate drag started event");
        return;
    }
    if (dragStartedAt.get() > 0)
    {
        logger.warn("Unclosed drag event is still active while another was started!  Cleaning up...");
        conceptDragCompleted();
    }
    dragStartedAt.set(System.currentTimeMillis());
    for (Node n : codeDropTargets)
    {
        Effect existing = n.getEffect();
        if (existing != null)
        {
            existingEffect.put(n, existing);
        }
        n.setEffect(FxUtils.lightGreenDropShadow);
    }
    timedDragCancel = Utility.schedule(() ->
    {
        if (dragStartedAt.get() > 0)
        {
            logger.warn("Unclosed drag event is still active 10 seconds after starting!  Cleaning up...");
            Platform.runLater(() -> {conceptDragCompleted();});
        }
    }, 10, TimeUnit.SECONDS);
}
项目:narjillos    文件:ThingView.java   
private Effect getHaloEffect(double zoomLevel) {
    double minZoomLevel = 0.2;
    if (zoomLevel <= minZoomLevel)
        return null;
    double alpha = (zoomLevel - minZoomLevel) * 2.5;
    double limitedAlpha = Math.max(0, Math.min(1, alpha));
    Color color = new Color(0.9, 0.9, 0.9, limitedAlpha);
    return new DropShadow(20, 7, 7, color);
}
项目:kotlinfx-ensemble    文件:DigitalClock.java   
public Digit(Color onColor, Color offColor, Effect onEffect, Effect offEffect) {
    this.onColor = onColor;
    this.offColor = offColor;
    this.onEffect = onEffect;
    this.offEffect = offEffect;
    getChildren().addAll(polygons);
    getTransforms().add(new Shear(-0.1,0));
    showNumber(0);
}
项目:MasteringTables    文件:ResultView.java   
/**
 * Build the drop shadow.
 *
 * @return the drop shadow effect
 */
private Effect getDropShadow() {
    return DropShadowBuilder.create()
                            .offsetX(0)
                            .offsetY(5)
                            .color(MTColors.BEAN_SHADOW.get())
                            .blurType(BlurType.GAUSSIAN)
                            .radius(5)
                            .spread(0.1)
                            .build();
}
项目:FxEditor    文件:FxIconBuilder.java   
public void setEffect(Effect x)
{
    effect = x;
}
项目:openjfx-8u-dev-tests    文件:NodeSnapshot2App.java   
slotWithDefaultDrawNode (final Effect _e) {
    e = _e;
}
项目:openjfx-8u-dev-tests    文件:NodeSnapshot2App.java   
public NamedEffect(String name, Effect effect) {
    this.name = name;
    this.effect = effect;
}
项目:openjfx-8u-dev-tests    文件:CanvasEffects2App.java   
slotWithDefaultDrawNode (final Effect _e) {
    e = _e;
}
项目:openjfx-8u-dev-tests    文件:CanvasEffects2App.java   
slotWithTextNode (final Effect _e) {
    e = _e;
}
项目:openjfx-8u-dev-tests    文件:CanvasEffects2App.java   
slotWithHugeTextNode (final Effect _e) {
    e = _e;
}
项目:openjfx-8u-dev-tests    文件:CanvasEffects2App.java   
public NamedEffect(String name, Effect effect) {
    this.name = name;
    this.effect = effect;
}
项目:openjfx-8u-dev-tests    文件:EffectsApp.java   
public Node create(final Effect e) {
            return new Group() {
                {
                    setEffect(e);
                    int angle = 0;
                    for (final Color color : new Color[]{Color.RED, Color.GREEN, Color.BLUE}) {
                        getChildren().add(new Arc(40, 40, 40, 40, 120 * angle++, 120) {
                            {
                                setType(ArcType.ROUND);
                                setFill(color);
                            }
                        });
                    }
                }
            };
        }
    });
}

//DisplacementMap
{
    final FloatMap mapWaves = new FloatMap();
    mapWaves.setWidth(100);
    mapWaves.setHeight(80);
    for (int i = 0; i < mapWaves.getWidth() - 1; i++) {
        float v = (float) ((Math.sin(i / 30f * Math.PI) - 0.5f) / 20f);
        for (int j = 0; j < mapWaves.getHeight() - 1; j++) {
            mapWaves.setSamples(i, j, 0f, v);
        }
    }

    List<NamedEffect> nes = new ArrayList<NamedEffect>();
    nes.add(new NamedEffect("defaults", new DisplacementMap() {
        {
            setMapData(mapWaves);
        }
    }));
    nes.add(new NamedEffect("scale", new DisplacementMap() {
        {
            setMapData(mapWaves);
            setScaleX(1.2f);
            setScaleY(2.0f);
        }
    }));
    nes.add(new NamedEffect("offset", new DisplacementMap() {
        {
            setMapData(mapWaves);
            setOffsetX(0.2f);
            setOffsetY(0.1f);
        }
    }));
    nes.add(new NamedEffect("wrap", new DisplacementMap() {
        {
            setMapData(mapWaves);
            setWrap(true);
            setOffsetX(0.5f);
            setOffsetY(0.3f);
        }
    }));

    register(Pages.Map.name(), 120, nes, new Factory() {
项目:openjfx-8u-dev-tests    文件:EffectsApp.java   
public Node create(final Effect effect) {
            return new Group() {
                {
                    setEffect(effect);
                    getChildren().add(new Rectangle(10, 10, 100, 50));
                    getChildren().add(new Rectangle(0, 0, 120, 120) {
                        {
                            setFill(Color.TRANSPARENT);
                        }
                    }); // widener
                    Text tmpTxt = new Text("Waves");
                    tmpTxt.setX(11);
                    tmpTxt.setY(50);
                    tmpTxt.setFill(Color.RED);
                    tmpTxt.setFont(Font.font("Verdana", 28));
                    getChildren().add(tmpTxt);
                }
            };
        }
    });
}
//DropShadow
{
    List<NamedEffect> nes = new ArrayList<NamedEffect>();
    nes.add(new NamedEffect("colored", new DropShadow() {
        {
            setColor(Color.GREEN);
        }
    }));
    nes.add(new NamedEffect("height: 40", new DropShadow() {
        {
            setHeight(40);
        }
    }));
    nes.add(new NamedEffect("width: 40", new DropShadow() {
        {
            setWidth(40);
        }
    }));
    nes.add(new NamedEffect("spread: 0.7 ", new DropShadow() {
        {
            setSpread(0.7f);
        }
    }));
    for (final BlurType bt : BlurType.values()) {
        nes.add(new NamedEffect("bt:" + bt.name(), new DropShadow() {
            {
                setBlurType(bt);
            }
        }));
    }
    nes.add(new NamedEffect("offset: 10, 20", new DropShadow() {
        {
            setOffsetX(10);
            setOffsetY(20);
        }
    }));

    register(Pages.DropShadow.name(), 125, nes, defaultFactory);
}

addPage(Pages.Flood.name(), new Runnable() {
项目:openjfx-8u-dev-tests    文件:EffectsApp.java   
private void initFactories() {
    defaultFactory = new Factory() {
        public Node create(final Effect e) {
            return new Group() {
                {
                    setEffect(e);
                    getChildren().add(new Rectangle(10, 10, 100, 50) {
                        {
                            setFill(Color.YELLOW);
                        }
                    });
                    Text tmpTxt = new Text("Text");
                    tmpTxt.setFill(Color.RED);
                    tmpTxt.setFont(Font.font("Verdana", 28));
                    getChildren().add(tmpTxt);
                }
            };
        }
    };

    textFactory = new Factory() {
        public Node create(final Effect e) {
            Group group = new Group();
            group.setEffect(e);

            Text text = new Text("Text");
            text.setX(10);
            text.setY(60);
            text.setFont(Font.font("Verdana", 36));
            text.setFill(Color.RED);
            group.getChildren().add(text);

            return group;
        }
    };

    hugeFontFactory = new Factory() {
        public Node create(final Effect e) {
            return new Group() {
                {
                    setEffect(e);
                    Text tmpTxt = new Text("XO");
                    tmpTxt.setX(10);
                    tmpTxt.setFill(Color.YELLOW);
                    tmpTxt.setFont(Font.font("Verdana", 80));
                    getChildren().add(tmpTxt);
                    getChildren().add(new Rectangle(10, 10, 100, 40) {
                        {
                            setFill(Color.LIGHTBLUE);
                        }
                    });
                }
            };
        }
    };
}
项目:openjfx-8u-dev-tests    文件:EffectsApp.java   
public NamedEffect(String name, Effect effect) {
    this.name = name;
    this.effect = effect;
}
项目:openjfx-8u-dev-tests    文件:EffectTestAction.java   
public EffectTestAction(Effect effect, boolean lcdWork) {
    this.effect = effect;
    this.lcdWork = lcdWork;
}
项目:openjfx-8u-dev-tests    文件:EffectAction.java   
public EffectAction(Effect effect, boolean lcdWork) {
    this.lcdWork = lcdWork;
    this.effect = effect;
}
项目:ReqTraq    文件:FxIconBuilder.java   
public void setEffect(Effect x)
{
    effect = x;
}
项目:urmusic-desktop    文件:Renderer.java   
private void setupEffect() {
    Effect finalEffect = null;

    if(this.glowness > 0.0f) {
        this.glowEffect.setColor(this.section.color);
        this.glowEffect.setWidth(this.glowness * this.currentScaleX);
        this.glowEffect.setHeight(this.glowness * this.currentScaleY);

        finalEffect = this.glowEffect;
    }

    if(this.motionBlur) {
        float posX = 0; // (this.section.posX.getValueAsFloat() + this.settings.globalOffsetX.getValueAsFloat()) * this.csize * this.glblscl;
        float posY = 0; // (this.section.posY.getValueAsFloat() + this.settings.globalOffsetY.getValueAsFloat()) * this.csize * this.glblscl;

        float[] lastPos;
        if(this.lastPositions.containsKey(this.section)) {
            lastPos = this.lastPositions.get(this.section);

            float diffX = posX - lastPos[0];
            float diffY = posY - lastPos[1];

            float angle = (float) Math.toDegrees(Math.atan2(diffX, diffY));
            float dist = (float) Math.sqrt(diffX * diffX + diffY * diffY);

            lastPos[0] = posX;
            lastPos[1] = posY;

            this.motionEffect.setInput(finalEffect);
            this.motionEffect.setAngle(angle);
            this.motionEffect.setRadius(Utils.clamp(dist * this.motionBlurAmount, 0.0, 63.0));

            finalEffect = this.motionEffect;
        } else {
            lastPos = new float[] { posX, posY };
            this.lastPositions.put(this.section, lastPos);
            this.section.addDisposeListener((s) -> {
                this.lastPositions.remove(s);
            });
        }
    }

    this.gtx.setEffect(finalEffect);
}
项目:FxDock    文件:FxIconBuilder.java   
public void setEffect(Effect x)
{
    effect = x;
}
项目:FXGL    文件:FXGLScene.java   
/**
 * @return currently applied effect or null if no effect is applied
 */
public final Effect getEffect() {
    return contentRoot.getEffect();
}
项目:FXImgurUploader    文件:FxDialogs.java   
private static String showConfirm(Stage owner, String title, String message, String... options) {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.initStyle(StageStyle.TRANSPARENT);
        alert.initModality(Modality.WINDOW_MODAL);
        alert.initOwner(owner);
        alert.setTitle("Choose an option");
        alert.setHeaderText(title);
        alert.setContentText(message);

        //To make enter key press the actual focused button, not the first one. Just like pressing "space".
        alert.getDialogPane().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
            if (event.getCode().equals(KeyCode.ENTER)) {
                event.consume();
                try {
                    Robot r = new Robot();
                    r.keyPress(java.awt.event.KeyEvent.VK_SPACE);
                    r.keyRelease(java.awt.event.KeyEvent.VK_SPACE);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        if (options == null || options.length == 0) {
            options = new String[]{OK, CANCEL};
        }

        List<ButtonType> buttons = new ArrayList<>();
        for (String option : options) {
            buttons.add(new ButtonType(option));
        }
        alert.getButtonTypes().setAll(buttons);

        Effect previousEffect = owner.getScene().getRoot().getEffect();
        GaussianBlur blur = new GaussianBlur(5);
        blur.setInput(previousEffect);
        owner.getScene().getRoot().setEffect(blur);
//        buttonBar.getButtons().get(0).getStyleClass()
//        alert.getDialogPane().getScene().getRoot().setStyle("-fx-background-color: transparent; -fx-background-radius: 10px;");
        alert.getDialogPane().getScene().setFill(Color.TRANSPARENT);
//        alert.getDialogPane().setStyle("-fx-background-color: -imgur-color-bg-1; -fx-background-radius: 10;");
//        alert.getDialogPane().getHeader().getStyleClass().add("tooltip");

        Optional<ButtonType> result = alert.showAndWait();
        owner.getScene().getRoot().setEffect(previousEffect);
        if (!result.isPresent()) {
            return CANCEL;
        } else {
            return result.get().getText();
        }
    }