javafx.scene.text.TextAlignment Java Examples
The following examples show how to use
javafx.scene.text.TextAlignment.
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: Watch.java From jace with GNU General Public License v2.0 | 8 votes |
public Watch(int address, final MetacheatUI outer) { super(); this.outer = outer; this.address = address; cell = outer.cheatEngine.getMemoryCell(address); redraw = outer.animationTimer.scheduleAtFixedRate(this::redraw, MetacheatUI.FRAME_RATE, MetacheatUI.FRAME_RATE, TimeUnit.MILLISECONDS); setBackground(new Background(new BackgroundFill(Color.NAVY, CornerRadii.EMPTY, Insets.EMPTY))); Label addrLabel = new Label("$" + Integer.toHexString(address)); addrLabel.setOnMouseClicked((evt)-> outer.inspectAddress(address)); addrLabel.setTextAlignment(TextAlignment.CENTER); addrLabel.setMinWidth(GRAPH_WIDTH); addrLabel.setFont(new Font(Font.getDefault().getFamily(), 14)); addrLabel.setTextFill(Color.WHITE); graph = new Canvas(GRAPH_WIDTH, GRAPH_HEIGHT); getChildren().add(addrLabel); getChildren().add(graph); CheckBox hold = new CheckBox("Hold"); holding = hold.selectedProperty(); holding.addListener((prop, oldVal, newVal) -> this.updateHold()); getChildren().add(hold); hold.setTextFill(Color.WHITE); }
Example #2
Source File: HappinessIndicator.java From tilesfx with Apache License 2.0 | 6 votes |
private void initGraphics() { if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) { if (getPrefWidth() > 0 && getPrefHeight() > 0) { setPrefSize(getPrefWidth(), getPrefHeight()); } else { setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); ctx = canvas.getGraphicsContext2D(); text = new Text(String.format(Locale.US, "%.0f%%", getValue() * 100.0)); text.setTextAlignment(TextAlignment.CENTER); text.setTextOrigin(VPos.TOP); text.setFill(getTextColor()); Helper.enableNode(text, getTextVisible()); getChildren().setAll(canvas, text); }
Example #3
Source File: AreaHeatMap.java From charts with Apache License 2.0 | 6 votes |
private void drawDataPoints() { ctx.setTextAlign(TextAlignment.CENTER); ctx.setTextBaseline(VPos.CENTER); ctx.setFont(Font.font(size * 0.0175)); for (int i = 0 ; i < points.size() ; i++) { DataPoint point = points.get(i); ctx.setFill(Color.rgb(255, 255, 255, 0.5)); ctx.fillOval(point.getX() - 8, point.getY() - 8, 16, 16); //ctx.setStroke(getUseColorMapping() ? getColorForValue(point.getValue(), 1) : getColorForValue(point.getValue(), isDiscreteColors())); ctx.setStroke(Color.BLACK); ctx.strokeOval(point.getX() - 8, point.getY() - 8, 16, 16); ctx.setFill(Color.BLACK); ctx.fillText(Long.toString(Math.round(point.getValue())), point.getX(), point.getY(), 16); } }
Example #4
Source File: ClockSkin.java From Enzo with Apache License 2.0 | 6 votes |
private void drawLogoLayer() { ctx.clearRect(0, 0, size, size); if (Clock.Design.BOSCH == getSkinnable().getDesign()) { ctx.setFill(getSkinnable().isNightMode() ? Color.rgb(240, 240, 240) : Color.rgb(10, 10, 10)); ctx.fillRect(size * 0.5 - 1, size * 0.18, 2, size * 0.27); ctx.fillRect(size * 0.5 - 1, size * 0.55, 2, size * 0.27); ctx.fillRect(size * 0.18, size * 0.5 - 1, size * 0.27, 2); ctx.fillRect(size * 0.55, size * 0.5 - 1, size * 0.27, 2); } if (getSkinnable().getText().isEmpty()) return; ctx.setFill(getSkinnable().isNightMode() ? Color.WHITE : Color.BLACK); ctx.setFont(Fonts.opensansSemiBold(size * 0.05)); ctx.setTextBaseline(VPos.CENTER); ctx.setTextAlign(TextAlignment.CENTER); ctx.fillText(getSkinnable().getText(), size * 0.5, size * 0.675, size * 0.8); }
Example #5
Source File: ClientLoginNode.java From helloiot with GNU General Public License v3.0 | 6 votes |
@Override public void updateItem(TopicInfo item, boolean empty) { super.updateItem(item, empty); if (item == null) { setGraphic(null); setText(null); } else { Text t = IconBuilder.create(item.getFactory().getGlyph(), 18.0).build(); t.setFill(Color.WHITE); TextFlow tf = new TextFlow(t); tf.setTextAlignment(TextAlignment.CENTER); tf.setPadding(new Insets(5, 5, 5, 5)); tf.setStyle("-fx-background-color: #505050; -fx-background-radius: 5px;"); tf.setPrefWidth(30.0); setGraphic(tf); String label = item.getLabel().getValue(); setText(item.getFactory().getTypeName() + ((label == null || label.isEmpty()) ? "" : " : " + label)); } }
Example #6
Source File: TextTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void initGraphics() { super.initGraphics(); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); description = new Label(tile.getDescription()); description.setAlignment(tile.getDescriptionAlignment()); description.setTextAlignment(TextAlignment.RIGHT); description.setWrapText(true); description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); description.setTextFill(tile.getTextColor()); description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795); Helper.enableNode(description, tile.isTextVisible()); text = new Text(tile.getText()); text.setFill(tile.getUnitColor()); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(titleText, text, description); }
Example #7
Source File: YOLOApp.java From java-ml-projects with Apache License 2.0 | 6 votes |
private void drawBoxes(List<DetectedObject> predictedObjects) { ctx.setLineWidth(3); int w = yoloModel.getInputWidth(); int h = yoloModel.getInputHeight(); int gridW = yoloModel.getGridW(); int gridH = yoloModel.getGridH(); ctx.setTextAlign(TextAlignment.CENTER); for (DetectedObject obj : predictedObjects) { String cl = yoloModel.getModelClasses()[obj.getPredictedClass()]; double[] xy1 = obj.getTopLeftXY(); double[] xy2 = obj.getBottomRightXY(); int x1 = (int) Math.round(w * xy1[0] / gridW); int y1 = (int) Math.round(h * xy1[1] / gridH); int x2 = (int) Math.round(w * xy2[0] / gridW); int y2 = (int) Math.round(h * xy2[1] / gridH); int rectW = x2 - x1; int rectH = y2 - y1; ctx.setStroke(colors.get(cl)); ctx.strokeRect(x1, y1, rectW, rectH); ctx.strokeText(cl, x1 + (rectW / 2), y1 - 2); ctx.setFill(Color.WHITE); ctx.fillText(cl, x1 + (rectW / 2), y1 - 2); } }
Example #8
Source File: RadarNodeChart.java From tilesfx with Apache License 2.0 | 6 votes |
private void drawText() { final double CENTER_X = 0.5 * width; final double CENTER_Y = 0.5 * height; final int NO_OF_SECTORS = getNoOfSectors(); Font font = Fonts.latoRegular(0.035 * size); double radAngle = RadarChartMode.SECTOR == getMode() ? Math.toRadians(180 + angleStep * 0.5) : Math.toRadians(180); double radAngleStep = Math.toRadians(angleStep); textGroup.getChildren().clear(); for (int i = 0 ; i < NO_OF_SECTORS ; i++) { double r = size * 0.48; double x = CENTER_X - size * 0.015 + (-Math.sin(radAngle) * r); double y = CENTER_Y + (+Math.cos(radAngle) * r); Text text = new Text(data.get(i).getName()); text.setFont(font); text.setFill(data.get(i).getTextColor()); text.setTextOrigin(VPos.CENTER); text.setTextAlignment(TextAlignment.CENTER); text.setRotate(Math.toDegrees(radAngle) - 180); text.setX(x); text.setY(y); textGroup.getChildren().add(text); radAngle += radAngleStep; } }
Example #9
Source File: SnapshotTable.java From phoebus with Eclipse Public License 1.0 | 6 votes |
private void setup(String text, String tooltip, int minWidth, int prefWidth, boolean resizable) { label = new Label(text); label.setTooltip(new Tooltip(tooltip)); label.setTextAlignment(TextAlignment.CENTER); setGraphic(label); if (minWidth != -1) { setMinWidth(minWidth); } if (prefWidth != -1) { setPrefWidth(prefWidth); } setResizable(resizable); // setOnEditStart(e -> controller.suspend()); // setOnEditCancel(e -> controller.resume()); // setOnEditCommit(e -> controller.resume()); this.text = text; }
Example #10
Source File: Tracker.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** Create tracker with restricted position range * @param restriction Bounds within which tracker will stay */ public Tracker(final Rectangle2D restriction) { this.restriction = restriction; tracker.getStyleClass().add("tracker"); handle_top_left = createHandle(); handle_top = createHandle(); handle_top_right = createHandle(); handle_right = createHandle(); handle_bottom_right = createHandle(); handle_bottom = createHandle(); handle_bottom_left = createHandle(); handle_left = createHandle(); locationLabel = createLabel(TextAlignment.LEFT, Pos.TOP_LEFT); sizeLabel = createLabel(TextAlignment.RIGHT, Pos.BOTTOM_RIGHT); getChildren().addAll(tracker, handle_top_left, handle_top, handle_top_right, handle_right, handle_bottom_right, handle_bottom, handle_bottom_left, handle_left, locationLabel, sizeLabel); hookEvents(); }
Example #11
Source File: StateTransitionEdgeViewer.java From JetUML with GNU General Public License v3.0 | 6 votes |
private void drawLabel(StateTransitionEdge pEdge, GraphicsContext pGraphics) { adjustLabelFont(pEdge); Rectangle2D labelBounds = getLabelBounds(pEdge); double x = labelBounds.getMinX(); double y = labelBounds.getMinY(); Paint oldFill = pGraphics.getFill(); Font oldFont = pGraphics.getFont(); pGraphics.translate(x, y); pGraphics.setFill(Color.BLACK); pGraphics.setFont(aFont); pGraphics.setTextAlign(TextAlignment.CENTER); pGraphics.fillText(pEdge.getMiddleLabel(), labelBounds.getWidth()/2, 0); pGraphics.setFill(oldFill); pGraphics.setFont(oldFont); pGraphics.translate(-x, -y); }
Example #12
Source File: TextTileSkin.java From OEE-Designer with MIT License | 6 votes |
@Override protected void initGraphics() { super.initGraphics(); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); description = new Label(tile.getDescription()); description.setAlignment(tile.getDescriptionAlignment()); description.setTextAlignment(TextAlignment.RIGHT); description.setWrapText(true); description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); description.setTextFill(tile.getDescriptionColor()); description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795); Helper.enableNode(description, tile.isTextVisible()); text = new Text(tile.getText()); text.setFill(tile.getUnitColor()); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(titleText, text, description); }
Example #13
Source File: LoginPane.java From pattypan with MIT License | 6 votes |
private void setContent() { TextFlow flow = new TextFlow(new Text(Util.text("login-intro")), link); flow.setTextAlignment(TextAlignment.CENTER); addElement(flow); addElement(loginText); addElement(passwordText); addElement(loginButton); addElement(loginStatus); if (!Settings.getSetting("user").isEmpty()) { loginText.setText(Settings.getSetting("user")); Platform.runLater(() -> { passwordText.requestFocus(); }); } }
Example #14
Source File: CharacterTileSkin.java From OEE-Designer with MIT License | 6 votes |
@Override protected void initGraphics() { super.initGraphics(); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); description = new Label(tile.getDescription()); description.setAlignment(Pos.CENTER); description.setTextAlignment(TextAlignment.CENTER); description.setWrapText(true); description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); description.setTextFill(tile.getTextColor()); description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795); Helper.enableNode(description, tile.isTextVisible()); text = new Text(tile.getText()); text.setFill(tile.getUnitColor()); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(titleText, text, description); }
Example #15
Source File: CreateFilePane.java From pattypan with MIT License | 6 votes |
private void showOpenFileButton() { Hyperlink link = new Hyperlink(Util.text("create-file-open")); TextFlow flow = new TextFlow(new WikiLabel("create-file-success"), link); flow.setTextAlignment(TextAlignment.CENTER); addElement(flow); link.setOnAction(ev -> { try { Desktop.getDesktop().open(Session.FILE); } catch (IOException ex) { Session.LOGGER.log(Level.WARNING, "Cannot open file: {0}", new String[]{ex.getLocalizedMessage()} ); } }); nextButton.linkTo("StartPane", stage, true).setText(Util.text("create-file-back-to-start")); nextButton.setVisible(true); }
Example #16
Source File: YOLOApp.java From java-ml-projects with Apache License 2.0 | 5 votes |
private Parent buildCenterPane() { Canvas canvas = new Canvas(yoloModel.getInputWidth(), yoloModel.getInputHeight()); Parent spCanvas = ZoomPane.createZoomPane(new Group(canvas)); ctx = canvas.getGraphicsContext2D(); ctx.setTextAlign(TextAlignment.CENTER); ctx.fillText("Loading the model. This may take a while...", canvas.getWidth() / 2, canvas.getHeight() / 2); return spCanvas; }
Example #17
Source File: WikiPane.java From pattypan with MIT License | 5 votes |
public void addElement(String text, String cssClass, int height) { WikiLabel label = new WikiLabel(text).setWrapped(true); label.setTextAlignment(TextAlignment.LEFT); label.setClass(cssClass); VBox box = new VBox(); box.getChildren().add(label); box.setMinHeight(height); addElement(box); }
Example #18
Source File: Timer.java From Quelea with GNU General Public License v3.0 | 5 votes |
private TextAlignment alignmentFromIndex(int index) { switch (index) { case -1: return TextAlignment.LEFT; case 0: return TextAlignment.CENTER; case 1: return TextAlignment.RIGHT; } return TextAlignment.CENTER; }
Example #19
Source File: AboutWindow.java From kafka-message-tool with MIT License | 5 votes |
private void initAboutContent() { final Text appNameText = getAppNameText(); final Text appVersionText = getAppVersionText(); final Text authorText = getAuthorText(); textFlow.setTextAlignment(TextAlignment.CENTER); textFlow.getChildren().addAll(appNameText, new Text("\n"), appVersionText, new Text("\n\n"), authorText, new Text("\n\n"), new Text("Source: " ), sourceCodePage); }
Example #20
Source File: LcdClockSkin.java From Medusa with Apache License 2.0 | 5 votes |
private void updateBackgroundText() { // Setup the semitransparent background timeText backgroundTimeText.setTextOrigin(VPos.BASELINE); backgroundTimeText.setTextAlignment(TextAlignment.RIGHT); backgroundSecondText.setTextOrigin(VPos.BASELINE); backgroundSecondText.setTextAlignment(TextAlignment.RIGHT); // Setup the semitransparent background timeText // Width of one time segment String backgroundSegment = "_"; switch(clock.getLcdFont()) { case LCD : backgroundSegment = "8"; break; case DIGITAL : case DIGITAL_BOLD: case ELEKTRA : backgroundSegment = "_"; break; } // Add segments to background timeText backgroundTextBuilder.setLength(0); backgroundTextBuilder.append(backgroundSegment); backgroundTextBuilder.append(backgroundSegment); backgroundTextBuilder.append(":"); backgroundTextBuilder.append(backgroundSegment); backgroundTextBuilder.append(backgroundSegment); backgroundTimeText.setText(backgroundTextBuilder.toString()); backgroundSecondText.setText(backgroundSegment + backgroundSegment); }
Example #21
Source File: FxUtils.java From stagedisplayviewer with MIT License | 5 votes |
/** * Converts the String property TextAlignment to the appropriate TextAlignment. * @return */ private TextAlignment getAlignment() { try { return TextAlignment.valueOf(Property.TEXT_ALIGN.toString().toUpperCase()); } catch(IllegalArgumentException e) { log.warn(String.format( "Invalid TEXT_ALIGN property: %s. It should be one of (Case insensitive): Center, Right, Left, or Justify.", Property.TEXT_ALIGN.toString() ), e ); // Default to center align. return TextAlignment.CENTER; } }
Example #22
Source File: GraphicsContextImpl.java From openchemlib-js with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void drawText(String s, double x, double y, boolean centerHorz, boolean centerVert) { ctx.setTextAlign(centerHorz ? TextAlignment.CENTER : TextAlignment.LEFT); ctx.setTextBaseline(centerVert ? VPos.CENTER : VPos.TOP); ctx.strokeText(s, x, y); }
Example #23
Source File: StopWatchSample.java From marathonv5 with Apache License 2.0 | 5 votes |
private Text createNumber(String number, double layoutX, double layoutY) { Text text = new Text(number); text.setLayoutX(layoutX); text.setLayoutY(layoutY); text.setTextAlignment(TextAlignment.CENTER); text.setFill(FILL_COLOR); text.setFont(NUMBER_FONT); return text; }
Example #24
Source File: CheckListFormNode.java From marathonv5 with Apache License 2.0 | 5 votes |
private Node addSeparator(String name) { Separator separator = new Separator(); separator.setPadding(new Insets(8, 0, 0, 0)); HBox.setHgrow(separator, Priority.ALWAYS); Text text = new Text(name); text.setTextAlignment(TextAlignment.CENTER); HBox hBox = new HBox(text, separator); HBox.setHgrow(hBox, Priority.ALWAYS); return hBox; }
Example #25
Source File: StopWatch.java From netbeans with Apache License 2.0 | 5 votes |
private Text createNumber(String number, double layoutX, double layoutY) { Text text = new Text(number); text.setLayoutX(layoutX); text.setLayoutY(layoutY); text.setTextAlignment(TextAlignment.CENTER); text.setFill(FILL_COLOR); text.setFont(NUMBER_FONT); return text; }
Example #26
Source File: InitialDigit.java From SpaceFX with Apache License 2.0 | 5 votes |
private void initGraphics() { if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) { if (getPrefWidth() > 0 && getPrefHeight() > 0) { setPrefSize(getPrefWidth(), getPrefHeight()); } else { setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } canvas = new Canvas(getPrefWidth(), getPrefHeight()); ctx = canvas.getGraphicsContext2D(); ctx.setTextAlign(TextAlignment.CENTER); ctx.setTextBaseline(VPos.CENTER); getChildren().setAll(canvas); }
Example #27
Source File: NewTradeProtocolLaunchWindow.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@NotNull private VBox getFeatureBox(String title, String description, String imageId, String url) { Label featureTitle = new Label(title); featureTitle.setTextAlignment(TextAlignment.LEFT); featureTitle.getStyleClass().add("news-feature-headline"); ImageView sectionScreenshot = new ImageView(); sectionScreenshot.setId(imageId); HBox imageContainer = new HBox(sectionScreenshot); imageContainer.getStyleClass().add("news-feature-image"); Label featureDescription = new Label(description); featureDescription.setTextAlignment(TextAlignment.LEFT); featureDescription.getStyleClass().add("news-feature-description"); featureDescription.setWrapText(true); HyperlinkWithIcon learnMore = new ExternalHyperlink(Res.get("shared.learnMore"), "highlight"); learnMore.setOnAction(event -> { if (DontShowAgainLookup.showAgain(GUIUtil.OPEN_WEB_PAGE_KEY)) { hide(); GUIUtil.openWebPage(url, true, () -> { this.rowIndex = -1; this.show(); }); } else { GUIUtil.openWebPage(url); } }); VBox vBox = new VBox(featureTitle, imageContainer, featureDescription, learnMore); vBox.setAlignment(Pos.CENTER_LEFT); vBox.setSpacing(20); vBox.setMaxWidth(300); return vBox; }
Example #28
Source File: DaoLaunchWindow.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private void createContent() { HBox slidingContentWithPagingBox = new HBox(); slidingContentWithPagingBox.setPadding(new Insets(30, 0, 0, 0)); slidingContentWithPagingBox.setAlignment(Pos.CENTER); Button prevButton = getIconButton(MaterialDesignIcon.ARROW_LEFT, "dao-launch-paging-button"); prevButton.setOnAction(event -> { autoPlayTimeline.stop(); goToPrevSection(); }); Button nextButton = getIconButton(MaterialDesignIcon.ARROW_RIGHT, "dao-launch-paging-button"); nextButton.setOnAction(event -> { autoPlayTimeline.stop(); goToNextSection(); }); VBox slidingContent = new VBox(); slidingContent.setMinWidth(616); slidingContent.setSpacing(20); sectionDescriptionLabel = new Label(); sectionDescriptionLabel.setTextAlignment(TextAlignment.CENTER); sectionDescriptionLabel.getStyleClass().add("dao-launch-description"); sectionDescriptionLabel.setMaxWidth(562); sectionDescriptionLabel.setWrapText(true); selectedSection = sections.get(currentSectionIndex.get()); sectionDescriptionLabel.setText(selectedSection.description); sectionScreenshot = new ImageView(); sectionScreenshot.setOpacity(0); sectionScreenshot.setId(selectedSection.imageId); slidingContent.setAlignment(Pos.CENTER); slidingContent.getChildren().addAll(sectionDescriptionLabel, sectionScreenshot); slidingContentWithPagingBox.getChildren().addAll(prevButton, slidingContent, nextButton); GridPane.setRowIndex(slidingContentWithPagingBox, ++rowIndex); GridPane.setColumnSpan(slidingContentWithPagingBox, 2); GridPane.setHgrow(slidingContent, Priority.ALWAYS); gridPane.getChildren().add(slidingContentWithPagingBox); }
Example #29
Source File: ParallelCoordinatesChart.java From charts with Apache License 2.0 | 5 votes |
private void initGraphics() { if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) { if (getPrefWidth() > 0 && getPrefHeight() > 0) { setPrefSize(getPrefWidth(), getPrefHeight()); } else { setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } axisCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); axisCtx = axisCanvas.getGraphicsContext2D(); Color selectionRectColor = getSelectionRectColor(); rect = new Rectangle(); rect.setMouseTransparent(true); rect.setVisible(false); rect.setStroke(Helper.getColorWithOpacity(selectionRectColor, 0.5)); rect.setFill(Helper.getColorWithOpacity(selectionRectColor, 0.25)); connectionCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT); connectionCanvas.setMouseTransparent(true); connectionCtx = connectionCanvas.getGraphicsContext2D(); connectionCtx.setTextAlign(TextAlignment.LEFT); connectionCtx.setTextBaseline(VPos.CENTER); dragText = new Text(""); dragText.setVisible(false); dragText.setTextOrigin(VPos.CENTER); dragText.setFill(Helper.getColorWithOpacity(getHeaderColor(), 0.5)); getChildren().setAll(axisCanvas, rect, connectionCanvas, dragText); }
Example #30
Source File: SankeyPlot.java From charts with Apache License 2.0 | 5 votes |
private void redraw() { ctx.clearRect(0, 0, width, height); paths.forEach((path, plotItem) -> { path.draw(ctx, true, false); }); boolean useItemColor = getUseItemColor(); Color itemColor = getItemColor(); Color textColor = getTextColor(); // Draw bezier curves between items for (int level = minLevel ; level <= maxLevel ; level++) { List<PlotItemData> itemDataInLevel = itemsPerLevel.get(level); // Go through all item data of the current level for (PlotItemData itemData : itemDataInLevel) { PlotItem item = itemData.getPlotItem(); CtxBounds bounds = itemData.getBounds(); // Draw item boxes with their labels ctx.setFill(useItemColor ? item.getFill() : itemColor); ctx.fillRect(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); ctx.setFill(textColor); ctx.setTextAlign(level == maxLevel ? TextAlignment.RIGHT : TextAlignment.LEFT); ctx.fillText(item.getName(), itemData.getTextPoint().getX(), itemData.getTextPoint().getY()); } } }