类javafx.scene.image.ImageView源码实例Demo

下面列出了怎么用javafx.scene.image.ImageView的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: iliasDownloaderTool   文件: CoursesTreeView.java
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();
}
 
源代码2 项目: ShootOFF   文件: CheckableImageListCell.java
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);
}
 
源代码3 项目: ChatFX   文件: ClientController.java
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);
}
 
源代码4 项目: marathonv5   文件: FlowPaneSample.java
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);
}
 
源代码5 项目: Solitaire   文件: CardPileView.java
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();
		}
	};
}
 
源代码6 项目: jmonkeybuilder   文件: SceneFileEditor.java
@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);
}
 
源代码7 项目: gluon-samples   文件: MediaService.java
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();
}
 
源代码8 项目: DashboardFx   文件: UserDetail.java
@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;
}
 
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);
}
 
源代码10 项目: scenic-view   文件: JavaDocTab.java
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);
            }
        }
    });
}
 
源代码11 项目: JRemapper   文件: Icons.java
/**
 * 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;
}
 
源代码12 项目: jmonkeybuilder   文件: NodeTreeCell.java
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);
}
 
源代码13 项目: FXMaps   文件: DirectionsStepPane.java
/**
 * 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;
}
 
源代码14 项目: VickyWarAnalyzer   文件: CountryLabel.java
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);

}
 
源代码15 项目: exit_code_java   文件: DraggableNode.java
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;

}
 
源代码16 项目: phoebus   文件: ChannelTreeController.java
@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);
}
 
源代码17 项目: phoebus   文件: JobViewer.java
@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);
}
 
源代码18 项目: NSMenuFX   文件: AboutStageBuilder.java
public AboutStageBuilder withImage(Image image, double width, double height) {
  this.image = new ImageView(image);
  this.image.setFitWidth(width);
  this.image.setFitHeight(height);

  return this;
}
 
源代码19 项目: JavaFX-Chat   文件: CellRenderer.java
@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;
}
 
源代码20 项目: bisq   文件: ImageUtil.java
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;
    }
}
 
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));
}
 
源代码22 项目: marathonv5   文件: HyperlinkSample.java
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);
}
 
源代码23 项目: MSPaintIDE   文件: CreateProjectWindow.java
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"
    ));
}
 
源代码24 项目: JavaFX   文件: SingleClassNoXmlBallGame.java
private void checkBoxCollisions() {
	for (ImageView r : boxes) {
		if (r.isVisible() && ball.intersects(r.getBoundsInParent())) {
			boxesLeft.set(boxesLeft.get() - 1);
			r.setVisible(false);
		}
	}
}
 
源代码25 项目: FXyzLib   文件: Skybox.java
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);      
   
}
 
源代码26 项目: jmonkeybuilder   文件: NewFileByCreatorAction.java
/**
 * 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));
}
 
源代码27 项目: MyBox   文件: FxmlImageManufacture.java
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;
        }

    }
 
源代码28 项目: MyBox   文件: ListImageCheckBoxCell.java
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);
}
 
源代码29 项目: MyBox   文件: ImagesBrowserController.java
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);
}
 
源代码30 项目: Sword_emulator   文件: VgaController.java
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);
}
 
 类所在包
 同包方法