Java Code Examples for javafx.scene.Node#setOpacity()

The following examples show how to use javafx.scene.Node#setOpacity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimelineChart.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
protected void dataItemAdded(final Series<Number, Number> series,
        final int itemIndex, final Data<Number, Number> item) {

    final Node prospective;
    if (item.getExtraValue() instanceof Interaction) {
        prospective = (Interaction) item.getExtraValue();
    } else {
        prospective = (Cluster) item.getExtraValue();
    }
    item.setNode(prospective);

    if (shouldAnimate()) {
        prospective.setOpacity(0);
        getPlotChildren().add(prospective);

        // fade in new child
        final FadeTransition ft = new FadeTransition(Duration.millis(500), prospective);
        ft.setToValue(1);
        ft.play();
    } else {
        getPlotChildren().add(prospective);
    }
}
 
Example 2
Source File: AdvCandleStickChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override protected void dataItemAdded(Series<Number, Number> series, int itemIndex, Data<Number, Number> item) {
    Node candle = createCandle(getData().indexOf(series), item, itemIndex);
    if (shouldAnimate()) {
        candle.setOpacity(0);
        getPlotChildren().add(candle);
        // fade in new candle
        FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
        ft.setToValue(1);
        ft.play();
    } else {
        getPlotChildren().add(candle);
    }
    // always draw average line on top
    if (series.getNode() != null) {
        series.getNode().toFront();
    }
}
 
Example 3
Source File: AdvCandleStickChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override protected void seriesAdded(Series<Number, Number> series, int seriesIndex) {
    // handle any data already in series
    for (int j = 0; j < series.getData().size(); j++) {
        Data item = series.getData().get(j);
        Node candle = createCandle(seriesIndex, item, j);
        if (shouldAnimate()) {
            candle.setOpacity(0);
            getPlotChildren().add(candle);
            // fade in new candle
            FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
            ft.setToValue(1);
            ft.play();
        } else {
            getPlotChildren().add(candle);
        }
    }
    // create series path
    Path seriesPath = new Path();
    seriesPath.getStyleClass().setAll("candlestick-average-line", "series" + seriesIndex);
    series.setNode(seriesPath);
    getPlotChildren().add(seriesPath);
}
 
Example 4
Source File: AdvCandleStickChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override protected void dataItemAdded(Series<Number, Number> series, int itemIndex, Data<Number, Number> item) {
    Node candle = createCandle(getData().indexOf(series), item, itemIndex);
    if (shouldAnimate()) {
        candle.setOpacity(0);
        getPlotChildren().add(candle);
        // fade in new candle
        FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
        ft.setToValue(1);
        ft.play();
    } else {
        getPlotChildren().add(candle);
    }
    // always draw average line on top
    if (series.getNode() != null) {
        series.getNode().toFront();
    }
}
 
Example 5
Source File: AdvCandleStickChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override protected void seriesAdded(Series<Number, Number> series, int seriesIndex) {
    // handle any data already in series
    for (int j = 0; j < series.getData().size(); j++) {
        Data item = series.getData().get(j);
        Node candle = createCandle(seriesIndex, item, j);
        if (shouldAnimate()) {
            candle.setOpacity(0);
            getPlotChildren().add(candle);
            // fade in new candle
            FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
            ft.setToValue(1);
            ft.play();
        } else {
            getPlotChildren().add(candle);
        }
    }
    // create series path
    Path seriesPath = new Path();
    seriesPath.getStyleClass().setAll("candlestick-average-line", "series" + seriesIndex);
    series.setNode(seriesPath);
    getPlotChildren().add(seriesPath);
}
 
