本文整理了Java中javafx.scene.paint.Color
类的一些代码示例,展示了Color
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Color
类的具体详情如下:
包路径:javafx.scene.paint.Color
类名称:Color
暂无
代码示例来源:origin: jfoenixadmin/JFoenix
@Override
public Paint getUnFocusColor() {
return unFocusColor == null ? Color.rgb(77, 77, 77) : unFocusColor.get();
}
代码示例来源:origin: jfoenixadmin/JFoenix
public static String colorToHex(Color c) {
if (c != null) {
return String.format((Locale) null, "#%02x%02x%02x",
Math.round(c.getRed() * 255),
Math.round(c.getGreen() * 255),
Math.round(c.getBlue() * 255)).toUpperCase();
} else {
return null;
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
void createOverlay() {
if (overlayRect == null) {
overlayRect = new OverLayRipple();
overlayRect.setClip(getMask());
getChildren().add(0, overlayRect);
if (ripplerFill.get() instanceof Color) {
overlayRect.setFill(new Color(((Color) ripplerFill.get()).getRed(),
((Color) ripplerFill.get()).getGreen(),
((Color) ripplerFill.get()).getBlue(),
0.2));
}else{
overlayRect.setFill(Color.TRANSPARENT);
}
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
/**
* {@inheritDoc}
*/
@Override
protected void interpolate(double frac) {
if (start == null) {
starting();
}
Color newColor = start.interpolate(end, frac);
if (Color.TRANSPARENT.equals(start)) {
newColor = new Color(end.getRed(), end.getGreen(), end.getBlue(), newColor.getOpacity());
}
region.get().setBackground(new Background(new BackgroundFill(newColor, radii, insets)));
}
}
代码示例来源:origin: com.github.peterbecker/configuration-parser
/**
* Method to decode an AWT color encoded the JavaFX/web way.
* <p/>
* AWT has Color::decode, but that needs a full three byte integer value. JavaFX allows all CSS variants, including
* names.
*/
private static Color decodeAwtColor(String s) {
javafx.scene.paint.Color color = javafx.scene.paint.Color.valueOf(s);
return new Color((float) color.getRed(), (float) color.getGreen(), (float) color.getBlue(), (float) color.getOpacity());
}
代码示例来源:origin: jfoenixadmin/JFoenix
Color fontColor = ((Color) newVal.getFills().get(0).getFill()).grayscale()
.getRed() > 0.5 ? Color.valueOf(
"rgba(40, 40, 40, 0.87)") : Color.valueOf("rgba(255, 255, 255, 0.87)");
for (Node tabNode : tabs.lookupAll(".tab")) {
for (Node node : tabNode.lookupAll(".tab-label")) {
(int) (newColor.getRed() * 255),
(int) (newColor.getGreen() * 255),
(int) (newColor.getBlue() * 255));
String rgb = String.format("rgba(%d, %d, %d, 1)",
(int) (newColor.getRed() * 255),
(int) (newColor.getGreen() * 255),
(int) (newColor.getBlue() * 255));
String hsb = String.format("hsl(%d, %d%%, %d%%)",
(int) (newColor.getHue()),
(int) (newColor.getSaturation() * 100),
(int) (newColor.getBrightness() * 100));
代码示例来源:origin: com.guigarage/imaging
@Override
public int[] filter(int imageWidth, int imageHeigth, int[] inPixels) {
int[] filteredPixels = new int[inPixels.length];
for(int index = 0; index < inPixels.length; index++) {
int argb = inPixels[index];
int a = (argb >> 24) & 0xff;
int r = (argb >> 16) & 0xff;
int g = (argb >> 8) & 0xff;
int b = argb & 0xff;
Color c = Color.rgb(r, g, b, a / 255.0);
c = c.invert();
filteredPixels[index] = ((int)(c.getOpacity() * 255.0) << 24) | ((int)(c.getRed() * 255.0) << 16) | ((int)(c.getGreen() * 255.0) << 8) | (int)(c.getBlue() * 255.0);
}
return filteredPixels;
}
}
代码示例来源:origin: edu.utah.bmi.nlp/nlp-core
public static int[] getRandomBeautifulColors() {
String colorString=Integer.toHexString((int)Math.floor(Math.random()*16777215));
if(colorString.length()==5) {
colorString = "0" + colorString;
// System.out.println(colorString);
}
Color color = Color.valueOf(colorString);
if(color.getSaturation()>0.78){
color=Color.hsb(color.getHue(),0.78,color.getBrightness());
}
if(color.getBrightness()<0.43){
color=Color.hsb(color.getHue(),color.getSaturation(),0.43);
}
// System.out.println(color.getRed());
// System.out.println(color.getGreen());
// System.out.println(color.getBlue());
int red = (int) (color.getRed() * 255);
int green = (int) (color.getGreen() * 255);
int blue = (int) (color.getBlue() * 255);
return new int[]{red, green, blue};
}
代码示例来源:origin: com.aquafx-project/aquafx
@Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
List<BackgroundFill> list = new ArrayList<>();
// the animated fill
Stop[] stops = new Stop[] { new Stop(0f, Color.color(
(endColor1val.getRed() - startColor1val.getRed()) * newValue.doubleValue() + startColor1val.getRed(),
(endColor1val.getGreen() - startColor1val.getGreen()) * newValue.doubleValue() + startColor1val.getGreen(),
(endColor1val.getBlue() - startColor1val.getBlue()) * newValue.doubleValue() + startColor1val.getBlue())), new Stop(0.5f, Color.color(
(endColor2val.getRed() - startColor2val.getRed()) * newValue.doubleValue() + startColor2val.getRed(),
(endColor2val.getGreen() - startColor2val.getGreen()) * newValue.doubleValue() + startColor2val.getGreen(),
(endColor2val.getBlue() - startColor2val.getBlue()) * newValue.doubleValue() + startColor2val.getBlue())), new Stop(0.51f, Color.color(
(endColor3val.getRed() - startColor3val.getRed()) * newValue.doubleValue() + startColor3val.getRed(),
(endColor3val.getGreen() - startColor3val.getGreen()) * newValue.doubleValue() + startColor3val.getGreen(),
(endColor3val.getBlue() - startColor3val.getBlue()) * newValue.doubleValue() + startColor3val.getBlue())), new Stop(1f, Color.color(
(endColor4val.getRed() - startColor4val.getRed()) * newValue.doubleValue() + startColor4val.getRed(),
(endColor4val.getGreen() - startColor4val.getGreen()) * newValue.doubleValue() + startColor4val.getGreen(),
(endColor4val.getBlue() - startColor4val.getBlue()) * newValue.doubleValue() + startColor4val.getBlue())) };
LinearGradient gradient = new LinearGradient(0.0, 0.0, 0.0, 1.0, true, CycleMethod.NO_CYCLE, stops);
BackgroundFill backkgroudFill = new BackgroundFill(gradient, new CornerRadii(4.0), new Insets(0));
list.add(backkgroudFill);
getSkinnable().setBackground(new Background(list.get(0)));
}
代码示例来源:origin: jfoenixadmin/JFoenix
return new Color(red, green, blue, 1);
代码示例来源:origin: jfoenixadmin/JFoenix
private void updateColor() {
final ColorPicker colorPicker = (ColorPicker) getSkinnable();
Color color = colorPicker.getValue();
// update picker box color
Color circleColor = color == null ? Color.WHITE : color;
Circle colorCircle = new Circle();
colorCircle.setFill(circleColor);
colorCircle.setLayoutX(colorBox.getWidth() / 4);
colorCircle.setLayoutY(colorBox.getHeight() / 2);
colorBox.getChildren().add(colorCircle);
Timeline animateColor = new Timeline(new KeyFrame(Duration.millis(240),
new KeyValue(colorCircle.radiusProperty(),
200,
Interpolator.EASE_BOTH)));
animateColor.setOnFinished((finish) -> {
JFXNodeUtils.updateBackground(colorBox.getBackground(), colorBox, colorCircle.getFill());
colorBox.getChildren().remove(colorCircle);
});
animateColor.play();
// update label color
displayNode.setTextFill(circleColor.grayscale().getRed() < 0.5 ? Color.valueOf(
"rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)"));
if (colorLabelVisible.get()) {
displayNode.setText(JFXNodeUtils.colorToHex(circleColor));
} else {
displayNode.setText("");
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
path.getTransforms().add(rotate);
this.getChildren().add(shapesStartIndex, path);
path.setFill(Color.valueOf(getDefaultColor(i)));
path.addEventHandler(MouseEvent.MOUSE_CLICKED, (event) -> selectedPath.set(path));
newVal.setStroke(Color.rgb(255, 255, 255, 0.87));
newVal.playTransition(1);
hslColorPicker.moveToColor((Color) newVal.getFill());
代码示例来源:origin: us.ihmc/ihmc-javafx-toolkit
private Color getColorAtIndex(int x)
{
double hue;
if (hueResolution != -1)
hue = 360.0 * (double) x / (double) hueResolution;
else
hue = 360.0 * hueConstant;
double saturation;
if (saturationResolution != -1)
{
saturation = (double) x / (double) saturationResolution;
}
else
saturation = saturationConstant;
double brightness;
if (brightnessResolution != -1)
brightness = (double) x / (double) brightnessResolution;
else
brightness = brightnessConstant;
return Color.hsb(hue, saturation, brightness);
}
代码示例来源:origin: speedment/speedment
@Override
public void initialize(URL location, ResourceBundle resources) {
title.setTextFill(Color.web("#45a6fc")); // TODO Use styleClass instead
header.setText("Component Explorer");
final RootItem root = new RootItem(speedment);
root.getChildren().addAll(components());
tree.setRoot(root);
close.setOnAction(newCloseHandler());
}
代码示例来源:origin: us.ihmc/robot-environment-awareness-visualizers
private Node createConvexPolygonGraphics(PlanarRegion data)
{
List<ConvexPolygon2D> convexPolygons = new ArrayList<>();
for (int i = 0; i < data.getNumberOfConvexPolygons(); i++)
convexPolygons.add(data.getConvexPolygon(i));
JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(new TextureColorAdaptivePalette(64));
int regionId = data.getRegionId();
RigidBodyTransform rigidBodyTransform = new RigidBodyTransform();
data.getTransformToWorld(rigidBodyTransform);
Color regionColor = OcTreeMeshBuilder.getRegionColor(regionId);
for (int i = 0; i < convexPolygons.size(); i++)
{
ConvexPolygon2D convexPolygon = convexPolygons.get(i);
Color color = Color.hsb(regionColor.getHue(), 0.9, 0.5 + 0.5 * ((double) i / (double) convexPolygons.size()));
meshBuilder.addPolygon(rigidBodyTransform, convexPolygon, color);
}
MeshView meshView = new MeshView(meshBuilder.generateMesh());
meshView.setMaterial(meshBuilder.generateMaterial());
return meshView;
}
代码示例来源:origin: us.ihmc/robot-environment-awareness-visualizers
private Node createBorderEdgesGraphics(PlanarRegionSegmentationRawData rawData, ConcaveHullFactoryResult concaveHullFactoryResult)
{
int regionId = rawData.getRegionId();
JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(new TextureColorAdaptivePalette(16));
Point3D planeOrigin = rawData.getOrigin();
Quaternion planeOrientation = rawData.getOrientation();
Color regionColor = OcTreeMeshBuilder.getRegionColor(regionId);
for (ConcaveHullVariables intermediateVariables : concaveHullFactoryResult.getIntermediateVariables())
{
Set<QuadEdge> borderEdges = intermediateVariables.getBorderEdges();
for (QuadEdge edge : borderEdges)
{
Point3D dest = PolygonizerTools.toPointInWorld(edge.dest().getX(), edge.dest().getY(), planeOrigin, planeOrientation);
Point3D orig = PolygonizerTools.toPointInWorld(edge.orig().getX(), edge.orig().getY(), planeOrigin, planeOrientation);
boolean isEdgeTooLong = dest.distance(orig) > parameters.getEdgeLengthThreshold();
Color lineColor = Color.hsb(regionColor.getHue(), regionColor.getSaturation(), isEdgeTooLong ? 0.25 : regionColor.getBrightness());
meshBuilder.addLine(dest, orig, 0.0015, lineColor);
}
}
MeshView meshView = new MeshView(meshBuilder.generateMesh());
meshView.setMaterial(meshBuilder.generateMaterial());
meshView.setMouseTransparent(true);
return meshView;
}
代码示例来源:origin: org.fxmisc.richtext/richtextfx
@Override
public Color decode(DataInputStream is) throws IOException {
return Color.color(
is.readDouble(),
is.readDouble(),
is.readDouble(),
is.readDouble());
}
代码示例来源:origin: org.codehaus.griffon/griffon-javafx
private static int alpha(Color color) {
return toIntColor(color.getOpacity());
}
代码示例来源:origin: us.ihmc/ihmc-graphics-description
public static java.awt.Color jfxToAwt(javafx.scene.paint.Color jfxColor)
{
return new java.awt.Color((float) jfxColor.getRed(), (float) jfxColor.getGreen(), (float) jfxColor.getBlue(), (float) jfxColor.getOpacity());
}
代码示例来源:origin: com.jfoenix/jfoenix
/**
* {@inheritDoc}
*/
@Override
protected void interpolate(double frac) {
if (start == null) {
starting();
}
Color newColor = start.interpolate(end, frac);
if (Color.TRANSPARENT.equals(start)) {
newColor = new Color(end.getRed(), end.getGreen(), end.getBlue(), newColor.getOpacity());
}
region.get().setBackground(new Background(new BackgroundFill(newColor, radii, insets)));
}
}
内容来源于网络,如有侵权,请联系作者删除!