javafx.scene.paint.Color#color ( )源码实例Demo

下面列出了javafx.scene.paint.Color#color ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FXTutorials   文件: NotificationPane.java
public NotificationPane(int w, int h) {
    this.w = w;
    this.h = h;

    bg = new Rectangle(w, h, Color.color(0.2, 0.2, 0.2, 0.75));

    getChildren().add(bg);

    tt.setOnFinished(e -> isAnimating = false);

    tt.setInterpolator(new Interpolator() {
        @Override
        protected double curve(double t) {
            //return (t == 0.0) ? 0.0 : Math.pow(2.0, 10 * (t - 1));
            return (t == 1.0) ? 1.0 : 1 - Math.pow(2.0, -10 * t);
        }
    });
}
 
源代码2 项目: Medusa   文件: SpaceXSkin.java
@Override protected void redraw() {
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(gauge.getBorderWidth() / PREFERRED_WIDTH * width))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));
    barColor                 = gauge.getBarColor();
    thresholdColor           = gauge.getThresholdColor();
    barBackgroundColor       = gauge.getBarBackgroundColor();
    thresholdBackgroundColor = Color.color(thresholdColor.getRed(), thresholdColor.getGreen(), thresholdColor.getBlue(), 0.25);
    barBackground.setFill(barBackgroundColor);
    thresholdBar.setFill(thresholdBackgroundColor);
    dataBar.setFill(barColor);
    dataBarThreshold.setFill(thresholdColor);

    titleText.setFill(gauge.getTitleColor());
    titleText.setText(gauge.getTitle());

    valueText.setFill(gauge.getValueColor());
    valueText.setText(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue()));

    unitText.setFill(gauge.getUnitColor());
    unitText.setText(gauge.getUnit());
    
    resizeStaticText();
    resizeValueText();
    
}
 
源代码3 项目: charts   文件: Helper.java
public static Color hslToRGB(double hue, double saturation, double luminance, double opacity) {
    saturation = clamp(0, 1, saturation);
    luminance  = clamp(0, 1, luminance);
    opacity    = clamp(0, 1, opacity);

    hue = hue % 360.0;
    hue /= 360;

    double q = luminance < 0.5 ? luminance * (1 + saturation) : (luminance + saturation) - (saturation * luminance);
    double p = 2 * luminance - q;

    double r = clamp(0, 1, hueToRGB(p, q, hue + (1.0/3.0)));
    double g = clamp(0, 1, hueToRGB(p, q, hue));
    double b = clamp(0, 1, hueToRGB(p, q, hue - (1.0/3.0)));

    return Color.color(r, g, b, opacity);
}
 
源代码4 项目: FXGLGames   文件: SpaceInvadersFactory.java
@Spawns("LaserBeam")
public Entity newLaserBeam(SpawnData data) {
    Rectangle view = new Rectangle(10, Config.HEIGHT - 25, Color.color(1.0, 1.0, 1.0, 0.86));
    view.setArcWidth(15);
    view.setArcHeight(15);
    view.setStroke(Color.BLUE);
    view.setStrokeWidth(1);

    return entityBuilder()
            .from(data)
            .type(LASER_BEAM)
            .viewWithBBox(view)
            .with(new CollidableComponent(true))
            .with(new LaserBeamComponent())
            .build();
}
 
源代码5 项目: RichTextFX   文件: Codec.java
@Override
public Color decode(DataInputStream is) throws IOException {
    return Color.color(
            is.readDouble(),
            is.readDouble(),
            is.readDouble(),
            is.readDouble());
}
 
