当前位置: 首页>>代码示例>>Java>>正文


Java Color.color方法代码示例

本文整理汇总了Java中javafx.scene.paint.Color.color方法的典型用法代码示例。如果您正苦于以下问题:Java Color.color方法的具体用法?Java Color.color怎么用?Java Color.color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.paint.Color的用法示例。


在下文中一共展示了Color.color方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createColorPalette

import javafx.scene.paint.Color; //导入方法依赖的package包/类
public static final List<Color> createColorPalette(final Color FROM_COLOR, final Color TO_COLOR, final int NO_OF_COLORS) {
    int    steps        = clamp(1, 50, NO_OF_COLORS) - 1;
    double step         = 1.0 / steps;
    double deltaRed     = (TO_COLOR.getRed()     - FROM_COLOR.getRed())     * step;
    double deltaGreen   = (TO_COLOR.getGreen()   - FROM_COLOR.getGreen())   * step;
    double deltaBlue    = (TO_COLOR.getBlue()    - FROM_COLOR.getBlue())    * step;
    double deltaOpacity = (TO_COLOR.getOpacity() - FROM_COLOR.getOpacity()) * step;

    List<Color> palette      = new ArrayList<>(NO_OF_COLORS);
    Color       currentColor = FROM_COLOR;
    palette.add(currentColor);
    for (int i = 0 ; i < steps ; i++) {
        double red     = clamp(0d, 1d, (currentColor.getRed()     + deltaRed));
        double green   = clamp(0d, 1d, (currentColor.getGreen()   + deltaGreen));
        double blue    = clamp(0d, 1d, (currentColor.getBlue()    + deltaBlue));
        double opacity = clamp(0d, 1d, (currentColor.getOpacity() + deltaOpacity));
        currentColor   = Color.color(red, green, blue, opacity);
        palette.add(currentColor);
    }
    return palette;
}
 
开发者ID:HanSolo,项目名称:horizon,代码行数:22,代码来源:Helper.java

示例2: draw

import javafx.scene.paint.Color; //导入方法依赖的package包/类
private void draw(final int LIMIT, final double RESOLUTION) {
    int limit        = LIMIT > points.size() ? points.size() : LIMIT + 1;
    double pixelSize = 2 * RESOLUTION;

    ctx.clearRect(0, 0, width, height);

    for (double y = 0 ; y < height ; y += RESOLUTION) {
        for (double x = 0 ; x < width ; x += RESOLUTION) {
            double value = getValueAt(limit, x, y);
            if (value != -255) {
                Color          color    = getUseColorMapping() ? getColorForValue(value) : getColorForValue(value, isDiscreteColors());
                RadialGradient gradient = new RadialGradient(0, 0, x, y, RESOLUTION,
                                                             false, CycleMethod.NO_CYCLE,
                                                             new Stop(0, Color.color(color.getRed(), color.getGreen(), color.getBlue(), getHeatMapOpacity())),
                                                             new Stop(1, Color.color(color.getRed(), color.getGreen(), color.getBlue(), 0.0)));
                ctx.setFill(gradient);
                ctx.fillOval(x - RESOLUTION, y - RESOLUTION, pixelSize, pixelSize);
            }
        }
    }
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:22,代码来源:AreaHeatMap.java

示例3: convertSRGBtoLinearRGB

import javafx.scene.paint.Color; //导入方法依赖的package包/类
/**
 * 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());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:15,代码来源:HeatTabController.java

示例4: convertLinearRGBtoSRGB

import javafx.scene.paint.Color; //导入方法依赖的package包/类
/**
 * Helper function to convert a color in linear RGB space to SRGB space.
 */
public static Color convertLinearRGBtoSRGB(Color color) {
    double[] colors = new double[] { color.getRed(), color.getGreen(), color.getBlue() };
    for (int i=0; i<colors.length; i++) {
        if (colors[i] <= 0.0031308) {
            colors[i] = colors[i] * 12.92;
        } else {
            colors[i] = (1.055 * Math.pow(colors[i], (1.0 / 2.4))) - 0.055;
        }
    }
    return Color.color(colors[0], colors[1], colors[2], color.getOpacity());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:15,代码来源:HeatTabController.java

示例5: getColorWithOpacity

import javafx.scene.paint.Color; //导入方法依赖的package包/类
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);
}
 
开发者ID:HanSolo,项目名称:circularplot,代码行数:8,代码来源:Helper.java

示例6: DragBox

