Java Code Examples for javafx.scene.layout.Pane#setEffect()

The following examples show how to use javafx.scene.layout.Pane#setEffect() . 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: LaTeXDraw.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
private void showSplash(final Stage initStage, final Task<Void> task) {
	final ProgressBar loadProgress = new ProgressBar();
	loadProgress.progressProperty().bind(task.progressProperty());

	final Pane splashLayout = new VBox();
	final Image img = new Image("res/LaTeXDrawSmall.png", 450, 250, true, true); //NON-NLS
	final ImageView splash = new ImageView(img);
	splashLayout.getChildren().addAll(splash, loadProgress);
	splashLayout.setEffect(new DropShadow());
	loadProgress.setPrefWidth(img.getWidth());

	task.setOnSucceeded(ignore -> {
		loadProgress.progressProperty().unbind();
		loadProgress.setProgress(1d);
		final FadeTransition fadeSplash = new FadeTransition(Duration.seconds(0.8), splashLayout);
		fadeSplash.setFromValue(1d);
		fadeSplash.setToValue(0d);
		fadeSplash.setOnFinished(evt -> {
			initStage.hide();
			mainStage.setIconified(false);
			mainStage.toFront();
		});
		fadeSplash.play();
	});

	final Scene splashScene = new Scene(splashLayout);
	initStage.setScene(splashScene);
	initStage.initStyle(StageStyle.UNDECORATED);
	initStage.getIcons().add(new Image("/res/LaTeXDrawIcon.png")); //NON-NLS
	initStage.centerOnScreen();
	initStage.toFront();
	initStage.show();
}
 
Example 2
Source File: LcdSkin.java    From Medusa with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    mainInnerShadow0 = new InnerShadow();
    mainInnerShadow0.setOffsetX(0.0);
    mainInnerShadow0.setOffsetY(0.0);
    mainInnerShadow0.setRadius(0.0625 * PREFERRED_HEIGHT);
    mainInnerShadow0.setColor(Color.rgb(255, 255, 255, 0.5));
    mainInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX);

    mainInnerShadow1 = new InnerShadow();
    mainInnerShadow1.setOffsetX(0.0);
    mainInnerShadow1.setOffsetY(1.0);
    mainInnerShadow1.setRadius(0.04166667 * PREFERRED_HEIGHT);
    mainInnerShadow1.setColor(Color.rgb(0, 0, 0, 0.65));
    mainInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX);
    mainInnerShadow1.setInput(mainInnerShadow0);

    crystalClip = new Rectangle(0, 0, width, height);
    crystalClip.setArcWidth(5);
    crystalClip.setArcHeight(5);

    crystalImage   = Helper.createNoiseImage(PREFERRED_WIDTH, PREFERRED_HEIGHT, DARK_NOISE_COLOR, BRIGHT_NOISE_COLOR, 8);
    crystalOverlay = new ImageView(crystalImage);
    crystalOverlay.setClip(crystalClip);
    boolean crystalEnabled = gauge.isLcdCrystalEnabled();
    Helper.enableNode(crystalOverlay, crystalEnabled);

    threshold = new Path();
    threshold.setStroke(null);
    Helper.enableNode(threshold, gauge.isThresholdVisible());

    average = new Path();
    average.setStroke(null);
    Helper.enableNode(average, gauge.isAverageVisible());

    backgroundText = new Text(String.format(locale, valueFormatString, gauge.getCurrentValue()));
    backgroundText.setFill(gauge.getLcdDesign().lcdBackgroundColor);
    backgroundText.setOpacity((LcdFont.LCD == gauge.getLcdFont() || LcdFont.ELEKTRA == gauge.getLcdFont()) ? 1 : 0);

    valueText = new Text(String.format(locale, valueFormatString, gauge.getCurrentValue()));
    valueText.setFill(gauge.getLcdDesign().lcdForegroundColor);

    unitText = new Text(gauge.getUnit());
    unitText.setFill(gauge.getLcdDesign().lcdForegroundColor);
    Helper.enableNode(unitText, !gauge.getUnit().isEmpty());

    title = new Text(gauge.getTitle());
    title.setFill(gauge.getLcdDesign().lcdForegroundColor);
    Helper.enableNode(title, !gauge.getTitle().isEmpty());

    lowerRightText = new Text(gauge.getSubTitle());
    lowerRightText.setFill(gauge.getLcdDesign().lcdForegroundColor);
    Helper.enableNode(lowerRightText, !gauge.getSubTitle().isEmpty());

    upperLeftText = new Text(String.format(locale, otherFormatString, gauge.getMinMeasuredValue()));
    upperLeftText.setFill(gauge.getLcdDesign().lcdForegroundColor);
    Helper.enableNode(upperLeftText, gauge.isMinMeasuredValueVisible());

    upperRightText = new Text(String.format(locale, otherFormatString, gauge.getMaxMeasuredValue()));
    upperRightText.setFill(gauge.getLcdDesign().lcdForegroundColor);
    Helper.enableNode(upperRightText, gauge.isMaxMeasuredValueVisible());

    lowerCenterText = new Text(String.format(locale, otherFormatString, gauge.getOldValue()));
    lowerCenterText.setFill(gauge.getLcdDesign().lcdForegroundColor);
    Helper.enableNode(lowerCenterText, gauge.isOldValueVisible());

    shadowGroup = new Group();
    shadowGroup.setEffect(gauge.isShadowsEnabled() ? FOREGROUND_SHADOW : null);
    shadowGroup.getChildren().setAll(threshold,
                                     average,
                                     valueText,
                                     unitText,
                                     title,
                                     lowerRightText,
                                     upperLeftText,
                                     upperRightText,
                                     lowerCenterText);

    pane = new Pane(crystalOverlay, backgroundText, shadowGroup);
    pane.setEffect(gauge.isShadowsEnabled() ? mainInnerShadow1 : null);
    getChildren().setAll(pane);
}
 
