Java Code Examples for javafx.scene.image.ImageView

The following examples show how to use javafx.scene.image.ImageView. 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 check out the related API usage on the sidebar.
Example 1
private void redraw() {
	if (node == null) {
		setGraphic(null);
		return;
	}

	final BorderPane pane = new BorderPane();
	final Label box = new Label();
	box.setAlignment(Pos.TOP_LEFT);

	if (node instanceof IliasFolder) {
		IliasFolder folder = (IliasFolder) node;
		box.setGraphic(folder.getGraphic());
	} else if (node instanceof IliasFile) {
		IliasFile file = (IliasFile) node;
		box.setGraphic(file.getGraphic());
	} else if (node instanceof IliasForum) {
		box.setGraphic(new ImageView("img/forum.png"));
	}

	box.setText(node.toString());
	pane.setLeft(box);
	createAndAddActions(pane);
	setGraphic(pane);
	createToolTip();
}
 
Example 2
public static void cacheCamera(Camera c, CameraSelectionListener listener) {
	final ImageView iv = new ImageView();
	iv.setFitWidth(100);
	iv.setFitHeight(75);

	new Thread(() -> {
		final Optional<Image> img = fetchWebcamImage(c);

		if (img.isPresent()) {
			iv.setImage(img.get());
		}
	}, "FetchImageCellWebcamImages").start();

	final CheckBox cb = new CheckBox();
	cb.setOnAction((event) -> {
		if (listener != null) listener.cameraSelectionChanged(c, cb.isSelected());
	});
	checkCache.put(c, cb);

	final HBox webcamContainer = new HBox(cb, iv);
	webcamContainer.setAlignment(Pos.CENTER);
	containerCache.put(c, webcamContainer);
}
 
Example 3
Source Project: ChatFX   Source File: ClientController.java    License: MIT License 6 votes vote down vote up
private void addMsg(String msg, boolean senderIsServer) {
    Label lbl = new Label(msg);
    lbl.setStyle("-fx-font-size: 16px;"
            + "-fx-background-color: #" + (senderIsServer ? "B00020" : "2196f3") + ";"
            + "-fx-text-fill: #FFF;"
            + "-fx-background-radius:25;"
            + "-fx-padding: 10px;");
    lbl.setWrapText(true);
    lbl.setMaxWidth(400);
    
    HBox container = new HBox();
    if(senderIsServer) {
        container.getChildren().add(new ImageView(new Image("/images/server-48px.png")));
        container.setAlignment(Pos.CENTER_LEFT);
        container.setSpacing(10);
        container.setPadding(new Insets(0, 10, 0, 0));
    } else {
        container.setAlignment(Pos.CENTER_RIGHT);
        container.setPadding(new Insets(0, 10, 0, 10));
    }
    container.getChildren().add(lbl);
    container.setPrefHeight(40);

    msgNodes.getItems().add(container);
}
 
Example 4
Source Project: marathonv5   Source File: FlowPaneSample.java    License: Apache License 2.0 6 votes vote down vote up
public FlowPaneSample() {
    super(400, 400);

    FlowPane flowPane = new FlowPane(2, 4);
    flowPane.setPrefWrapLength(200); //preferred wraplength
    Label[] shortLabels = new Label[ITEMS];
    Label[] longLabels = new Label[ITEMS];
    ImageView[] imageViews = new ImageView[ITEMS];

    for (int i = 0; i < ITEMS; i++) {
        shortLabels[i] = new Label("Short label.");
        longLabels[i] = new Label("I am a slightly longer label.");
        imageViews[i] = new ImageView(ICON_48);
        flowPane.getChildren().addAll(shortLabels[i], longLabels[i], imageViews[i]);
    }
    getChildren().add(flowPane);
}
 
