// REMOVE ME public static Node createIconContent() { StackPane sp = new StackPane(); BorderPane borderPane = new BorderPane(); Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY); rectangle.setStroke(Color.BLACK); borderPane.setPrefSize(rectangle.getWidth(), rectangle.getHeight()); Rectangle recTop = new Rectangle(62, 5, Color.web("#349b00")); recTop.setStroke(Color.BLACK); Rectangle recBottom = new Rectangle(62, 14, Color.web("#349b00")); recBottom.setStroke(Color.BLACK); Rectangle recLeft = new Rectangle(20, 41, Color.TRANSPARENT); recLeft.setStroke(Color.BLACK); Rectangle recRight = new Rectangle(20, 41, Color.TRANSPARENT); recRight.setStroke(Color.BLACK); Rectangle centerRight = new Rectangle(20, 41, Color.TRANSPARENT); centerRight.setStroke(Color.BLACK); borderPane.setRight(recRight); borderPane.setTop(recTop); borderPane.setLeft(recLeft); borderPane.setBottom(recBottom); borderPane.setCenter(centerRight); sp.getChildren().addAll(rectangle, borderPane); return new Group(sp); }
@FXML public void setRoleRogue() throws RemoteException { lbGameHunter.setTextFill(Color.web("#32cd32")); lbGameWarrior.setTextFill(Color.web("#32cd32")); lbGameMage.setTextFill(Color.web("#32cd32")); lbGameRogue.setTextFill(Color.web("#FFFFFF")); roleID = 0; setRole(); }
@Override public void start(Stage primaryStage) throws Exception { Group root = new Group(); Group circles = new Group(); for (int i = 0; i < 30; i++) { Circle circle = new Circle(150, Color.web("white", 0.05)); circle.setStrokeType(StrokeType.OUTSIDE); circle.setStroke(Color.web("white", 0.16)); circle.setStrokeWidth(4); circles.getChildren().add(circle); } root.getChildren().add(circles); Scene scene = new Scene(root, 800, 600, Color.BLACK); Rectangle colors = new Rectangle( scene.getWidth(), scene.getHeight(), new LinearGradient( 0f, 1f, 1f, 0f, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.web("#f8bd55")), new Stop(0.14, Color.web("#c0fe56")), new Stop(0.28, Color.web("#5dfbc1")), new Stop(0.43, Color.web("#64c2f8")), new Stop(0.57, Color.web("#be4af7")), new Stop(0.71, Color.web("#ed5fc2")), new Stop(0.85, Color.web("#ef504c")), new Stop(1, Color.web("#f2660f")), })); colors.widthProperty().bind(scene.widthProperty()); colors.heightProperty().bind(scene.heightProperty()); root.getChildren().add(colors); Timeline timeline = new Timeline(); for (Node circle : circles.getChildren()) { timeline .getKeyFrames() .addAll( new KeyFrame( Duration.ZERO, // set start position at 0 new KeyValue(circle.translateXProperty(), random() * 800), new KeyValue(circle.translateYProperty(), random() * 600)), new KeyFrame( new Duration(40000), // set end position at 40s new KeyValue(circle.translateXProperty(), random() * 800), new KeyValue(circle.translateYProperty(), random() * 600))); } timeline.play(); primaryStage.setScene(scene); primaryStage.show(); }
public static Color getDefaultBaseColor(final String theme) { switch (theme) { case Application.STYLESHEET_CASPIAN: return Color.web(DEFAULT_CASPIAN_BASE_COLOR); case Application.STYLESHEET_MODENA: return Color.web(DEFAULT_MODENA_BASE_COLOR); default: return Color.web(DEFAULT_MODENA_BASE_COLOR); } }
/** * Update background, tick and gridline colors * * @param cfg cfg[0] Background, cfg[1] Chart background, cfg[2] y cfg[3] gridline */ public void updateChartColors(String[] cfg) { strBackgroundColor = cfg[0]; for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { le.setStyle("-fx-background-color:" + strBackgroundColor); ((LegendAxis) le).selected = false; } } chart.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); chartPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder( scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))))); chartPanel.setBackground(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); legendFrame.setStyle("marco: " + strBackgroundColor + ";-fx-background-color: marco;"); strChartBackgroundColor = cfg[1]; ; plot.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strChartBackgroundColor))); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { le.setStyle("-fx-background-color:" + strBackgroundColor); ((LegendAxis) le).selected = false; for (Node nn : ((LegendAxis) le).getChildren()) { if (nn instanceof Label) { ((Label) nn) .setStyle( "fondo: " + strChartBackgroundColor + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: " + String.valueOf(fontSize) + "px"); } } } } strGridlineColor = cfg[2]; ; plot.setDomainGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); plot.setRangeGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); strTickColor = cfg[3]; ; abcissaAxis.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); abcissaAxis.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); for (NumberAxis ejeOrdenada : AxesList) { ejeOrdenada.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); ejeOrdenada.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); } }
private void configureDesign() { rectangleVisual.setLayoutY(0f); rectangleVisual.setLayoutX(-14); rectangleVisual.setFill(Color.TRANSPARENT); rectangleSmall.setLayoutX(-7); rectangleSmall.setLayoutY(5); rectangleSmall.setFill( new LinearGradient( 0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, colorWeak), new Stop(0.5, colorStrong), new Stop(1, colorWeak) })); rectangleBig.setLayoutX(-14); rectangleBig.setLayoutY(0); rectangleBig.setFill( new LinearGradient( 0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, colorStrong), new Stop(0.5, colorWeak), new Stop(1, colorStrong) })); rectangleWatch.setFill( new LinearGradient( 0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0, Color.web("#4e605f")), new Stop(0.2, Color.web("#c3d6d5")), new Stop(0.5, Color.web("#f9ffff")), new Stop(0.8, Color.web("#c3d6d5")), new Stop(1, Color.web("#4e605f")) })); rectangleWatch.setLayoutX(-12); rectangleWatch.setLayoutY(12); }
static { preferences = Preferences.userNodeForPackage(ThemeManager.class); final StringProperty _baseColorProperty = new SimpleStringProperty(); // restore the old value fontScaleProperty.set(preferences.getDouble(FONT_SIZE, 1)); // Save the value when it changes fontScaleProperty.addListener( (observable, oldValue, newValue) -> { if (newValue != null) { preferences.putDouble(FONT_SIZE, newValue.doubleValue()); } }); baseColorProperty.setValue(Color.web(preferences.get(BASE_COLOR, DEFAULT_MODENA_BASE_COLOR))); // restore the old base color value switch (preferences.get(LAST, Application.STYLESHEET_MODENA)) { case Application.STYLESHEET_CASPIAN: baseColorProperty.setValue( Color.web(preferences.get(BASE_COLOR, DEFAULT_CASPIAN_BASE_COLOR))); break; case Application.STYLESHEET_MODENA: baseColorProperty.setValue( Color.web(preferences.get(BASE_COLOR, DEFAULT_MODENA_BASE_COLOR))); break; default: baseColorProperty.setValue( Color.web(preferences.get(BASE_COLOR, DEFAULT_MODENA_BASE_COLOR))); } _baseColorProperty.setValue(colorToHex(baseColorProperty.getValue())); // Save the value when it changes baseColorProperty.addListener( (observable, oldValue, newValue) -> { if (newValue != null) { preferences.put(BASE_COLOR, colorToHex(newValue)); _baseColorProperty.setValue(colorToHex(newValue)); } }); // Create the binding format for the style / font size styleProperty = Bindings.format( "-fx-font-size: %1$.6fem; -fx-base:%2$s", fontScaleProperty, _baseColorProperty); }
public void update() { PainelConfig config = main.getConfig(); // servicos servidor.setText(config.get(PainelConfig.KEY_SERVER).getValue()); unidadeAtual = config.get(PainelConfig.KEY_UNIDADE, Integer.class).getValue(); updateUnidades(main.getService().buscarUnidades()); // som e tema vocalizar.setSelected(config.get(PainelConfig.KEY_SOUND_VOICE, Boolean.class).getValue()); corFundo.setValue(Color.web(config.get(PainelConfig.KEY_COR_FUNDO).getValue())); corMensagem.setValue(Color.web(config.get(PainelConfig.KEY_COR_MENSAGEM).getValue())); corSenha.setValue(Color.web(config.get(PainelConfig.KEY_COR_SENHA).getValue())); corGuiche.setValue(Color.web(config.get(PainelConfig.KEY_COR_GUICHE).getValue())); // screensaver videoUrl.setText(config.get(PainelConfig.KEY_SCREENSAVER_URL).getValue()); }
public static Polygon createArrow() { Polygon polygon = new Polygon(new double[] {7.5, 0, 15, 15, 10, 15, 10, 30, 5, 30, 5, 15, 0, 15}); polygon.setFill(Color.web("#ff0900")); return polygon; }
public Watch() { startButton = new Button(Color.web("#8cc700"), Color.web("#71a000")); stopButton = new Button(Color.web("#AA0000"), Color.web("#660000")); mainDial = new Dial(117, true, 12, 60, Color.RED, true); minutesDial = new Dial(30, false, 12, 60, "minutes", Color.BLACK, false); tenthsDial = new Dial(30, false, 12, 60, "10ths", Color.BLACK, false); configureBackground(); myLayout(); configureListeners(); configureTimeline(); getChildren() .addAll( background, minutesDial, tenthsDial, digitalClock, mainDial, startButton, stopButton); }
@SuppressWarnings("unchecked") private void initComponents() { pane = new AnchorPane(); pane.setPrefSize(800, 600); pane.setStyle( "-fx-background-color: linear-gradient(from 0% 0% to 100% 100%, blue 0%, silver 100%);"); txPesquisa = new TextField(); DropShadow ds = new DropShadow(); ds.setSpread(0.5); ds.setColor(Color.web("#FF0000")); txPesquisa.setEffect(ds); txPesquisa.setPromptText("Digite o item para pesquisa"); txPesquisa.setPrefWidth(200); txPesquisa.setFocusTraversable(false); tbVitrine = new TableView<ItensProperty>(); initItens(); tbVitrine.setItems(listItens); tbVitrine.setPrefSize(780, 550); columnProduto = new TableColumn<ItensProperty, String>(); columnProduto.setCellValueFactory(new PropertyValueFactory<ItensProperty, String>("produto")); columnProduto.setText("Produto"); columnPreco = new TableColumn<ItensProperty, Double>(); columnPreco.setCellValueFactory(new PropertyValueFactory<ItensProperty, Double>("preco")); columnPreco.setText("Preço"); tbVitrine.getColumns().addAll(columnProduto, columnPreco); pane.getChildren().addAll(txPesquisa, tbVitrine); }
// REMOVE ME public static Node createIconContent() { final Rectangle r1 = new Rectangle(50, 50, 14, 14); r1.setArcHeight(4); r1.setArcWidth(4); r1.setFill(Color.web("#ed4b00")); Polygon polygon = createArrow(); polygon.setLayoutX(68); polygon.setLayoutY(25); polygon.setRotate(45); Rectangle r3 = new Rectangle(25, 25, 64, 64); r3.setArcHeight(15); r3.setArcWidth(15); r3.setFill(Color.web("#f49b00")); javafx.scene.Group g = new javafx.scene.Group(r3, r1, polygon); return new javafx.scene.Group(g); }
private Text createDot(String string) { Text text = new Text(string); text.setFill(Color.web("#000000")); text.setFont(FONT); text.setTextOrigin(VPos.TOP); text.setLayoutX(1); text.setLayoutY(-4); return text; }
private Region generateFloorSurfacePane(int t, int n, int e, int s, int w) { Region floor = new Region(); floor.setPrefHeight(CELL_SIZE); floor.setPrefWidth(CELL_SIZE); Color floorSurface = Color.web("fff"); switch (t) { case (0): floorSurface = BARE_FLOOR_COLOR; break; case (1): floorSurface = LOW_PILE_COLOR; break; case (2): floorSurface = HIGH_PILE_COLOR; break; case (3): // TODO: replace with stair color floorSurface = Color.web("f00"); break; default: System.out.println("Unsupported floor type"); break; } int floor_n = 0, floor_e = 0, floor_s = 0, floor_w = 0; if (n > 0) { floor_n = BORDER_WIDTH; } if (e > 0) { floor_e = BORDER_WIDTH; } if (s > 0) { floor_s = BORDER_WIDTH; } if (w > 0) { floor_w = BORDER_WIDTH; } Insets floorGap = new Insets(floor_n, floor_e, floor_s, floor_w); floor.setBackground( new Background(new BackgroundFill(floorSurface, CornerRadii.EMPTY, floorGap))); return floor; }
@Override public void start(Stage stage) { // create scene stage.setTitle(Constants.APP_TITLE); System.err.println(Helpers.HOME); scene = new Scene(new Browser(stage), 900, 600, Color.web("#666970")); stage.setScene(scene); // apply CSS style scene.getStylesheets().add("/BrowserToolbar.css"); // show stage stage.show(); }
private void configureBackground() { ImageView imageView = new ImageView(); Image image = loadImage(); imageView.setImage(image); Circle circle1 = new Circle(); circle1.setCenterX(140); circle1.setCenterY(140); circle1.setRadius(120); circle1.setFill(Color.TRANSPARENT); circle1.setStroke(Color.web("#0A0A0A")); circle1.setStrokeWidth(0.3); Circle circle2 = new Circle(); circle2.setCenterX(140); circle2.setCenterY(140); circle2.setRadius(118); circle2.setFill(Color.TRANSPARENT); circle2.setStroke(Color.web("#0A0A0A")); circle2.setStrokeWidth(0.3); Circle circle3 = new Circle(); circle3.setCenterX(140); circle3.setCenterY(140); circle3.setRadius(140); circle3.setFill(Color.TRANSPARENT); circle3.setStroke(Color.web("#818a89")); circle3.setStrokeWidth(1); Ellipse ellipse = new Ellipse(140, 95, 180, 95); Circle ellipseClip = new Circle(140, 140, 140); ellipse.setFill(Color.web("#535450")); ellipse.setStrokeWidth(0); GaussianBlur ellipseEffect = new GaussianBlur(); ellipseEffect.setRadius(10); ellipse.setEffect(ellipseEffect); ellipse.setOpacity(0.1); ellipse.setClip(ellipseClip); background.getChildren().addAll(imageView, circle1, circle2, circle3, ellipse); }
@Override void bindItem(Property newItem) { tfKey.textProperty().bindBidirectional(newItem.keyProperty()); if (newItem.getValue().matches("#[0-9a-fA-F]{6}")) { cpColor.setVisible(true); tfValue.setVisible(false); cpColor.setValue(Color.web(newItem.getValue())); newItem.valueProperty().bindBidirectional(cpColor.valueProperty(), colorConverter); } else { cpColor.setVisible(false); tfValue.setVisible(true); tfValue.textProperty().bindBidirectional(newItem.valueProperty()); } }
private void configureEffect() { handEffect.setOffsetX(radius / 40); handEffect.setOffsetY(radius / 40); handEffect.setRadius(6); handEffect.setColor(Color.web("#000000")); Lighting lighting = new Lighting(); Light.Distant light = new Light.Distant(); light.setAzimuth(225); lighting.setLight(light); handEffect.setInput(lighting); handEffectGroup.setEffect(handEffect); }
// REMOVE ME public static Node createIconContent() { StackPane sp = new StackPane(); Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY); rectangle.setStroke(Color.BLACK); Group g = new Group(); for (int i = 0; i < 5; i++) { Rectangle r = new Rectangle(); r.setY(i * 10); r.setWidth(62); r.setHeight(10); r.setFill(Color.TRANSPARENT); r.setStroke(Color.BLACK); g.getChildren().add(r); } for (int j = 0; j < 5; j++) { Rectangle r = new Rectangle(); r.setX(j * 10); r.setWidth(10); r.setHeight(62); r.setFill(Color.TRANSPARENT); r.setStroke(Color.BLACK); g.getChildren().add(r); } Rectangle smallerRec = new Rectangle(10, 20, 35, 10); smallerRec.setFill(Color.web("#1c89f4")); Rectangle smallerRec2 = new Rectangle(5, 3, 20, 10); smallerRec2.setFill(Color.web("#349b00")); Group recGroup = new Group(); recGroup.getChildren().addAll(smallerRec, smallerRec2); sp.getChildren().addAll(rectangle, g, recGroup); return new Group(sp); }
/** * Constructs a Box3D object given specification of the parameters in Save Data File format. * * @param lineString Box: format data string */ public Box3D(String lineString) { StringTokenizer st = new StringTokenizer(lineString, ",;: "); String dataType = st.nextToken().trim(); if (dataType.equals("Box")) { double x = Double.valueOf(st.nextToken()).doubleValue(); double y = Double.valueOf(st.nextToken()).doubleValue(); double z = Double.valueOf(st.nextToken()).doubleValue(); this.p = new Point3D(x, y, z); this.width = Double.valueOf(st.nextToken()).doubleValue(); this.height = Double.valueOf(st.nextToken()).doubleValue(); this.depth = Double.valueOf(st.nextToken()).doubleValue(); this.xr = 0.0; this.yr = 0.0; this.zr = 0.0; if (st.hasMoreTokens()) { this.xr = Double.valueOf(st.nextToken()).doubleValue(); this.yr = Double.valueOf(st.nextToken()).doubleValue(); this.zr = Double.valueOf(st.nextToken()).doubleValue(); } if (st.hasMoreTokens()) { dm = DrawMode.valueOf(st.nextToken()); } if (st.hasMoreTokens()) { cf = CullFace.valueOf(st.nextToken()); } if (st.hasMoreTokens()) { this.m = new PhongMaterial(); this.m.setDiffuseColor(Color.web(st.nextToken())); if (st.hasMoreTokens()) { this.m.setSpecularColor(Color.web(st.nextToken())); } } else { this.m = null; } } }
/** * Constructs an Arrow3D object given specification of the parameters in Save Data File format. * * @param lineString Arrow: format data string */ public Arrow3D(String lineString) { StringTokenizer st = new StringTokenizer(lineString, ",;: "); String dataType = st.nextToken().trim(); if (dataType.equals("Arrow")) { double x1 = Double.valueOf(st.nextToken()).doubleValue(); double y1 = Double.valueOf(st.nextToken()).doubleValue(); double z1 = Double.valueOf(st.nextToken()).doubleValue(); this.p1 = new Point3D(x1, y1, z1); double x2 = Double.valueOf(st.nextToken()).doubleValue(); double y2 = Double.valueOf(st.nextToken()).doubleValue(); double z2 = Double.valueOf(st.nextToken()).doubleValue(); this.p2 = new Point3D(x2, y2, z2); this.arrowRadius = Double.valueOf(st.nextToken()).doubleValue(); if (st.hasMoreTokens()) { this.m = new PhongMaterial(); this.m.setDiffuseColor(Color.web(st.nextToken())); if (st.hasMoreTokens()) { this.m.setSpecularColor(Color.web(st.nextToken())); } } else { this.m = null; } } }
// REMOVE ME 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; }
@Override public void start(Stage primaryStage) { // Text Button Button btnText = new Button(); btnText.setText("Button!"); btnText.setTextFill(Color.web("red")); btnText.setFont(new Font("Verdana", 15)); // Image Text Button Button btnTextImage = new Button(); btnTextImage.setText("Check"); btnTextImage.setFont(Font.font(20)); btnTextImage.setPrefSize(150, 100); Image imgCheck = new Image("file:resources/images/check.png"); btnTextImage.setGraphic(new ImageView(imgCheck)); // Image Button Button btnRight = new Button(); Image imgRight = new Image("file:resources/images/button_right.png"); btnRight.setGraphic(new ImageView(imgRight)); Button btnLeft = new Button(); Image imgLeft = new Image("file:resources/images/button_left.png"); btnLeft.setGraphic(new ImageView(imgLeft)); HBox hBoxFirst = new HBox(25); hBoxFirst.getChildren().addAll(btnText, btnTextImage); HBox hBoxSecond = new HBox(10); hBoxSecond.getChildren().addAll(btnLeft, btnRight); VBox vBox = new VBox(20); vBox.getChildren().addAll(hBoxFirst, hBoxSecond); vBox.setPadding(new Insets(20, 20, 20, 20)); StackPane layout = new StackPane(vBox); Scene scene = new Scene(layout, 300, 180); primaryStage.setTitle("Sample 03. Button"); primaryStage.setScene(scene); primaryStage.show(); }
private void configureDigits() { for (int i : numbers) { digits[i] = new Text("0"); digits[i].setFont(FONT); digits[i].setTextOrigin(VPos.TOP); digits[i].setLayoutX(2.3); digits[i].setLayoutY(-1); Rectangle background; if (i < 6) { background = createBackground(Color.web("#a39f91"), Color.web("#FFFFFF")); digits[i].setFill(Color.web("#000000")); } else { background = createBackground(Color.web("#bdbeb3"), Color.web("#FF0000")); digits[i].setFill(Color.web("#FFFFFF")); } digitsGroup[i] = new Group(background, digits[i]); } }
@Override public void start(Stage pStage) { // create the scene stage = pStage; stage.setTitle("Web View"); URL startFile = this.getClass().getResource("/resources/html/layout.html"); System.out.println("startFile: " + startFile); Resources resources = new Resources(); resources.addStyle( this.getResource("bower_components/bootstrap/dist/css/bootstrap.css").toExternalForm()); resources.addStyle(this.getResource("css/styles.css").toExternalForm()); resources.addJsHead( this.getResource("bower_components/jquery/dist/jquery.js").toExternalForm()); resources.addJsHead(this.getResource("js/scripts.js").toExternalForm()); Browser browser = new Browser(resources, new JsObject(stage)); scene = new Scene(browser.run(startFile.toExternalForm()), 750, 500, Color.web("#666970")); stage.setScene(scene); scene.getStylesheets().add("webviewsample/BrowserToolbar.css"); stage.show(); }
private void updateViewModel() { setText(null); setGraphic(null); if (getItem() != null) { BorderPane mainBox = new BorderPane(); mainBox.setPadding(new Insets(3.0, 5.0, 3.0, 3.0)); VBox taskNameDisplay = new VBox(); taskNameDisplay.setAlignment(Pos.CENTER_LEFT); Text taskNameText = new Text(); taskNameDisplay.getChildren().addAll(taskNameText); HBox priorityDueDateDisplay = new HBox(); priorityDueDateDisplay.setAlignment(Pos.CENTER_RIGHT); Text taskPriorityText = new Text(); Text taskDueDateText = new Text(); taskPriorityText.setScaleX(1.25); taskPriorityText.setScaleY(1.25); priorityDueDateDisplay.setSpacing(40); priorityDueDateDisplay.getChildren().addAll(taskDueDateText, taskPriorityText); mainBox.leftProperty().set(taskNameDisplay); mainBox.rightProperty().set(priorityDueDateDisplay); mainBox.setMargin(mainBox.getLeft(), new Insets(0, 20, 0, 0)); Task currentTask = getItem(); int currentTaskPriority = currentTask.getPriority(); // setting task name to be displayed by the cell taskNameText.setText(currentTask.getTaskTitle()); // setting task due date to be displayed by the cell if (currentTask.getTaskDueDate() != null) { LocalDate currentDueDate = currentTask.getTaskDueDate(); taskDueDateText.setText( currentDueDate.getMonthValue() + "/" + currentDueDate.getDayOfMonth() + "/" + currentDueDate.getYear()); } // setting task priority to be displayed by the cell switch (currentTaskPriority) { case 1: { taskPriorityText.setText("!"); taskPriorityText.setFill(Color.web("#28ae33")); break; } case 2: { taskPriorityText.setText("!!"); taskPriorityText.setFill(Color.web("#babf23")); break; } case 3: { taskPriorityText.setText("!!!"); taskPriorityText.setFill(Color.web("#ee0606")); break; } default: { } } if (!currentTask.getComplete()) { taskNameText.setStrikethrough(false); } else { // if task is completed, strike out the task name mainBox.setOpacity(0.5); taskNameText.setStrikethrough(true); } setText(null); setGraphic(mainBox); } }
public class main extends Application { int CELL_SIZE = 75; int CELL_GAP = 2; int MAP_PADDING = 10; int BORDER_WIDTH = 5; // surface type colors Color BARE_FLOOR_COLOR = Color.web("eee"); Color LOW_PILE_COLOR = Color.web("ccc"); Color HIGH_PILE_COLOR = Color.web("aaa"); // TODO: find a surface for stairs // border colors Color OPEN_DOOR_COLOR = Color.GREEN; Color CLOSED_DOOR_COLOR = Color.YELLOW; Color WALL_COLOR = Color.BLACK; @Override public void start(Stage primaryStage) { // generated layout to be converted to GUI File sampleLayoutXMLFile = new File("MapLayout.xml"); // added to see functionality with xml file Map layout = new Map(sampleLayoutXMLFile); // <== // Map layout = new Map(); // main container for GUI: has areas for top/bottom/left/right/center BorderPane root = new BorderPane(); // container for map GUI GridPane map = new GridPane(); map.setPadding(new Insets(MAP_PADDING)); map.setHgap(CELL_GAP); map.setVgap(CELL_GAP); // array of cells to be added to map GUI StackPane cells[][] = new StackPane[layout.getWidth()][layout.getHeight()]; for (int row = 0; row < layout.getHeight(); row++) { for (int col = 0; col < layout.getWidth(); col++) { // create the cell's appearance cells[row][col] = buildCell(layout.getCell(row, col)); // this is the correct way to have it // https://docs.oracle.com/javafx/2/api/javafx/scene/layout/GridPane.html#add(javafx.scene.Node, int, int) map.add(cells[row][col], row, col); } } root.setCenter(map); Scene scene = new Scene(root); primaryStage.setScene(scene); primaryStage.setTitle("Clean Sweep Vacuum"); primaryStage.show(); } private StackPane buildCell(Cell c) { // query the map object to find out information about cell // build out the stack pane for that cell based on this info // * surface type // * borders int north_border = c.getNorth(); int east_border = c.getEast(); int south_border = c.getSouth(); int west_border = c.getWest(); Region floor = generateFloorSurfacePane(c.getType(), north_border, east_border, south_border, west_border); Region closedDoor = generateClosedDoorPane(north_border, east_border, south_border, west_border); Region openDoor = generateOpenDoorPane(north_border, east_border, south_border, west_border); StackPane sp = new StackPane(closedDoor, openDoor, floor); sp.setBackground( new Background(new BackgroundFill(WALL_COLOR, CornerRadii.EMPTY, Insets.EMPTY))); return sp; } private Region generateFloorSurfacePane(int t, int n, int e, int s, int w) { Region floor = new Region(); floor.setPrefHeight(CELL_SIZE); floor.setPrefWidth(CELL_SIZE); Color floorSurface = Color.web("fff"); switch (t) { case (0): floorSurface = BARE_FLOOR_COLOR; break; case (1): floorSurface = LOW_PILE_COLOR; break; case (2): floorSurface = HIGH_PILE_COLOR; break; case (3): // TODO: replace with stair color floorSurface = Color.web("f00"); break; default: System.out.println("Unsupported floor type"); break; } int floor_n = 0, floor_e = 0, floor_s = 0, floor_w = 0; if (n > 0) { floor_n = BORDER_WIDTH; } if (e > 0) { floor_e = BORDER_WIDTH; } if (s > 0) { floor_s = BORDER_WIDTH; } if (w > 0) { floor_w = BORDER_WIDTH; } Insets floorGap = new Insets(floor_n, floor_e, floor_s, floor_w); floor.setBackground( new Background(new BackgroundFill(floorSurface, CornerRadii.EMPTY, floorGap))); return floor; } private Region generateOpenDoorPane(int n, int e, int s, int w) { Region openDoor = new Region(); openDoor.setPrefHeight(CELL_SIZE); openDoor.setPrefWidth(CELL_SIZE); int north_gap = BORDER_WIDTH, east_gap = BORDER_WIDTH, south_gap = BORDER_WIDTH, west_gap = BORDER_WIDTH; if (n == 2) { north_gap = 0; } if (e == 2) { east_gap = 0; } if (s == 2) { south_gap = 0; } if (w == 2) { west_gap = 0; } Insets gap = new Insets(north_gap, east_gap, south_gap, west_gap); openDoor.setBackground( new Background(new BackgroundFill(OPEN_DOOR_COLOR, CornerRadii.EMPTY, gap))); return openDoor; } private Region generateClosedDoorPane(int n, int e, int s, int w) { Region closedDoor = new Region(); closedDoor.setPrefHeight(CELL_SIZE); closedDoor.setPrefWidth(CELL_SIZE); int north_gap = BORDER_WIDTH, east_gap = BORDER_WIDTH, south_gap = BORDER_WIDTH, west_gap = BORDER_WIDTH; if (n == 3) { north_gap = 0; } if (e == 3) { east_gap = 0; } if (s == 3) { south_gap = 0; } if (w == 3) { west_gap = 0; } Insets gap = new Insets(north_gap, east_gap, south_gap, west_gap); closedDoor.setBackground( new Background(new BackgroundFill(CLOSED_DOOR_COLOR, CornerRadii.EMPTY, gap))); return closedDoor; } public static void main(String[] args) { launch(args); } }
public ColorPickerPopover() { getStyleClass().add("color-picker-popover"); popup.setAutoHide(true); // add this to popup popup.getContent().add(this); // load stylesheet getStylesheets().add(ColorPicker.class.getResource("ColorPicker.css").toString()); // create popover path for main shape final Path p = new Path(); p.getElements() .addAll( new MoveTo(PICKER_PADDING, PICKER_PADDING + ARROW_SIZE + RADIUS), new ArcTo( RADIUS, RADIUS, 90, PICKER_PADDING + RADIUS, PICKER_PADDING + ARROW_SIZE, false, true), new LineTo(PICKER_PADDING + ARROW_X - (ARROW_SIZE * 0.8), PICKER_PADDING + ARROW_SIZE), new LineTo(PICKER_PADDING + ARROW_X, PICKER_PADDING), new LineTo(PICKER_PADDING + ARROW_X + (ARROW_SIZE * 0.8), PICKER_PADDING + ARROW_SIZE), new LineTo(PICKER_PADDING + PICKER_WIDTH - RADIUS, PICKER_PADDING + ARROW_SIZE), new ArcTo( RADIUS, RADIUS, 90, PICKER_PADDING + PICKER_WIDTH, PICKER_PADDING + ARROW_SIZE + RADIUS, false, true), new LineTo( PICKER_PADDING + PICKER_WIDTH, PICKER_PADDING + ARROW_SIZE + PICKER_HEIGHT - RADIUS), new ArcTo( RADIUS, RADIUS, 90, PICKER_PADDING + PICKER_WIDTH - RADIUS, PICKER_PADDING + ARROW_SIZE + PICKER_HEIGHT, false, true), new LineTo(PICKER_PADDING + RADIUS, PICKER_PADDING + ARROW_SIZE + PICKER_HEIGHT), new ArcTo( RADIUS, RADIUS, 90, PICKER_PADDING, PICKER_PADDING + ARROW_SIZE + PICKER_HEIGHT - RADIUS, false, true), new ClosePath()); p.setFill( new LinearGradient( 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0, Color.web("#313131")), new Stop(0.5, Color.web("#5f5f5f")), new Stop(1, Color.web("#313131")))); p.setStroke(null); p.setEffect(new DropShadow(15, 0, 1, Color.gray(0, 0.6))); p.setCache(true); // create rectangle to capture mouse events to hide Rectangle windowClickRect = RectangleBuilder.create() .width(PICKER_PADDING + PICKER_WIDTH + PICKER_PADDING) .height(PICKER_PADDING + PICKER_HEIGHT + PICKER_PADDING) .fill(Color.TRANSPARENT) .onMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { System.out.println("x= " + event.getX()); System.out.println( "p.contains(event.getX(), event.getY()) = " + p.contains(event.getX(), event.getY())); if (!p.contains(event.getX(), event.getY())) { hide(); } } }) .build(); final Circle colorRectIndicator = CircleBuilder.create() .centerX(60) .centerY(60) .radius(5) .stroke(Color.WHITE) .fill(null) .effect(new DropShadow(2, 0, 1, Color.BLACK)) .build(); colorRectIndicator .centerXProperty() .bind( new DoubleBinding() { { bind(sat); } @Override protected double computeValue() { return (PICKER_PADDING + 10) + (RECT_SIZE * (sat.get() / 100)); } }); colorRectIndicator .centerYProperty() .bind( new DoubleBinding() { { bind(bright); } @Override protected double computeValue() { return (PICKER_PADDING + ARROW_SIZE + 10) + (RECT_SIZE * (1 - (bright.get() / 100))); } }); final Rectangle colorRect = RectangleBuilder.create() .x(PICKER_PADDING + 10) .y(PICKER_PADDING + ARROW_SIZE + 10) .width(RECT_SIZE) .height(RECT_SIZE) .build(); colorRect .fillProperty() .bind( new ObjectBinding<Paint>() { { bind(color); } @Override protected Paint computeValue() { return Color.hsb(hue.getValue(), 1, 1); } }); Rectangle colorRectOverlayOne = RectangleBuilder.create() .x(PICKER_PADDING + 10) .y(PICKER_PADDING + ARROW_SIZE + 10) .width(RECT_SIZE) .height(RECT_SIZE) .fill( new LinearGradient( 0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(255, 255, 255, 1)), new Stop(1, Color.rgb(255, 255, 255, 0)))) .build(); EventHandler<MouseEvent> rectMouseHandler = new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { final double x = event.getX() - colorRect.getX(); final double y = event.getY() - colorRect.getY(); sat.set(clamp(x / RECT_SIZE) * 100); bright.set(100 - (clamp(y / RECT_SIZE) * 100)); } }; Rectangle colorRectOverlayTwo = RectangleBuilder.create() .x(PICKER_PADDING + 10) .y(PICKER_PADDING + ARROW_SIZE + 10) .width(RECT_SIZE) .height(RECT_SIZE) .fill( new LinearGradient( 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(0, 0, 0, 0)), new Stop(1, Color.rgb(0, 0, 0, 1)))) .onMouseDragged(rectMouseHandler) .onMouseClicked(rectMouseHandler) .build(); final Rectangle colorBar = RectangleBuilder.create() .x(PICKER_PADDING + PICKER_WIDTH - 30) .y(PICKER_PADDING + ARROW_SIZE + 10) .width(20) .height(RECT_SIZE) .fill(createHueGradient()) .build(); final Rectangle colorBarIndicator = RectangleBuilder.create() .x(PICKER_PADDING + PICKER_WIDTH - 32) .y(PICKER_PADDING + ARROW_SIZE + 15) .width(24) .height(10) .arcWidth(4) .arcHeight(4) .stroke(Color.WHITE) .fill(null) .effect(new DropShadow(2, 0, 1, Color.BLACK)) .build(); colorBarIndicator .yProperty() .bind( new DoubleBinding() { { bind(hue); } @Override protected double computeValue() { return (PICKER_PADDING + ARROW_SIZE + 5) + (RECT_SIZE * (hue.get() / 360)); } }); EventHandler<MouseEvent> barMouseHandler = new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { final double y = event.getY() - colorBar.getY(); hue.set(clamp(y / RECT_SIZE) * 360); } }; colorBar.setOnMouseDragged(barMouseHandler); colorBar.setOnMouseClicked(barMouseHandler); Label brightnessLabel = new Label("Brightness:"); brightnessLabel.setMinWidth(Control.USE_PREF_SIZE); GridPane.setConstraints(brightnessLabel, 0, 0); Slider brightnessSlider = SliderBuilder.create().min(0).max(100).id("BrightnessSlider").build(); brightnessSlider.valueProperty().bindBidirectional(bright); GridPane.setConstraints(brightnessSlider, 1, 0); IntegerField brightnessField = new IntegerField(); brightnessField.valueProperty().bindBidirectional(bright); brightnessField.setPrefColumnCount(7); GridPane.setConstraints(brightnessField, 2, 0); Label saturationLabel = new Label("Saturation:"); saturationLabel.setMinWidth(Control.USE_PREF_SIZE); GridPane.setConstraints(saturationLabel, 0, 1); Slider saturationSlider = SliderBuilder.create().min(0).max(100).id("SaturationSlider").build(); saturationSlider.valueProperty().bindBidirectional(sat); GridPane.setConstraints(saturationSlider, 1, 1); saturationSlider .styleProperty() .bind( new StringBinding() { { bind(color); } @Override protected String computeValue() { return "picker-color: hsb(" + hue.get() + ",100%,100%);"; } }); IntegerField saturationField = new IntegerField(); saturationField.valueProperty().bindBidirectional(sat); saturationField.setPrefColumnCount(7); GridPane.setConstraints(saturationField, 2, 1); Label webLabel = new Label("Web:"); webLabel.setMinWidth(Control.USE_PREF_SIZE); GridPane.setConstraints(webLabel, 0, 2); WebColorField webField = new WebColorField(); webField.valueProperty().bindBidirectional(color); GridPane.setConstraints(webField, 1, 2, 2, 1); GridPane controls = new GridPane(); controls.setVgap(5); controls.setHgap(5); controls .getChildren() .addAll( brightnessLabel, brightnessSlider, brightnessField, saturationLabel, saturationSlider, saturationField, webLabel, webField); controls.setManaged(false); controls.resizeRelocate( PICKER_PADDING + 10, PICKER_PADDING + ARROW_SIZE + 10 + 170 + 10, PICKER_WIDTH - 20, controls.getPrefHeight()); getChildren() .addAll( windowClickRect, p, colorRect, colorRectOverlayOne, colorRectOverlayTwo, colorBar, colorRectIndicator, colorBarIndicator, controls); }
public static Color getColor() { return Color.web("CFE2F7"); }
private class Dial extends Parent { private final double radius; private final Color color; private final Color FILL_COLOR = Color.web("#0A0A0A"); private final Font NUMBER_FONT = new Font(16); private final Text name = new Text(); private final Group hand = new Group(); private final Group handEffectGroup = new Group(hand); private final DropShadow handEffect = new DropShadow(); private int numOfMarks; private int numOfMinorMarks; public Dial( double radius, boolean hasNumbers, int numOfMarks, int numOfMinorMarks, Color color, boolean hasEffect) { this.color = color; this.radius = radius; this.numOfMarks = numOfMarks; this.numOfMinorMarks = numOfMinorMarks; configureHand(); if (hasEffect) { configureEffect(); } if (hasNumbers) { getChildren().add(createNumbers()); } getChildren().addAll(createTickMarks(), handEffectGroup); } public Dial( double radius, boolean hasNumbers, int numOfMarks, int numOfMinorMarks, String name, Color color, boolean hasEffect) { this(radius, hasNumbers, numOfMarks, numOfMinorMarks, color, hasEffect); configureName(name); getChildren().add(this.name); } private Group createTickMarks() { Group group = new Group(); for (int i = 0; i < numOfMarks; i++) { double angle = (360 / numOfMarks) * (i); group.getChildren().add(createTic(angle, radius / 10, 1.5)); } for (int i = 0; i < numOfMinorMarks; i++) { double angle = (360 / numOfMinorMarks) * i; group.getChildren().add(createTic(angle, radius / 20, 1)); } return group; } private Rectangle createTic(double angle, double width, double height) { Rectangle rectangle = new Rectangle(-width / 2, -height / 2, width, height); rectangle.setFill(Color.rgb(10, 10, 10)); rectangle.setRotate(angle); rectangle.setLayoutX(radius * Math.cos(Math.toRadians(angle))); rectangle.setLayoutY(radius * Math.sin(Math.toRadians(angle))); return rectangle; } private void configureName(String string) { Font font = new Font(9); name.setText(string); name.setBoundsType(TextBoundsType.VISUAL); name.setLayoutX(-name.getBoundsInLocal().getWidth() / 2 + 4.8); name.setLayoutY(radius * 1 / 2 + 4); name.setFill(FILL_COLOR); name.setFont(font); } private Group createNumbers() { return new Group( createNumber("30", -9.5, radius - 16 + 4.5), createNumber("0", -4.7, -radius + 22), createNumber("45", -radius + 10, 5), createNumber("15", radius - 30, 5)); } private Text createNumber(String number, double layoutX, double layoutY) { Text text = new Text(number); text.setLayoutX(layoutX); text.setLayoutY(layoutY); text.setTextAlignment(TextAlignment.CENTER); text.setFill(FILL_COLOR); text.setFont(NUMBER_FONT); return text; } public void setAngle(double angle) { Rotate rotate = new Rotate(angle); hand.getTransforms().clear(); hand.getTransforms().add(rotate); } private void configureHand() { Circle circle = new Circle(0, 0, radius / 18); circle.setFill(color); Rectangle rectangle1 = new Rectangle( -0.5 - radius / 140, +radius / 7 - radius / 1.08, radius / 70 + 1, radius / 1.08); Rectangle rectangle2 = new Rectangle( -0.5 - radius / 140, +radius / 3.5 - radius / 7, radius / 70 + 1, radius / 7); rectangle1.setFill(color); rectangle2.setFill(Color.BLACK); hand.getChildren().addAll(circle, rectangle1, rectangle2); } private void configureEffect() { handEffect.setOffsetX(radius / 40); handEffect.setOffsetY(radius / 40); handEffect.setRadius(6); handEffect.setColor(Color.web("#000000")); Lighting lighting = new Lighting(); Light.Distant light = new Light.Distant(); light.setAzimuth(225); lighting.setLight(light); handEffect.setInput(lighting); handEffectGroup.setEffect(handEffect); } }