Example 6
Source File: CandleStickChart.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void dataItemAdded(XYChart.Series<Number, Number> series, int itemIndex, XYChart.Data<Number, Number> item) {
    Node candle = createCandle(getData().indexOf(series), item, itemIndex);
    getPlotChildren().remove(candle);

    if (shouldAnimate()) {
        candle.setOpacity(0);
        getPlotChildren().add(candle);
        // fade in new candle
        FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
        ft.setToValue(1);
        ft.play();
    } else {
        getPlotChildren().add(candle);
    }
    // always draw average line on top

    if (series.getNode() instanceof Path) {
        Path seriesPath = (Path) series.getNode();
        seriesPath.toFront();
    }
}
 
Example 7
Source File: TargetIO.java    From ShootOFF with GNU General Public License v3.0 6 votes vote down vote up
private static Group processVisualTags(List<Node> regions) {
	final Group targetGroup = new Group();
	for (final Node node : regions) {
		final TargetRegion region = (TargetRegion) node;

		if (region.tagExists(TargetView.TAG_VISIBLE)
				&& !Boolean.parseBoolean(region.getTag(TargetView.TAG_VISIBLE))) {
			node.setVisible(false);
		}

		if (region.getType() != RegionType.IMAGE) {
			if (region.tagExists(TargetView.TAG_OPACITY)) {
				node.setOpacity(Double.parseDouble(region.getTag(TargetView.TAG_OPACITY)));
			} else {
				node.setOpacity(DEFAULT_OPACITY);
			}
		}
		targetGroup.getChildren().add(node);
	}

	return targetGroup;
}
 
Example 8
Source File: VolumeChart.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void seriesAdded(XYChart.Series<Number, Number> series, int seriesIndex) {
    for (int j = 0; j < series.getData().size(); j++) {
        XYChart.Data<Number, Number> item = series.getData().get(j);
        Node volumeBar = createCandle(seriesIndex, item, j);
        if (shouldAnimate()) {
            volumeBar.setOpacity(0);
            getPlotChildren().add(volumeBar);
            FadeTransition ft = new FadeTransition(Duration.millis(500), volumeBar);
            ft.setToValue(1);
            ft.play();
        } else {
            getPlotChildren().add(volumeBar);
        }
    }
}
 
Example 9
Source File: TimelineChart.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
protected void seriesAdded(final Series<Number, Number> series, int seriesIndex) {
    // Handle any data already in series:
    for (int j = 0; j < series.getData().size(); j++) {
        final Data<Number, Number> item = series.getData().get(j);

        final Node prospective;
        if (item.getExtraValue() instanceof Interaction) {
            prospective = (Interaction) item.getExtraValue();
        } else {
            prospective = (Cluster) item.getExtraValue();
        }

        item.setNode(prospective);

        if (shouldAnimate()) {
            prospective.setOpacity(0);
            getPlotChildren().add(prospective);

            final FadeTransition ft = new FadeTransition(Duration.millis(500), prospective);
            ft.setToValue(1);
            ft.play();
        } else {
            getPlotChildren().add(prospective);
        }
    }
}
 
Example 10
Source File: VolumeChart.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void dataItemAdded(XYChart.Series<Number, Number> series, int itemIndex, XYChart.Data<Number, Number> item) {
    Node volumeBar = createCandle(getData().indexOf(series), item, itemIndex);
    getPlotChildren().remove(volumeBar);

    if (shouldAnimate()) {
        volumeBar.setOpacity(0);
        getPlotChildren().add(volumeBar);
        FadeTransition ft = new FadeTransition(Duration.millis(500), volumeBar);
        ft.setToValue(1);
        ft.play();
    } else {
        getPlotChildren().add(volumeBar);
    }
}
 
Example 11
Source File: SelectionStripSkin.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private FadeTransition createFadeTransition(Node node, double from, double to) {
  node.setOpacity(from);
  FadeTransition faderTransition = new FadeTransition();
  faderTransition.setNode(node);
  faderTransition.setFromValue(from);
  faderTransition.setToValue(to);
  faderTransition.setDuration(Duration.millis(200));
  return faderTransition;
}
 
