Java Code Examples for javafx.scene.paint.Color

The following examples show how to use javafx.scene.paint.Color. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: charts   Source File: XYPane.java    License: Apache License 2.0 6 votes vote down vote up
public XYPane(final Paint BACKGROUND, final int BANDS, final XYSeries<T>... SERIES) {
    getStylesheets().add(XYPane.class.getResource("chart.css").toExternalForm());
    aspectRatio        = PREFERRED_HEIGHT / PREFERRED_WIDTH;
    keepAspect         = false;
    _chartBackground   = BACKGROUND;
    listOfSeries       = FXCollections.observableArrayList(SERIES);
    scaleX             = 1;
    scaleY             = 1;
    symbolSize         = 2;
    noOfBands          = clamp(1, 5, BANDS);
    _lowerBoundX       = 0;
    _upperBoundX       = 100;
    _lowerBoundY       = 0;
    _upperBoundY       = 100;
    referenceZero      = true;
    _thresholdY        = 100;
    _thresholdYVisible = false;
    _thresholdYColor   = Color.RED;
    _polarTickStep     = PolarTickStep.FOURTY_FIVE;

    initGraphics();
    registerListeners();
}
 
Example 2
Source Project: mars-sim   Source File: DotMatrix.java    License: GNU General Public License v3.0 6 votes vote down vote up
public DotMatrix(final double PREFERRED_WIDTH, final double PREFERRED_HEIGHT, final int COLS, final int ROWS, final Color DOT_ON_COLOR, final Color DOT_OFF_COLOR, final DotShape DOT_SHAPE, final MatrixFont FONT) {
    preferredWidth         = PREFERRED_WIDTH;
    preferredHeight        = PREFERRED_HEIGHT;
    dotOnColor             = convertToInt(DOT_ON_COLOR);
    dotOffColor            = convertToInt(DOT_OFF_COLOR);
    dotShape               = DOT_SHAPE;
    cols                   = COLS;
    rows                   = ROWS;
    matrix                 = new int[cols][rows];
    matrixFont             = FONT;
    characterWidth         = matrixFont.getCharacterWidth();
    characterHeight        = matrixFont.getCharacterHeight();
    characterWidthMinusOne = characterWidth - 1;
    initGraphics();
    registerListeners();
}
 
Example 3
Source Project: marathonv5   Source File: HBoxSample.java    License: Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    StackPane sp = new StackPane();
    HBox hbox = new HBox(3);
    hbox.setAlignment(Pos.CENTER);

    Rectangle rectangle = new Rectangle(70, 25, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    hbox.setPrefSize(rectangle.getWidth(), rectangle.getHeight());

    Rectangle r1 = new Rectangle(14, 14, Color.web("#1c89f4"));
    Rectangle r2 = new Rectangle(14, 14, Color.web("#349b00"));
    Rectangle r3 = new Rectangle(18, 14, Color.web("#349b00"));

    hbox.getChildren().addAll(r1, r2, r3);
    sp.getChildren().addAll(rectangle, hbox);

    return new Group(sp);
}
 
Example 4
Source Project: phoebus   Source File: ImageScaling.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void start(final Stage stage)
{
    // Image with red border
    final WritableImage image = new WritableImage(WIDTH, HEIGHT);
    final PixelWriter writer = image.getPixelWriter();
    for (int x=0; x<WIDTH; ++x)
    {
        writer.setColor(x, 0, Color.RED);
        writer.setColor(x, HEIGHT-1, Color.RED);
    }
    for (int y=0; y<HEIGHT; ++y)
    {
        writer.setColor(0, y, Color.RED);
        writer.setColor(WIDTH-1, y, Color.RED);
    }

    // Draw into canvas, scaling 'up'
    final Canvas canvas = new Canvas(800, 600);
    canvas.getGraphicsContext2D().drawImage(image, 0, 0, canvas.getWidth(), canvas.getHeight());

    final Scene scene = new Scene(new Group(canvas), canvas.getWidth(), canvas.getHeight());
    stage.setScene(scene);
    stage.show();
}
 
