javafx.scene.paint.Color Java Examples
The following examples show how to use
javafx.scene.paint.Color.
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: KeyStrokeMotion.java From netbeans with Apache License 2.0 | 7 votes |
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 #2
Source File: CSSFXTesterApp.java From cssfx with Apache License 2.0 | 6 votes |
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 #3
Source File: DotMatrix.java From mars-sim with GNU General Public License v3.0 | 6 votes |
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 #4
Source File: CellGestures.java From fxgraph with Do What The F*ck You Want To Public License | 6 votes |
@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 #5
Source File: HBoxSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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 #6
Source File: XYPane.java From charts with Apache License 2.0 | 6 votes |
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 #7
Source File: PathSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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 #8
Source File: ImageScaling.java From phoebus with Eclipse Public License 1.0 | 6 votes |
@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 #9
Source File: StarsComponent.java From FXGLGames with MIT License | 6 votes |
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 #10
Source File: MainScene.java From mars-sim with GNU General Public License v3.0 | 6 votes |
/** * 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 #11
Source File: SpaceInvadersFactory.java From FXGLGames with MIT License | 6 votes |
@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 File: KeyboardExample.java From JavaFX with MIT License | 6 votes |
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 #13
Source File: DebugDrawJavaFX.java From jbox2d with BSD 2-Clause "Simplified" License | 6 votes |
@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 #14
Source File: TreeModelItemCell.java From phoebus with Eclipse Public License 1.0 | 6 votes |
@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 #15
Source File: CellGestures.java From fxgraph with Do What The F*ck You Want To Public License | 6 votes |
@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 #16
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 5 votes |
public static boolean isColorMatch2(Color color1, Color color2, int distance2) { if (color1.equals(color2)) { return true; } else if (distance2 == 0) { return false; } return calculateColorDistance2(color1, color2) <= distance2; }
Example #17
Source File: DockingDemo.java From phoebus with Eclipse Public License 1.0 | 5 votes |
@Override public void start(final Stage stage) { // Add dock items to the original stage final DockItem tab1 = new DockItem("Tab 1"); final BorderPane layout = new BorderPane(); layout.setTop(new Label("Top")); layout.setCenter(new Label("Tab that indicates resize behavior")); layout.setBottom(new Label("Bottom")); tab1.setContent(layout); final DockItem tab2 = new DockItem("Tab 2"); tab2.setContent(new Rectangle(500, 500, Color.RED)); // The DockPane is added to a stage by 'configuring' it. // Initial tabs can be provided right away DockPane tabs = DockStage.configureStage(stage, tab1, tab2); stage.setX(100); // .. or tabs are added later final DockItem tab3 = new DockItem("Tab 3"); tab3.setContent(new Rectangle(500, 500, Color.GRAY)); tabs.addTab(tab3); // Create another stage with more dock items final DockItem tab4 = new DockItem("Tab 4"); tab4.setContent(new Rectangle(500, 500, Color.YELLOW)); final DockItem tab5 = new DockItem("Tab 5"); tab5.setContent(new Rectangle(500, 500, Color.BISQUE)); final Stage other = new Stage(); DockStage.configureStage(other, tab4, tab5); other.setX(600); stage.show(); other.show(); }
Example #18
Source File: AngleConicalGradient.java From Enzo with Apache License 2.0 | 5 votes |
public AngleConicalGradient(final Point2D CENTER, final double OFFSET_ANGLE, final Map<Double, Color> ANGLE_STOP_MAP) { final double ANGLE_FACTOR = 1d / 360d; double offset = Util.clamp(0d, 1d, (OFFSET_ANGLE % 360) * ANGLE_FACTOR); List<Stop> stops = new LinkedList<>(); for (Double fraction : ANGLE_STOP_MAP.keySet()) { stops.add(new Stop(Util.clamp(0d, 1d, (fraction % 360) * ANGLE_FACTOR), ANGLE_STOP_MAP.get(fraction))); } gradient = new ConicalGradient(CENTER, offset, stops); }
Example #19
Source File: Desk.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
/** * Node that represents the playing area/desktop where the puzzle pieces sit */ Desk(int numOfColumns, int numOfRows) { setStyle("-fx-background-color: #cccccc; " + "-fx-border-color: #464646; " + "-fx-effect: innershadow( two-pass-box , rgba(0,0,0,0.8) , 15, 0.0 , 0 , 4 );"); double DESK_WIDTH = Piece.SIZE * numOfColumns; double DESK_HEIGHT = Piece.SIZE * numOfRows; setPrefSize(DESK_WIDTH, DESK_HEIGHT); setMaxSize(DESK_WIDTH, DESK_HEIGHT); autosize(); // create path for lines Path grid = new Path(); grid.setStroke(Color.rgb(70, 70, 70)); getChildren().add(grid); // create vertical lines for (int col = 0; col < numOfColumns - 1; col++) { grid.getElements().addAll( new MoveTo(Piece.SIZE + Piece.SIZE * col, 5), new LineTo(Piece.SIZE + Piece.SIZE * col, Piece.SIZE * numOfRows - 5)); } // create horizontal lines for (int row = 0; row < numOfRows - 1; row++) { grid.getElements().addAll( new MoveTo(5, Piece.SIZE + Piece.SIZE * row), new LineTo(Piece.SIZE * numOfColumns - 5, Piece.SIZE + Piece.SIZE * row)); } }
Example #20
Source File: ImageManufactureCropController.java From MyBox with Apache License 2.0 | 5 votes |
@Override public boolean setColor(Control control, Color color) { if (control == null || color == null) { return false; } if (paletteButton.equals(control)) { bgRect.setFill(color); FxmlControl.setTooltip(bgRect, FxmlColor.colorNameDisplay(color)); AppVariables.setUserConfigValue("CropBackgroundColor", color.toString()); } return true; }
Example #21
Source File: StarfieldFX.java From mars-sim with GNU General Public License v3.0 | 5 votes |
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 #22
Source File: ImageManufactureMarginsController.java From MyBox with Apache License 2.0 | 5 votes |
@Override public boolean setColor(Control control, Color color) { if (control == null || color == null) { return false; } if (paletteButton.equals(control)) { bgRect.setFill(color); FxmlControl.setTooltip(bgRect, FxmlColor.colorNameDisplay(color)); AppVariables.setUserConfigValue("ImageShadowBackground", color.toString()); } return true; }
Example #23
Source File: JFXNodeUtils.java From JFoenix with Apache License 2.0 | 5 votes |
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; } }
Example #24
Source File: ScriptingWebWidget.java From BowlerStudio with GNU General Public License v3.0 | 5 votes |
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 #25
Source File: HeatTabController.java From marathonv5 with Apache License 2.0 | 5 votes |
/** * 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 #26
Source File: Demo.java From mars-sim with GNU General Public License v3.0 | 5 votes |
@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 File: RadarNodeChart.java From tilesfx with Apache License 2.0 | 5 votes |
public RadarNodeChart(final List<ChartData> DATA) { _minValue = 0; _maxValue = 100; _range = 100; _threshold = 100; _noOfSectors = MIN_NO_OF_SECTORS; _unit = ""; _legendVisible = false; _thresholdVisible = false; _mode = RadarChartMode.POLYGON; gradientStops = FXCollections.observableArrayList(); decimals = 0; formatString = new StringBuilder("%.").append(decimals).append("f").toString(); data = FXCollections.observableArrayList(); legendScaleFactor = 1.0; _smoothing = false; _chartBackgroundColor = Color.TRANSPARENT; _chartForegroundColor = Tile.FOREGROUND; _chartTextColor = Tile.FOREGROUND; _gridColor = Tile.GRAY; _chartFill = Tile.BLUE; _thresholdColor = Tile.LIGHT_RED; resizeListener = o -> resize(); gradientListener = change -> { stops.clear(); for (Stop stop : getGradientStops()) { if (Double.compare(stop.getOffset(), 0.0) == 0) { stops.add(new Stop(0, stop.getColor())); } stops.add(new Stop(stop.getOffset() * 0.69924 + 0.285, stop.getColor())); } redraw(); }; init(); initGraphics(); initData(DATA); registerListeners(); }
Example #28
Source File: ImagePane.java From paintera with GNU General Public License v2.0 | 5 votes |
/** * @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 #29
Source File: SmoothedChart.java From OEE-Designer with MIT License | 5 votes |
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 #30
Source File: CoxcombChart.java From charts with Apache License 2.0 | 5 votes |
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(); }