Example 5
Source Project: Solitaire   Source File: CardPileView.java    License: GNU General Public License v2.0 6 votes vote down vote up
private EventHandler<DragEvent> createDragEnteredHandler(final ImageView pImageView, final Card pCard)
{
	return new EventHandler<DragEvent>()
	{
		@Override
		public void handle(DragEvent pEvent)
		{
			CardTransfer transfer = new CardTransfer(pEvent.getDragboard().getString());
			if( GameModel.instance().isLegalMove(transfer.getTop(), aIndex) )
			{
				pImageView.setEffect(new DropShadow());
			}
			pEvent.consume();
		}
	};
}
 
Example 6
Source Project: jmonkeybuilder   Source File: SceneFileEditor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@FxThread
protected void createToolbar(@NotNull final HBox container) {
    super.createToolbar(container);

    lightButton = new ToggleButton();
    lightButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_SHOW_LIGHTS));
    lightButton.setGraphic(new ImageView(Icons.LIGHT_16));
    lightButton.setSelected(true);
    lightButton.selectedProperty().addListener((observable, oldValue, newValue) -> changeLight(newValue));

    audioButton = new ToggleButton();
    audioButton.setTooltip(new Tooltip(Messages.SCENE_FILE_EDITOR_ACTION_SHOW_AUDIO));
    audioButton.setGraphic(new ImageView(Icons.AUDIO_16));
    audioButton.setSelected(true);
    audioButton.selectedProperty().addListener((observable, oldValue, newValue) -> changeAudio(newValue));

    DynamicIconSupport.addSupport(lightButton, audioButton);

    FXUtils.addClassesTo(lightButton, audioButton, CssClasses.FILE_EDITOR_TOOLBAR_BUTTON);

    FXUtils.addToPane(lightButton, container);
    FXUtils.addToPane(audioButton, container);
}
 
Example 7
public MediaService() {
    
    MobileApplication.getInstance().addLayerFactory(POPUP_NAME, () -> {
        imageView = new ImageView();
        imageView.setFitHeight(50);
        imageView.setPreserveRatio(true);
        HBox adsBox = new HBox(imageView);
        adsBox.getStyleClass().add("mediaBox");
        return new SidePopupView(adsBox, Side.BOTTOM, false);
    });
    
    Services.get(LifecycleService.class).ifPresent(service -> {
        service.addListener(LifecycleEvent.PAUSE, this::stopExecutor);
        service.addListener(LifecycleEvent.RESUME, this::startExecutor);
    });
    startExecutor();
}
 
Example 8
Source Project: DashboardFx   Source File: UserDetail.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public Node icon() {
    Image image = new Image(getClass().getResource("/com/gn/media/img/avatar.png").toExternalForm());
    ImageView imageView = new ImageView(image);
    imageView.setFitHeight(30);
    imageView.setFitWidth(30);

    Circle circle = new Circle(12);
    circle.setStroke(Color.WHITE);
    circle.setStrokeWidth(5);
    circle.setCenterX(imageView.getFitWidth() / 2);
    circle.setCenterY(imageView.getFitHeight() / 2);
    imageView.setClip(circle);

    return imageView;
}
 
Example 9
public StatisticCellWithArrows(double width, boolean odd, String unit) {
    this.unit = unit;
    setPrefSize(width, 22);
    setSpacing(5);
    setAlignment(Pos.CENTER_RIGHT);
    Platform.runLater(() -> {
        getStyleClass().add("statsTableColCell");
        if (odd) {
            getStyleClass().add("statsTableColCellOdd");
        }
    });
    imageView = new ImageView();
    getChildren().add(imageView);
    value = new Label();
    getChildren().add(value);
}
 
Example 10
Source Project: scenic-view   Source File: JavaDocTab.java    License: GNU General Public License v3.0 6 votes vote down vote up
public JavaDocTab(final ScenicViewGui view) {
    super(TAB_NAME);
    
    this.scenicView = view;
    this.webView = new ProgressWebView();
    webView.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);

    setContent(webView);
    setGraphic(new ImageView(DisplayUtils.getUIImage("javadoc.png")));
    setClosable(false);
    selectedProperty().addListener(new ChangeListener<Boolean>() {
        @Override public void changed(final ObservableValue<? extends Boolean> arg0, final Boolean arg1, final Boolean newValue) {
            if (newValue) {
                DisplayUtils.showWebView(true);
                loadAPI(null);
            } else {
                DisplayUtils.showWebView(false);
            }
        }
    });
}
 