Example 3
Source File: LcdClockSkin.java    From Medusa with Apache License 2.0 4 votes vote down vote up
@Override protected void initGraphics() {
    // Set initial size
    if (Double.compare(clock.getPrefWidth(), 0.0) <= 0 || Double.compare(clock.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(clock.getWidth(), 0.0) <= 0 || Double.compare(clock.getHeight(), 0.0) <= 0) {
        if (clock.getPrefWidth() > 0 && clock.getPrefHeight() > 0) {
            clock.setPrefSize(clock.getPrefWidth(), clock.getPrefHeight());
        } else {
            clock.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    mainInnerShadow0 = new InnerShadow();
    mainInnerShadow0.setOffsetX(0.0);
    mainInnerShadow0.setOffsetY(0.0);
    mainInnerShadow0.setRadius(3.0 / 132.0 * PREFERRED_WIDTH);
    mainInnerShadow0.setColor(Color.rgb(255, 255, 255, 0.5));
    mainInnerShadow0.setBlurType(BlurType.TWO_PASS_BOX);

    mainInnerShadow1 = new InnerShadow();
    mainInnerShadow1.setOffsetX(0.0);
    mainInnerShadow1.setOffsetY(1.0);
    mainInnerShadow1.setRadius(2.0 / 132.0 * PREFERRED_WIDTH);
    mainInnerShadow1.setColor(Color.rgb(0, 0, 0, 0.65));
    mainInnerShadow1.setBlurType(BlurType.TWO_PASS_BOX);
    mainInnerShadow1.setInput(mainInnerShadow0);

    crystalClip = new Rectangle(0, 0, PREFERRED_WIDTH, PREFERRED_HEIGHT);
    crystalClip.setArcWidth(5);
    crystalClip.setArcHeight(5);

    crystalImage   = Helper.createNoiseImage(PREFERRED_WIDTH, PREFERRED_HEIGHT, DARK_NOISE_COLOR, BRIGHT_NOISE_COLOR, 8);
    crystalOverlay = new ImageView(crystalImage);
    crystalOverlay.setClip(crystalClip);
    boolean crystalEnabled = clock.isLcdCrystalEnabled();
    crystalOverlay.setManaged(crystalEnabled);
    crystalOverlay.setVisible(crystalEnabled);

    boolean secondsVisible = clock.isSecondsVisible();

    backgroundTimeText = new Text("");
    backgroundTimeText.setFill(clock.getLcdDesign().lcdBackgroundColor);
    backgroundTimeText.setOpacity((LcdFont.LCD == clock.getLcdFont() || LcdFont.ELEKTRA == clock.getLcdFont()) ? 1 : 0);

    backgroundSecondText = new Text("");
    backgroundSecondText.setFill(clock.getLcdDesign().lcdBackgroundColor);
    backgroundSecondText.setOpacity((LcdFont.LCD == clock.getLcdFont() || LcdFont.ELEKTRA == clock.getLcdFont()) ? 1 : 0);
    backgroundSecondText.setManaged(secondsVisible);
    backgroundSecondText.setVisible(secondsVisible);

    timeText = new Text("");
    timeText.setFill(clock.getLcdDesign().lcdForegroundColor);

    secondText = new Text("");
    secondText.setFill(clock.getLcdDesign().lcdForegroundColor);
    secondText.setManaged(secondsVisible);
    secondText.setVisible(secondsVisible);

    title = new Text(clock.getTitle());
    title.setFill(clock.getLcdDesign().lcdForegroundColor);
    boolean titleVisible = clock.isTitleVisible();
    title.setManaged(titleVisible);
    title.setVisible(titleVisible);

    dateText = new Text(dateFormat.format(clock.getTime()));
    dateText.setFill(clock.getLcdDesign().lcdForegroundColor);
    boolean dateVisible = clock.isDateVisible();
    dateText.setManaged(dateVisible);
    dateText.setVisible(dateVisible);

    dayOfWeekText = new Text("");
    dayOfWeekText.setFill(clock.getLcdDesign().lcdForegroundColor);
    dayOfWeekText.setManaged(dateVisible);
    dayOfWeekText.setVisible(dateVisible);

    alarm = new Path();
    alarm.setFillRule(FillRule.EVEN_ODD);
    alarm.setStroke(null);
    boolean alarmVisible = clock.getAlarms().size() > 0;
    alarm.setManaged(alarmVisible);
    alarm.setVisible(alarmVisible);

    shadowGroup = new Group();
    shadowGroup.setEffect(clock.getShadowsEnabled() ? FOREGROUND_SHADOW : null);
    shadowGroup.getChildren().setAll(timeText,
                                     secondText,
                                     title,
                                     dateText,
                                     dayOfWeekText,
                                     alarm);

    pane = new Pane();
    pane.setEffect(clock.getShadowsEnabled() ? mainInnerShadow1 : null);
    pane.getChildren().setAll(crystalOverlay,
                              backgroundTimeText,
                              backgroundSecondText,
                              shadowGroup);
    getChildren().setAll(pane);
}
 
Example 4
Source File: Regulator.java    From regulators with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    dropShadow  = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), PREFERRED_WIDTH * 0.016, 0.0, 0, PREFERRED_WIDTH * 0.028);
    highlight   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.2), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.2), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    highlight.setInput(innerShadow);
    dropShadow.setInput(highlight);

    barArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE, 0);
    barArc.setType(ArcType.OPEN);
    barArc.setStrokeLineCap(StrokeLineCap.ROUND);
    barArc.setFill(null);
    barArc.setStroke(barColor.get());

    double center = PREFERRED_WIDTH * 0.5;
    ring = Shape.subtract(new Circle(center, center, PREFERRED_WIDTH * 0.42),
                          new Circle(center, center, PREFERRED_WIDTH * 0.3));
    ring.setFill(color.get());
    ring.setEffect(dropShadow);

    mainCircle = new Circle();
    mainCircle.setFill(color.get().darker().darker());

    text = new Text(String.format(Locale.US, formatString, getTargetValue()));
    text.setFill(Color.WHITE);
    text.setTextOrigin(VPos.CENTER);

    indicatorRotate = new Rotate(-ANGLE_RANGE *  0.5, center, center);

    indicatorGlow        = new DropShadow(BlurType.TWO_PASS_BOX, getIndicatorColor(), PREFERRED_WIDTH * 0.02, 0.0, 0, 0);
    indicatorInnerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.5), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    indicatorHighlight   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.35), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    indicatorHighlight.setInput(indicatorInnerShadow);

    indicator = new Circle();
    indicator.setFill(color.get().darker());
    indicator.setStroke(color.get().darker().darker());
    indicator.setMouseTransparent(true);
    indicator.getTransforms().add(indicatorRotate);

    Group indicatorGroup = new Group(indicator);
    indicatorGroup.setEffect(indicatorHighlight);

    symbol = new Region();
    symbol.getStyleClass().setAll("symbol");
    symbol.setCacheHint(CacheHint.SPEED);

    icon = new FontIcon();
    icon.setTextOrigin(VPos.CENTER);

    iconPane = new StackPane(symbol, icon);

    pane = new Pane(barArc, ring, mainCircle, text, indicatorGroup, iconPane);
    pane.setPrefSize(PREFERRED_HEIGHT, PREFERRED_HEIGHT);
    pane.setBackground(new Background(new BackgroundFill(color.get().darker(), new CornerRadii(1024), Insets.EMPTY)));
    pane.setEffect(highlight);

    getChildren().setAll(pane);
}
 