源代码6 项目: charts   文件: Helper.java
public static final Color interpolateColor(final Color COLOR1, final Color COLOR2, final double FRACTION, final double TARGET_OPACITY) {
    double fraction       = clamp(0, 1, FRACTION);
    double targetOpacity  = TARGET_OPACITY < 0 ? TARGET_OPACITY : clamp(0, 1, FRACTION);

    final double RED1     = COLOR1.getRed();
    final double GREEN1   = COLOR1.getGreen();
    final double BLUE1    = COLOR1.getBlue();
    final double OPACITY1 = COLOR1.getOpacity();

    final double RED2     = COLOR2.getRed();
    final double GREEN2   = COLOR2.getGreen();
    final double BLUE2    = COLOR2.getBlue();
    final double OPACITY2 = COLOR2.getOpacity();

    final double DELTA_RED     = RED2 - RED1;
    final double DELTA_GREEN   = GREEN2 - GREEN1;
    final double DELTA_BLUE    = BLUE2 - BLUE1;
    final double DELTA_OPACITY = OPACITY2 - OPACITY1;

    double red     = RED1 + (DELTA_RED * fraction);
    double green   = GREEN1 + (DELTA_GREEN * fraction);
    double blue    = BLUE1 + (DELTA_BLUE * fraction);
    double opacity = targetOpacity < 0 ? OPACITY1 + (DELTA_OPACITY * fraction) : targetOpacity;

    red     = clamp(0, 1, red);
    green   = clamp(0, 1, green);
    blue    = clamp(0, 1, blue);
    opacity = clamp(0, 1, opacity);

    return Color.color(red, green, blue, opacity);
}
 
源代码7 项目: FXGLGames   文件: CoinHighlightViewComponent.java
public CoinHighlightViewComponent() {
    super(5, 5);

    Rectangle rect = new Rectangle(30, 30, Color.color(0.8, 0, 0, 0.9));
    rect.setArcWidth(15);
    rect.setArcHeight(15);
    rect.setEffect(new Bloom(0.9));

    getViewRoot().getChildren().add(rect);
}
 
源代码8 项目: tilesfx   文件: Helper.java
public static final Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
    final double POS  = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());

    final double DELTA_RED     = (UPPER_BOUND.getColor().getRed()     - LOWER_BOUND.getColor().getRed())     * POS;
    final double DELTA_GREEN   = (UPPER_BOUND.getColor().getGreen()   - LOWER_BOUND.getColor().getGreen())   * POS;
    final double DELTA_BLUE    = (UPPER_BOUND.getColor().getBlue()    - LOWER_BOUND.getColor().getBlue())    * POS;
    final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;

    double red     = clamp(0, 1, (LOWER_BOUND.getColor().getRed()     + DELTA_RED));
    double green   = clamp(0, 1, (LOWER_BOUND.getColor().getGreen()   + DELTA_GREEN));
    double blue    = clamp(0, 1, (LOWER_BOUND.getColor().getBlue()    + DELTA_BLUE));
    double opacity = clamp(0, 1, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));

    return Color.color(red, green, blue, opacity);
}
 
源代码9 项目: OEE-Designer   文件: Helper.java
public static final Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
	final double POS = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());

	final double DELTA_RED = (UPPER_BOUND.getColor().getRed() - LOWER_BOUND.getColor().getRed()) * POS;
	final double DELTA_GREEN = (UPPER_BOUND.getColor().getGreen() - LOWER_BOUND.getColor().getGreen()) * POS;
	final double DELTA_BLUE = (UPPER_BOUND.getColor().getBlue() - LOWER_BOUND.getColor().getBlue()) * POS;
	final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;

	double red = clamp(0, 1, (LOWER_BOUND.getColor().getRed() + DELTA_RED));
	double green = clamp(0, 1, (LOWER_BOUND.getColor().getGreen() + DELTA_GREEN));
	double blue = clamp(0, 1, (LOWER_BOUND.getColor().getBlue() + DELTA_BLUE));
	double opacity = clamp(0, 1, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));

	return Color.color(red, green, blue, opacity);
}
 
源代码10 项目: OEE-Designer   文件: GradientLookup.java
private Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
    final double POS  = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());

    final double DELTA_RED     = (UPPER_BOUND.getColor().getRed()     - LOWER_BOUND.getColor().getRed())     * POS;
    final double DELTA_GREEN   = (UPPER_BOUND.getColor().getGreen()   - LOWER_BOUND.getColor().getGreen())   * POS;
    final double DELTA_BLUE    = (UPPER_BOUND.getColor().getBlue()    - LOWER_BOUND.getColor().getBlue())    * POS;
    final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;

    double red     = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getRed()     + DELTA_RED));
    double green   = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getGreen()   + DELTA_GREEN));
    double blue    = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getBlue()    + DELTA_BLUE));
    double opacity = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));

    return Color.color(red, green, blue, opacity);
}
 