Example 11
Source Project: JRemapper   Source File: Icons.java    License: MIT License 6 votes vote down vote up
/**
 * Get image representation of a class by its access flags. Shows additional
 * flags such as {@code public, private, etc.}.
 * 
 * @param access
 *            Flags <i>(Modifiers)</i>
 * @return Image for flags.
 */
public static Group getClassExtended(int access) {
	Group g = getClass(access);
	if (Access.isPublic(access)) {
		g.getChildren().add(new ImageView(F_PUBLIC));
	}
	if (Access.isProtected(access)) {
		g.getChildren().add(new ImageView(F_PROTECTED));
	}
	if (Access.isPrivate(access)) {
		g.getChildren().add(new ImageView(F_PRIVATE));
	}
	if (Access.isSynthetic(access)) {
		g.getChildren().add(new ImageView(MOD_SYNTHETIC));
	}
	return g;
}
 
Example 12
Source Project: jmonkeybuilder   Source File: NodeTreeCell.java    License: Apache License 2.0 5 votes vote down vote up
public NodeTreeCell(@NotNull final M nodeTree) {
    this.nodeTree = nodeTree;
    this.icon = new ImageView();
    this.content = new HBox();
    this.text = new Label();
    this.visibleIcon = new ImageView();
    this.visibleIcon.addEventFilter(MouseEvent.MOUSE_RELEASED, this::processHide);
    this.visibleIcon.setOnMouseReleased(this::processHide);
    this.visibleIcon.setPickOnBounds(true);

    setOnMouseClicked(this::processClick);
    setOnDragDetected(this::startDrag);
    setOnDragDone(this::stopDrag);
    setOnDragOver(this::dragOver);
    setOnDragDropped(this::dragDropped);
    setOnDragExited(this::dragExited);
    setOnKeyReleased(event -> {
        if (isEditing()) event.consume();
    });

    FXUtils.addToPane(icon, content);
    FXUtils.addToPane(visibleIcon, content);
    FXUtils.addToPane(text, content);

    setConverter(stringConverter);

    FXUtils.addClassTo(content, CssClasses.DEF_HBOX);
    FXUtils.addClassTo(this, CssClasses.ABSTRACT_NODE_TREE_CELL);
}
 
Example 13
/**
 * Returns an {@link ImageView} node capable of being displayed
 * in this {@code DirectionsStepPane}
 * 
 * @param d     the {@link Direction} enum indicating icon subsection
 * @return      the constructed {@link ImageView}
 */
private ImageView getImageView(Direction d) {
    ImageView iv = new ImageView(imagePath);
    iv.setViewport(new Rectangle2D(0, d.index(), d.w(), d.h()));
    iv.fitWidthProperty().set(22);
    iv.fitHeightProperty().set(22);
    return iv;
}
 
Example 14
Source Project: VickyWarAnalyzer   Source File: CountryLabel.java    License: MIT License 5 votes vote down vote up
public CountryLabel(Country country) {
	super(country.getOfficialName());
	tag = country.getTag();

	ImageView iv2 = new ImageView(country.getFlag());
	iv2.setFitWidth(32); // 30 to 35 looks good
	iv2.setPreserveRatio(true);
	iv2.setSmooth(true);
	iv2.setCache(true);

	setGraphic(iv2);
	setContentDisplay(ContentDisplay.LEFT);

}
 
Example 15
Source Project: exit_code_java   Source File: DraggableNode.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void snapOnEdge(double x, double y, double width, double height){
    HBox titleBar=(HBox) getTop();
    Button btnMax= (Button) titleBar.getChildren().get(3);
    btnMax.setGraphic(new ImageView(Apps.maximize_img));

    setLayoutX(x);
    setLayoutY(y);
    setPrefWidth(width);
    setPrefHeight(height);
    onEdge=true;

}
 
