Java Code Examples for javafx.scene.paint.Color#deriveColor()
The following examples show how to use
javafx.scene.paint.Color#deriveColor() .
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: HeadingPane.java From constellation with Apache License 2.0 | 5 votes |
private Shape makeSquare(Color colour, Color border) { Stop[] stops = new Stop[]{new Stop(0, colour), new Stop(0.95, colour.deriveColor(1, 1, .75, 1)), new Stop(1.0, colour.deriveColor(1, 1, 0.5, 1))}; LinearGradient gradient = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stops); Rectangle square = new Rectangle(SQUARE_SIZE, SQUARE_SIZE); square.setStroke(border); square.setFill(gradient); return square; }
Example 2
Source File: DefaultRenderColorScheme.java From chart-fx with Apache License 2.0 | 5 votes |
private static Color getColorModifier(final Map<String, List<String>> parameterMap, final Color orignalColor) { Color color = orignalColor; final List<String> intensityModifier = parameterMap.get(XYChartCss.DATASET_INTENSITY.toLowerCase(Locale.UK)); if ((color != null) && (intensityModifier != null) && !intensityModifier.isEmpty()) { try { final double intensity = Double.parseDouble(intensityModifier.get(0)); color = color.deriveColor(0, intensity / 100, 1.0, intensity / 100); } catch (final NumberFormatException e) { // re-use unmodified original color } } return color; }
Example 3
Source File: StringTable.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** @param color Text color */ public void setTextColor(final Color color) { text_color = color; last_row_color = color.deriveColor(0, 0, 0, 0.5); updateStyle(); }
Example 4
Source File: QualityGauge.java From mars-sim with GNU General Public License v3.0 | 5 votes |
private void updateValue() { double value = model.getValue(); if (value == 0) { currentQuality.setFill(Color.TRANSPARENT); currentQuality.setStroke(Color.TRANSPARENT); currentQualityText.setFill(Color.TRANSPARENT); currentQualityText.setText(""); knob.setFill(Color.web("#cccccc")); } else { currentQualityRotate.setAngle(279 + ((int) value) * sectionAngle - sectionAngle); double radius = width * 0.45; double sinValue = Math.sin(Math.toRadians(currentQualityRotate.getAngle() + (-sectionAngle * ((int) value + 0.5) + model.getStartAngle() + 270 + sectionAngle))); double cosValue = Math.cos(Math.toRadians(currentQualityRotate.getAngle() + (-sectionAngle * ((int) value + 0.5) + model.getStartAngle() + 270 + sectionAngle))); Color sectionColor = model.getSections().get((int) value - 1).getColor().deriveColor(0, 2.5, 1, 1); LinearGradient currentQualityFill = new LinearGradient(centerX + radius * sinValue, centerY + radius * cosValue, centerX, centerY, false, CycleMethod.NO_CYCLE, new Stop(0.0, sectionColor), new Stop(0.22, sectionColor), new Stop(0.22, sectionColor.deriveColor(0, 0.7, 1.1, 1)), new Stop(1.0, sectionColor.deriveColor(0, 0.7, 1.1, 1))); currentQuality.setFill(currentQualityFill); currentQuality.setStroke(Color.WHITE); sinValue = Math.sin(Math.toRadians(-sectionAngle * ((int) value + 0.5) + model.getStartAngle() + 270 + sectionAngle)); cosValue = Math.cos(Math.toRadians(-sectionAngle * ((int) value + 0.5) + model.getStartAngle() + 270 + sectionAngle)); currentQualityText.setFont(Fonts.latoBold(height * 0.14860681)); currentQualityText.setText(model.getSections().get((int) value - 1).getText()); currentQualityText.setFill(Color.WHITE); currentQualityText.setX(centerX - (currentQualityText.getLayoutBounds().getWidth() * 0.55) + radius * sinValue); currentQualityText.setY(centerY + radius * cosValue); knob.setFill(sectionColor); } }
Example 5
Source File: QualityGauge.java From mars-sim with GNU General Public License v3.0 | 4 votes |
private void resize() { width = getWidth() - getInsets().getLeft() - getInsets().getRight(); height = getHeight() - getInsets().getTop() - getInsets().getBottom(); if (aspectRatio * width > height) { width = 1 / (aspectRatio / height); } else if (1 / (aspectRatio / height) > width) { height = aspectRatio * width; } if (width > 0 && height > 0) { pane.setMaxSize(width, height); pane.setPrefSize(width, height); pane.relocate((getWidth() - width) * 0.5, (getHeight() - height) * 0.5); centerX = width * 0.5; centerY = height * 0.94736842; int noOfSections = sections.size(); double radius = width * 0.43831169; double sinValue; double cosValue; Color sectionColor; for (int i = 0 ; i < noOfSections ; i++) { sinValue = Math.sin(Math.toRadians(-sectionAngle * (i + 0.5) + model.getStartAngle() + 270)); cosValue = Math.cos(Math.toRadians(-sectionAngle * (i + 0.5) + model.getStartAngle() + 270)); sectionColor = model.getSections().get(i).getColor(); LinearGradient secFill = new LinearGradient(centerX + radius * sinValue, centerY + radius * cosValue, centerX, centerY, false, CycleMethod.NO_CYCLE, new Stop(0.0, sectionColor), new Stop(0.2, sectionColor), new Stop(0.2, sectionColor.deriveColor(0, 0.8, 1.1, 1)), new Stop(1.0, sectionColor.deriveColor(0, 0.8, 1.1, 1))); Path sec = sections.get(i); sec.setFill(secFill); sec.setStrokeWidth(height * 0.01); MoveTo moveTo = (MoveTo) sec.getElements().get(0); moveTo.setX(centerX); moveTo.setY(centerY); sinValue = Math.sin(Math.toRadians(-sectionAngle * i + model.getStartAngle() + 270)); cosValue = Math.cos(Math.toRadians(-sectionAngle * i + model.getStartAngle() + 270)); LineTo lineTo1 = (LineTo) sec.getElements().get(1); lineTo1.setX(centerX + radius * sinValue); lineTo1.setY(centerY + radius * cosValue); sinValue = Math.sin(Math.toRadians(-sectionAngle * (i + 1) + model.getStartAngle() + 270)); cosValue = Math.cos(Math.toRadians(-sectionAngle * (i + 1) + model.getStartAngle() + 270)); LineTo lineTo2 = (LineTo) sec.getElements().get(2); lineTo2.setX(centerX + radius * sinValue); lineTo2.setY(centerY + radius * cosValue); } currentQualityRotate.setPivotX(centerX); currentQualityRotate.setPivotY(centerY); moveTo.setX(centerX); moveTo.setY(centerY); lineTo1.setX(centerX + width * 0.06856705); lineTo1.setY(height * 0.12174644); cubicCurveTo1.setControlX1(centerX + width * 0.06856705); cubicCurveTo1.setControlY1(height * 0.12174644); cubicCurveTo1.setControlX2(centerX + width * 0.06899351); cubicCurveTo1.setControlY2(height * 0.11400031); cubicCurveTo1.setX(centerX + width * 0.06899351); cubicCurveTo1.setY(height * 0.10990712); cubicCurveTo2.setControlX1(centerX + width * 0.06899351); cubicCurveTo2.setControlY1(height * 0.03723715); cubicCurveTo2.setControlX2(centerX + width * 0.03810455); cubicCurveTo2.setControlY2(-height * 0.02167183); cubicCurveTo2.setX(centerX); cubicCurveTo2.setY(-height * 0.02167183); cubicCurveTo3.setControlX1(centerX + -width * 0.03810455); cubicCurveTo3.setControlY1(-height * 0.02167183); cubicCurveTo3.setControlX2(centerX - width * 0.06899351); cubicCurveTo3.setControlY2(height * 0.03723715); cubicCurveTo3.setX(centerX - width * 0.06899351); cubicCurveTo3.setY(height * 0.10990712); cubicCurveTo4.setControlX1(centerX - width * 0.06899351); cubicCurveTo4.setControlY1(height * 0.11400031); cubicCurveTo4.setControlX2(centerX - width * 0.06856705); cubicCurveTo4.setControlY2(height * 0.12174644); cubicCurveTo4.setX(centerX - width * 0.06856705); cubicCurveTo4.setY(height * 0.12174644); lineTo2.setX(centerX); lineTo2.setY(centerY); currentQuality.setStrokeWidth(height * 0.01); updateValue(); knob.setCenterX(width * 0.5); knob.setCenterY(height * 0.94736842); knob.setRadius(height * 0.05572755); knob.setStrokeWidth(height * 0.01); redraw(); } }