Example 12
Source File: JFXAlertAnimation.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void initAnimation(Node contentContainer, Node overlay) {
    overlay.setOpacity(0);
    contentContainer.setTranslateX(contentContainer.getLayoutX()
                                   + contentContainer.getLayoutBounds().getMaxX());
}
 
Example 13
Source File: JFXAlertAnimation.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void initAnimation(Node contentContainer, Node overlay) {
    overlay.setOpacity(0);
    contentContainer.setTranslateY(-(contentContainer.getLayoutY()
                                     + contentContainer.getLayoutBounds().getMaxY()));
}
 
Example 14
Source File: JFXAlertAnimation.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void initAnimation(Node contentContainer, Node overlay) {
    overlay.setOpacity(0);
    contentContainer.setTranslateY(contentContainer.getLayoutY()
                                   + contentContainer.getLayoutBounds().getMaxY());
}
 
Example 15
Source File: JFXAlertAnimation.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void initAnimation(Node contentContainer, Node overlay) {
    overlay.setOpacity(0);
    contentContainer.setTranslateX(-(contentContainer.getLayoutX()
                                     + contentContainer.getLayoutBounds().getMaxX()));
}
 
Example 16
Source File: JFXAlertAnimation.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void initAnimation(Node contentContainer, Node overlay) {
    overlay.setOpacity(0);
    contentContainer.setScaleX(.80);
    contentContainer.setScaleY(.80);
}
 
Example 17
Source File: JFXTogglePane.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
public final void setContentNode(final Node content) {
    this.contentNodeProperty().set(content);
    content.setOpacity(0);
}
 
Example 18
Source File: MosaicPane.java    From Mosaic with Apache License 2.0 4 votes vote down vote up
public SurfaceListener<T> getSurfaceObserver() {
	SurfaceListener<T> l = new SurfaceListener<T>() {
		public void changed(ChangeType changeType, Node n, String id, Rectangle2D r1, Rectangle2D r2) {
			switch(changeType) {
		    	case REMOVE_DISCARD: {
		    		content.getChildren().remove(n);
		    		requestLayout();
		    		break;
		    	}
		    	case RESIZE_RELOCATE: {
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
			        
			        break;
		    	}
		    	case ADD_COMMIT: {
		    		content.getChildren().add(n);
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
			        break;
		    	}
		    	case MOVE_BEGIN: {
		    		DropShadow shadow = new DropShadow();
		    		shadow.setOffsetX(10);
		    		shadow.setOffsetY(10);
		    		shadow.setRadius(5);
		    		shadow.setColor(Color.GRAY);
		    		n.setEffect(shadow);
		    		n.toFront();
		    		n.setOpacity(.5);
		    		break;
		    	}
		    	case RELOCATE_DRAG_TARGET: {
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
		    		break;
		    	}
		    	case RESIZE_DRAG_TARGET: {
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
			        break;
		    	}
		    	case MOVE_END: {
		    		n.setOpacity(1);
		    		n.setEffect(null);
		    		break;
		    	}
		    	case ANIMATE_RESIZE_RELOCATE: {
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
			        break;
		    	}
		    	default: break;
	    	}
		}
	};
	return l;
}
 
Example 19
Source File: SummonToken.java    From metastone with GNU General Public License v2.0 4 votes vote down vote up
private void visualizeStealth(Summon summon) {
	Node token = summon.hasAttribute(Attribute.TAUNT) ? taunt : defaultToken;
	token.setOpacity(summon.hasAttribute(Attribute.STEALTH) ? 0.5 : 1);
}
 
Example 20
Source File: CloudToTweetStep.java    From TweetwallFX with MIT License 4 votes vote down vote up
private FadeTransition addFadeTransition(final Duration duration, final Node node, final double initialOpacity, final double targetOpacity) {
    FadeTransition ft = new FadeTransition(duration, node);
    node.setOpacity(initialOpacity);
    ft.setToValue(targetOpacity);
    return ft;
}