Example 16
Source Project: phoebus   Source File: ChannelTreeController.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@FXML
public void createContextMenu() {

    final ContextMenu contextMenu = new ContextMenu();

    List<ContextMenuEntry> contextEntries = ContextMenuService.getInstance().listSupportedContextMenuEntries();
    contextEntries.forEach(entry -> {
        MenuItem item = new MenuItem(entry.getName(), new ImageView(entry.getIcon()));
        item.setOnAction(e -> {
            try {
                SelectionService.getInstance().getSelection();
                ObservableList<TreeItem<ChannelTreeByPropertyNode>> old = treeTableView.getSelectionModel()
                        .getSelectedItems();

                List<Object> supportedTypes = SelectionService.getInstance().getSelection().getSelections().stream()
                        .map(s -> {
                            return AdapterService.adapt(s, entry.getSupportedType()).get();
                        }).collect(Collectors.toList());
                // set the selection
                SelectionService.getInstance().setSelection(treeTableView, supportedTypes);
                entry.call(SelectionService.getInstance().getSelection());
                // reset the selection
                SelectionService.getInstance().setSelection(treeTableView, old);
            } catch (Exception ex) {
                logger.log(Level.WARNING, "Failed to execute action " + entry.getName(), ex);
            }
        });
        contextMenu.getItems().add(item);
    });

    treeTableView.setContextMenu(contextMenu);
}
 
Example 17
Source Project: phoebus   Source File: JobViewer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void updateItem(final Boolean ignored, final boolean empty)
{
    super.updateItem(ignored, empty);

    boolean running = ! empty;

    TableRow<JobInfo> row = null;
    if (running)
    {
        row = getTableRow();
        if (row == null)
            running = false;
    }

    if (running)
    {
        setAlignment(Pos.CENTER_RIGHT);
        final JobInfo info = row.getItem();
        final Button cancel = new Button(Messages.JobCancel, new ImageView(ABORT));
        cancel.setOnAction(event -> info.job.cancel());
        cancel.setMaxWidth(Double.MAX_VALUE);
        setGraphic(cancel);
    }
    else
        setGraphic(null);
}
 
Example 18
public AboutStageBuilder withImage(Image image, double width, double height) {
  this.image = new ImageView(image);
  this.image.setFitWidth(width);
  this.image.setFitHeight(height);

  return this;
}
 
Example 19
Source Project: JavaFX-Chat   Source File: CellRenderer.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public ListCell<User> call(ListView<User> p) {

    ListCell<User> cell = new ListCell<User>(){

        @Override
        protected void updateItem(User user, boolean bln) {
            super.updateItem(user, bln);
            setGraphic(null);
            setText(null);
            if (user != null) {
                HBox hBox = new HBox();

                Text name = new Text(user.getName());

                ImageView statusImageView = new ImageView();
                Image statusImage = new Image(getClass().getClassLoader().getResource("images/" + user.getStatus().toString().toLowerCase() + ".png").toString(), 16, 16,true,true);
                statusImageView.setImage(statusImage);

                ImageView pictureImageView = new ImageView();
                Image image = new Image(getClass().getClassLoader().getResource("images/" + user.getPicture().toLowerCase() + ".png").toString(),50,50,true,true);
                pictureImageView.setImage(image);

                hBox.getChildren().addAll(statusImageView, pictureImageView, name);
                hBox.setAlignment(Pos.CENTER_LEFT);

                setGraphic(hBox);
            }
        }
    };
    return cell;
}
 
Example 20
Source Project: bisq   Source File: ImageUtil.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static ImageView getCountryIconImageView(Country country) {
    try {
        return ImageUtil.getImageViewByUrl("/images/countries/" + country.code.toLowerCase() + ".png");
    } catch (Exception e) {
        log.error("Country icon not found URL = /images/countries/" + country.code.toLowerCase() +
                ".png / country name = " + country.name);
        return null;
    }
}
 