Example 5
Source Project: marathonv5   Source File: PathSample.java    License: Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    Path path = new Path();
           path.getElements().addAll(
            new MoveTo(25, 25),
            new HLineTo(45),
            new ArcTo(20, 20, 0, 80, 25, true, true)
            );
    path.setStroke(Color.web("#b9c0c5"));
    path.setStrokeWidth(5);
    path.getStrokeDashArray().addAll(15d,15d);
    path.setFill(null);
    javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
    effect.setOffsetX(1);
    effect.setOffsetY(1);
    effect.setRadius(3);
    effect.setColor(Color.rgb(0,0,0,0.6));
    path.setEffect(effect);
    return path;
}
 
Example 6
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();
	final ReadOnlyDoubleProperty widthProperty = region.prefWidthProperty();
	final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty();

	final Rectangle resizeHandleSE = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleSE.xProperty().bind(xProperty.add(widthProperty).subtract(handleRadius / 2));
	resizeHandleSE.yProperty().bind(yProperty.add(heightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleSE, mouseLocation, Cursor.SE_RESIZE);

	resizeHandleSE.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragSouth(event, mouseLocation, region, handleRadius);
			dragEast(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleSE;
}
 
Example 7
Source Project: netbeans   Source File: KeyStrokeMotion.java    License: Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 8
Source Project: phoebus   Source File: TreeModelItemCell.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void updateItem(final TreeModelItem item, final boolean empty)
{
    super.updateItem(item, empty);
    if (empty  ||  item == null)
    {
        setText(null);
        setGraphic(null);
    }
    else
    {
        setText(item.toString());
        final AlarmSeverity severity = item.getSeverity();
        if (severity == null)
        {
            setGraphic(new ImageView(NO_ICON));
            setTextFill(Color.BLACK);
        }
        else
        {
            final int ordinal = severity.ordinal();
            setGraphic(new ImageView(ALARM_ICONS[ordinal]));
            setTextFill(SeverityColors.getTextColor(severity));
        }
    }
}
 
Example 9
Source Project: jbox2d   Source File: DebugDrawJavaFX.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
  Color f = cpool.getColor(color.x, color.y, color.z, .4f);
  Color s = cpool.getColor(color.x, color.y, color.z, 1f);
  GraphicsContext g = getGraphics();
  saveState(g);
  double[] xs = xDoublePool.get(vertexCount);
  double[] ys = yDoublePool.get(vertexCount);
  for (int i = 0; i < vertexCount; i++) {
    getWorldToScreenToOut(vertices[i], temp);
    xs[i] = temp.x;
    ys[i] = temp.y;
  }
  g.setLineWidth(stroke);
  g.setFill(f);
  g.fillPolygon(xs, ys, vertexCount);
  g.setStroke(s);
  g.strokePolygon(xs, ys, vertexCount);
  restoreState(g);
}
 
Example 10
Source Project: JavaFX   Source File: KeyboardExample.java    License: MIT License 6 votes vote down vote up
public Node createNode() {
	final StackPane keyNode = new StackPane();
	keyNode.setFocusTraversable(true);
	installEventHandler(keyNode);

	final Rectangle keyBackground = new Rectangle(50, 50);
	keyBackground.fillProperty().bind(
			Bindings.when(pressedProperty)
					.then(Color.RED)
					.otherwise(
							Bindings.when(keyNode.focusedProperty())
									.then(Color.LIGHTGRAY)
									.otherwise(Color.WHITE)));
	keyBackground.setStroke(Color.BLACK);
	keyBackground.setStrokeWidth(2);
	keyBackground.setArcWidth(12);
	keyBackground.setArcHeight(12);

	final Text keyLabel = new Text(keyCode.getName());
	keyLabel.setFont(Font.font("Arial", FontWeight.BOLD, 20));

	keyNode.getChildren().addAll(keyBackground, keyLabel);

	return keyNode;
}
 
