本文整理匯總了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;
}
示例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);
}
}
}
}
示例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());
}
示例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());
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}