Example 5
Source File: ColorRegulator.java    From regulators with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    dropShadow  = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), PREFERRED_WIDTH * 0.016, 0.0, 0, PREFERRED_WIDTH * 0.028);
    highlight   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.2), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.2), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    highlight.setInput(innerShadow);
    dropShadow.setInput(highlight);

    Stop[] stops = { new Stop(0.0, Color.rgb(255,255,0)),
                     new Stop(0.125, Color.rgb(255,0,0)),
                     new Stop(0.375, Color.rgb(255,0,255)),
                     new Stop(0.5, Color.rgb(0,0,255)),
                     new Stop(0.625, Color.rgb(0,255,255)),
                     new Stop(0.875, Color.rgb(0,255,0)),
                     new Stop(1.0, Color.rgb(255,255,0)) };

    List<Stop> reorderedStops = reorderStops(stops);

    gradientLookup = new GradientLookup(stops);

    barGradient = new ConicalGradient(reorderedStops);
    barArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE, 0);
    barArc.setType(ArcType.OPEN);
    barArc.setStrokeLineCap(StrokeLineCap.ROUND);
    barArc.setFill(null);
    barArc.setStroke(barGradient.getImagePattern(new Rectangle(0, 0, PREFERRED_WIDTH, PREFERRED_HEIGHT)));

    buttonOn = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, -125, 34.75);
    buttonOn.setFill(null);
    buttonOn.setStroke(color.get());
    buttonOn.setStrokeLineCap(StrokeLineCap.BUTT);
    buttonOn.setStrokeWidth(PREFERRED_WIDTH * 0.072);
    buttonOn.setEffect(dropShadow);

    buttonOff = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, -89.75, 34.75);
    buttonOff.setFill(null);
    buttonOff.setStroke(color.get());
    buttonOff.setStrokeLineCap(StrokeLineCap.BUTT);
    buttonOff.setStrokeWidth(PREFERRED_WIDTH * 0.072);
    buttonOff.setEffect(dropShadow);

    double center = PREFERRED_WIDTH * 0.5;
    ring = Shape.subtract(new Circle(center, center, PREFERRED_WIDTH * 0.42),
                          new Circle(center, center, PREFERRED_WIDTH * 0.3));
    ring.setFill(color.get());
    ring.setEffect(highlight);

    mainCircle = new Circle();
    mainCircle.setFill(color.get().darker().darker());

    textOn = new Text("ON");
    textOn.setFill(textColor.get());
    textOn.setTextOrigin(VPos.CENTER);
    textOn.setMouseTransparent(true);
    textOn.setRotate(17);

    textOff = new Text("OFF");
    textOff.setFill(textColor.get());
    textOff.setTextOrigin(VPos.CENTER);
    textOff.setMouseTransparent(true);
    textOff.setRotate(-17);

    indicatorRotate = new Rotate(-ANGLE_RANGE *  0.5, center, center);

    indicatorGlow        = new DropShadow(BlurType.TWO_PASS_BOX, getIndicatorColor(), PREFERRED_WIDTH * 0.02, 0.0, 0, 0);
    indicatorInnerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.5), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    indicatorHighlight   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.35), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    indicatorHighlight.setInput(indicatorInnerShadow);

    indicator = new Circle();
    indicator.setFill(color.get().darker());
    indicator.setStroke(color.get().darker().darker());
    indicator.setMouseTransparent(true);
    indicator.getTransforms().add(indicatorRotate);

    Group indicatorGroup = new Group(indicator);
    indicatorGroup.setEffect(indicatorHighlight);

    innerRing = Shape.subtract(new Circle(center, center, PREFERRED_WIDTH * 0.24),
                               new Circle(center, center, PREFERRED_WIDTH * 0.2));
    innerRing.setFill(color.get());

    currentColorCircle = new Circle();
    currentColorCircle.setFill(targetColor.get());
    currentColorCircle.setVisible(isOn());

    pane = new Pane(barArc, ring, mainCircle, currentColorCircle, innerRing, indicatorGroup, buttonOn, textOn, buttonOff, textOff);
    pane.setPrefSize(PREFERRED_HEIGHT, PREFERRED_HEIGHT);
    pane.setBackground(new Background(new BackgroundFill(color.get().darker(), new CornerRadii(1024), Insets.EMPTY)));
    pane.setEffect(highlight);

    getChildren().setAll(pane);
}
 