Example 11
Source Project: FXGLGames   Source File: SpaceInvadersFactory.java    License: MIT License 6 votes vote down vote up
@Spawns("LaserBeam")
public Entity newLaserBeam(SpawnData data) {
    Rectangle view = new Rectangle(10, Config.HEIGHT - 25, Color.color(1.0, 1.0, 1.0, 0.86));
    view.setArcWidth(15);
    view.setArcHeight(15);
    view.setStroke(Color.BLUE);
    view.setStrokeWidth(1);

    return entityBuilder()
            .from(data)
            .type(LASER_BEAM)
            .viewWithBBox(view)
            .with(new CollidableComponent(true))
            .with(new LaserBeamComponent())
            .build();
}
 
Example 12
Source Project: mars-sim   Source File: MainScene.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates the new ticker billboard
 */
public void createBillboard() {

	matrix = DotMatrixBuilder.create().prefSize(925, 54).colsAndRows(196, 11).dotOnColor(Color.rgb(255, 55, 0))
			.dotOffColor(Color.rgb(64, 64, 64)).dotShape(DotShape.ROUND).matrixFont(MatrixFont8x8.INSTANCE).build();

	billboard = new StackPane(matrix);
	// billboard.setPadding(new Insets(1));
	billboard.setBackground(
			new Background(new BackgroundFill(Color.rgb(20, 20, 20), CornerRadii.EMPTY, Insets.EMPTY)));
	// billboard.setBorder(new Border(new BorderStroke(Color.DARKCYAN,
	// BorderStrokeStyle.DOTTED, CornerRadii.EMPTY, BorderWidths.FULL)));
	dragNode = new DraggableNode(billboard, stage, 925, 54);

	dragNode.setCache(true);
	dragNode.setCacheShape(true);
	dragNode.setCacheHint(CacheHint.SPEED);
}
 
Example 13
Source Project: FXGLGames   Source File: StarsComponent.java    License: MIT License 6 votes vote down vote up
private void respawn(Rectangle star) {
    star.setWidth(random(0.5f, 2.5f));
    star.setHeight(random(0.5f, 2.5f));
    star.setArcWidth(random(0.5f, 2.5f));
    star.setArcHeight(random(0.5f, 2.5f));

    star.setFill(Color.color(
            random(0.75, 1.0),
            random(0.75, 1.0),
            random(0.75, 1.0),
            random(0.5f, 1.0f)
    ));

    star.setTranslateX(random(0, FXGL.getAppWidth()));
    star.setTranslateY(-random(10, FXGL.getAppHeight()));
}
 
Example 14
Source Project: cssfx   Source File: CSSFXTesterApp.java    License: Apache License 2.0 6 votes vote down vote up
private Group buildCirclePane(int prefWidth, int prefHeight) {
    Group freePlacePane = new Group();
    int defaultShapeSize = 50;
    int shapeNumber = 10;
    Random r = new Random();

    for (int i = 0; i < shapeNumber; i++) {
        Circle c = new Circle(Math.max(10, defaultShapeSize * r.nextInt(100) / 100));
        c.getStyleClass().add("circle");
        if (i % 2 == 0) {
            c.getStyleClass().add("even");
        } else {
            c.getStyleClass().add("odd");
        }
        c.setCenterX(r.nextInt(prefWidth));
        c.setCenterY(r.nextInt(prefHeight));
        c.setFill(Color.BLUE);
        freePlacePane.getChildren().add(c);
    }

    freePlacePane.getStyleClass().add("circles");
    freePlacePane.prefWidth(250);
    freePlacePane.prefWidth(200);
    return freePlacePane;
}
 
