Java Code Examples for javafx.scene.paint.Color#GREEN

The following examples show how to use javafx.scene.paint.Color#GREEN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorPickerApp.java    From oim-fx with MIT License 6 votes vote down vote up
public Parent createContent() {
    final ColorPicker colorPicker = new ColorPicker(Color.GREEN);
    final Label coloredText = new Label("Colors");
    Font font = new Font(53);
    coloredText.setFont(font);
    final Button coloredButton = new Button("Colored Control");
    Color c = colorPicker.getValue();
    coloredText.setTextFill(c);
    coloredButton.setStyle(createRGBString(c));
    
    colorPicker.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent t) {
            Color newColor = colorPicker.getValue();
            coloredText.setTextFill(newColor);
            coloredButton.setStyle(createRGBString(newColor));
        }
    });
    
    VBox outerVBox = new VBox(coloredText, coloredButton, colorPicker);
    outerVBox.setAlignment(Pos.CENTER);
    outerVBox.setSpacing(20);
    outerVBox.setMaxSize(VBox.USE_PREF_SIZE, VBox.USE_PREF_SIZE);
    
    return outerVBox;
}
 
Example 2
Source File: CardToken.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
protected void setScoreValue(Group group, int value, int baseValue, int maxValue) {
	Color color = Color.WHITE;
	if (value < maxValue) {
		color = Color.RED;
	} else if (value > baseValue) {
		color = Color.GREEN;
	}
	DigitFactory.showPreRenderedDigits(group, value, color);
}
 
Example 3
Source File: ShipImage.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
 * 補給ゲージ(燃料・弾薬)を取得します
 *
 * @param ship 艦娘
 * @return 補給ゲージ
 */
static Image getSupplyGauge(Ship ship) {
    Canvas canvas = new Canvas(36, 12);
    GraphicsContext gc = canvas.getGraphicsContext2D();

    Optional<ShipMst> mstOpt = Ships.shipMst(ship);
    if (mstOpt.isPresent()) {
        double width = canvas.getWidth();

        ShipMst mst = mstOpt.get();
        double fuelPer = (double) ship.getFuel() / (double) mst.getFuelMax();
        double ammoPer = (double) ship.getBull() / (double) mst.getBullMax();

        gc.setFill(Color.GRAY);
        gc.fillRect(0, 3, width, 2);

        gc.setFill(Color.GRAY);
        gc.fillRect(0, 10, width, 2);

        Color fuelColor = fuelPer >= 0.5D ? Color.GREEN : fuelPer >= 0.4D ? Color.ORANGE : Color.RED;
        Color ammoColor = ammoPer >= 0.5D ? Color.SADDLEBROWN : ammoPer >= 0.4D ? Color.ORANGE : Color.RED;

        gc.setFill(fuelColor);
        gc.fillRect(0, 0, width * fuelPer, 4);

        gc.setFill(ammoColor);
        gc.fillRect(0, 7, width * ammoPer, 4);
    }
    SnapshotParameters sp = new SnapshotParameters();
    sp.setFill(Color.TRANSPARENT);

    return canvas.snapshot(sp, null);
}
 
Example 4
Source File: Main.java    From FXTutorials with MIT License 5 votes vote down vote up
private Parent createContent() {
    Pane root = new Pane();
    root.setPrefSize(1280, 720);

    info.setTranslateX(50);
    info.setTranslateY(50);

    player = new Entity(400, 400, 30, 60, Color.GREEN);
    enemy = new Entity(300, 300, 40, 40, Color.RED);

    root.getChildren().addAll(info, player, enemy);
    return root;
}
 
Example 5
Source File: Main.java    From FXTutorials with MIT License 5 votes vote down vote up
private Parent createContent() {
    Pane root = new Pane();
    root.setPrefSize(1280, 720);

    info.setTranslateX(50);
    info.setTranslateY(50);

    player = new Entity(400, 400, 30, 60, Color.GREEN);
    enemy = new Entity(300, 300, 40, 40, Color.RED);
    coin = new Entity(300, 400, 20, 20, Color.YELLOW);

    player.setUserData("Player");
    enemy.setUserData("Enemy");
    coin.setUserData("Coin");

    objects.addAll(Arrays.asList(player, enemy, coin));

    registeredCollisions.add(new CollisionPair("Player", "Enemy", () -> {
        info.setText("Got hit by enemy");
    }));

    registeredCollisions.add(new CollisionPair("Player", "Coin", () -> {
        info.setText("Picked up a coin");
    }));

    root.getChildren().addAll(info, player, enemy, coin);
    return root;
}
 
