Java Code Examples for eu.hansolo.tilesfx.tools.Helper#getColorWithOpacity()
The following examples show how to use
eu.hansolo.tilesfx.tools.Helper#getColorWithOpacity() .
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: StatusTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void redraw() { super.redraw(); titleText.setText(tile.getTitle()); text.setText(tile.getText()); description.setText(tile.getDescription()); description.setAlignment(tile.getDescriptionAlignment()); leftValueLabel.setText(String.format(Locale.US, "%.0f", tile.getLeftValue())); middleValueLabel.setText(String.format(Locale.US, "%.0f", tile.getMiddleValue())); rightValueLabel.setText(String.format(Locale.US, "%.0f", tile.getRightValue())); leftLabel.setText(tile.getLeftText()); middleLabel.setText(tile.getMiddleText()); rightLabel.setText(tile.getRightText()); resizeDynamicText(); resizeStaticText(); titleText.setFill(tile.getTitleColor()); text.setFill(tile.getTextColor()); description.setTextFill(tile.getTextColor()); Color foregroundColor = getSkinnable().getForegroundColor(); Color halfTranslucent = Helper.getColorWithOpacity(foregroundColor, 0.5); leftValueLabel.setTextFill(foregroundColor); middleValueLabel.setTextFill(foregroundColor); rightValueLabel.setTextFill(foregroundColor); leftLabel.setTextFill(halfTranslucent); middleLabel.setTextFill(halfTranslucent); rightLabel.setTextFill(halfTranslucent); verticalDivider.setStroke(halfTranslucent); horizontal1Divider.setStroke(halfTranslucent); horizontal2Divider.setStroke(halfTranslucent); }
Example 2
Source File: StatusTileSkin.java From tilesfx with Apache License 2.0 | 4 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()); Color foregroundColor = getSkinnable().getForegroundColor(); Color halfTranslucent = Helper.getColorWithOpacity(foregroundColor, 0.5); verticalDivider = new Line(0, PREFERRED_HEIGHT * 0.35, PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.35); verticalDivider.getStrokeDashArray().addAll(2.0, 2.0); verticalDivider.setStrokeDashOffset(1); verticalDivider.setStroke(halfTranslucent); verticalDivider.setStrokeWidth(1); horizontal1Divider = new Line(PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.45, PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.85); horizontal1Divider.getStrokeDashArray().addAll(2.0, 2.0); horizontal1Divider.setStrokeDashOffset(1); horizontal1Divider.setStroke(halfTranslucent); horizontal1Divider.setStrokeWidth(1); horizontal2Divider = new Line(2 * PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.45, 2 * PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.85); horizontal2Divider.getStrokeDashArray().addAll(2.0, 2.0); horizontal2Divider.setStrokeDashOffset(1); horizontal2Divider.setStroke(halfTranslucent); horizontal2Divider.setStrokeWidth(1); leftGraphicsPane = new StackPane(); middleGraphicsPane = new StackPane(); rightGraphicsPane = new StackPane(); if (null != tile.getLeftGraphics()) { leftGraphicsPane.getChildren().setAll(tile.getLeftGraphics()); } if (null != tile.getMiddleGraphics()) { middleGraphicsPane.getChildren().setAll(tile.getMiddleGraphics()); } if (null != tile.getRightGraphics()) { rightGraphicsPane.getChildren().setAll(tile.getRightGraphics()); } leftValueLabel = new Label(); leftValueLabel.setAlignment(Pos.CENTER); middleValueLabel = new Label(); middleValueLabel.setAlignment(Pos.CENTER); rightValueLabel = new Label(); rightValueLabel.setAlignment(Pos.CENTER); leftLabel = new Label(); leftLabel.setAlignment(Pos.CENTER); middleLabel = new Label(); middleLabel.setAlignment(Pos.CENTER); rightLabel = new Label(); rightLabel.setAlignment(Pos.CENTER); text = new Text(tile.getText()); text.setFill(tile.getUnitColor()); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(titleText, description, verticalDivider, horizontal1Divider, horizontal2Divider, leftGraphicsPane, middleGraphicsPane, rightGraphicsPane, leftValueLabel, middleValueLabel, rightValueLabel, leftLabel, middleLabel, rightLabel, text); }
Example 3
Source File: SmoothAreaChartTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void redraw() { super.redraw(); smoothing = tile.isSmoothing(); titleText.setText(tile.getTitle()); if (tile.getCustomDecimalFormatEnabled()) { valueText.setText(decimalFormat.format(tile.getCurrentValue())); } else { valueText.setText(String.format(locale, formatString, tile.getCurrentValue())); } if (tile.getUnit().contains("/")) { String[] units = tile.getUnit().split("/"); upperUnitText.setText(units[0]); unitText.setText(units[1]); Helper.enableNode(fractionLine, true); } else { upperUnitText.setText(" "); unitText.setText(tile.getUnit()); Helper.enableNode(fractionLine, false); } resizeDynamicText(); resizeStaticText(); titleText.setFill(tile.getTitleColor()); valueText.setFill(tile.getValueColor()); upperUnitText.setFill(tile.getUnitColor()); fractionLine.setStroke(tile.getUnitColor()); unitText.setFill(tile.getUnitColor()); selector.setStroke(tile.getForegroundColor()); selector.setFill(tile.getBackgroundColor()); Color fillPathColor1 = Helper.getColorWithOpacity(tile.getBarColor(), 0.7); Color fillPathColor2 = Helper.getColorWithOpacity(tile.getBarColor(), 0.1); if (tile.isFillWithGradient() && !tile.getGradientStops().isEmpty()) { fillPath.setFill(new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, tile.getGradientStops())); strokePath.setStroke(tile.getGradientStops().get(0).getColor()); if (dataPointsVisible) { drawDataPoints(points, tile.getGradientStops().get(0).getColor()); } } else { fillPath.setFill(new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0, fillPathColor1), new Stop(1, fillPathColor2))); strokePath.setStroke(tile.getBarColor()); if (dataPointsVisible) { drawDataPoints(points, tile.getBarColor()); } } drawChart(points); }