本文整理汇总了Java中javafx.scene.paint.Color类的典型用法代码示例。如果您正苦于以下问题:Java Color类的具体用法?Java Color怎么用?Java Color使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Color类属于javafx.scene.paint包,在下文中一共展示了Color类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawYValueBox
import javafx.scene.paint.Color; //导入依赖的package包/类
@Override
public void drawYValueBox() {
if (showMouseHoverIndicator.getValue()){
double y = mouseY.getValue();
y = y - 10;
double x = 0;
double wd = 150;
double ht = 18;
if (mouseY == null) {
return;
}
int yIntPos = (int)Math.round(mouseY.getValue());
Float yValue = this.getValueByYPos(yIntPos);
if ( yValue != null && yValue != 0){
String strVolume = String.format("%.2f", yValue);
GraphicsContext gc = getGraphicsContext2D();
gc.setFill(Color.web("#010a23"));
gc.fillRect(x, y, wd, ht);
gc.setFill(Color.web("#4bf221"));
gc.fillText(strVolume, x + 13, y+13);
}
}
}
示例2: start
import javafx.scene.paint.Color; //导入依赖的package包/类
@Override
public void start(Stage stage) {
stage.setTitle("Vokabeltrainer");
Scene scene = new Scene(new VBox(), 400, 350);
scene.setFill(Color.OLDLACE);
MenuBar menuBar = new MenuBar();
// --- Menu File
Menu menuFile = new Menu("Vokabeln");
MenuItem sample = new MenuItem("Sample");
sample.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
// Do stuff here
}
});
menuFile.getItems().add(sample);
// --- Menu Edit
Menu menuEdit = new Menu("Abfragemodus");
// --- Menu View
Menu menuView = new Menu("Statistik");
menuBar.getMenus().addAll(menuFile, menuEdit, menuView);
((VBox) scene.getRoot()).getChildren().addAll(menuBar);
stage.setScene(scene);
stage.show();
}
示例3: init
import javafx.scene.paint.Color; //导入依赖的package包/类
@Override public void init() {
int noOfValues = 24 * 60;
LocalDateTime start = LocalDateTime.now();
LocalDateTime end = start.plusHours(24);
List<TYChartItem> tyData1 = new ArrayList<>();
for (int i = 0 ; i < noOfValues ; i++) {
tyData1.add(new TYChartItem(start.plusMinutes(i), RND.nextDouble() * 12 + RND.nextDouble() * 6, "P" + i, COLORS[RND.nextInt(3)]));
}
tySeries1 = new XYSeries(tyData1, ChartType.LINE, Color.RED, Color.rgb(255, 0, 0, 0.5));
tySeries1.setSymbolsVisible(false);
// XYChart
Converter tempConverter = new Converter(TEMPERATURE, CELSIUS); // Type Temperature with BaseUnit Celsius
double tempFahrenheitMin = tempConverter.convert(0, FAHRENHEIT);
double tempFahrenheitMax = tempConverter.convert(20, FAHRENHEIT);
xAxisBottom = createBottomTimeAxis(start, end, "HH:mm", true);
yAxisLeft = createLeftYAxis(0, 20, true);
yAxisRight = createRightYAxis(tempFahrenheitMin, tempFahrenheitMax, false);
tyChart = new XYChart<>(new XYPane(tySeries1), yAxisLeft, yAxisRight, xAxisBottom);
tyChart.setPrefSize(400, 200);
}
示例4: EllipseSample
import javafx.scene.paint.Color; //导入依赖的package包/类
public EllipseSample() {
super(180,90);
// Simple red filled ellipse
Ellipse ellipse1 = new Ellipse(45,45,30,45);
ellipse1.setFill(Color.RED);
// Blue stroked ellipse
Ellipse ellipse2 = new Ellipse(135,45,30,45);
ellipse2.setStroke(Color.DODGERBLUE);
ellipse2.setFill(null);
// Create a group to show all the ellipses);
getChildren().add(new Group(ellipse1,ellipse2));
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Ellipse 1 Fill", ellipse1.fillProperty()),
new SimplePropertySheet.PropDesc("Ellipse 1 Width", ellipse1.radiusXProperty(), 10d, 40d),
new SimplePropertySheet.PropDesc("Ellipse 1 Height", ellipse1.radiusYProperty(), 10d, 45d),
new SimplePropertySheet.PropDesc("Ellipse 2 Stroke", ellipse2.strokeProperty()),
new SimplePropertySheet.PropDesc("Ellipse 2 Stroke Width", ellipse2.strokeWidthProperty(), 1d, 5d),
new SimplePropertySheet.PropDesc("Ellipse 2 Width", ellipse2.radiusXProperty(), 10d, 40d),
new SimplePropertySheet.PropDesc("Ellipse 2 Height", ellipse2.radiusYProperty(), 10d, 45d)
);
// END REMOVE ME
}
示例5: createLetter
import javafx.scene.paint.Color; //导入依赖的package包/类
private void createLetter(String c) {
final Text letter = new Text(c);
letter.setFill(Color.BLACK);
letter.setFont(FONT_DEFAULT);
letter.setTextOrigin(VPos.TOP);
letter.setTranslateX((getWidth() - letter.getBoundsInLocal().getWidth()) / 2);
letter.setTranslateY((getHeight() - letter.getBoundsInLocal().getHeight()) / 2);
getChildren().add(letter);
// over 3 seconds move letter to random position and fade it out
final Timeline timeline = new Timeline();
timeline.getKeyFrames().add(
new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
// we are done remove us from scene
getChildren().remove(letter);
}
},
new KeyValue(letter.translateXProperty(), getRandom(0.0f, getWidth() - letter.getBoundsInLocal().getWidth()),INTERPOLATOR),
new KeyValue(letter.translateYProperty(), getRandom(0.0f, getHeight() - letter.getBoundsInLocal().getHeight()),INTERPOLATOR),
new KeyValue(letter.opacityProperty(), 0f)
));
timeline.play();
}
示例6: initialize
import javafx.scene.paint.Color; //导入依赖的package包/类
@FXML
private void initialize() {
System.out.println("CaptureWindow initialized");
// Scene
Scene scene = new Scene(stackPane, screenWidth, screenHeight, Color.TRANSPARENT);
setScene(scene);
addKeyHandlers();
mainCanvas.setWidth(screenWidth);
mainCanvas.setHeight(screenHeight);
mainCanvas.setOnMousePressed(m -> {
xFrom = (int) m.getSceneX();
yFrom = (int) m.getScreenY();
});
mainCanvas.setOnMouseDragged(m -> {
xNow = (int) m.getScreenX();
yNow = (int) m.getScreenY();
repaintCanvas();
});
gc = mainCanvas.getGraphicsContext2D();
}
示例7: simpleScene
import javafx.scene.paint.Color; //导入依赖的package包/类
private Scene simpleScene() {
try {
VBox root = new VBox();
Pane pane = new Pane();
Rectangle rectangle = new Rectangle(100, 100, Color.AQUA);
pane.getChildren().addAll(rectangle);
VerticalResizeContainerController controller = new VerticalResizeContainerController(pane);
root.getChildren().addAll(controller.getView());
VBox.setVgrow(controller.getView(), Priority.ALWAYS);
Scene scene = new Scene(root, 800, 600);
return scene;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例8: updateItem
import javafx.scene.paint.Color; //导入依赖的package包/类
@Override
public void updateItem(Number item, boolean empty) {
super.updateItem(item, empty);
// format the number as if it were a monetary value using the
// formatting relevant to the current locale. This would format
// 43.68 as "$43.68", and -23.67 as "($23.67)"
setText(item == null ? "" : NumberFormat.getCurrencyInstance().format(item));
if (item != null) {
double value = item.doubleValue();
setTextFill(value == 0 ? Color.BLACK :
value < 0 ? Color.RED : Color.GREEN);
}
}
示例9: init
import javafx.scene.paint.Color; //导入依赖的package包/类
private static void init() {
root = new Group();
s = new Scene(root, SCENE_WIDTH, SCENE_HEIGHT);
c = new Canvas(CANVAS_WIDTH, CANVAS_HEIGHT);
root.getChildren().add(c);
gc = c.getGraphicsContext2D();
gc.setStroke(Color.BLUE);
gc.setLineWidth(2);
gc.setFill(Color.BLUE);
Renderer.init();
GameLoop.start(gc);
//Initialize Objects
Player p = new Player();
setPlayer(p);
//load map
loadMap();
//should be called at last it based on player
EventHandler.attachEventHandlers(s);
}
示例10: start
import javafx.scene.paint.Color; //导入依赖的package包/类
@Override
public void start(Stage stage)
{
// create the scene
stage.setTitle("Social Network");
scene = new Scene(new Browser(),750,500, Color.web("#666970"));
stage.setScene(scene);
scene.getStylesheets().add("webviewsample/BrowserToolbar.css");
stage.show();
}
示例11: RotateTransitionSample
import javafx.scene.paint.Color; //导入依赖的package包/类
public RotateTransitionSample() {
super(140,140);
Rectangle rect = new Rectangle(20, 20, 100, 100);
rect.setArcHeight(20);
rect.setArcWidth(20);
rect.setFill(Color.ORANGE);
getChildren().add(rect);
rotateTransition = RotateTransitionBuilder.create()
.node(rect)
.duration(Duration.seconds(4))
.fromAngle(0)
.toAngle(720)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(true)
.build();
}
示例12: FadeTransitionSample
import javafx.scene.paint.Color; //导入依赖的package包/类
public FadeTransitionSample() {
super(100,100);
Rectangle rect = new Rectangle(0, 0, 100, 100);
rect.setArcHeight(20);
rect.setArcWidth(20);
rect.setFill(Color.DODGERBLUE);
getChildren().add(rect);
fadeTransition = FadeTransitionBuilder.create()
.duration(Duration.seconds(4))
.node(rect)
.fromValue(1)
.toValue(0.2)
.cycleCount(Timeline.INDEFINITE)
.autoReverse(true)
.build();
}
示例13: addColorsPane
import javafx.scene.paint.Color; //导入依赖的package包/类
private void addColorsPane() {
colorPickers.add(colorOne);
colorPickers.add(colorTwo);
colorPickers.add(colorThree);
colorPickers.add(colorFour);
colorPickers.add(colorFive);
// Get the colors from the database, so the colorpickers can be set
// to those colors.
String[] colors = Database.INSTANCE.getColorsFromDatabase();
for (int i = 0; i < colorPickers.size(); i++) {
colorPickers.get(i).getStyleClass().add("button");
// Set the color in the database on the color picker.
colorPickers.get(i).setValue(Color.web(colors[i]));
}
}
示例14: drawConner
import javafx.scene.paint.Color; //导入依赖的package包/类
/**
* 设置图形节点为选中样式
*/
@Override
public void drawConner() {
canvas.setMouseTransparent(true);
isConnerShow = true;
GraphicsContext gc = canvas.getGraphicsContext2D();
double whiteR = 12;
double blueR = 10;
if (x1 != null) {
double X = x.doubleValue();
double Y = y.doubleValue();
gc.setFill(Color.WHITE);
gc.fillOval(x1.doubleValue() -6+ X, y1.doubleValue() -6+ Y, whiteR, whiteR);
gc.fillOval(x2.doubleValue() - 6+ X, y2.doubleValue() - 6 + Y, whiteR, whiteR);
gc.setFill(Color.color(0.03, 0.43, 0.81));
gc.fillOval(x1.doubleValue() -5 + X, y1.doubleValue() -5 + Y, blueR, blueR);
gc.fillOval(x2.doubleValue()-5+ X, y2.doubleValue() - 5 + Y, blueR, blueR);
}
}
示例15: ladder
import javafx.scene.paint.Color; //导入依赖的package包/类
/**
* Get the color at the give {@code position} in the ladder of color stops
*/
private static Color ladder(final double position, final Stop[] stops) {
Stop prevStop = null;
for (int i=0; i<stops.length; i++) {
Stop stop = stops[i];
if(position <= stop.getOffset()){
if (prevStop == null) {
return stop.getColor();
} else {
return interpolateLinear((position-prevStop.getOffset())/(stop.getOffset()-prevStop.getOffset()), prevStop.getColor(), stop.getColor());
}
}
prevStop = stop;
}
// position is greater than biggest stop, so will we biggest stop's color
return prevStop.getColor();
}