Example 15
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();
	final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty();

	final Rectangle resizeHandleSW = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleSW.xProperty().bind(xProperty.subtract(handleRadius / 2));
	resizeHandleSW.yProperty().bind(yProperty.add(heightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleSW, mouseLocation, Cursor.SW_RESIZE);

	resizeHandleSW.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragSouth(event, mouseLocation, region, handleRadius);
			dragWest(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleSW;
}
 
Example 16
Source Project: paintera   Source File: ImagePane.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
	 * @param width
	 * 		preferred component width.
	 * @param height
	 * 		preferred component height.
	 */
	public ImagePane(
			final int width,
			final int height)
	{
		super();
		super.getChildren().add(imageView);
		this.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
		setWidth(width);
		setHeight(height);
//		super.getChildren().setAll(this.imageView);
	}
 
Example 17
Source Project: Intro-to-Java-Programming   Source File: Exercise_16_03.java    License: MIT License 5 votes vote down vote up
/** Return a circle */
private Circle getCircle() {
	Circle c = new Circle(10);
	c.setFill(Color.WHITE);
	c.setStroke(Color.BLACK);
	return c;
}
 
Example 18
Source Project: Quelea   Source File: MultimediaPanel.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a new image panel.
 */
public MultimediaPanel() {
    this.controlPanel = new MultimediaControls();
    controlPanel.setDisableControls(true);
    drawer = new MultimediaDrawer(controlPanel);
    imgView = new ImageView(new Image("file:icons/vid preview.png"));
    BorderPane.setMargin(controlPanel, new Insets(30));
    setCenter(controlPanel);
    VBox centerBit = new VBox(5);
    centerBit.setAlignment(Pos.CENTER);
    previewText = new Text();
    previewText.setFont(Font.font("Verdana", 20));
    previewText.setFill(Color.WHITE);
    BorderPane.setMargin(centerBit, new Insets(10));
    centerBit.getChildren().add(previewText);
    imgView.fitHeightProperty().bind(heightProperty().subtract(200));
    imgView.fitWidthProperty().bind(widthProperty().subtract(20));
    centerBit.getChildren().add(imgView);
    setBottom(centerBit);
    setMinWidth(50);
    setMinHeight(50);
    setStyle("-fx-background-color:grey;");
    
    addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent t) -> {
        if (t.getCode().equals(KeyCode.PAGE_DOWN) || t.getCode().equals(KeyCode.DOWN)) {
            t.consume();
            QueleaApp.get().getMainWindow().getMainPanel().getLivePanel().advance();
        } else if (t.getCode().equals(KeyCode.PAGE_UP) || t.getCode().equals(KeyCode.UP)) {
            t.consume();
            QueleaApp.get().getMainWindow().getMainPanel().getLivePanel().previous();
        }
    });
    
    DisplayCanvas dummyCanvas = new DisplayCanvas(false, false, false, this::updateCanvas, DisplayCanvas.Priority.LOW);
    registerDisplayCanvas(dummyCanvas);
}
 
Example 19
Source Project: restfb-examples   Source File: LoginJavaFXExample.java    License: MIT License 5 votes vote down vote up
public void start(Stage stage) {
  // parse arguments
  appId = getParameters().getRaw().get(0);
  appSecret = getParameters().getRaw().get(1);

  WebView webView = new WebView();
  WebEngine webEngine = webView.getEngine();

  // create the scene
  stage.setTitle("Facebook Login Example");
  // use quite a wide window to handle cookies popup nicely
  stage.setScene(new Scene(new VBox(webView), 1000, 600, Color.web("#666970")));
  stage.show();

  // obtain Facebook access token by loading login page
  DefaultFacebookClient facebookClient = new DefaultFacebookClient(Version.LATEST);
  String loginDialogUrl = facebookClient.getLoginDialogUrl(appId, SUCCESS_URL, new ScopeBuilder());
  webEngine.load(loginDialogUrl + "&display=popup&response_type=code");
  webEngine.locationProperty().addListener((property, oldValue, newValue) -> {
        if (newValue.startsWith(SUCCESS_URL)) {
          // extract access token
          CLIENT_LOGGER.debug(newValue);
          int codeOffset = newValue.indexOf("code=");
          String code = newValue.substring(codeOffset + "code=".length());
          AccessToken accessToken = facebookClient.obtainUserAccessToken(
              appId, appSecret, SUCCESS_URL, code);

          // trigger further code's execution
          consumeAccessToken(accessToken);

          // close the app as goal was reached
          stage.close();

        } else if ("https://www.facebook.com/dialog/close".equals(newValue)) {
          throw new IllegalStateException("dialog closed");
        }
      }
  );
}
 
Example 20
Source Project: tilesfx   Source File: SmoothedChart.java    License: Apache License 2.0 5 votes vote down vote up
public void setSelectorStrokeColor(final Color COLOR) {
    if (null == selectorStrokeColor) {
        _selectorStrokeColor = COLOR;
        selector.setStroke(_selectorStrokeColor);
        layoutPlotChildren();
    } else {
        selectorStrokeColor.set(COLOR);
    }
}
 