Example 21
public ConversionFailPopup(@NotNull String message) {
	super(ArmaDialogCreator.getPrimaryStage(), new VBox(5), null);

	ResourceBundle bundle = Lang.ApplicationBundle();
	setTitle(bundle.getString("Popups.ImageConversion.convert_error_popup_title"));

	myStage.initModality(Modality.APPLICATION_MODAL);
	myRootElement.setPadding(new Insets(10));
	myRootElement.getChildren().addAll(new HBox(10, new ImageView("/com/armadialogcreator/img/icons/error64.png"), new Label(message)));
	myStage.setMinWidth(340d);

	myRootElement.getChildren().addAll(new Separator(Orientation.HORIZONTAL), getBoundResponseFooter(false, true, false));
}
 
Example 22
Source Project: marathonv5   Source File: HyperlinkSample.java    License: Apache License 2.0 5 votes vote down vote up
public HyperlinkSample() {
    super(400,100);
    ImageView iv = new ImageView(ICON_48);
    VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setAlignment(Pos.CENTER_LEFT);

    Hyperlink h1 = new Hyperlink("Hyperlink");
    Hyperlink h2 = new Hyperlink("Hyperlink with Image");
    h2.setGraphic(iv);

    vbox.getChildren().add(h1);
    vbox.getChildren().add(h2);
    getChildren().add(vbox);
}
 
Example 23
Source Project: MSPaintIDE   Source File: CreateProjectWindow.java    License: MIT License 5 votes vote down vote up
public CreateProjectWindow(MainGUI mainGUI) throws IOException {
    super();
    this.mainGUI = mainGUI;
    FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("gui/CreateProject.fxml"));
    loader.setController(this);
    Parent root = loader.load();

    ImageView icon = new ImageView(getClass().getClassLoader().getResource("icons/taskbar/ms-paint-logo-colored.png").toString());
    icon.setFitHeight(25);
    icon.setFitWidth(25);

    JFXDecorator jfxDecorator = new JFXDecorator(this, root, false, true, true);
    jfxDecorator.setGraphic(icon);
    jfxDecorator.setTitle("Welcome to MS Paint IDE");

    Scene scene = new Scene(jfxDecorator);
    scene.getStylesheets().add("style.css");

    setScene(scene);
    this.mainGUI.getThemeManager().addStage(this);
    show();

    setTitle("Welcome to MS Paint IDE");
    getIcons().add(new Image(getClass().getClassLoader().getResourceAsStream("ms-paint-logo-taskbar.png")));

    this.mainGUI.getThemeManager().onDarkThemeChange(root, Map.of(".search-label", "dark",
            ".found-context", "dark",
            ".language-selection", "language-selection-dark"
    ));
}
 
Example 24
Source Project: JavaFX   Source File: SingleClassNoXmlBallGame.java    License: MIT License 5 votes vote down vote up
private void checkBoxCollisions() {
	for (ImageView r : boxes) {
		if (r.isVisible() && ball.intersects(r.getBoundsInParent())) {
			boxesLeft.set(boxesLeft.get() - 1);
			r.setVisible(false);
		}
	}
}
 
Example 25
Source Project: FXyzLib   Source File: Skybox.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void layoutViews() {
    
    for(ImageView v : views){
        v.setFitWidth(getSize());
        v.setFitHeight(getSize());
    }
    
    back.setTranslateX(-0.5 * getSize());
    back.setTranslateY(-0.5 * getSize());
    back.setTranslateZ(-0.5 * getSize());          
            
    front.setTranslateX(-0.5 * getSize());
    front.setTranslateY(-0.5 * getSize());
    front.setTranslateZ(0.5 * getSize());
    front.setRotationAxis(Rotate.Z_AXIS);
    front.setRotate(-180);
    front.getTransforms().add(new Rotate(180,front.getFitHeight() / 2, 0,0, Rotate.X_AXIS));
    front.setTranslateY(front.getTranslateY() - getSize());
            
    top.setTranslateX(-0.5 * getSize());
    top.setTranslateY(-1 * getSize());
    top.setRotationAxis(Rotate.X_AXIS);
    top.setRotate(-90);
            
    bottom.setTranslateX(-0.5 * getSize());
    bottom.setTranslateY(0);
    bottom.setRotationAxis(Rotate.X_AXIS);
    bottom.setRotate(90);
            
    left.setTranslateX(-1 * getSize());
    left.setTranslateY(-0.5 * getSize());
    left.setRotationAxis(Rotate.Y_AXIS);
    left.setRotate(90);        
    
    right.setTranslateX(0);
    right.setTranslateY(-0.5 * getSize());
    right.setRotationAxis(Rotate.Y_AXIS);
    right.setRotate(-90);      
   
}
 
