Java Code Examples for javafx.scene.text.Text#setMouseTransparent()
The following examples show how to use
javafx.scene.text.Text#setMouseTransparent() .
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: RadialMovieMenu.java From RadialFx with GNU Lesser General Public License v3.0 | 7 votes |
private List<Text> getTextNodes(final String title, final double startAngle) { final List<Text> texts = new ArrayList<Text>(); final char[] titleCharArray = title.toCharArray(); for (int i = titleCharArray.length - 1; i >= 0; i--) { final Text charText = new Text( Character.toString(titleCharArray[i])); charText.setFontSmoothingType(FontSmoothingType.LCD); charText.setSmooth(true); charText.setMouseTransparent(true); charText.setFill(textColor); charText.setBlendMode(BlendMode.COLOR_BURN); charText.setFont(textFont); texts.add(charText); } return texts; }
Example 2
Source File: LinearSkin.java From WorkbenchFX with Apache License 2.0 | 5 votes |
@Override public void initializeParts() { value = new Text(0, ARTBOARD_HEIGHT * 0.5, String.format(FORMAT, getSkinnable().getValue())); value.getStyleClass().add("value"); value.setTextOrigin(VPos.CENTER); value.setTextAlignment(TextAlignment.CENTER); value.setMouseTransparent(true); value.setWrappingWidth(ARTBOARD_HEIGHT); value.setBoundsType(TextBoundsType.VISUAL); thumb = new Circle(ARTBOARD_HEIGHT * 0.5, ARTBOARD_HEIGHT * 0.5, ARTBOARD_HEIGHT * 0.5); thumb.getStyleClass().add("thumb"); thumbGroup = new Group(thumb, value); valueBar = new Line(); valueBar.getStyleClass().add("valueBar"); valueBar.setStrokeLineCap(StrokeLineCap.ROUND); applyCss(valueBar); strokeWidthFromCSS = valueBar.getStrokeWidth(); scale = new Line(); scale.getStyleClass().add("scale"); scale.setStrokeLineCap(StrokeLineCap.ROUND); // always needed drawingPane = new Pane(); }
Example 3
Source File: PushButtonSkin.java From Enzo with Apache License 2.0 | 5 votes |
private void initGraphics() { frame = new Region(); frame.getStyleClass().setAll("frame"); outerBorder = new Region(); outerBorder.getStyleClass().setAll("outer-border"); innerBorder = new Region(); innerBorder.getStyleClass().setAll("inner-border"); body = new Region(); body.getStyleClass().setAll("body"); body.setMouseTransparent(true); text = new Text("Push"); text.setTextOrigin(VPos.CENTER); text.setMouseTransparent(true); text.getStyleClass().setAll("text"); pane.getChildren().setAll(frame, outerBorder, innerBorder, body, text); getChildren().setAll(pane); resize(); }
Example 4
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 5
Source File: PlainAmpSkin.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); 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.66 * 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); // Add all nodes pane = new Pane(); pane.getChildren().setAll(ticksAndSectionsCanvas, markerPane, ledCanvas, unitText, lcd, lcdText, shadowGroup); getChildren().setAll(pane); }
Example 6
Source File: SectionSkin.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); } } ring = new Path(); ring.setFillRule(FillRule.EVEN_ODD); ring.setStroke(null); ring.setFill(Gauge.DARK_COLOR); ring.setEffect(new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.35), 1, 0, 0, 1)); sectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); sectionsCtx = sectionsCanvas.getGraphicsContext2D(); mask = new Circle(); mask.setStroke(null); mask.setFill(gauge.getBackgroundPaint()); knob = new Circle(); knob.setStroke(null); knob.setFill(gauge.getKnobColor()); angleStep = ANGLE_RANGE / (gauge.getRange()); double targetAngle = 180 - START_ANGLE + (gauge.getValue() - gauge.getMinValue()) * angleStep; needleRotate = new Rotate(180 - START_ANGLE); needleRotate.setAngle(Helper.clamp(180 - START_ANGLE, 180 - START_ANGLE + ANGLE_RANGE, targetAngle)); needle = new Path(); needle.setFillRule(FillRule.EVEN_ODD); needle.setStroke(null); needle.getTransforms().setAll(needleRotate); valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getMinValue()) + gauge.getUnit()); valueText.setMouseTransparent(true); valueText.setTextOrigin(VPos.CENTER); valueText.setFill(gauge.getValueColor()); Helper.enableNode(valueText, gauge.isValueVisible()); titleText = new Text(gauge.getTitle()); titleText.setTextOrigin(VPos.CENTER); titleText.setFill(gauge.getTitleColor()); Helper.enableNode(titleText, !gauge.getTitle().isEmpty()); // Add all nodes pane = new Pane(ring, sectionsCanvas, mask, knob, needle, valueText, titleText); getChildren().setAll(pane); }
Example 7
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 8
Source File: SimpleSkin.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); } } sectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); sectionsCtx = sectionsCanvas.getGraphicsContext2D(); needleRotate = new Rotate(180 - START_ANGLE); angleStep = ANGLE_RANGE / (gauge.getRange()); double targetAngle = 180 - START_ANGLE + (gauge.getValue() - gauge.getMinValue()) * angleStep; needleRotate.setAngle(Helper.clamp(180 - START_ANGLE, 180 - START_ANGLE + ANGLE_RANGE, targetAngle)); needleMoveTo1 = new MoveTo(); needleCubicCurveTo2 = new CubicCurveTo(); needleCubicCurveTo3 = new CubicCurveTo(); needleCubicCurveTo4 = new CubicCurveTo(); needleLineTo5 = new LineTo(); needleLineTo6 = new LineTo(); needleCubicCurveTo7 = new CubicCurveTo(); needleClosePath8 = new ClosePath(); needle = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleLineTo5, needleLineTo6, needleCubicCurveTo7, needleClosePath8); needle.setFillRule(FillRule.EVEN_ODD); needle.getTransforms().setAll(needleRotate); needle.setFill(gauge.getNeedleColor()); needle.setStroke(gauge.getBorderPaint()); needle.setStrokeLineCap(StrokeLineCap.ROUND); needle.setStrokeLineJoin(StrokeLineJoin.BEVEL); valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getMinValue()) + gauge.getUnit()); valueText.setMouseTransparent(true); valueText.setTextOrigin(VPos.CENTER); valueText.setFill(gauge.getValueColor()); enableNode(valueText, gauge.isValueVisible()); titleText = new Text(gauge.getTitle()); titleText.setTextOrigin(VPos.CENTER); titleText.setFill(gauge.getTitleColor()); enableNode(titleText, !gauge.getTitle().isEmpty()); subTitleText = new Text(gauge.getSubTitle()); subTitleText.setTextOrigin(VPos.CENTER); subTitleText.setFill(gauge.getSubTitleColor()); enableNode(subTitleText, !gauge.getSubTitle().isEmpty()); // Add all nodes pane = new Pane(sectionsCanvas, needle, valueText, titleText, subTitleText); getChildren().setAll(pane); }
Example 9
Source File: LevelSkin.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); } } tube = new Path(); tube.setFillRule(FillRule.EVEN_ODD); tube.setStroke(null); Tooltip.install(tube, barTooltip); tubeTop = new Ellipse(); tubeTop.setStroke(Color.rgb(255, 255, 255, 0.5)); tubeTop.setStrokeType(StrokeType.INSIDE); tubeTop.setStrokeWidth(1); tubeBottom = new Ellipse(); tubeBottom.setStroke(null); fluidUpperLeft = new CubicCurveTo(0.21794871794871795 * PREFERRED_WIDTH, 0.24444444444444444 * PREFERRED_HEIGHT, 0.0, 0.18888888888888888 * PREFERRED_HEIGHT, 0.0, 0.12222222222222222 * PREFERRED_HEIGHT); fluidUpperCenter = new CubicCurveTo(PREFERRED_WIDTH, 0.18888888888888888 * PREFERRED_HEIGHT, 0.782051282051282 * PREFERRED_WIDTH, 0.24444444444444444 * PREFERRED_HEIGHT, 0.5 * PREFERRED_WIDTH, 0.24444444444444444 * PREFERRED_HEIGHT); fluidUpperRight = new CubicCurveTo(PREFERRED_WIDTH, 0.7111111111111111 * PREFERRED_HEIGHT, PREFERRED_WIDTH, 0.12222222222222222 * PREFERRED_HEIGHT, PREFERRED_WIDTH, 0.12222222222222222 * PREFERRED_HEIGHT); fluidBody = new Path(); fluidBody.getElements().add(new MoveTo(0.0, 0.7111111111111111 * PREFERRED_HEIGHT)); fluidBody.getElements().add(new CubicCurveTo(0.0, 0.7777777777777778 * PREFERRED_HEIGHT, 0.21794871794871795 * PREFERRED_WIDTH, 0.8333333333333334 * PREFERRED_HEIGHT, 0.5 * PREFERRED_WIDTH, 0.8333333333333334 * PREFERRED_HEIGHT)); fluidBody.getElements().add(new CubicCurveTo(0.782051282051282 * PREFERRED_WIDTH, 0.8333333333333334 * PREFERRED_HEIGHT, PREFERRED_WIDTH, 0.7777777777777778 * PREFERRED_HEIGHT, PREFERRED_WIDTH, 0.7111111111111111 * PREFERRED_HEIGHT)); fluidBody.getElements().add(fluidUpperRight); fluidBody.getElements().add(fluidUpperCenter); fluidBody.getElements().add(fluidUpperLeft); fluidBody.getElements().add(new CubicCurveTo(0.0, 0.12222222222222222 * PREFERRED_HEIGHT, 0.0, 0.7111111111111111 * PREFERRED_HEIGHT, 0.0, 0.7111111111111111 * PREFERRED_HEIGHT)); fluidBody.getElements().add(new ClosePath()); fluidBody.setFillRule(FillRule.EVEN_ODD); fluidBody.setStroke(null); fluidTop = new Ellipse(); fluidTop.setStroke(null); valueText = new Text(String.format(locale, formatString, gauge.getCurrentValue())); valueText.setMouseTransparent(true); Helper.enableNode(valueText, gauge.isValueVisible()); titleText = new Text(gauge.getTitle()); // Add all nodes pane = new Pane(tubeBottom, fluidBody, fluidTop, tube, tubeTop, valueText, titleText); pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth())))); pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY))); getChildren().setAll(pane); }
Example 10
Source File: ColorRegulator.java From regulators with Apache License 2.0 | 4 votes |
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 11
Source File: HeatControlSkin.java From Enzo with Apache License 2.0 | 4 votes |
private void initGraphics() { innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), PREFERRED_HEIGHT * 0.1, 0, 0, 0); Color color = gradientLookup.getColorAt(getSkinnable().getValue() / (getSkinnable().getMaxValue() - getSkinnable().getMinValue())); background = new Circle(0.5 * PREFERRED_WIDTH, 0.5 * PREFERRED_HEIGHT, 0.5 * PREFERRED_WIDTH); background.setFill(new LinearGradient(0, 0, 0, PREFERRED_HEIGHT, false, CycleMethod.NO_CYCLE, new Stop(0, color.deriveColor(0, 1, 0.8, 1)), new Stop(1, color.deriveColor(0, 1, 0.6, 1)))); background.setEffect(innerShadow); ticksCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); ticksCanvas.setMouseTransparent(true); ticks = ticksCanvas.getGraphicsContext2D(); targetIndicator = new Region(); targetIndicator.getStyleClass().setAll("target-indicator"); targetIndicatorRotate = new Rotate(180 - getSkinnable().getStartAngle() - getSkinnable().getMinValue() * angleStep); targetIndicator.getTransforms().setAll(targetIndicatorRotate); targetExceeded = false; targetIndicator.setVisible(getSkinnable().isTargetEnabled()); valueIndicator = new Region(); valueIndicator.getStyleClass().setAll("value-indicator"); valueIndicatorRotate = new Rotate(180 - getSkinnable().getStartAngle()); valueIndicatorRotate.setAngle(valueIndicatorRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue() - getSkinnable().getMinValue()) * angleStep); valueIndicator.getTransforms().setAll(valueIndicatorRotate); infoText = new Text(getSkinnable().getInfoText().toUpperCase()); infoText.setTextOrigin(VPos.CENTER); infoText.setFont(Fonts.opensansSemiBold(0.06 * PREFERRED_HEIGHT)); infoText.setMouseTransparent(true); infoText.getStyleClass().setAll("info-text"); value = new Text(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getValue())); value.setMouseTransparent(true); value.setTextOrigin(VPos.CENTER); value.setFont(Fonts.opensansBold(0.32 * PREFERRED_HEIGHT)); value.setMouseTransparent(true); value.getStyleClass().setAll("value"); // Add all nodes pane = new Pane(); pane.getChildren().setAll(background, ticksCanvas, valueIndicator, targetIndicator, infoText, value); getChildren().setAll(pane); }
Example 12
Source File: SimpleGaugeSkin.java From Enzo with Apache License 2.0 | 4 votes |
private void initGraphics() { Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.06 * PREFERRED_HEIGHT)); // "OpenSans" sectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); sectionsCtx = sectionsCanvas.getGraphicsContext2D(); measuredRangeCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); measuredRangeCanvas.setManaged(getSkinnable().isMeasuredRangeVisible()); measuredRangeCanvas.setVisible(getSkinnable().isMeasuredRangeVisible()); measuredRangeCtx = measuredRangeCanvas.getGraphicsContext2D(); if (getSkinnable().getValue() < getSkinnable().getMinValue()) getSkinnable().setValue(getSkinnable().getMinValue()); if (getSkinnable().getValue() > getSkinnable().getMaxValue()) getSkinnable().setValue(getSkinnable().getMaxValue()); needleRotate = new Rotate(180 - getSkinnable().getStartAngle()); if (getSkinnable().getMinValue() < 0) { needleRotate.setAngle(needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue() - getSkinnable().getMinValue()) * angleStep); } else { //needleRotate.setAngle(needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue() + getSkinnable().getMinValue()) * angleStep); } angleStep = getSkinnable().getAngleRange() / (getSkinnable().getMaxValue() - getSkinnable().getMinValue()); needleRotate.setAngle(needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue()) * angleStep); needle = new Path(); needle.setFillRule(FillRule.EVEN_ODD); needle.getStyleClass().setAll("needle"); needle.getTransforms().setAll(needleRotate); value = new Text(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getMinValue()) + getSkinnable().getUnit()); value.setMouseTransparent(true); value.setTextOrigin(VPos.CENTER); value.getStyleClass().setAll("value"); title = new Text(getSkinnable().getTitle()); title.setTextOrigin(VPos.CENTER); title.getStyleClass().setAll("title"); // Add all nodes pane = new Pane(); pane.getStyleClass().add("simple-gauge"); pane.getChildren().setAll(sectionsCanvas, measuredRangeCanvas, needle, value, title); getChildren().setAll(pane); resize(); }