源代码11 项目: charts   文件: GradientLookup.java
private Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
    final double POS  = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());

    final double DELTA_RED     = (UPPER_BOUND.getColor().getRed()     - LOWER_BOUND.getColor().getRed())     * POS;
    final double DELTA_GREEN   = (UPPER_BOUND.getColor().getGreen()   - LOWER_BOUND.getColor().getGreen())   * POS;
    final double DELTA_BLUE    = (UPPER_BOUND.getColor().getBlue()    - LOWER_BOUND.getColor().getBlue())    * POS;
    final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;

    double red     = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getRed()     + DELTA_RED));
    double green   = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getGreen()   + DELTA_GREEN));
    double blue    = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getBlue()    + DELTA_BLUE));
    double opacity = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));

    return Color.color(red, green, blue, opacity);
}
 
源代码12 项目: charts   文件: GradientLookup.java
private Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
    final double POS  = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());

    final double DELTA_RED     = (UPPER_BOUND.getColor().getRed()     - LOWER_BOUND.getColor().getRed())     * POS;
    final double DELTA_GREEN   = (UPPER_BOUND.getColor().getGreen()   - LOWER_BOUND.getColor().getGreen())   * POS;
    final double DELTA_BLUE    = (UPPER_BOUND.getColor().getBlue()    - LOWER_BOUND.getColor().getBlue())    * POS;
    final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;

    double red     = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getRed() + DELTA_RED));
    double green   = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getGreen()   + DELTA_GREEN));
    double blue    = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getBlue()    + DELTA_BLUE));
    double opacity = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));

    return Color.color(red, green, blue, opacity);
}
 
源代码13 项目: marathonv5   文件: HeatTabController.java
/**
 * Helper function to convert a color in sRGB space to linear RGB space.
 */
public static Color convertSRGBtoLinearRGB(Color color) {
    double[] colors = new double[] { color.getRed(), color.getGreen(), color.getBlue() };
    for (int i=0; i<colors.length; i++) {
        if (colors[i] <= 0.04045) {
            colors[i] = colors[i] / 12.92;
        } else {
            colors[i] = Math.pow((colors[i] + 0.055) / 1.055, 2.4);
        }
    }
    return Color.color(colors[0], colors[1], colors[2], color.getOpacity());
}
 
源代码14 项目: charts   文件: Helper.java
public static final Color getColorWithOpacity(final Color COLOR, final double OPACITY) {
    double red     = COLOR.getRed();
    double green   = COLOR.getGreen();
    double blue    = COLOR.getBlue();
    double opacity = clamp(0, 1, OPACITY);
    return Color.color(red, green, blue, opacity);
}
 
源代码15 项目: marathonv5   文件: HeatTabController.java
/**
 * Helper function to convert a color in sRGB space to linear RGB space.
 */
public static Color convertSRGBtoLinearRGB(Color color) {
    double[] colors = new double[] { color.getRed(), color.getGreen(), color.getBlue() };
    for (int i=0; i<colors.length; i++) {
        if (colors[i] <= 0.04045) {
            colors[i] = colors[i] / 12.92;
        } else {
            colors[i] = Math.pow((colors[i] + 0.055) / 1.055, 2.4);
        }
    }
    return Color.color(colors[0], colors[1], colors[2], color.getOpacity());
}
 