Example 6
Source File: GameToken.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
protected void setScoreValueLowerIsBetter(Group group, int value, int baseValue) {
	Color color = Color.WHITE;
	if (value < baseValue) {
		color = Color.GREEN;
	} else if (value > baseValue) {
		color = Color.RED;
	}
	DigitFactory.showPreRenderedDigits(group, value, color);
}
 
Example 7
Source File: GameToken.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
protected void setScoreValue(Group group, int value, int baseValue, int maxValue) {
	Color color = Color.WHITE;
	if (value < maxValue) {
		color = Color.RED;
	} else if (value > baseValue) {
		color = Color.GREEN;
	}
	DigitFactory.showPreRenderedDigits(group, value, color);
}
 
Example 8
Source File: GameToken.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
protected void setScoreValue(Group group, int value, int baseValue) {
	Color color = Color.WHITE;
	if (value > baseValue) {
		color = Color.GREEN;
	}
	DigitFactory.showPreRenderedDigits(group, value, color);
}
 
Example 9
Source File: CardToken.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
private void setScoreValueLowerIsBetter(Group group, int value, int baseValue) {
	Color color = Color.WHITE;
	if (value < baseValue) {
		color = Color.GREEN;
	} else if (value > baseValue) {
		color = Color.RED;
	}
	DigitFactory.showPreRenderedDigits(group, value, color);
}
 
Example 10
Source File: CardToken.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
protected void setScoreValue(Group group, int value, int baseValue) {
	Color color = Color.WHITE;
	if (value > baseValue) {
		color = Color.GREEN;
	}
	DigitFactory.showPreRenderedDigits(group, value, color);
}
 
Example 11
Source File: TargetEditorController.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
public static Color createColor(final String name) {
	switch (name) {
	case "black":
		return Color.BLACK;
	case "blue":
		return Color.BLUE;
	case "brown":
		return Color.SADDLEBROWN;
	case "gray":
		return DARK_GRAY;
	case "green":
		return Color.GREEN;
	case "orange":
		return Color.ORANGE;
	case "red":
		return Color.RED;
	case "white":
		return Color.WHITE;
	default:
		if (name.startsWith("#")) {
			try {
				return Color.web(name);
			} catch (IllegalArgumentException e) {
				return Color.CORNSILK;
			}
		} else {
			return Color.CORNSILK;	
		}
	}
}
 
Example 12
Source File: LegendTest.java    From charts with Apache License 2.0 5 votes vote down vote up
@Override public void init() {
    LegendItem item1 = new LegendItem(Symbol.CIRCLE, "Item 1", Color.RED, Color.BLACK);
    LegendItem item2 = new LegendItem(Symbol.SQUARE, "Item 2", Color.GREEN, Color.BLACK);
    LegendItem item3 = new LegendItem(Symbol.TRIANGLE, "Item 3", Color.BLUE, Color.BLACK);

    legend = new Legend(item1, item2, item3);
    legend.setOrientation(Orientation.VERTICAL);
}
 
Example 13
Source File: StateCell.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
static Color getStateColor(final ScanState state)
{
    switch (state)
    {
    case Idle:      return Color.DARKBLUE;
    case Aborted:   return Color.DARKGOLDENROD;
    case Failed:    return Color.RED;
    case Finished:  return Color.DARKGREEN;
    case Paused:    return Color.GRAY;
    case Running:   return Color.GREEN;
    default:        return Color.BLACK;
    }
}
 
Example 14
Source File: Cube3D.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Node create3dContent() {
    Cube c = new Cube(50,Color.RED,1);
    c.rx.setAngle(45);
    c.ry.setAngle(45);
    Cube c2 = new Cube(50,Color.GREEN,1);
    c2.setTranslateX(100);
    c2.rx.setAngle(45);
    c2.ry.setAngle(45);
    Cube c3 = new Cube(50,Color.ORANGE,1);
    c3.setTranslateX(-100);
    c3.rx.setAngle(45);
    c3.ry.setAngle(45);

    animation = new Timeline();
    animation.getKeyFrames().addAll(
            new KeyFrame(Duration.ZERO,
                    new KeyValue(c.ry.angleProperty(), 0d),
                    new KeyValue(c2.rx.angleProperty(), 0d),
                    new KeyValue(c3.rz.angleProperty(), 0d)
            ),
            new KeyFrame(Duration.seconds(1),
                    new KeyValue(c.ry.angleProperty(), 360d),
                    new KeyValue(c2.rx.angleProperty(), 360d),
                    new KeyValue(c3.rz.angleProperty(), 360d)
            ));
    animation.setCycleCount(Animation.INDEFINITE);

    return new Group(c,c2,c3);
}
 
