Java Code Examples for javafx.scene.transform.Rotate#setAngle()
The following examples show how to use
javafx.scene.transform.Rotate#setAngle() .
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: SplitFlapSkin.java From Enzo with Apache License 2.0 | 6 votes |
public SplitFlapSkin(final SplitFlap CONTROL) { super(CONTROL); FLIP_FINISHED = new FlipEvent(this, getSkinnable(), FlipEvent.FLIP_FINISHED); selectedSet = getSkinnable().getSelectedSet(); currentSelectionIndex = getSkinnable().getSelectedSet().indexOf(getSkinnable().getText()); nextSelectionIndex = currentSelectionIndex + 1 > getSkinnable().getSelectedSet().size() ? 0 : currentSelectionIndex + 1; aspectRatio = PREFERRED_HEIGHT / PREFERRED_WIDTH; pane = new Pane(); rotateFlap = new Rotate(); rotateFlap.setAxis(Rotate.X_AXIS); rotateFlap.setAngle(0); flapHeight = 0.49206349206349204 * PREFERRED_HEIGHT; timeline = new Timeline(); init(); initGraphics(); registerListeners(); }
Example 2
Source File: TagBoard.java From OpenLabeler with Apache License 2.0 | 5 votes |
private void initModel(Annotation model) { scale = new Scale(1, 1); translate = new Translate(PADDING, PADDING); rotate = new Rotate(); board.getTransforms().setAll(scale, rotate); scale.addEventHandler(TransformChangedEvent.TRANSFORM_CHANGED, event -> { // Maintain constant padding at different zoom level board.setPadding(new Insets(max(PADDING / scale.getX(), PADDING / scale.getY()))); canvas.setWidth(imageView.getBoundsInLocal().getWidth()); canvas.setHeight(imageView.getBoundsInLocal().getHeight()); }); scale.setX(1); scale.setY(1); rotate.setAngle(0); selectedObjectProperty.setValue(null); tagCoordsProperty.set(""); objectsProperty.clear(); hintsProperty.clear(); imageView.setImage(model == null ? null : model.getSize().getImage()); imageView.setCache(true); if (model != null && model.getObjects().size() > 0) { model.getObjects().forEach(obj -> createObjectTag(obj)); statusProperty.set(MessageFormat.format(bundle.getString("msg.objectsCount"), model.getObjects().size())); } else { statusProperty.set(bundle.getString("msg.noObjects")); } findHints(); }
Example 3
Source File: JFXTimePickerContent.java From JFoenix with Apache License 2.0 | 5 votes |
private StackPane createMinutesContent(LocalTime time) { // create minutes content StackPane minsPointer = new StackPane(); Circle selectionCircle = new Circle(contentCircleRadius / 6); selectionCircle.fillProperty().bind(timePicker.defaultColorProperty()); Circle minCircle = new Circle(selectionCircle.getRadius() / 8); minCircle.setFill(Color.rgb(255, 255, 255, 0.87)); minCircle.setTranslateX(selectionCircle.getRadius() - minCircle.getRadius()); minCircle.setVisible(time.getMinute() % 5 != 0); selectedMinLabel.textProperty().addListener((o, oldVal, newVal) -> { if (Integer.parseInt(newVal) % 5 == 0) { minCircle.setVisible(false); } else { minCircle.setVisible(true); } }); double shift = 9; Line line = new Line(shift, 0, contentCircleRadius, 0); line.fillProperty().bind(timePicker.defaultColorProperty()); line.strokeProperty().bind(line.fillProperty()); line.setStrokeWidth(1.5); minsPointer.getChildren().addAll(line, selectionCircle, minCircle); StackPane.setAlignment(selectionCircle, Pos.CENTER_LEFT); StackPane.setAlignment(minCircle, Pos.CENTER_LEFT); Group pointerGroup = new Group(); pointerGroup.getChildren().add(minsPointer); pointerGroup.setTranslateX((-contentCircleRadius + shift) / 2); minsPointerRotate = new Rotate(0, contentCircleRadius - shift, selectionCircle.getRadius()); pointerGroup.getTransforms().add(minsPointerRotate); Pane clockLabelsContainer = new Pane(); // inner circle radius double radius = contentCircleRadius - shift - selectionCircle.getRadius(); for (int i = 0; i < 12; i++) { StackPane labelContainer = new StackPane(); int val = ((i + 3) * 5) % 60; Label label = new Label(String.valueOf(unitConverter.toString(val))); label.setFont(Font.font(ROBOTO, FontWeight.BOLD, 12)); // init label color label.setTextFill(val == time.getMinute() ? Color.rgb(255, 255, 255, 0.87) : Color.rgb(0, 0, 0, 0.87)); selectedMinLabel.textProperty().addListener((o, oldVal, newVal) -> { if (Integer.parseInt(newVal) == Integer.parseInt(label.getText())) { label.setTextFill(Color.rgb(255, 255, 255, 0.87)); } else { label.setTextFill(Color.rgb(0, 0, 0, 0.87)); } }); labelContainer.getChildren().add(label); double labelSize = (selectionCircle.getRadius() / Math.sqrt(2)) * 2; labelContainer.setMinSize(labelSize, labelSize); double angle = 2 * i * Math.PI / 12; double xOffset = radius * Math.cos(angle); double yOffset = radius * Math.sin(angle); final double startx = contentCircleRadius + xOffset; final double starty = contentCircleRadius + yOffset; labelContainer.setLayoutX(startx - labelContainer.getMinWidth() / 2); labelContainer.setLayoutY(starty - labelContainer.getMinHeight() / 2); // add label to the parent node clockLabelsContainer.getChildren().add(labelContainer); } minsPointerRotate.setAngle(180 + (time.getMinute() + 45) % 60 * Math.toDegrees(2 * Math.PI / 60)); return new StackPane(pointerGroup, clockLabelsContainer); }
Example 4
Source File: HeatControlSkin.java From Enzo with Apache License 2.0 | 5 votes |
private void touchRotate(final double X, final double Y, final Rotate ROTATE) { double theta = getTheta(X, Y); interactiveAngle = (theta + 90) % 360; double newValue = Double.compare(interactiveAngle, 180) <= 0 ? (interactiveAngle + 180.0 + getSkinnable().getStartAngle() - 360) / angleStep + getSkinnable().getMinValue(): (interactiveAngle - 180.0 + getSkinnable().getStartAngle() - 360) / angleStep + getSkinnable().getMinValue(); if (Double.compare(newValue, getSkinnable().getMinValue()) >= 0 && Double.compare(newValue, getSkinnable().getMaxValue()) <= 0) { ROTATE.setAngle(interactiveAngle); value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", newValue)); newTarget = value.getText(); resizeText(); } }
Example 5
Source File: RadialBargraphSkin.java From Enzo with Apache License 2.0 | 5 votes |
private void touchRotate(final double X, final double Y, final Rotate ROTATE) { double theta = getTheta(X, Y); interactiveAngle = (theta + 90) % 360; double newValue = Double.compare(interactiveAngle, 180) <= 0 ? (interactiveAngle + 180.0 + getSkinnable().getStartAngle() - 360) / angleStep : (interactiveAngle - 180.0 + getSkinnable().getStartAngle() - 360) / angleStep; if (Double.compare(newValue, getSkinnable().getMinValue()) >= 0 && Double.compare(newValue, getSkinnable().getMaxValue()) <= 0) { ROTATE.setAngle(interactiveAngle); value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", newValue)); resizeText(); } }
Example 6
Source File: GaugeSkin.java From Enzo with Apache License 2.0 | 5 votes |
private void touchRotate(final double X, final double Y, final Rotate ROTATE) { double theta = getTheta(X, Y); interactiveAngle = (theta + 90) % 360; double newValue = Double.compare(interactiveAngle, 180) <= 0 ? (interactiveAngle + 180.0 + getSkinnable().getStartAngle() - 360) / angleStep + getSkinnable().getMinValue(): (interactiveAngle - 180.0 + getSkinnable().getStartAngle() - 360) / angleStep + getSkinnable().getMinValue(); if (Double.compare(newValue, getSkinnable().getMinValue()) >= 0 && Double.compare(newValue, getSkinnable().getMaxValue()) <= 0) { ROTATE.setAngle(interactiveAngle); value.setText(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", newValue)); resizeText(); } }
Example 7
Source File: FlipTileSkin.java From OEE-Designer with MIT License | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); timeline = new Timeline(); characters = tile.getCharacterList(); currentSelectionIndex = 0; nextSelectionIndex = 1; centerX = PREFERRED_WIDTH * 0.5; centerY = PREFERRED_HEIGHT * 0.5; pane.setBackground(null); pane.setBorder(null); rotateFlap = new Rotate(); rotateFlap.setAxis(Rotate.X_AXIS); rotateFlap.setAngle(0); flapHeight = PREFERRED_HEIGHT * 0.495; upperBackground = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.495); upperBackgroundCtx = upperBackground.getGraphicsContext2D(); upperBackgroundText = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.495); upperBackgroundTextCtx = upperBackgroundText.getGraphicsContext2D(); upperBackgroundTextCtx.setTextBaseline(VPos.CENTER); upperBackgroundTextCtx.setTextAlign(TextAlignment.CENTER); lowerBackground = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.495); lowerBackgroundCtx = lowerBackground.getGraphicsContext2D(); lowerBackgroundText = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.495); lowerBackgroundTextCtx = lowerBackgroundText.getGraphicsContext2D(); lowerBackgroundTextCtx.setTextBaseline(VPos.CENTER); lowerBackgroundTextCtx.setTextAlign(TextAlignment.CENTER); flap = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.495); flap.getTransforms().add(rotateFlap); flapCtx = flap.getGraphicsContext2D(); flapTextFront = new Canvas(); flapTextFront.getTransforms().add(rotateFlap); flapTextFrontCtx = flapTextFront.getGraphicsContext2D(); flapTextFrontCtx.setTextBaseline(VPos.CENTER); flapTextFrontCtx.setTextAlign(TextAlignment.CENTER); flapTextBack = new Canvas(); flapTextBack.getTransforms().add(rotateFlap); flapTextBack.setOpacity(0); flapTextBackCtx = flapTextBack.getGraphicsContext2D(); flapTextBackCtx.setTextBaseline(VPos.CENTER); flapTextBackCtx.setTextAlign(TextAlignment.CENTER); pane.getChildren().addAll(upperBackground, lowerBackground, upperBackgroundText, lowerBackgroundText, flap, flapTextFront, flapTextBack); }
Example 8
Source File: FlipTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); timeline = new Timeline(); characters = tile.getCharacterList(); currentSelectionIndex = 0; nextSelectionIndex = 1; centerX = PREFERRED_WIDTH * 0.5; centerY = PREFERRED_HEIGHT * 0.5; pane.setBackground(null); pane.setBorder(null); rotateFlap = new Rotate(); rotateFlap.setAxis(Rotate.X_AXIS); rotateFlap.setAngle(0); flapHeight = PREFERRED_HEIGHT * 0.495; upperBackground = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.495); upperBackgroundCtx = upperBackground.getGraphicsContext2D(); upperBackgroundText = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.495); upperBackgroundTextCtx = upperBackgroundText.getGraphicsContext2D(); upperBackgroundTextCtx.setTextBaseline(VPos.CENTER); upperBackgroundTextCtx.setTextAlign(TextAlignment.CENTER); lowerBackground = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.495); lowerBackgroundCtx = lowerBackground.getGraphicsContext2D(); lowerBackgroundText = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.495); lowerBackgroundTextCtx = lowerBackgroundText.getGraphicsContext2D(); lowerBackgroundTextCtx.setTextBaseline(VPos.CENTER); lowerBackgroundTextCtx.setTextAlign(TextAlignment.CENTER); flap = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.495); flap.getTransforms().add(rotateFlap); flapCtx = flap.getGraphicsContext2D(); flapTextFront = new Canvas(); flapTextFront.getTransforms().add(rotateFlap); flapTextFrontCtx = flapTextFront.getGraphicsContext2D(); flapTextFrontCtx.setTextBaseline(VPos.CENTER); flapTextFrontCtx.setTextAlign(TextAlignment.CENTER); flapTextBack = new Canvas(); flapTextBack.getTransforms().add(rotateFlap); flapTextBack.setOpacity(0); flapTextBackCtx = flapTextBack.getGraphicsContext2D(); flapTextBackCtx.setTextBaseline(VPos.CENTER); flapTextBackCtx.setTextAlign(TextAlignment.CENTER); pane.getChildren().addAll(upperBackground, lowerBackground, upperBackgroundText, lowerBackgroundText, flap, flapTextFront, flapTextBack); }
Example 9
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 10
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 11
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 12
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 13
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 14
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 15
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(); }