Java Code Examples for javafx.scene.Node#setStyle()
The following examples show how to use
javafx.scene.Node#setStyle() .
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: MultipleAxesLineChart.java From chart-fx with Apache License 2.0 | 6 votes |
private void styleBackgroundChart(final LineChart<?, ?> lineChart, final Color lineColor) { styleChartLine(lineChart, lineColor); final Node chartContent = lineChart.lookup(".chart-content"); if (chartContent != null) { final Node chartPlotBackground = chartContent.lookup(".chart-plot-background"); if (chartPlotBackground != null) { chartPlotBackground.setStyle("-fx-background-color: transparent;"); } } lineChart.setVerticalZeroLineVisible(false); lineChart.setHorizontalZeroLineVisible(false); lineChart.setVerticalGridLinesVisible(false); lineChart.setHorizontalGridLinesVisible(false); lineChart.setCreateSymbols(false); }
Example 2
Source File: ImageAnalyseController.java From MyBox with Apache License 2.0 | 6 votes |
protected void showComponentsHistogram(int index, final ColorComponent component) { if (image == null || data == null) { return; } // https://stackoverflow.com/questions/31774771/javafx-chart-axis-only-shows-last-label?r=SearchResults int[] histogram = data.histogram(component); XYChart.Series series = new XYChart.Series(); for (int i = 0; i < histogram.length; ++i) { series.getData().add(new XYChart.Data(i + "", histogram[i])); } series.setName(message(component.name())); colorsBarchart.getData().add(index, series); String colorString = FxmlColor.rgb2Hex(ImageColor.color(component)); for (Node n : colorsBarchart.lookupAll(".default-color" + index + ".chart-bar")) { n.setStyle("-fx-bar-fill: " + colorString + "; "); } }
Example 3
Source File: ImageAnalyseController.java From MyBox with Apache License 2.0 | 6 votes |
private void updateComponentsLegend() { try { if (image == null || data == null) { return; } if (!componentsLegendCheck.isSelected()) { colorsBarchart.setLegendVisible(false); return; } colorsBarchart.setLegendVisible(true); Set<Node> legendItems = colorsBarchart.lookupAll("Label.chart-legend-item"); if (legendItems.isEmpty()) { return; } for (Node legendItem : legendItems) { Label legendLabel = (Label) legendItem; Node legend = legendLabel.getGraphic(); if (legend != null) { String colorString = FxmlColor.rgb2Hex(ImageColor.componentColor(legendLabel.getText())); legend.setStyle("-fx-background-color: " + colorString); } } } catch (Exception e) { } }
Example 4
Source File: FxmlControl.java From MyBox with Apache License 2.0 | 6 votes |
public static boolean setStyle(Node node, String style) { try { if (node == null) { return false; } if (node instanceof ComboBox) { ComboBox c = (ComboBox) node; c.getEditor().setStyle(style); } else { node.setStyle(style); } return true; } catch (Exception e) { return false; } }
Example 5
Source File: FxmlControl.java From MyBox with Apache License 2.0 | 6 votes |
public static void setPieColors(PieChart pie, List<String> palette, boolean showLegend) { if (pie == null || palette == null || pie.getData() == null || pie.getData().size() > palette.size()) { return; } for (int i = 0; i < pie.getData().size(); i++) { PieChart.Data data = pie.getData().get(i); data.getNode().setStyle("-fx-pie-color: " + palette.get(i) + ";"); } pie.setLegendVisible(showLegend); if (showLegend) { Set<Node> legendItems = pie.lookupAll("Label.chart-legend-item"); if (legendItems.isEmpty()) { return; } for (Node legendItem : legendItems) { Label legendLabel = (Label) legendItem; Node legend = legendLabel.getGraphic(); if (legend != null) { for (int i = 0; i < pie.getData().size(); i++) { String name = pie.getData().get(i).getName(); if (name.equals(legendLabel.getText())) { legend.setStyle("-fx-background-color: " + palette.get(i)); break; } } } } } }
Example 6
Source File: MultipleAxesLineChart.java From chart-fx with Apache License 2.0 | 5 votes |
private void styleChartLine(final LineChart<?, ?> chart, final Color lineColor) { chart.getYAxis().lookup(".axis-label").setStyle("-fx-text-fill: " + toRGBCode(lineColor) + "; -fx-font-weight: bold;"); final Node seriesLine = chart.lookup(".chart-series-line"); seriesLine.setStyle("-fx-stroke: " + toRGBCode(lineColor) + "; -fx-stroke-width: " + strokeWidth + ";"); }
Example 7
Source File: InternalWindow.java From desktoppanefx with Apache License 2.0 | 5 votes |
private Pane makeContentPane(Node content) { this.content = content; AnchorPane paneContent = new AnchorPane(content); paneContent.getStyleClass().add("internal-window-content"); content.setStyle("-fx-background-color: #F9F9F9; -fx-border-color: #F2F2F2"); AnchorPane.setBottomAnchor(content, 0d); AnchorPane.setLeftAnchor(content, 0d); AnchorPane.setRightAnchor(content, 0d); AnchorPane.setTopAnchor(content, 0d); return paneContent; }
Example 8
Source File: StringTable.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Set cell style * @param cell Cell to style * @param color Background color */ private static void setCellStyle(final Node cell, final Color color) { if (color == null) cell.setStyle(null); else // Based on modena.css // .table-cell has no -fx-background-color to see overall background, // but .table-cell:selected uses this to get border with an inset color cell.setStyle("-fx-background-color: -fx-table-cell-border-color, " + JFXUtil.webRGB(color) + ";-fx-background-insets: 0, 0 0 1 0;"); }
Example 9
Source File: ManageGroupsManager.java From youtube-comment-suite with MIT License | 5 votes |
private void installDataTooltip(Tooltip tooltip, Node node, LineChart.Data<?, ?> dataPoint) { node.setStyle("-fx-background-color: transparent;"); node.setOnMouseEntered(e -> node.setStyle("-fx-background-color: orangered;")); node.setOnMouseExited(e -> node.setStyle("-fx-background-color: transparent;")); Tooltip.install(node, tooltip); dataPoint.setNode(node); }
Example 10
Source File: BreakingNewsDemoView.java From htm.java-examples with GNU Affero General Public License v3.0 | 5 votes |
public LineChart<String, Number> createChart(LabelledRadiusPane pane) { CategoryAxis xAxis = new CategoryAxis(); NumberAxis yAxis = new NumberAxis(); chart = new LineChart<>(xAxis, yAxis); chart.setTitle("Tweet Trend Analysis"); chart.setCreateSymbols(false); chart.setLegendVisible(false); xAxis.setLabel("Time of Tweet"); yAxis.setUpperBound(1.0); yAxis.setLowerBound(0.0); yAxis.setLabel("Anomaly\n Score"); yAxis.setForceZeroInRange(true); series = new XYChart.Series<>(); series.setName("Tweet Data"); chart.getData().add(series); chartSeriesProperty.set(series); Node line = series.getNode().lookup(".chart-series-line"); line.setStyle("-fx-stroke: rgb(20, 164, 220)"); chart.setPrefWidth(1200); chart.setPrefHeight(275); chart.setLayoutY(pane.labelHeightProperty().get() + 10); return chart; }
Example 11
Source File: JFXColorPickerUI.java From JFoenix with Apache License 2.0 | 5 votes |
private void setColorAtLocation(int x, int y) { if (allowColorChange) { Color color = getColorAtLocation(x, y); String colorString = "rgb(" + color.getRed() * 255 + "," + color.getGreen() * 255 + "," + color.getBlue() * 255 + ");"; for (Node node : colorNodes) node.setStyle("-fx-background-color:" + colorString + "; -fx-fill:" + colorString+";"); } }
Example 12
Source File: FxmlControl.java From MyBox with Apache License 2.0 | 4 votes |
public static void setBarChartColors(BarChart chart, List<String> palette, boolean showLegend) { if (chart == null || palette == null) { return; } List<XYChart.Series> seriesList = chart.getData(); if (seriesList == null || seriesList.size() > palette.size()) { return; } for (int i = 0; i < seriesList.size(); i++) { XYChart.Series series = seriesList.get(i); if (series.getData() == null) { continue; } for (int j = 0; j < series.getData().size(); j++) { XYChart.Data item = (XYChart.Data) series.getData().get(j); if (item.getNode() != null) { String color = palette.get(i); item.getNode().setStyle("-fx-bar-fill: " + color + ";"); } } } chart.setLegendVisible(showLegend); if (showLegend) { Set<Node> legendItems = chart.lookupAll("Label.chart-legend-item"); if (legendItems.isEmpty()) { return; } for (Node legendItem : legendItems) { Label legendLabel = (Label) legendItem; Node legend = legendLabel.getGraphic(); if (legend != null) { for (int i = 0; i < seriesList.size(); i++) { if (seriesList.get(i).getName().equals(legendLabel.getText())) { legend.setStyle("-fx-background-color: " + palette.get(i)); break; } } } } } }