Java Code Examples for javafx.scene.effect.DropShadow#setOffsetY()
The following examples show how to use
javafx.scene.effect.DropShadow#setOffsetY() .
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: MvcLogoExample.java From gef with Eclipse Public License 2.0 | 6 votes |
private static Effect createShadowEffect() { DropShadow outerShadow = new DropShadow(); outerShadow.setRadius(3); outerShadow.setSpread(0.2); outerShadow.setOffsetX(3); outerShadow.setOffsetY(3); outerShadow.setColor(new Color(0.3, 0.3, 0.3, 1)); Distant light = new Distant(); light.setAzimuth(-135.0f); Lighting l = new Lighting(); l.setLight(light); l.setSurfaceScale(3.0f); Blend effects = new Blend(BlendMode.MULTIPLY); effects.setTopInput(l); effects.setBottomInput(outerShadow); return effects; }
Example 2
Source File: GeometryNodeSnippet.java From gef with Eclipse Public License 2.0 | 6 votes |
protected static Effect createShadowEffect() { final DropShadow outerShadow = new DropShadow(); outerShadow.setRadius(3); outerShadow.setSpread(0.2); outerShadow.setOffsetX(3); outerShadow.setOffsetY(3); outerShadow.setColor(new Color(0.3, 0.3, 0.3, 1)); final Distant light = new Distant(); light.setAzimuth(-135.0f); final Lighting l = new Lighting(); l.setLight(light); l.setSurfaceScale(3.0f); final Blend effects = new Blend(BlendMode.MULTIPLY); effects.setTopInput(l); effects.setBottomInput(outerShadow); return effects; }
Example 3
Source File: Toast.java From ApkToolPlus with Apache License 2.0 | 6 votes |
public Toast(final String msg) { label = new Label(msg); String style = "-fx-background-color:black;" + "-fx-background-radius:10;" + "-fx-font: 16px \"Microsoft YaHei\";" + "-fx-text-fill:white;-fx-padding:10;"; label.setStyle(style); DropShadow dropShadow = new DropShadow(); dropShadow.setBlurType(BlurType.THREE_PASS_BOX); dropShadow.setWidth(40); dropShadow.setHeight(40); dropShadow.setRadius(19.5); dropShadow.setOffsetX(0); dropShadow.setOffsetY(00); dropShadow.setColor(Color.color(0, 0, 0)); label.setEffect(dropShadow); }
Example 4
Source File: DisplayPreview.java From Quelea with GNU General Public License v3.0 | 5 votes |
/** * Create a new display preview. * * @param canvas the display canvas to use in this preview. */ public DisplayPreview(DisplayCanvas canvas) { this.canvas = canvas; DropShadow dropShadow = new DropShadow(); dropShadow.setRadius(10); dropShadow.setOffsetX(6); dropShadow.setOffsetY(6); dropShadow.setColor(Color.GRAY); canvas.setEffect(dropShadow); if (!QueleaProperties.get().getUseDarkTheme()) { setStyle("-fx-background-color:#dddddd;"); } getChildren().add(canvas); updateSize(); ChangeListener<Number> cl = new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) { updateSize(); } }; widthProperty().addListener(cl); heightProperty().addListener(cl); QueleaApp.get().getProjectionWindow().widthProperty().addListener(cl); QueleaApp.get().getProjectionWindow().heightProperty().addListener(cl); }
Example 5
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 5 votes |
public static Image addTextFx(Image image, String textString, Font font, Color color, int x, int y, float transparent, int shadow) { try { Group group = new Group(); Text text = new Text(x, y, textString); text.setFill(color); text.setFont(font); if (shadow > 0) { DropShadow dropShadow = new DropShadow(); dropShadow.setOffsetX(shadow); dropShadow.setOffsetY(shadow); text.setEffect(dropShadow); } group.getChildren().add(text); Blend blend = new Blend(BlendMode.SRC_OVER); blend.setBottomInput(new ImageInput(image)); blend.setOpacity(1.0 - transparent); group.setEffect(blend); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { logger.error(e.toString()); return null; } }
Example 6
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 5 votes |
public static Image addShadowFx(Image image, int shadow, Color color) { try { if (image == null || shadow <= 0) { return null; } double imageWidth = image.getWidth(), imageHeight = image.getHeight(); Group group = new Group(); Scene s = new Scene(group); ImageView view = new ImageView(image); view.setPreserveRatio(true); view.setFitWidth(imageWidth); view.setFitHeight(imageHeight); DropShadow dropShadow = new DropShadow(); dropShadow.setOffsetX(shadow); dropShadow.setOffsetY(shadow); dropShadow.setColor(color); view.setEffect(dropShadow); group.getChildren().add(view); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { // logger.error(e.toString()); return null; } }
Example 7
Source File: ChangeListenerSample.java From marathonv5 with Apache License 2.0 | 5 votes |
private static Group createBean(double rotate, double translateX, double translateY) { javafx.scene.shape.Ellipse bean1 = new javafx.scene.shape.Ellipse(16, 10); javafx.scene.shape.Ellipse bean1end = new javafx.scene.shape.Ellipse( 4,3, 3.2, 1.8); bean1end.setFill(Color.WHITESMOKE); bean1.setFill(Color.BROWN); javafx.scene.Group group = new javafx.scene.Group(bean1, bean1end); group.setRotate(rotate); group.setTranslateX(translateX+57); group.setTranslateY(translateY+57); DropShadow dropShadow = new DropShadow(); dropShadow.setOffsetX(2); dropShadow.setOffsetY(3); group.setEffect(dropShadow); return group; }
Example 8
Source File: DropShadowSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Node createIconContent() { Text sample = new Text("FX"); sample.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD,80)); sample.setStyle("-fx-font-size: 80px;"); sample.setFill(Color.web("#333333")); final DropShadow dropShadow = new DropShadow(); dropShadow.setOffsetX(4); dropShadow.setOffsetY(6); dropShadow.setColor(Color.rgb(0,0,0,0.7)); sample.setEffect(dropShadow); return sample; }
Example 9
Source File: KeyStrokeMotion.java From marathonv5 with Apache License 2.0 | 5 votes |
public LettersPane() { setId("LettersPane"); setPrefSize(480,480); setFocusTraversable(true); setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent me) { requestFocus(); me.consume(); } }); setOnKeyPressed(new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent ke) { createLetter(ke.getText()); ke.consume(); } }); // create press keys text pressText = new Text("Press Keys"); pressText.setTextOrigin(VPos.TOP); pressText.setFont(new Font(Font.getDefault().getFamily(), 40)); pressText.setLayoutY(5); pressText.setFill(Color.rgb(80, 80, 80)); DropShadow effect = new DropShadow(); effect.setRadius(0); effect.setOffsetY(1); effect.setColor(Color.WHITE); pressText.setEffect(effect); getChildren().add(pressText); }
Example 10
Source File: BasicView.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void updateShapeAppearance( Shape shape, boolean selected ) { if ( shape == null ) return; shape.setFill(selected ? Color.LIGHTGREEN : Color.LIGHTBLUE); shape.setStroke(Color.DARKGRAY); shape.setStrokeWidth(2.5); DropShadow shadow = new DropShadow(); shadow.setOffsetY(3.0); shadow.setOffsetX(3.0); shadow.setColor(Color.GRAY); shape.setEffect(shadow); }
Example 11
Source File: ClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { // Set initial size if (Double.compare(getSkinnable().getPrefWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getPrefHeight(), 0.0) <= 0 || Double.compare(getSkinnable().getWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getHeight(), 0.0) <= 0) { if (getSkinnable().getPrefWidth() > 0 && getSkinnable().getPrefHeight() > 0) { getSkinnable().setPrefSize(getSkinnable().getPrefWidth(), getSkinnable().getPrefHeight()); } else { getSkinnable().setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } sectionsAndAreasCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); sectionsAndAreasCtx = sectionsAndAreasCanvas.getGraphicsContext2D(); tickCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); tickCtx = tickCanvas.getGraphicsContext2D(); alarmPane = new Pane(); hour = new Rectangle(3, 60); hour.setArcHeight(3); hour.setArcWidth(3); hour.setStroke(getSkinnable().getHourColor()); hour.getTransforms().setAll(hourRotate); minute = new Rectangle(3, 96); minute.setArcHeight(3); minute.setArcWidth(3); minute.setStroke(getSkinnable().getMinuteColor()); minute.getTransforms().setAll(minuteRotate); second = new Rectangle(1, 96); second.setArcHeight(1); second.setArcWidth(1); second.setStroke(getSkinnable().getSecondColor()); second.getTransforms().setAll(secondRotate); second.setVisible(getSkinnable().isSecondsVisible()); second.setManaged(getSkinnable().isSecondsVisible()); knob = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, 4.5); knob.setStroke(Color.web("#282a3280")); dropShadow = new DropShadow(); dropShadow.setColor(Color.rgb(0, 0, 0, 0.25)); dropShadow.setBlurType(BlurType.TWO_PASS_BOX); dropShadow.setRadius(0.015 * PREFERRED_WIDTH); dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH); shadowGroupHour = new Group(hour); shadowGroupMinute = new Group(minute); shadowGroupSecond = new Group(second, knob); shadowGroupHour.setEffect(getSkinnable().getShadowsEnabled() ? dropShadow : null); shadowGroupMinute.setEffect(getSkinnable().getShadowsEnabled() ? dropShadow : null); shadowGroupSecond.setEffect(getSkinnable().getShadowsEnabled() ? dropShadow : null); title = new Text(""); title.setVisible(getSkinnable().isTitleVisible()); title.setManaged(getSkinnable().isTitleVisible()); dateText = new Text(""); dateText.setVisible(getSkinnable().isDateVisible()); dateText.setManaged(getSkinnable().isDateVisible()); text = new Text(""); text.setVisible(getSkinnable().isTextVisible()); text.setManaged(getSkinnable().isTextVisible()); pane = new Pane(sectionsAndAreasCanvas, tickCanvas, alarmPane, title, dateText, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond); pane.setBorder(new Border(new BorderStroke(getSkinnable().getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(getSkinnable().getBorderWidth())))); pane.setBackground(new Background(new BackgroundFill(getSkinnable().getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY))); getChildren().setAll(pane); }
Example 12
Source File: CImageDisplay.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
@Override public Node getNode( PageActionManager actionmanager, CPageData inputdata, Window parentwindow, TabPane[] parenttabpanes, CollapsibleNode nodetocollapsewhenactiontriggered) { inputdata.addInlineActionDataRef(this.inlineactiondataref); this.actionmanager = actionmanager; SFile thumbnail = getThumbnail(inputdata, datareference); if (!thumbnail.isEmpty()) { ByteArrayInputStream imagedata = new ByteArrayInputStream(thumbnail.getContent()); Image image = new Image(imagedata); double imagewidth = image.getWidth(); double imageheight = image.getHeight(); thumbnailview = new ImageView(image); thumbnailview.setFitWidth(imagewidth); thumbnailview.setFitHeight(imageheight); thumbnailview.setOnMousePressed(actionmanager.getMouseHandler()); actionmanager.registerInlineAction(thumbnailview, fullimageaction); BorderPane border = new BorderPane(); border.setBorder(new Border( new BorderStroke(Color.web("#ddeeff"), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(3)), new BorderStroke(Color.web("#bbccdd"), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(1)))); border.setCenter(thumbnailview); border.setMaxHeight(imageheight + 6); border.setMaxWidth(imagewidth + 6); DropShadow ds = new DropShadow(); ds.setRadius(3.0); ds.setOffsetX(1.5); ds.setOffsetY(1.5); ds.setColor(Color.color(0.2, 0.2, 0.2)); border.setEffect(ds); if (this.islabel) { FlowPane thispane = new FlowPane(); Label thislabel = new Label(label); thislabel.setFont( Font.font(thislabel.getFont().getName(), FontPosture.ITALIC, thislabel.getFont().getSize())); thislabel.setMinWidth(120); thislabel.setWrapText(true); thislabel.setMaxWidth(120); thispane.setRowValignment(VPos.TOP); thispane.getChildren().add(thislabel); thispane.getChildren().add(border); return thispane; } else { return border; } } return null; }
Example 13
Source File: AmpSkin.java From Medusa with Apache License 2.0 | 4 votes |
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); } } ticksAndSectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); ticksAndSections = ticksAndSectionsCanvas.getGraphicsContext2D(); ledCanvas = new Canvas(); led = ledCanvas.getGraphicsContext2D(); thresholdTooltip = new Tooltip("Threshold\n(" + String.format(locale, formatString, gauge.getThreshold()) + ")"); thresholdTooltip.setTextAlignment(TextAlignment.CENTER); threshold = new Path(); Helper.enableNode(threshold, gauge.isThresholdVisible()); Tooltip.install(threshold, thresholdTooltip); average = new Path(); Helper.enableNode(average, gauge.isAverageVisible()); markerPane = new Pane(); needleRotate = new Rotate(180 - START_ANGLE); needleRotate.setAngle(needleRotate.getAngle() + (gauge.getValue() - oldValue - gauge.getMinValue()) * angleStep); needleMoveTo1 = new MoveTo(); needleCubicCurveTo2 = new CubicCurveTo(); needleCubicCurveTo3 = new CubicCurveTo(); needleCubicCurveTo4 = new CubicCurveTo(); needleLineTo5 = new LineTo(); needleCubicCurveTo6 = new CubicCurveTo(); needleClosePath7 = new ClosePath(); needle = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleLineTo5, needleCubicCurveTo6, needleClosePath7); needle.setFillRule(FillRule.EVEN_ODD); needle.getTransforms().setAll(needleRotate); dropShadow = new DropShadow(); dropShadow.setColor(Color.rgb(0, 0, 0, 0.25)); dropShadow.setBlurType(BlurType.TWO_PASS_BOX); dropShadow.setRadius(0.015 * PREFERRED_WIDTH); dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH); shadowGroup = new Group(needle); shadowGroup.setEffect(gauge.isShadowsEnabled() ? dropShadow : null); titleText = new Text(gauge.getTitle()); titleText.setTextOrigin(VPos.CENTER); titleText.setFill(gauge.getTitleColor()); Helper.enableNode(titleText, !gauge.getTitle().isEmpty()); unitText = new Text(gauge.getUnit()); unitText.setMouseTransparent(true); unitText.setTextOrigin(VPos.CENTER); lcd = new Rectangle(0.3 * PREFERRED_WIDTH, 0.1 * PREFERRED_HEIGHT); lcd.setArcWidth(0.0125 * PREFERRED_HEIGHT); lcd.setArcHeight(0.0125 * PREFERRED_HEIGHT); lcd.relocate((PREFERRED_WIDTH - lcd.getWidth()) * 0.5, 0.44 * PREFERRED_HEIGHT); Helper.enableNode(lcd, gauge.isLcdVisible() && gauge.isValueVisible()); lcdText = new Label(String.format(locale, "%." + gauge.getDecimals() + "f", gauge.getValue())); lcdText.setAlignment(Pos.CENTER_RIGHT); lcdText.setVisible(gauge.isValueVisible()); // Set initial value angleStep = ANGLE_RANGE / gauge.getRange(); double targetAngle = 180 - START_ANGLE + (gauge.getValue() - gauge.getMinValue()) * angleStep; targetAngle = clamp(180 - START_ANGLE, 180 - START_ANGLE + ANGLE_RANGE, targetAngle); needleRotate.setAngle(targetAngle); lightEffect = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.65), 2, 0.0, 0.0, 2.0); foreground = new SVGPath(); foreground.setContent("M 26 26.5 C 26 20.2432 26.2432 20 32.5 20 L 277.5 20 C 283.7568 20 284 20.2432 284 26.5 L 284 143.5 C 284 149.7568 283.7568 150 277.5 150 L 32.5 150 C 26.2432 150 26 149.7568 26 143.5 L 26 26.5 ZM 0 6.7241 L 0 253.2758 C 0 260 0 260 6.75 260 L 303.25 260 C 310 260 310 260 310 253.2758 L 310 6.7241 C 310 0 310 0 303.25 0 L 6.75 0 C 0 0 0 0 0 6.7241 Z"); foreground.setEffect(lightEffect); // Add all nodes pane = new Pane(); pane.getChildren().setAll(ticksAndSectionsCanvas, markerPane, ledCanvas, unitText, lcd, lcdText, shadowGroup, foreground, titleText); getChildren().setAll(pane); }
Example 14
Source File: DBClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
@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); } } sectionsAndAreasCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); sectionsAndAreasCtx = sectionsAndAreasCanvas.getGraphicsContext2D(); tickCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); tickCtx = tickCanvas.getGraphicsContext2D(); alarmPane = new Pane(); hour = new Rectangle(3, 60); hour.setArcHeight(3); hour.setArcWidth(3); hour.setStroke(null); hour.setFill(clock.getHourColor()); hour.getTransforms().setAll(hourRotate); minute = new Rectangle(3, 96); minute.setArcHeight(3); minute.setArcWidth(3); minute.setStroke(null); minute.setFill(clock.getMinuteColor()); minute.getTransforms().setAll(minuteRotate); second = new Path(); second.setFillRule(FillRule.EVEN_ODD); second.setStroke(null); second.setFill(clock.getSecondColor()); second.getTransforms().setAll(secondRotate); enableNode(second, clock.isSecondsVisible()); dropShadow = new DropShadow(); dropShadow.setColor(Color.rgb(0, 0, 0, 0.25)); dropShadow.setBlurType(BlurType.TWO_PASS_BOX); dropShadow.setRadius(0.015 * PREFERRED_WIDTH); dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH); knob = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, 4.5); knob.setStroke(null); knob.setFill(clock.getKnobColor()); knob.setEffect(dropShadow); shadowGroupHour = new Group(hour); shadowGroupMinute = new Group(minute); shadowGroupSecond = new Group(second); shadowGroupHour.setEffect(clock.getShadowsEnabled() ? dropShadow : null); shadowGroupMinute.setEffect(clock.getShadowsEnabled() ? dropShadow : null); shadowGroupSecond.setEffect(clock.getShadowsEnabled() ? dropShadow : null); title = new Text(""); title.setVisible(clock.isTitleVisible()); title.setManaged(clock.isTitleVisible()); text = new Text(""); text.setVisible(clock.isTextVisible()); text.setManaged(clock.isTextVisible()); pane = new Pane(sectionsAndAreasCanvas, tickCanvas, alarmPane, title, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond, knob); pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth())))); pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY))); getChildren().setAll(pane); }
Example 15
Source File: MosaicPane.java From Mosaic with Apache License 2.0 | 4 votes |
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 16
Source File: CustomPlainAmpSkin.java From medusademo with Apache License 2.0 | 4 votes |
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); } } ticksAndSectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); ticksAndSections = ticksAndSectionsCanvas.getGraphicsContext2D(); ledCanvas = new Canvas(); led = ledCanvas.getGraphicsContext2D(); thresholdTooltip = new Tooltip("Threshold\n(" + String.format(locale, formatString, gauge.getThreshold()) + ")"); thresholdTooltip.setTextAlignment(TextAlignment.CENTER); threshold = new Path(); Helper.enableNode(threshold, gauge.isThresholdVisible()); Tooltip.install(threshold, thresholdTooltip); average = new Path(); Helper.enableNode(average, gauge.isAverageVisible()); markerPane = new Pane(); needleRotate = new Rotate(180 - START_ANGLE); needleRotate.setAngle(needleRotate.getAngle() + (gauge.getValue() - oldValue - gauge.getMinValue()) * angleStep); needleMoveTo1 = new MoveTo(); needleCubicCurveTo2 = new CubicCurveTo(); needleCubicCurveTo3 = new CubicCurveTo(); needleCubicCurveTo4 = new CubicCurveTo(); needleLineTo5 = new LineTo(); needleCubicCurveTo6 = new CubicCurveTo(); needleClosePath7 = new ClosePath(); needle = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleLineTo5, needleCubicCurveTo6, needleClosePath7); needle.setFillRule(FillRule.EVEN_ODD); needle.getTransforms().setAll(needleRotate); needle.getStyleClass().add("needle"); dropShadow = new DropShadow(); dropShadow.setColor(Color.rgb(0, 0, 0, 0.25)); dropShadow.setBlurType(BlurType.TWO_PASS_BOX); dropShadow.setRadius(0.015 * PREFERRED_WIDTH); dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH); shadowGroup = new Group(needle); shadowGroup.setEffect(gauge.isShadowsEnabled() ? dropShadow : null); shadowGroup.getStyleClass().add("shadow-group"); unitText = new Text(gauge.getUnit()); unitText.setMouseTransparent(true); unitText.setTextOrigin(VPos.CENTER); unitText.getStyleClass().add("unit"); lcd = new Rectangle(0.3 * PREFERRED_WIDTH, 0.1 * PREFERRED_HEIGHT); lcd.setArcWidth(0.0125 * PREFERRED_HEIGHT); lcd.setArcHeight(0.0125 * PREFERRED_HEIGHT); lcd.relocate((PREFERRED_WIDTH - lcd.getWidth()) * 0.5, 0.66 * PREFERRED_HEIGHT); lcd.getStyleClass().add("lcd"); Helper.enableNode(lcd, gauge.isLcdVisible() && gauge.isValueVisible()); lcdText = new Label(String.format(locale, "%." + gauge.getDecimals() + "f", gauge.getValue())); lcdText.setAlignment(Pos.CENTER_RIGHT); lcdText.setVisible(gauge.isValueVisible()); lcdText.getStyleClass().add("lcd-foreground"); // Set initial value angleStep = ANGLE_RANGE / gauge.getRange(); double targetAngle = 180 - START_ANGLE + (gauge.getValue() - gauge.getMinValue()) * angleStep; targetAngle = clamp(180 - START_ANGLE, 180 - START_ANGLE + ANGLE_RANGE, targetAngle); needleRotate.setAngle(targetAngle); // Add all nodes pane = new Pane(); pane.getChildren().setAll(ticksAndSectionsCanvas, markerPane, ledCanvas, unitText, lcd, lcdText, shadowGroup); pane.getStyleClass().add("background-pane"); getChildren().setAll(pane); }
Example 17
Source File: TimerControlTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); currentValueListener = o -> { if (tile.isRunning()) { return; } // Update time only if clock is not already running updateTime(ZonedDateTime.ofInstant(Instant.ofEpochSecond(tile.getCurrentTime()), ZoneId.of(ZoneId.systemDefault().getId()))); }; timeListener = o -> updateTime(tile.getTime()); dateFormatter = DateTimeFormatter.ofPattern("EE d", tile.getLocale()); sectionMap = new HashMap<>(tile.getTimeSections().size()); for (TimeSection section : tile.getTimeSections()) { sectionMap.put(section, new Arc()); } minuteRotate = new Rotate(); hourRotate = new Rotate(); secondRotate = new Rotate(); sectionsPane = new Pane(); sectionsPane.getChildren().addAll(sectionMap.values()); Helper.enableNode(sectionsPane, tile.getSectionsVisible()); minuteTickMarks = new Path(); minuteTickMarks.setFillRule(FillRule.EVEN_ODD); minuteTickMarks.setFill(null); minuteTickMarks.setStroke(tile.getMinuteColor()); minuteTickMarks.setStrokeLineCap(StrokeLineCap.ROUND); hourTickMarks = new Path(); hourTickMarks.setFillRule(FillRule.EVEN_ODD); hourTickMarks.setFill(null); hourTickMarks.setStroke(tile.getHourColor()); hourTickMarks.setStrokeLineCap(StrokeLineCap.ROUND); hour = new Rectangle(3, 60); hour.setArcHeight(3); hour.setArcWidth(3); hour.setStroke(tile.getHourColor()); hour.getTransforms().setAll(hourRotate); minute = new Rectangle(3, 96); minute.setArcHeight(3); minute.setArcWidth(3); minute.setStroke(tile.getMinuteColor()); minute.getTransforms().setAll(minuteRotate); second = new Rectangle(1, 96); second.setArcHeight(1); second.setArcWidth(1); second.setStroke(tile.getSecondColor()); second.getTransforms().setAll(secondRotate); second.setVisible(tile.isSecondsVisible()); second.setManaged(tile.isSecondsVisible()); knob = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, 4.5); knob.setStroke(Color.web("#282a3280")); dropShadow = new DropShadow(); dropShadow.setColor(Color.rgb(0, 0, 0, 0.25)); dropShadow.setBlurType(BlurType.TWO_PASS_BOX); dropShadow.setRadius(0.015 * PREFERRED_WIDTH); dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH); shadowGroupHour = new Group(hour); shadowGroupMinute = new Group(minute); shadowGroupSecond = new Group(second, knob); shadowGroupHour.setEffect(tile.isShadowsEnabled() ? dropShadow : null); shadowGroupMinute.setEffect(tile.isShadowsEnabled() ? dropShadow : null); shadowGroupSecond.setEffect(tile.isShadowsEnabled() ? dropShadow : null); titleText = new Text(""); titleText.setTextOrigin(VPos.TOP); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); amPmText = new Text(tile.getTime().get(ChronoField.AMPM_OF_DAY) == 0 ? "AM" : "PM"); dateText = new Text(""); Helper.enableNode(dateText, tile.isDateVisible()); text = new Text(""); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(sectionsPane, hourTickMarks, minuteTickMarks, titleText, amPmText, dateText, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond); }
Example 18
Source File: PearClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
@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); } } sectionsAndAreasCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); sectionsAndAreasCtx = sectionsAndAreasCanvas.getGraphicsContext2D(); tickCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); tickCtx = tickCanvas.getGraphicsContext2D(); alarmPane = new Pane(); hour = new Path(); hour.setFillRule(FillRule.EVEN_ODD); hour.setStroke(null); hour.getTransforms().setAll(hourRotate); minute = new Path(); minute.setFillRule(FillRule.EVEN_ODD); minute.setStroke(null); minute.getTransforms().setAll(minuteRotate); second = new Path(); second.setFillRule(FillRule.EVEN_ODD); second.setStroke(null); second.getTransforms().setAll(secondRotate); second.setVisible(clock.isSecondsVisible()); second.setManaged(clock.isSecondsVisible()); dropShadow = new DropShadow(); dropShadow.setColor(Color.rgb(0, 0, 0, 0.25)); dropShadow.setBlurType(BlurType.TWO_PASS_BOX); dropShadow.setRadius(0.015 * PREFERRED_WIDTH); dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH); shadowGroupHour = new Group(hour); shadowGroupMinute = new Group(minute); shadowGroupSecond = new Group(second); shadowGroupHour.setEffect(clock.getShadowsEnabled() ? dropShadow : null); shadowGroupMinute.setEffect(clock.getShadowsEnabled() ? dropShadow : null); shadowGroupSecond.setEffect(clock.getShadowsEnabled() ? dropShadow : null); title = new Text(""); title.setVisible(clock.isTitleVisible()); title.setManaged(clock.isTitleVisible()); dateText = new Text(""); dateText.setVisible(clock.isDateVisible()); dateText.setManaged(clock.isDateVisible()); dateNumber = new Text(""); dateNumber.setVisible(clock.isDateVisible()); dateNumber.setManaged(clock.isDateVisible()); text = new Text(""); text.setVisible(clock.isTextVisible()); text.setManaged(clock.isTextVisible()); pane = new Pane(sectionsAndAreasCanvas, tickCanvas, alarmPane, title, dateText, dateNumber, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond); pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(clock.getBorderWidth())))); pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY))); getChildren().setAll(pane); }
Example 19
Source File: MainScene.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void createBlend() { blend = new Blend(); blend.setMode(BlendMode.MULTIPLY); DropShadow ds = new DropShadow(); ds.setColor(Color.rgb(254, 235, 66, 0.3)); ds.setOffsetX(5); ds.setOffsetY(5); ds.setRadius(5); ds.setSpread(0.2); blend.setBottomInput(ds); DropShadow ds1 = new DropShadow(); ds1.setColor(Color.web("#d68268")); // #d68268 is pinkish orange//f13a00")); ds1.setRadius(20); ds1.setSpread(0.2); Blend blend2 = new Blend(); blend2.setMode(BlendMode.MULTIPLY); InnerShadow is = new InnerShadow(); is.setColor(Color.web("#feeb42")); // #feeb42 is mid-pale yellow is.setRadius(9); is.setChoke(0.8); blend2.setBottomInput(is); InnerShadow is1 = new InnerShadow(); is1.setColor(Color.web("#278206")); // # f13a00 is bright red // 278206 is dark green is1.setRadius(5); is1.setChoke(0.4); blend2.setTopInput(is1); Blend blend1 = new Blend(); blend1.setMode(BlendMode.MULTIPLY); blend1.setBottomInput(ds1); blend1.setTopInput(blend2); blend.setTopInput(blend1); }
Example 20
Source File: TimerControlTileSkin.java From OEE-Designer with MIT License | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); currentValueListener = o -> { if (tile.isRunning()) { return; } // Update time only if clock is not already running updateTime(ZonedDateTime.ofInstant(Instant.ofEpochSecond(tile.getCurrentTime()), ZoneId.of(ZoneId.systemDefault().getId()))); }; timeListener = o -> updateTime(tile.getTime()); dateFormatter = DateTimeFormatter.ofPattern("EE d", tile.getLocale()); sectionMap = new HashMap<>(tile.getTimeSections().size()); for (TimeSection section : tile.getTimeSections()) { sectionMap.put(section, new Arc()); } minuteRotate = new Rotate(); hourRotate = new Rotate(); secondRotate = new Rotate(); sectionsPane = new Pane(); sectionsPane.getChildren().addAll(sectionMap.values()); Helper.enableNode(sectionsPane, tile.getSectionsVisible()); minuteTickMarks = new Path(); minuteTickMarks.setFillRule(FillRule.EVEN_ODD); minuteTickMarks.setFill(null); minuteTickMarks.setStroke(tile.getMinuteColor()); minuteTickMarks.setStrokeLineCap(StrokeLineCap.ROUND); hourTickMarks = new Path(); hourTickMarks.setFillRule(FillRule.EVEN_ODD); hourTickMarks.setFill(null); hourTickMarks.setStroke(tile.getHourColor()); hourTickMarks.setStrokeLineCap(StrokeLineCap.ROUND); hour = new Rectangle(3, 60); hour.setArcHeight(3); hour.setArcWidth(3); hour.setStroke(tile.getHourColor()); hour.getTransforms().setAll(hourRotate); minute = new Rectangle(3, 96); minute.setArcHeight(3); minute.setArcWidth(3); minute.setStroke(tile.getMinuteColor()); minute.getTransforms().setAll(minuteRotate); second = new Rectangle(1, 96); second.setArcHeight(1); second.setArcWidth(1); second.setStroke(tile.getSecondColor()); second.getTransforms().setAll(secondRotate); second.setVisible(tile.isSecondsVisible()); second.setManaged(tile.isSecondsVisible()); knob = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, 4.5); knob.setStroke(Color.web("#282a3280")); dropShadow = new DropShadow(); dropShadow.setColor(Color.rgb(0, 0, 0, 0.25)); dropShadow.setBlurType(BlurType.TWO_PASS_BOX); dropShadow.setRadius(0.015 * PREFERRED_WIDTH); dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH); shadowGroupHour = new Group(hour); shadowGroupMinute = new Group(minute); shadowGroupSecond = new Group(second, knob); shadowGroupHour.setEffect(tile.isShadowsEnabled() ? dropShadow : null); shadowGroupMinute.setEffect(tile.isShadowsEnabled() ? dropShadow : null); shadowGroupSecond.setEffect(tile.isShadowsEnabled() ? dropShadow : null); titleText = new Text(""); titleText.setTextOrigin(VPos.TOP); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); amPmText = new Text(tile.getTime().get(ChronoField.AMPM_OF_DAY) == 0 ? "AM" : "PM"); dateText = new Text(""); Helper.enableNode(dateText, tile.isDateVisible()); text = new Text(""); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(sectionsPane, hourTickMarks, minuteTickMarks, titleText, amPmText, dateText, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond); }