Example 6
Source File: FeedbackRegulator.java    From regulators with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    dropShadow  = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), PREFERRED_WIDTH * 0.016, 0.0, 0, PREFERRED_WIDTH * 0.028);
    highlight   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.2), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.2), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    highlight.setInput(innerShadow);
    dropShadow.setInput(highlight);

    Stop[] stops = {
        new Stop(0.0, Color.rgb(135, 255, 190)),
        new Stop(0.125, Color.rgb(254, 190, 106)),
        new Stop(0.389, Color.rgb(252, 84, 68)),
        new Stop(0.611, Color.rgb(99, 195, 255)),
        new Stop(1.0, Color.rgb(125, 255, 190))
    };

    barGradient = new ConicalGradient(stops);

    barArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE, 0);
    barArc.setType(ArcType.OPEN);
    barArc.setStrokeLineCap(StrokeLineCap.ROUND);
    barArc.setFill(null);
    barArc.setStroke(barGradient.getImagePattern(new Rectangle(0, 0, PREFERRED_WIDTH, PREFERRED_HEIGHT)));

    overlayBarArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE, 0);
    overlayBarArc.setType(ArcType.OPEN);
    overlayBarArc.setStrokeLineCap(StrokeLineCap.ROUND);
    overlayBarArc.setFill(null);
    overlayBarArc.setStroke(Color.rgb(0, 0, 0, 0.3));
    overlayBarArc.setVisible((int) targetValue.get() != (int) currentValue.get());

    double center = PREFERRED_WIDTH * 0.5;
    ring = Shape.subtract(new Circle(center, center, PREFERRED_WIDTH * 0.42),
                          new Circle(center, center, PREFERRED_WIDTH * 0.3));
    ring.setFill(color.get());
    ring.setEffect(dropShadow);

    mainCircle = new Circle();
    mainCircle.setFill(color.get().darker().darker());

    text = new Text(String.format(Locale.US, formatString, currentValue.get()));
    text.setFill(textColor.get());
    text.setTextOrigin(VPos.CENTER);

    targetText = new Text(String.format(Locale.US, formatString, targetValue.get()));
    targetText.setFill(textColor.get().darker());
    targetText.setTextOrigin(VPos.CENTER);
    targetText.setVisible((int) targetValue.get() != (int) currentValue.get());

    indicatorRotate = new Rotate(-ANGLE_RANGE *  0.5, center, center);

    indicatorGlow        = new DropShadow(BlurType.TWO_PASS_BOX, getIndicatorColor(), PREFERRED_WIDTH * 0.02, 0.0, 0, 0);
    indicatorInnerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.5), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    indicatorHighlight   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.35), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    indicatorHighlight.setInput(indicatorInnerShadow);

    indicator = new Circle();
    indicator.setFill(color.get().darker());
    indicator.setStroke(color.get().darker().darker());
    indicator.setMouseTransparent(true);
    indicator.getTransforms().add(indicatorRotate);

    Group indicatorGroup = new Group(indicator);
    indicatorGroup.setEffect(indicatorHighlight);

    symbol = new Region();
    symbol.getStyleClass().setAll("symbol");
    symbol.setCacheHint(CacheHint.SPEED);

    icon = new FontIcon();
    icon.setTextOrigin(VPos.CENTER);

    iconPane = new StackPane(symbol, icon);

    pane = new Pane(barArc, overlayBarArc, ring, mainCircle, text, targetText, indicatorGroup, iconPane);
    pane.setPrefSize(PREFERRED_HEIGHT, PREFERRED_HEIGHT);
    pane.setBackground(new Background(new BackgroundFill(color.get().darker(), new CornerRadii(1024), Insets.EMPTY)));
    pane.setEffect(highlight);

    getChildren().setAll(pane);
}
 