import javafx.scene.paint.Color; //导入方法依赖的package包/类
public DragBox(double x, double y, double w, double h, SHAPE.TYPE type, double rotate, double strokenWidth,
               double a, double r, double g, double b, double fa, double fr, double fg, double fb) {
    Width.set(w);
    Height.set(h);
    X = new SimpleDoubleProperty(x);
    Y = new SimpleDoubleProperty(y);
    this.rotate = rotate;
    this.strokeWidth = strokenWidth;
    this.type = type;
    paintFill = Color.color(fr, fg, fb, fa);
    paintStroke = Color.color(r, g, b, a);
    isLoadFromfile = true;
    isCopy = false;
    init();
}
 
开发者ID:xfangfang,项目名称:PhotoScript,代码行数:16,代码来源:DragBox.java

示例7: randomColor

import javafx.scene.paint.Color; //导入方法依赖的package包/类
/**
 * Generates a random {@link ColorAdjust} the a ship.
 * @return The new color for the ship.
 */
public static ColorAdjust randomColor(){
    ColorAdjust blackout = new ColorAdjust();
    Color color = Color.color(Math.random(), Math.random(), Math.random());
    System.out.println("color hue: " + color.getHue());
    double hue = map( (color.getHue() + 180) % 360, -1);
    System.out.println("hue: " + hue);
    blackout.setHue(hue);
    return blackout;
}
 
开发者ID:madar94,项目名称:FlappySpaceShip,代码行数:14,代码来源:Effects.java

示例8: hslToRGB

import javafx.scene.paint.Color; //导入方法依赖的package包/类
public static final Color hslToRGB(double hue, double saturation, double luminance) {
    double r, g, b;
    if (Double.compare(saturation, 0) == 0) {
        r = 1;
        b = 1;
        g = 1;
    } else {
        double q = luminance < 0.5 ? luminance * (1 + saturation) : luminance + saturation - luminance * saturation;
        double p = 2 * luminance - q;
        r = clamp(0, 1, hue2RGB(p, q, hue + 0.33));
        g = clamp(0, 1, hue2RGB(p, q, hue));
        b = clamp(0, 1, hue2RGB(p, q, hue - 0.33));
    }
    return Color.color(r, g, b);
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:16,代码来源:Helper.java

示例9: interpolateColor

import javafx.scene.paint.Color; //导入方法依赖的package包/类
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);
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:32,代码来源:Helper.java

示例10: interpolateColor

import javafx.scene.paint.Color; //导入方法依赖的package包/类
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);
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:16,代码来源:GradientLookup.java

示例11: interpolateColor

import javafx.scene.paint.Color; //导入方法依赖的package包/类
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);
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:16,代码来源:GradientLookup.java

示例12: start

import javafx.scene.paint.Color; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
    if (frontier == null) {
        throw new IllegalStateException("GUI launched without frontier");
    }
    formatter = new DecimalFormat("#.##");
    points = new XYChart.Series[frontier.size()];

    primaryStage.setTitle("VNFCP Optimization");
    FXMLLoader loader = new FXMLLoader(
            getClass().getResource("GuiApp.fxml")
    );
    loader.setController(this);
    Parent root = loader.load();
    primaryStage.setScene(new Scene(root));
    root.applyCss();
    root.layout();
    computeColorMinMax();

    // Gradient
    Stop[] stops = new Stop[]{
            new Stop(0, Color.BLACK),
            new Stop(0.8, Color.color(1, 0.63, 0.4)),
            new Stop(1, Color.color(1, 0.78, 0.5))
    };
    LinearGradient lg = new LinearGradient(0, 1, 0, 0, true, CycleMethod.NO_CYCLE, stops);
    colorStops = lg.getStops();
    rect.setFill(lg);

    // LineChart
    xAxis.setLabel("Total Delay");
    xAxis.setForceZeroInRange(false);
    yAxis.setLabel("Total Used CPU");
    yAxis.setForceZeroInRange(false);
    colorLegendLabel.setText("Num. of Hops");

    chart.setTitle("Pareto Frontier [" + frontier.size() + " elements]");

    for (int i = 0; i < frontier.size(); i++) {
        addSolutionToChart(i);
    }

    // Color Labels
    updateColumn2Width();
    colorLegendLabel.textProperty().addListener(observable -> updateColumn2Width());
    minColorValLabel.textProperty().addListener(observable -> updateColumn2Width());
    maxColorValLabel.textProperty().addListener(observable -> updateColumn2Width());

    primaryStage.show();
}
 
开发者ID:lsinfo3,项目名称:mo-vnfcp,代码行数:51,代码来源:GuiApp.java

示例13: randomTextColor

import javafx.scene.paint.Color; //导入方法依赖的package包/类
/**
 * Generates a random {@link Color}.
 * @return A new color.
 */
public static Color randomTextColor(){
    Color color = Color.color(Math.random(), Math.random(), Math.random());
    return color;
}
 
开发者ID:madar94,项目名称:FlappySpaceShip,代码行数:9,代码来源:Effects.java


注:本文中的javafx.scene.paint.Color.color方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。