源代码16 项目: arma-dialog-creator   文件: CanvasViewColors.java
/** Takes rgba values (0-255) and returns Color instance */
public static Color color(int r, int g, int b, int a) {
	return Color.color(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
}
 
源代码17 项目: FXGLGames   文件: CardViewComponent.java
Title(String name, int level, Color outlineColor) {
    super(-15);

    Circle circle = new Circle(20, 20, 20, Color.WHITE);
    circle.setStrokeWidth(2.0);
    circle.setStroke(outlineColor);

    var stack = new StackPane(circle, getUIFactory().newText("" + level, Color.BLACK, 30.0));

    Rectangle rect = new Rectangle(180, 30, Color.color(1, 1, 1, 0.8));
    rect.setStroke(Color.BLACK);

    getChildren().addAll(stack, new StackPane(rect, getUIFactory().newText(name, Color.BLACK, 16.0)));

    stack.toFront();
}
 
源代码18 项目: OEE-Designer   文件: RadialChartTileSkin.java
private void drawChart() {
    double          canvasSize     = chartCanvas.getWidth();
    double          radius         = canvasSize * 0.5;
    double          innerSpacer    = radius * 0.18;
    double          barWidth       = (radius - innerSpacer) / tile.getChartData().size();
    //List<RadialChartData> sortedDataList = tile.getChartData().stream().sorted(Comparator.comparingDouble(RadialChartData::getValue)).collect(Collectors.toList());
    List<ChartData> dataList       = tile.getChartData();
    int             noOfItems      = dataList.size();
    double          max            = noOfItems == 0 ? 0 : dataList.stream().max(Comparator.comparingDouble(ChartData::getValue)).get().getValue();

    double          nameX          = radius * 0.975;
    double          nameWidth      = radius * 0.95;
    double          valueY         = radius * 0.94;
    double          valueWidth     = barWidth * 0.9;
    Color           bkgColor       = Color.color(tile.getTextColor().getRed(), tile.getTextColor().getGreen(), tile.getTextColor().getBlue(), 0.15);

    chartCtx.clearRect(0, 0, canvasSize, canvasSize);
    chartCtx.setLineCap(StrokeLineCap.BUTT);
    chartCtx.setFill(tile.getTextColor());
    chartCtx.setTextAlign(TextAlignment.RIGHT);
    chartCtx.setTextBaseline(VPos.CENTER);
    chartCtx.setFont(Fonts.latoRegular(barWidth * 0.5));

    chartCtx.setStroke(bkgColor);
    chartCtx.setLineWidth(1);
    chartCtx.strokeLine(radius, 0, radius, radius - barWidth * 0.875);
    chartCtx.strokeLine(0, radius, radius - barWidth * 0.875, radius);
    chartCtx.strokeArc(noOfItems * barWidth, noOfItems * barWidth, canvasSize - (2 * noOfItems * barWidth), canvasSize - (2 * noOfItems * barWidth), 90, -270, ArcType.OPEN);

    for (int i = 0 ; i < noOfItems ; i++) {
        ChartData data  = dataList.get(i);
        double    value = clamp(0, Double.MAX_VALUE, data.getValue());
        double    bkgXY = i * barWidth;
        double    bkgWH = canvasSize - (2 * i * barWidth);
        double    barXY = barWidth * 0.5 + i * barWidth;
        double    barWH = canvasSize - barWidth - (2 * i * barWidth);
        double    angle = value / max * 270.0;

        // Background
        chartCtx.setLineWidth(1);
        chartCtx.setStroke(bkgColor);
        chartCtx.strokeArc(bkgXY, bkgXY, bkgWH, bkgWH, 90, -270, ArcType.OPEN);

        // DataBar
        chartCtx.setLineWidth(barWidth);
        chartCtx.setStroke(data.getFillColor());
        chartCtx.strokeArc(barXY, barXY, barWH, barWH, 90, -angle, ArcType.OPEN);

        // Name
        chartCtx.setTextAlign(TextAlignment.RIGHT);
        chartCtx.fillText(data.getName(), nameX, barXY, nameWidth);

        // Value
        chartCtx.setTextAlign(TextAlignment.CENTER);
        chartCtx.fillText(String.format(Locale.US, "%.0f", value), barXY, valueY, valueWidth);
    }
}
 
源代码19 项目: OEE-Designer   文件: SparkLineTileSkin.java
@Override protected void initGraphics() {
    super.initGraphics();

    averagingListener = o -> handleEvents("AVERAGING");

    timeFormatter = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale());

    if (tile.isAutoScale()) tile.calcAutoScale();

    niceScaleY = new NiceScale(tile.getMinValue(), tile.getMaxValue());
    niceScaleY.setMaxTicks(5);
    tickLineColor = Color.color(tile.getChartGridColor().getRed(), tile.getChartGridColor().getGreen(), tile.getChartGridColor().getBlue(), 0.5);
    horizontalTickLines = new ArrayList<>(5);
    tickLabelsY = new ArrayList<>(5);
    for (int i = 0 ; i < 5 ; i++) {
        Line hLine = new Line(0, 0, 0, 0);
        hLine.getStrokeDashArray().addAll(1.0, 2.0);
        hLine.setStroke(Color.TRANSPARENT);
        horizontalTickLines.add(hLine);
        Text tickLabelY = new Text("");
        tickLabelY.setFill(Color.TRANSPARENT);
        tickLabelsY.add(tickLabelY);
    }

    gradientLookup = new GradientLookup(tile.getGradientStops());
    low            = tile.getMaxValue();
    high           = tile.getMinValue();
    stdDeviation   = 0;
    movingAverage  = tile.getMovingAverage();
    noOfDatapoints = tile.getAveragingPeriod();
    dataList       = new LinkedList<>();

    // To get smooth lines in the chart we need at least 4 values
    if (noOfDatapoints < 4) throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3.");

    graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45);

    titleText = new Text(tile.getTitle());
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    valueText = new Text(String.format(locale, formatString, tile.getValue()));
    valueText.setFill(tile.getValueColor());
    Helper.enableNode(valueText, tile.isValueVisible());

    unitText = new Text(tile.getUnit());
    unitText.setFill(tile.getUnitColor());
    Helper.enableNode(unitText, !tile.getUnit().isEmpty());

    valueUnitFlow = new TextFlow(valueText, unitText);
    valueUnitFlow.setTextAlignment(TextAlignment.RIGHT);

    averageText = new Text(String.format(locale, formatString, tile.getAverage()));
    averageText.setFill(Tile.FOREGROUND);
    Helper.enableNode(averageText, tile.isAverageVisible());

    highText = new Text();
    highText.setTextOrigin(VPos.BOTTOM);
    highText.setFill(tile.getValueColor());

    lowText = new Text();
    lowText.setTextOrigin(VPos.TOP);
    lowText.setFill(tile.getValueColor());

    text = new Text(tile.getText());
    text.setTextOrigin(VPos.TOP);
    text.setFill(tile.getTextColor());

    timeSpanText = new Text("");
    timeSpanText.setTextOrigin(VPos.TOP);
    timeSpanText.setFill(tile.getTextColor());
    Helper.enableNode(timeSpanText, !tile.isTextVisible());

    stdDeviationArea = new Rectangle();
    Helper.enableNode(stdDeviationArea, tile.isAverageVisible());

    averageLine = new Line();
    averageLine.setStroke(Tile.FOREGROUND);
    averageLine.getStrokeDashArray().addAll(PREFERRED_WIDTH * 0.005, PREFERRED_WIDTH * 0.005);
    Helper.enableNode(averageLine, tile.isAverageVisible());

    pathElements = new ArrayList<>(noOfDatapoints);
    pathElements.add(0, new MoveTo());
    for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); }

    sparkLine = new Path();
    sparkLine.getElements().addAll(pathElements);
    sparkLine.setFill(null);
    sparkLine.setStroke(tile.getBarColor());
    sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075);
    sparkLine.setStrokeLineCap(StrokeLineCap.ROUND);
    sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND);

    dot = new Circle();
    dot.setFill(tile.getBarColor());

    getPane().getChildren().addAll(titleText, valueUnitFlow, stdDeviationArea, averageLine, sparkLine, dot, averageText, highText, lowText, timeSpanText, text);
    getPane().getChildren().addAll(horizontalTickLines);
    getPane().getChildren().addAll(tickLabelsY);
}
 
源代码20 项目: arma-dialog-creator   文件: SVColor.java
/** Convert this color into a JavaFX color */
@NotNull
default Color toJavaFXColor() {
	return Color.color(getRedF(), getGreenF(), getBlueF());
}