Example 26
Source Project: jmonkeybuilder   Source File: NewFileByCreatorAction.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a new New file by creator action.
 *
 * @param element     the element
 * @param description the description
 */
NewFileByCreatorAction(@NotNull final ResourceElement element, @NotNull final FileCreatorDescription description) {
    super(element);
    this.description = description;
    final Image icon = description.getIcon();
    setText(description.getFileDescription());
    setGraphic(new ImageView(icon == null ? Icons.NEW_FILE_16 : icon));
}
 
Example 27
Source Project: MyBox   Source File: FxmlImageManufacture.java    License: Apache License 2.0 5 votes vote down vote up
public static Image addArcFx(Image image, int arc, Color bgColor) {
        try {
            if (image == null || arc <= 0) {
                return null;
            }
            Group group = new Group();
            double imageWidth = image.getWidth(), imageHeight = image.getHeight();
            Scene scene = new Scene(group);

            ImageView view = new ImageView(image);
            view.setPreserveRatio(true);
            view.setFitWidth(imageWidth);
            view.setFitHeight(imageHeight);

            Rectangle clip = new Rectangle(imageWidth, imageHeight);
            clip.setArcWidth(arc);
            clip.setArcHeight(arc);
            view.setClip(clip);

            group.getChildren().add(view);

            Blend blend = new Blend(BlendMode.SRC_OVER);
            blend.setBottomInput(new ColorInput(0, 0, imageWidth, imageHeight, bgColor));
            group.setEffect(blend);

            SnapshotParameters parameters = new SnapshotParameters();
            parameters.setFill(Color.TRANSPARENT);
            WritableImage newImage = group.snapshot(parameters, null);
            return newImage;

        } catch (Exception e) {
//            logger.error(e.toString());
            return null;
        }

    }
 
Example 28
Source Project: MyBox   Source File: ListImageCheckBoxCell.java    License: Apache License 2.0 5 votes vote down vote up
private void init() {
    view = new ImageView();
    view.setPreserveRatio(true);
    view.setFitHeight(imageSize);
    rect = new Rectangle();
    rect.setWidth(40);
    rect.setHeight(40);
    Callback<ImageItem, ObservableValue<Boolean>> itemToBoolean
            = (ImageItem item) -> item.getSelected();
    setSelectedStateCallback(itemToBoolean);
}
 
Example 29
Source Project: MyBox   Source File: ImagesBrowserController.java    License: Apache License 2.0 5 votes vote down vote up
public void zoomOut(int index) {
    ImageView iView = imageViewList.get(index);
    ScrollPane sPane = imageScrollList.get(index);
    if (iView == null || iView.getImage() == null) {
        return;
    }
    FxmlControl.zoomOut(sPane, iView, xZoomStep, yZoomStep);
}
 
Example 30
Source Project: Sword_emulator   Source File: VgaController.java    License: GNU General Public License v3.0 5 votes vote down vote up
public VgaController(ImageView screen, Machine machine) {
    content = new WritableImage(WIDTH, HEIGHT);
    this.machine = machine;
    placeHolder = new Image(VgaController.class.getResourceAsStream("/drawable/placeholder.jpg"));
    this.screen = screen;
    screen.setImage(placeHolder);

    graphProvider = new GraphProvider(machine);
    textProvider = new TextProvider(machine);

    TimingRenderer.register(this);
}