Example 7
Source File: Story.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/** render the application on a stage */
  public StackPane createGUI() {

	SwingUtilities.invokeLater(() -> {
		//Simulation.instance().getJConsole().write(ADDRESS,Color.ORANGE,Color.BLACK);
	});

    // place the address content in a bordered title pane.
    Pane titledContent = new BorderedTitledPane(TITLE, getContent());
    titledContent.getStyleClass().add("titled-address");
    titledContent.setPrefSize(800, 745);

    // make some crumpled paper as a background.
    final Image paper = new Image(PAPER);
    final ImageView paperView = new ImageView(paper);
    ColorAdjust colorAdjust = new ColorAdjust(0, -.2, .2, 0);
    paperView.setEffect(colorAdjust);

    // place the address content over the top of the paper.
    StackPane stackedContent = new StackPane();
    stackedContent.getChildren().addAll(paperView, titledContent);

    // manage the viewport of the paper background, to size it to the content.
    paperView.setViewport(new Rectangle2D(0, 0, titledContent.getPrefWidth(), titledContent.getPrefHeight()));
    stackedContent.layoutBoundsProperty().addListener(new ChangeListener<Bounds>() {
      @Override public void changed(ObservableValue<? extends Bounds> observableValue, Bounds oldValue, Bounds newValue) {
        paperView.setViewport(new Rectangle2D(
          newValue.getMinX(), newValue.getMinY(),
          Math.min(newValue.getWidth(), paper.getWidth()), Math.min(newValue.getHeight(), paper.getHeight())
        ));
      }
    });

    // blend the content into the paper and make it look old.
    titledContent.setMaxWidth(paper.getWidth());
    titledContent.setEffect(new SepiaTone());
    titledContent.setBlendMode(BlendMode.MULTIPLY);

    // configure and display the scene and stage.
    //Scene scene = new Scene(stackedContent);
    //scene.getStylesheets().add(getClass().getResource("/css/gettysburg.css").toExternalForm());

/*
    stage.setTitle(TITLE);
    stage.getIcons().add(new Image(ICON));
    stage.setScene(scene);
    stage.setMinWidth(600); stage.setMinHeight(500);
    stage.show();
*/
    // make the scrollbar in the address scroll pane hide when it is not needed.
    makeScrollFadeable(titledContent.lookup(".address > .scroll-pane"));

    return stackedContent;
  }
 