Example 21
Source Project: charts   Source File: InfoPopup.java    License: Apache License 2.0 5 votes vote down vote up
private void updateTextColor(final Color COLOR) {
    seriesText.setFill(COLOR);
    seriesSumText.setFill(COLOR);
    itemText.setFill(COLOR);
    valueText.setFill(COLOR);
    line.setStroke(COLOR);
    seriesNameText.setFill(COLOR);
    seriesValueText.setFill(COLOR);
    itemNameText.setFill(COLOR);
    itemValueText.setFill(COLOR);
}
 
Example 22
public ObjectProperty<Color> colorProperty() {
	if( this.color == null) {
		this.color = new StyleableObjectProperty<Color>(DEFAULT_COLOR) {

			@Override
			protected void invalidated() {
				super.invalidated();
			}

			@Override
			public CssMetaData<? extends Styleable, Color> getCssMetaData() {
				return StyleableProperties.COLOR;
			}

			@Override
			public Object getBean() {
				return JFXStyleableColor.this;
			}

			@Override
			public String getName() {
				return "color";
			}
		};
	}
	return this.color;
}
 
Example 23
Source Project: CPUSim   Source File: FontData.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void setFontAndBackground(TableCell region) {
    if(region.getTableView().getSelectionModel().isSelected(region.getIndex())) {
        //if the row is selected, set the background to the selection color
        region.setBackground(new Background(new BackgroundFill(Color.web(
                            selection), null, null)));
    }
    else {
        region.setBackground(new Background(new BackgroundFill(Color.web(
                            background), null, null)));
    }
    String optQuote = font.contains(" ") ? "\"" : "";
    region.setStyle("-fx-font-size:" + fontSize + "; "
            + "-fx-font-family:" + optQuote + font + optQuote);
}
 
Example 24
Source Project: OEE-Designer   Source File: SmoothedChart.java    License: MIT License 5 votes vote down vote up
public void setXAxisBorderColor(final Paint FILL) {
    if (Side.BOTTOM == getXAxis().getSide()) {
        getXAxis().setBorder(new Border(
            new BorderStroke(FILL, Color.TRANSPARENT, Color.TRANSPARENT, Color.TRANSPARENT, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID,
                             BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderStroke.DEFAULT_WIDTHS, Insets.EMPTY)));
    } else {
        getXAxis().setBorder(new Border(
            new BorderStroke(Color.TRANSPARENT, Color.TRANSPARENT, FILL, Color.TRANSPARENT, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID,
                             BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderStroke.DEFAULT_WIDTHS, Insets.EMPTY)));
    }
}
 
Example 25
Source Project: mars-sim   Source File: StarfieldFX.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void generate() {

        for (int i=0; i<STAR_COUNT; i++) {
        	
        	int hex = 0;
        	
        	int randColor = RandomUtil.getRandomInt(31);
        	
        	if (randColor == 0)
        		hex = 0xe7420b; // red orange	
        	else if (randColor == 1)
        		hex = 0xd0d0f9;  // light blue
        	else if (randColor == 2)
        		hex = 0xf4df0d; // FFFFE0; // yellow
        	else 
        		hex = 0xffffff; // white
        	
        	if (hex != 0xffffff) {
	        	int rand = RandomUtil.getRandomInt(127);
	        	hex = hex + rand;
        	}
        	
        	String hexString = Integer.toHexString(hex);
         	
        	Color c = Color.web(hexString, 1.0);
     		
       		nodes[i] = new Rectangle(1, 1, c);
        	
        	angles[i] = 2.0 * Math.PI * random.nextDouble();
            //start[i] = random.nextInt(2000000000);
            start[i] = random.nextInt(2000000000);

        }
        
    }
 
Example 26
Source Project: mars-sim   Source File: Demo.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(matrix);
    pane.setPadding(new Insets(10));
    pane.setBackground(new Background(new BackgroundFill(Color.rgb(20, 20, 20), CornerRadii.EMPTY, Insets.EMPTY)));

    Scene scene = new Scene(pane);

    stage.setTitle("DotMatrix");
    stage.setScene(scene);
    stage.show();

    timer.start();
}
 