Example 15
Source File: CubeSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override public Node create3dContent() {
    Cube c = new Cube(50,Color.RED,1);
    c.rx.setAngle(45);
    c.ry.setAngle(45);
    Cube c2 = new Cube(50,Color.GREEN,1);
    c2.setTranslateX(100);
    c2.rx.setAngle(45);
    c2.ry.setAngle(45);
    Cube c3 = new Cube(50,Color.ORANGE,1);
    c3.setTranslateX(-100);
    c3.rx.setAngle(45);
    c3.ry.setAngle(45);

    animation = new Timeline();
    animation.getKeyFrames().addAll(
            new KeyFrame(Duration.ZERO,
                    new KeyValue(c.ry.angleProperty(), 0d),
                    new KeyValue(c2.rx.angleProperty(), 0d),
                    new KeyValue(c3.rz.angleProperty(), 0d)
            ),
            new KeyFrame(Duration.seconds(1),
                    new KeyValue(c.ry.angleProperty(), 360d),
                    new KeyValue(c2.rx.angleProperty(), 360d),
                    new KeyValue(c3.rz.angleProperty(), 360d)
            ));
    animation.setCycleCount(Animation.INDEFINITE);

    return new Group(c,c2,c3);
}
 
Example 16
Source File: CubeSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override public Node create3dContent() {
    Cube c = new Cube(50,Color.RED,1);
    c.rx.setAngle(45);
    c.ry.setAngle(45);
    Cube c2 = new Cube(50,Color.GREEN,1);
    c2.setTranslateX(100);
    c2.rx.setAngle(45);
    c2.ry.setAngle(45);
    Cube c3 = new Cube(50,Color.ORANGE,1);
    c3.setTranslateX(-100);
    c3.rx.setAngle(45);
    c3.ry.setAngle(45);

    animation = new Timeline();
    animation.getKeyFrames().addAll(
            new KeyFrame(Duration.ZERO,
                    new KeyValue(c.ry.angleProperty(), 0d),
                    new KeyValue(c2.rx.angleProperty(), 0d),
                    new KeyValue(c3.rz.angleProperty(), 0d)
            ),
            new KeyFrame(Duration.seconds(1),
                    new KeyValue(c.ry.angleProperty(), 360d),
                    new KeyValue(c2.rx.angleProperty(), 360d),
                    new KeyValue(c3.rz.angleProperty(), 360d)
            ));
    animation.setCycleCount(Animation.INDEFINITE);

    return new Group(c,c2,c3);
}
 
Example 17
Source File: CatchBall.java    From games_oop_javafx with Apache License 2.0 5 votes vote down vote up
private List<Circle> generateApples() {
    List<Circle> apples = new ArrayList<>();
    Random rn = new Random();
    for (int i = 0; i < 10; i++) {
        Circle apple = new Circle(10, Color.GREEN);
        apple.relocate(rn.nextInt(500), rn.nextInt(500));
        apples.add(apple);
    }
    return apples;
}
 
Example 18
Source File: FroggerApp.java    From FXTutorials with MIT License 4 votes vote down vote up
private Node initFrog() {
    Rectangle rect = new Rectangle(38, 38, Color.GREEN);
    rect.setTranslateY(600 - 39);

    return rect;
}
 
Example 19
Source File: Tutorial.java    From FXTutorials with MIT License 4 votes vote down vote up
private Parent createContent() {
    Cube c = new Cube(1, Color.GREEN);
    c.setTranslateX(-1);
    c.setRotationAxis(Rotate.Y_AXIS);
    c.setRotate(45);

    Cube c2 = new Cube(1, Color.BLUE);
    c2.setTranslateX(1);
    c2.setRotationAxis(Rotate.Y_AXIS);
    c2.setRotate(45);

    Cube c3 = new Cube(1, Color.RED);
    c3.setRotationAxis(Rotate.Y_AXIS);
    c3.setRotate(45);

    camera = new PerspectiveCamera(true);
    translate = new Translate(0, 0, -10);
    rotate = new Rotate(0, new Point3D(0, 1, 0));
    camera.getTransforms().addAll(translate, rotate);

    PointLight light = new PointLight(Color.WHITE);
    light.setTranslateX(3);
    light.setTranslateZ(-5);

    TranslateTransition tt = new TranslateTransition(Duration.seconds(2), light);
    tt.setFromX(-3);
    tt.setToX(3);
    tt.setAutoReverse(true);
    tt.setCycleCount(Animation.INDEFINITE);

    AmbientLight globalLight = new AmbientLight(Color.WHITE.deriveColor(0, 1, 0.2, 1));


    worldRoot.getChildren().addAll(c, c2, c3, globalLight, light);

    SubScene subScene = new SubScene(worldRoot, 800, 600, true, SceneAntialiasing.BALANCED);
    subScene.setCamera(camera);

    tt.play();

    return new Group(new Rectangle(800, 600), subScene);
}