public FxMapItem(FxMapModel model, MapData data) { mapModel = model; itemData = data; rect = new Rect(); rectangle = new Rectangle(); label = new Label(itemData.getName()); tooltip = new Tooltip(itemData.getName()); tooltip.setFont(new Font(DEFAULT_TOOLTIP_FONT_SIZE)); mainNode = new Group(rectangle, label); Tooltip.install(label, tooltip); applyStyle(model.getStyle()); if (data.hasChildrenData()) { rectangle.setEffect(new Glow()); } propertyChangeSupport = new PropertyChangeSupport(FxMapItem.this); propertyChangeSupport.addPropertyChangeListener(model); initInteractivity(); }
public MenuItem(String name) { Text text = new Text(name); text.setFill(Color.WHITE); text.setFont(Font.font(48)); getChildren().addAll(text); this.setOnMouseEntered(event -> { text.setStroke(Color.BLUE); }); this.setOnMouseExited(event -> { text.setStroke(null); }); this.setOnMousePressed(event -> { this.setEffect(new Glow(1)); }); this.setOnMouseReleased(event -> { this.setEffect(null); }); }
/** * Create a bulb based on provided parameters and associate a MouseEvent to * it such that clicking on a bulb will increase its size and enable the glow * effect. * * @param centerX X-coordinate of center of bulb. * @param centerY Y-coordinate of center of bulb. * @param radius Radius of bulb. * @param paint Paint/color instance to be used for bulb. * @return Christmas tree bulb with interactive support. */ private Circle createInteractiveBulb( final int centerX, final int centerY, final int radius, final Paint paint) { final Circle bulb = new Circle(centerX, centerY, radius, paint); bulb.setOnMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { bulb.setEffect(new Glow(1.0)); bulb.setRadius(bulb.getRadius() + 5); } }); return bulb; }
/** * takes the oil pump image and adds a plus to it */ public NewAgentPortrait(Image originalImage) { super(); ImageView firm = new ImageView(originalImage); size = firm.fitWidthProperty(); size.setValue(100);//just so that it has a value firm.setPreserveRatio(true); firm.setSmooth(true); firm.setCache(true); ImageView addPlus = new ImageView(PLUS_IMAGE); addPlus.setEffect(new Glow(2)); addPlus.fitWidthProperty().bind(firm.fitWidthProperty().divide(2)); addPlus.setPreserveRatio(true); addPlus.setSmooth(true); addPlus.setCache(true); addPlus.setBlendMode(BlendMode.SRC_OVER); this.getChildren().addAll(firm,addPlus); }
public TPABoard() { Image image = ResManager.getImage("centerstat.png"); main = new ImageView(); main.setImage(image); civil = new Label("0"); if (Manager.getGUI().enableGlowEffect) civil.setEffect(new Glow()); army = new Label("0"); if (Manager.getGUI().enableGlowEffect) army.setEffect(new Glow()); civil.setFont(Font.font("Arial", 36)); army.setFont(Font.font("Arial", 36)); civil.setLayoutX(221); civil.setLayoutY(26); civil.setTextFill(Color.web("#EEEEEE")); army.setLayoutX(311); army.setLayoutY(26); army.setTextFill(Color.web("#EEEEEE")); getChildren().add(main); getChildren().add(civil); getChildren().add(army); }
public Clock(Color onColor, Color offColor) { // create effect for on LEDs Glow onEffect = new Glow(1.7f); onEffect.setInput(new InnerShadow()); // create effect for on dot LEDs Glow onDotEffect = new Glow(1.7f); onDotEffect.setInput(new InnerShadow(5,Color.BLACK)); // create effect for off LEDs InnerShadow offEffect = new InnerShadow(); // create digits digits = new Digit[7]; for (int i = 0; i < 6; i++) { Digit digit = new Digit(onColor, offColor, onEffect, offEffect); digit.setLayoutX(i * 80 + ((i + 1) % 2) * 20); digits[i] = digit; getChildren().add(digit); } // create dots Group dots = new Group( new Circle(80 + 54 + 20, 44, 6, onColor), new Circle(80 + 54 + 17, 64, 6, onColor), new Circle((80 * 3) + 54 + 20, 44, 6, onColor), new Circle((80 * 3) + 54 + 17, 64, 6, onColor)); dots.setEffect(onDotEffect); getChildren().add(dots); // update digits to current time and start timer to update every second refreshClocks(); play(); }
public Clock(Color onColor, Color offColor) { // create effect for on LEDs Glow onEffect = new Glow(1.7f); onEffect.setInput(new InnerShadow()); // create effect for on dot LEDs Glow onDotEffect = new Glow(1.7f); onDotEffect.setInput(new InnerShadow(5,Color.BLACK)); // create effect for off LEDs InnerShadow offEffect = new InnerShadow(); // create digits digits = new Digit[7]; for (int i = 0; i < 6; i++) { Digit digit = new Digit(onColor, offColor, onEffect, offEffect); digit.setLayoutX(i * 80 + ((i + 1) % 2) * 20); digits[i] = digit; getChildren().add(digit); } // create dots Group dots = new Group( new Circle(80 + 54 + 20, 44, 6, onColor), new Circle(80 + 54 + 17, 64, 6, onColor), new Circle((80 * 3) + 54 + 20, 44, 6, onColor), new Circle((80 * 3) + 54 + 17, 64, 6, onColor)); dots.setEffect(onDotEffect); getChildren().add(dots); // update digits to current time and start timer to update every second refreshClocks(); }
@Override public void select (Selector selector) { ColorAdjust colorAdjust = new ColorAdjust(); colorAdjust.setBrightness(selector.getLightness()); this.setEffect(colorAdjust); this.setEffect(new Glow(selector.getGlow())); }
/** * determine selector for the object */ public void select (Selector selector) { ColorAdjust colorAdjust = new ColorAdjust(); colorAdjust.setBrightness(selector.getLightness()); this.setEffect(colorAdjust); this.setEffect(new Glow(selector.getGlow())); }
/** * Generate RMOUG text string with appropriate fill, font, and effect. * * @return "RMOUG" text string with fill, font, and effect. */ private Text generateTitleText() { return TextBuilder.create().text("Mars Simulation Project").x(20).y(20).fill(Color.DARKGRAY) .font(Font.font(java.awt.Font.SERIF, 75)) .effect(new Glow(0.25)).build(); }
public void aimedLightningBolt(Entity source, Point2D target) { Entity e = new Entity(Type.ENEMY_PROJECTILE); e.setProperty(Property.SUB_TYPE, Element.LIGHTNING); e.addControl(new PhysicsControl(consApp.physics)); e.addFXGLEventHandler(Event.COLLIDED_PLATFORM, event -> { consApp.getSceneManager().removeEntity(e); }); e.addFXGLEventHandler(Event.DEATH, event -> { consApp.getSceneManager().removeEntity(event.getTarget()); }); e.setVisible(false); e.setCollidable(false); Group g = new Group(); e.addControl(new PhysicsControl(consApp.physics)); LightningControl lc = new LightningControl(g); e.addControl(lc); e.setPosition(0, 0); g.getChildren().addAll(createBolt(new Point2D(target.getX(), -200), target, 5)); e.setGraphics(g); DropShadow shadow = new DropShadow(20, Color.PURPLE); shadow.setInput(new Glow(0.7)); g.setEffect(shadow); e.setProperty(Property.ENABLE_GRAVITY, false); consApp.getTimerManager().runOnceAfter(() -> { consApp.soundManager.playSFX(FileNames.LIGHTNING_DRUM); }, Config.LIGHTNING_DELAY.divide(2)); consApp.getSceneManager().addEntities(e); }
public MenuButton(String name) { text = new Text(name); text.setFont(text.getFont().font(20)); text.setFill(Color.WHITE); Rectangle bg = new Rectangle(250, 30); bg.setOpacity(0.6); bg.setFill(Color.BLACK); bg.setEffect(new GaussianBlur(3.5)); setAlignment(Pos.CENTER_LEFT); setRotate(-0.5); getChildren().addAll(bg, text); setOnMouseEntered(event -> { bg.setTranslateX(10); text.setTranslateX(10); bg.setFill(Color.WHITE); text.setFill(Color.BLACK); }); setOnMouseExited(event -> { bg.setTranslateX(0); text.setTranslateX(0); bg.setFill(Color.BLACK); text.setFill(Color.WHITE); }); DropShadow drop = new DropShadow(50, Color.WHITE); drop.setInput(new Glow()); setOnMousePressed(event -> setEffect(drop)); setOnMouseReleased(event -> setEffect(null)); }
/** * Animates a group of buttons by their coordinate values * @param coords The list of buttons at a coordinate to animate */ public void animateButtons(List<Coordinate> coords) { ANIMATION_TIMELINE.clear(); for (Coordinate c : coords) { CellButton btn = getCellButtonAt(c); Glow glow = new Glow(); glow.setLevel(1.0); //Sets a glow effect to the button btn.getGraphic().setEffect(glow); //Creates a timeline animation object that loops 4 ever Timeline timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //Defining of the different frames of the animation timeline KeyValue rotateValue = new KeyValue(btn.getGraphic().rotateProperty(), 20); KeyValue glowValue = new KeyValue(glow.levelProperty(), 0.1); KeyValue rotateValue2 = new KeyValue(btn.getGraphic().rotateProperty(), -20); KeyFrame rotateFrame = new KeyFrame(Duration.millis(200), rotateValue); KeyFrame glowFrame = new KeyFrame(Duration.millis(300), glowValue); KeyFrame rotateFrame2 = new KeyFrame(Duration.millis(400), rotateValue2); //Add all animation timelines to the timeline object and plays timeline.getKeyFrames().addAll(rotateFrame , glowFrame, rotateFrame2); timeline.play(); //Add to global list of timelines. This is so, that the animation could later be paused //If the used pauses the game ANIMATION_TIMELINE.add(timeline); } }
public GeographicalFirmPortrait(final GeographicalFirm agent, Color firmColor, GoodType goodSold, MacroII model) { super(agent,agent.xLocationProperty(),agent.yLocationProperty()); color.setValue(firmColor); this.firm = agent; //add a glow effect Glow glow = new Glow(3); Blend blend = new Blend(BlendMode.SRC_OVER, glow,icon.effectProperty().getValue()); icon.setEffect(blend); //schedule yourself to update your text StackPane.setAlignment(priceText, Pos.CENTER); priceText.setFont(Font.font("Verdana", FontWeight.BOLD,10)); model.scheduleSoon(ActionOrder.GUI_PHASE,new Steppable() { @Override public void step(SimState state) { if(!active) return; long price = agent.getSalesDepartment(goodSold).getLastAskedPrice(); Platform.runLater(() -> priceText.setText(String.valueOf(price))); //reschedule model.scheduleTomorrow(ActionOrder.GUI_PHASE,this); } }); //register as deactivable with the model model.registerDeactivable(this); }
public void initialise() { circle1.setEffect(new Bloom()); circle2.setEffect(new Glow()); circle3.setEffect(new GaussianBlur()); }
/** * Effect: configures the region to accept a file dropped onto it by * executing the specified command in the grow game with the dropped file's * URI as an argument. The program executes the action before executing the * command. * * @param r * the region * @param command * the command for the grow game. Should not start with * {@code ":"}; one will be added. * @param action * the action to run just before the command */ private void configureDrop(Region r, String command, Runnable action) { r.setOnDragOver(event -> { if (event.getGestureSource() != r && event.getDragboard().hasFiles()) { event.acceptTransferModes(TransferMode.COPY); } event.consume(); }); r.setOnDragEntered(event -> { if (event.getGestureSource() != r && event.getDragboard().hasFiles()) { r.setEffect(new Glow()); } event.consume(); }); r.setOnDragExited(event -> { if (event.getGestureSource() != r && event.getDragboard().hasFiles()) { r.setEffect(null); } event.consume(); }); r.setOnDragDropped(event -> { File newSound = null; if (event.getGestureSource() != r && event.getDragboard().hasFiles()) { if (event.getDragboard().hasFiles()) { List<File> files = event.getDragboard().getFiles(); if (files.size() == 1) { try { newSound = files.get(0); } catch (Exception e1) { newSound = null; } } } } boolean completed = false; if (newSound != null) { action.run(); if (gameThread.inject(":" + command + "\n" + newSound.toURI())) { completed = true; } else { new Alert(AlertType.ERROR, "You must finish editing before trying to drag and drop.", ButtonType.OK).showAndWait(); } } event.setDropCompleted(completed); event.consume(); }); }
public void setFill(Color color) { innerBar.setFill(color); DropShadow ds = new DropShadow(15, color); ds.setInput(new Glow(0.5)); innerBar.setEffect(ds); }
public QuarterCircle(String name) { Circle circle = new Circle(50); circle.setFill(null); circle.setStroke(Color.BLACK); circle.setStrokeWidth(30); Rectangle rect = new Rectangle(200, 100); rect.setTranslateX(-100); shape = Shape.subtract(circle, rect); rect = new Rectangle(100, 100); rect.setTranslateY(-100); shape = Shape.subtract(shape, rect); shape.setRotate(45); shape.setStroke(Color.BLACK); text = new Text(name); text.setFill(Color.WHITE); setOpacity(0.6); getChildren().addAll(shape, text); LinearGradient gradient = new LinearGradient(1, 1, 0.2, 0.2, true, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0.3, Color.GOLD), new Stop(0.9, Color.BLACK) }); DropShadow shadow = new DropShadow(5, Color.WHITE); shadow.setInput(new Glow(0.8)); setOnMouseEntered(event -> { setOpacity(0.9); shape.setFill(gradient); text.setFont(Font.font("", FontPosture.ITALIC, 12)); text.setEffect(shadow); }); setOnMouseExited(event -> { setOpacity(0.6); shape.setFill(Color.BLACK); text.setFont(Font.getDefault()); text.setEffect(null); }); }
public ItemView(int pos) { imageView.viewportProperty().bind(player.itemSpriteProperties.get(pos)); // imageView.setFitWidth(45); // imageView.setFitHeight(45); DropShadow drop = new DropShadow(1, Color.GOLD); drop.setInput(new Glow()); final Popup popup = new Popup(); Rectangle rect = new Rectangle(250, 150); rect.setArcWidth(30); rect.setArcHeight(30); rect.setFill(Color.AQUA); VBox box = new VBox(); box.setPadding(new Insets(5, 5, 5, 5)); box.setAlignment(Pos.CENTER); Text fullText = new Text(); fullText.setFont(fullText.getFont().font(18)); fullText.setWrappingWidth(200); fullText.textProperty().bind(player.itemDescProperties[pos]); box.getChildren().add(fullText); popup.getContent().addAll(rect, box); imageView.setOnMouseEntered(event -> { imageView.setEffect(drop); popup.setX(getX() + 400); popup.setY(getY()); popup.show(UIInventoryWindow.this); }); imageView.setOnMouseExited(event -> { imageView.setEffect(null); popup.hide(); }); imageView.setOnMouseClicked(event -> { Optional<GameItem> item = player.getInventory().getItem(pos); item.ifPresent(it -> { // if weapon or armor if (it instanceof Weapon || it instanceof Armor) { addActionRequest(new ActionRequest(Action.EQUIP, player.name, pos)); } else if (it instanceof UsableItem) { addActionRequest(new ActionRequest(Action.USE_ITEM, player.name, pos)); } }); }); // VBox vbox = new VBox(); // vbox.getChildren().addAll(imageView); getChildren().add(imageView); }
public EquipItemView(int pos) { imageView.viewportProperty().bind(player.equipItemSpriteProperties.get(pos)); // imageView.setFitWidth(45); // imageView.setFitHeight(45); DropShadow drop = new DropShadow(1, Color.GOLD); drop.setInput(new Glow()); final Popup popup = new Popup(); Rectangle rect = new Rectangle(250, 150); rect.setArcWidth(30); rect.setArcHeight(30); rect.setFill(Color.AQUA); VBox box = new VBox(); box.setPadding(new Insets(5, 5, 5, 5)); box.setAlignment(Pos.CENTER); Text fullText = new Text(); fullText.setFont(fullText.getFont().font(18)); fullText.setWrappingWidth(200); fullText.textProperty().bind(player.equipItemDescProperties[pos]); box.getChildren().add(fullText); popup.getContent().addAll(rect, box); imageView.setOnMouseEntered(event -> { imageView.setEffect(drop); popup.setX(getX() + 400); popup.setY(getY()); popup.show(UIInventoryWindow.this); }); imageView.setOnMouseExited(event -> { imageView.setEffect(null); popup.hide(); }); imageView.setOnMouseClicked(event -> { if (!player.isFree(pos)) addActionRequest(new ActionRequest(Action.UNEQUIP, player.name, pos)); }); // VBox vbox = new VBox(); // vbox.getChildren().addAll(imageView); getChildren().add(imageView); }
public SkillView(int pos) { text.setFont(text.getFont().font(16)); text.setFill(Color.DARKBLUE); text.textProperty().bind(new SimpleStringProperty("Lv ").concat(player.skillLevelProperties[pos])); imageView.imageProperty().bind(player.skillImageProperties.get(pos)); imageView.visibleProperty().bind(player.skillReadyProperties[pos]); imageView.setFitWidth(45); imageView.setFitHeight(45); DropShadow drop = new DropShadow(14, Color.GOLD); drop.setInput(new Glow()); final Popup popup = new Popup(); Rectangle rect = new Rectangle(250, 150); rect.setArcWidth(30); rect.setArcHeight(30); rect.setFill(Color.AQUA); VBox box = new VBox(); box.setPadding(new Insets(5, 5, 5, 5)); box.setAlignment(Pos.CENTER); Text fullText = new Text(); fullText.setFont(fullText.getFont().font(18)); fullText.setWrappingWidth(200); fullText.textProperty().bind(player.skillDescProperties[pos]); box.getChildren().add(fullText); popup.getContent().addAll(rect, box); imageView.setOnMouseEntered(event -> { imageView.setEffect(drop); popup.setX(getTranslateX() + 200); popup.setY(getTranslateY() - 50); popup.show(getStage()); }); imageView.setOnMouseExited(event -> { imageView.setEffect(null); popup.hide(); }); Button btn = new Button("+"); btn.visibleProperty().bind(player.skillPointsProperty.greaterThan(0) .and(player.skillLevelProperties[pos].lessThan(Skill.MAX_LEVEL))); btn.setOnAction(event -> { addActionRequest(new ActionRequest(Action.SKILL_UP, player.name, pos)); }); VBox vbox = new VBox(); vbox.getChildren().addAll(btn, imageView, text); getChildren().add(vbox); }
private void action(Boolean v, javafx.scene.Node n) { FxPlatformExecutor.runOnFxApplication(() -> { Effect e = (v) ? new Glow(0.8): null; n.setEffect(e); }); }
@PostConstruct /** * The @PostConstruct annotation labels methods executed when the component switch from inactive to active state * @param arg0 * @param resourceBundle */ public void onPostConstructComponent(final FXComponentLayout arg0, final ResourceBundle resourceBundle) { String family = "Helvetica"; TextFlow textFlow = new TextFlow(); textFlow.setLayoutX(40); textFlow.setLayoutY(40); DropShadow ds = new DropShadow(); ds.setOffsetY(6.0f); ds.setColor(Color.color(0.4f, 0.4f, 0.4f)); Text text1 = new Text(); text1.setX(5.0f); text1.setY(140.0f); text1.setCache(true); text1.setText("Welcome "); text1.setFill(Color.GREEN); text1.setFont(Font.font(null, FontWeight.BOLD, 36)); text1.setEffect(ds); text1.setTranslateY(10); Text text2 = new Text(); text2.setEffect(new GaussianBlur()); text2.setCache(true); text2.setX(10.0f); text2.setY(270.0f); text2.setFill(Color.GREEN); text2.setText("to the "); text2.setFont(Font.font(null, FontWeight.BOLD, 22)); text2.setTranslateY(50); Text text3 = new Text(); text3.setX(10.0f); text3.setY(50.0f); text3.setCache(true); text3.setText("Trivadis"); text3.setFill(Color.RED); text3.setFont(Font.font(null, FontWeight.BOLD, 50)); Reflection r = new Reflection(); r.setFraction(0.7f); text3.setEffect(r); text3.setTranslateY(80); Text text4 = new Text(" TechEvent!"); text4.setFill(Color.RED); text4.setCache(true); text4.setFont(Font.font(family, FontWeight.BOLD, 60)); text4.setEffect(new Glow()); text4.setTranslateY(120); textFlow.getChildren().addAll(text1, text2, text3, text4); Group group = new Group(textFlow); tab.getChildren().add(group); this.log.info("run on start of Demo1Component "); }
/** * <p> * Creates a new GlowImageButton. * </p> * * @param image The path to the image to display as the button. */ public GlowImageButton(final String image) { super(image); glow = new Glow(); glow.setLevel(0.0); setEffect(glow); }