Example 27
Source Project: marathonv5   Source File: HeatTabController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 28
private void reset() {
	running = false;
	Platform.runLater(() -> {
		runfx.setText("Run");
		runfx.setGraphic(AssetFactory.loadIcon("Run.png"));
		runfx.setBackground(new Background(new BackgroundFill(Color.LIGHTGREEN, CornerRadii.EMPTY, Insets.EMPTY)));

	});

}
 
Example 29
Source Project: tilesfx   Source File: SunburstChart.java    License: Apache License 2.0 5 votes vote down vote up
private Path createSegment(final double START_ANGLE, final double END_ANGLE, final double INNER_RADIUS, final double OUTER_RADIUS, final Color FILL, final Color STROKE, final TreeNode<ChartData> NODE) {
    double  startAngleRad = Math.toRadians(START_ANGLE + 90);
    double  endAngleRad   = Math.toRadians(END_ANGLE + 90);
    boolean largeAngle    = Math.abs(END_ANGLE - START_ANGLE) > 180.0;

    double x1 = centerX + INNER_RADIUS * Math.sin(startAngleRad);
    double y1 = centerY - INNER_RADIUS * Math.cos(startAngleRad);

    double x2 = centerX + OUTER_RADIUS * Math.sin(startAngleRad);
    double y2 = centerY - OUTER_RADIUS * Math.cos(startAngleRad);

    double x3 = centerX + OUTER_RADIUS * Math.sin(endAngleRad);
    double y3 = centerY - OUTER_RADIUS * Math.cos(endAngleRad);

    double x4 = centerX + INNER_RADIUS * Math.sin(endAngleRad);
    double y4 = centerY - INNER_RADIUS * Math.cos(endAngleRad);

    MoveTo moveTo1 = new MoveTo(x1, y1);
    LineTo lineTo2 = new LineTo(x2, y2);
    ArcTo  arcTo3  = new ArcTo(OUTER_RADIUS, OUTER_RADIUS, 0, x3, y3, largeAngle, true);
    LineTo lineTo4 = new LineTo(x4, y4);
    ArcTo  arcTo1  = new ArcTo(INNER_RADIUS, INNER_RADIUS, 0, x1, y1, largeAngle, false);

    Path path = new Path(moveTo1, lineTo2, arcTo3, lineTo4, arcTo1);

    path.setFill(FILL);
    path.setStroke(STROKE);

    String tooltipText = new StringBuilder(NODE.getItem().getName()).append("\n").append(String.format(Locale.US, formatString, NODE.getItem().getValue())).toString();
    Tooltip.install(path, new Tooltip(tooltipText));

    path.setOnMousePressed(new WeakEventHandler<>(e -> NODE.getTreeRoot().fireTreeNodeEvent(new TreeNodeEvent(NODE, EventType.NODE_SELECTED))));

    return path;
}
 
Example 30
Source Project: charts   Source File: CoxcombChart.java    License: Apache License 2.0 5 votes vote down vote up
public CoxcombChart(final List<ChartItem> ITEMS) {
    width               = PREFERRED_WIDTH;
    height              = PREFERRED_HEIGHT;
    size                = PREFERRED_WIDTH;
    items               = FXCollections.observableArrayList(ITEMS);
    _textColor          = Color.WHITE;
    _autoTextColor      = true;
    _order              = Order.DESCENDING;
    _equalSegmentAngles = false;
    itemListener        = e -> reorder(getOrder());
    itemListListener    = c -> {
        while (c.next()) {
            if (c.wasAdded()) {
                c.getAddedSubList().forEach(addedItem -> addedItem.setOnItemEvent(itemListener));
                reorder(getOrder());
            } else if (c.wasRemoved()) {
                c.getRemoved().forEach(removedItem -> removedItem.removeItemEventListener(itemListener));
                reorder(getOrder());
            }
        }
        redraw();
    };
    mouseHandler        = e -> handleMouseEvent(e);
    listeners           = new CopyOnWriteArrayList<>();
    initGraphics();
    registerListeners();
}