Example 8
Source File: LoadingScreen.java    From FXTutorials with MIT License 4 votes vote down vote up
private Node makeSymbol() {
    Pane symbol = new Pane();

    GaussianBlur blur = new GaussianBlur(2.5);
    symbol.setEffect(blur);

    Rectangle top = new Rectangle(70, 5, Colors.LOADING_SYMBOL);
    top.setArcWidth(25);
    top.setArcHeight(25);

    Rectangle mid = new Rectangle(100, 5, Colors.LOADING_SYMBOL);
    mid.setArcWidth(25);
    mid.setArcHeight(25);

    Rectangle bot = new Rectangle(70, 5, Colors.LOADING_SYMBOL);
    bot.setArcWidth(25);
    bot.setArcHeight(25);

    top.setTranslateX(15);
    bot.setTranslateX(15);

    top.setTranslateY(10);
    mid.setTranslateY(10 + 10 + 5);
    bot.setTranslateY(10 + 10 + 5 + 10 + 5);

    Circle circle = new Circle(25, 25, 25, Color.BLACK);
    circle.setStroke(Colors.LOADING_SYMBOL);
    circle.setStrokeWidth(2);
    circle.setTranslateX(25);

    Circle circle2 = new Circle(25, 25, 25, Color.BLACK);
    circle2.setStroke(Colors.LOADING_SYMBOL);
    circle2.setStrokeWidth(1);
    circle2.setTranslateX(25);
    circle2.setRadius(2);

    Circle point = new Circle(25, 25, 25, Colors.LOADING_SYMBOL);
    point.setStroke(Colors.LOADING_SYMBOL);
    point.setStrokeWidth(1);
    point.setTranslateX(25);
    point.setRadius(1);

    KeyFrame frame = new KeyFrame(Duration.seconds(1),
            new KeyValue(circle2.radiusProperty(), 20));

    timeline.getKeyFrames().add(frame);
    timeline.setCycleCount(5);
    timeline.play();

    symbol.getChildren().addAll(top, mid, bot, circle, circle2, point);
    return symbol;
}