Example usage for javafx.scene.image ImageView ImageView

List of usage examples for javafx.scene.image ImageView ImageView

Introduction

In this page you can find the example usage for javafx.scene.image ImageView ImageView.

Prototype

public ImageView(Image image) 

Source Link

Document

Allocates a new ImageView object using the given image.

Usage

From source file:ubicrypt.ui.ctrl.providers.ProvidersController.java

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
    String fxml = substringBefore(substringAfterLast(url.getFile(), "/"), ".fxml");
    navigator = new StackNavigator(root, fxml, controllerFactory);
    providers.setCellFactory(listView -> new ListCell<ProviderItem>() {
        @Override//from   w ww.  ja va2s .c o m
        protected void updateItem(ProviderItem pi, boolean empty) {
            super.updateItem(pi, empty);
            if (empty) {
                setText(null);
                setGraphic(null);
                return;
            }
            setContextMenu(pi.getContextMenu());
            Platform.runLater(() -> setGraphic(pi.getGraphics()));
        }
    });
    providerDescriptors.stream().forEach(pd -> {
        Button button = new Button();
        Image img = pd.getLogo().getImage();
        ImageView view = new ImageView(img);
        view.setFitWidth(30.0);
        view.setPickOnBounds(true);
        view.setPreserveRatio(true);
        button.setGraphic(view);
        button.setOnMouseClicked(mouseEvent -> {
            log.debug("adding provider :{}", pd.getCode());
            navigator.browse(format("provider/%s", pd.getCode()));
        });
        button.setTooltip(new Tooltip("Add " + pd.getDescription()));
        availableProviders.getItems().add(button);
    });

    //provider status events
    providerEvent.subscribe(pevent -> {
        UbiProvider provider = pevent.getHook().getProvider();
        if (!providers.getItems().stream().filter(pi -> pi.getProvider().equals(provider)).findFirst()
                .isPresent()) {
            log.info("add new provider:{}", pevent.getHook().getProvider());
            String code = providerDescriptors.stream().filter(pd -> pd.getType() == provider.getClass())
                    .map(ProviderDescriptor::getCode).findFirst().get();
            final ProviderItem providerItem = new ProviderItem(provider, providerDescriptors.stream()
                    .filter(pd -> pd.getType() == provider.getClass()).findFirst().get(), providerRemover,
                    navigator);
            providers.getItems().add(providerItem);
            pevent.getHook().getStatusEvents().subscribe(providerItem::changeStatus);
        }
        switch (pevent.getEvent()) {
        case removed:
            //TODO: remove provider
            break;
        default:
            log.warn("unmanaged event:{}", pevent.getEvent());
        }
        providers.getItems().stream().filter(pi -> pi.getProvider().equals(provider)).findFirst()
                .ifPresent(pi -> pi.changeStatus(pevent.getEvent()));
    });
}

From source file:ubicrypt.core.UbiConf.java

/**
 * providers//from w ww .  java2s .c  om
 */
@Bean
public List<ProviderDescriptor> providerDescriptors() {
    return ImmutableList.of(
            new ProviderDescriptor(FileProvider.class, "file", "local folder",
                    new ImageView("images/folder-48.png")),
            new ProviderDescriptor(FTProvider.class, "ftp", "ftp repository",
                    new ImageView("images/Ftp-48.png")));
}

From source file:jlotoprint.MainViewController.java

public static void loadAboutWindow() {

    //setup//from  www  .  ja va2 s  . c  om
    Dialog dialog = new Dialog<>();
    dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);
    dialog.setTitle("About JLotoPanel");
    dialog.setHeaderText("JLotoPanel v1.0");
    ImageView icon = new ImageView("file:resources/icon.png");
    icon.setSmooth(true);
    icon.setFitHeight(48.0);
    icon.setFitWidth(48.0);
    dialog.setGraphic(icon);
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.initOwner(JLotoPrint.stage.getScene().getWindow());
    //content
    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 0, 10));

    //text
    TextArea textArea = new TextArea("For more info, please visit: https://github.com/mbppower/JLotoPanel");
    textArea.setWrapText(true);
    grid.add(textArea, 0, 0);
    dialog.getDialogPane().setContent(grid);

    dialog.showAndWait();
}

From source file:org.eclipse.fx.ui.workbench.fx.internal.GraphicsLoaderImpl.java

@Override
public Node getGraphicsNode(URI _uri) {
    Map<@NonNull String, @NonNull String> map = new HashMap<>();
    if (this.themeManager != null && this.themeManager.getCurrentTheme() != null) {
        Theme currentTheme = this.themeManager.getCurrentTheme();
        if (currentTheme != null) {
            map.put("themeId", currentTheme.getId()); //$NON-NLS-1$
        }/*from   w w w  .ja va 2  s.  com*/
    }

    URI uri = replaceDynamicValues(_uri, map);
    GraphicNodeProvider graphicNodeProvider = this.providerComponent.getGraphicNodeProvider(uri);

    if (graphicNodeProvider == null) {
        Image img = getImage(uri);
        if (img != null) {
            return new ImageView(img);
        }
    } else {
        try {
            return graphicNodeProvider.getGraphicNode(uri);
        } catch (IOException e) {
            this.logger.error("Unable to load graphic node from '" + uri + "'", e); //$NON-NLS-1$ //$NON-NLS-2$
        }
    }

    return null;
}

From source file:ca.wumbo.doommanager.client.controller.file.TaskManagerController.java

@FXML
private void initialize() {
    log.debug("Initializing scene and stage for task manager.");
    taskManagerScene = new Scene(getRootPane());
    taskManagerStage = new Stage();
    taskManagerStage.setTitle("Task Manager");
    taskManagerStage.setScene(taskManagerScene);
    taskManagerStage.hide();//from   w w w  .  j  a  va  2 s .c o m

    fileIpColumn.setCellValueFactory((cellData) -> cellData.getValue().dataLocationProperty());
    progressBarColumn.setCellValueFactory((cellData) -> cellData.getValue().progressProperty().asObject());
    progressBarColumn.setCellFactory(ProgressBarTableCell.forTableColumn()); // Needed to render a progress bar.
    statusColumn.setCellValueFactory((cellData) -> cellData.getValue().messageProperty());

    clearFinishedMenuItem.setGraphic(new ImageView(resources.getImage("clear")));
    stopAllMenuItem.setGraphic(new ImageView(resources.getImage("stop")));
    closeMenuItem.setGraphic(new ImageView(resources.getImage("close")));
    helpMenuItem.setGraphic(new ImageView(resources.getImage("help")));

    // For some odd reason, the table is selected and it has a blue glow around it.
    // This is due to focusing, so we'll just focus on the root pane to fix that.
    Platform.runLater(() -> rootBorderPane.requestFocus());
}

From source file:org.sleuthkit.autopsy.imagegallery.gui.navpanel.GroupTreeCell.java

/**
 * {@inheritDoc }/*from  w  w w  .java2s  .  c om*/
 */
@Override
protected synchronized void updateItem(final TreeNode treeNode, boolean empty) {
    //if there was a previous group, remove the listeners
    Optional.ofNullable(getItem()).map(TreeNode::getGroup).ifPresent(group -> {
        group.fileIds().removeListener(fileCountListener);
        group.seenProperty().removeListener(seenListener);
    });

    super.updateItem(treeNode, empty);

    if (isNull(treeNode) || empty) {
        Platform.runLater(() -> {
            setTooltip(null);
            setText(null);
            setGraphic(null);
            setStyle("");
        });
    } else {

        if (isNull(treeNode.getGroup())) {
            final String groupName = getGroupName();
            //"dummy" group in file system tree <=>  a folder with no drawables
            Platform.runLater(() -> {
                setTooltip(new Tooltip(groupName));
                setText(groupName);
                setGraphic(new ImageView(EMPTY_FOLDER_ICON));
                setStyle("");
            });

        } else {
            //if number of files in this group changes (eg a file is recategorized), update counts via listener
            treeNode.getGroup().fileIds().addListener(fileCountListener);

            //if the seen state of this group changes update its style
            treeNode.getGroup().seenProperty().addListener(seenListener);

            //and use icon corresponding to group type
            final Image icon = treeNode.getGroup().groupKey.getAttribute().getIcon();
            final String text = getGroupName() + getCountsText();
            final String style = getSeenStyleClass();
            Platform.runLater(() -> {
                setTooltip(new Tooltip(text));
                setGraphic(new ImageView(icon));
                setText(text);
                setStyle(style);
            });
        }
    }
}

From source file:org.sleuthkit.autopsy.timeline.actions.SaveSnapshotAsReport.java

/**
 * Constructor//ww w .  j av  a2  s  .  c o m
 *
 * @param controller   The controller for this timeline action
 * @param nodeSupplier The Supplier of the node to snapshot.
 */
@NbBundle.Messages({ "Timeline.ModuleName=Timeline", "SaveSnapShotAsReport.action.dialogs.title=Timeline",
        "SaveSnapShotAsReport.action.name.text=Snapshot Report",
        "SaveSnapShotAsReport.action.longText=Save a screen capture of the current view of the timeline as a report.",
        "# {0} - report file path", "SaveSnapShotAsReport.ReportSavedAt=Report saved at [{0}]",
        "SaveSnapShotAsReport.Success=Success",
        "SaveSnapShotAsReport.FailedToAddReport=Failed to add snaphot to case as a report.",
        "# {0} - report path", "SaveSnapShotAsReport.ErrorWritingReport=Error writing report to disk at {0}.",
        "# {0} - generated default report name",
        "SaveSnapShotAsReport.reportName.prompt=leave empty for default report name: {0}.",
        "SaveSnapShotAsReport.reportName.header=Enter a report name for the Timeline Snapshot Report.",
        "SaveSnapShotAsReport.duplicateReportNameError.text=A report with that name already exists." })
public SaveSnapshotAsReport(TimeLineController controller, Supplier<Node> nodeSupplier) {
    super(Bundle.SaveSnapShotAsReport_action_name_text());
    setLongText(Bundle.SaveSnapShotAsReport_action_longText());
    setGraphic(new ImageView(SNAP_SHOT));

    this.controller = controller;
    this.currentCase = controller.getAutopsyCase();

    setEventHandler(actionEvent -> {
        //capture generation date and use to make default report name
        Date generationDate = new Date();
        final String defaultReportName = FileUtil.escapeFileName(currentCase.getName() + " "
                + new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss").format(generationDate)); //NON_NLS
        BufferedImage snapshot = SwingFXUtils.fromFXImage(nodeSupplier.get().snapshot(null, null), null);

        //prompt user to pick report name
        TextInputDialog textInputDialog = new TextInputDialog();
        PromptDialogManager.setDialogIcons(textInputDialog);
        textInputDialog.setTitle(Bundle.SaveSnapShotAsReport_action_dialogs_title());
        textInputDialog.getEditor()
                .setPromptText(Bundle.SaveSnapShotAsReport_reportName_prompt(defaultReportName));
        textInputDialog.setHeaderText(Bundle.SaveSnapShotAsReport_reportName_header());

        //keep prompt even if text field has focus, until user starts typing.
        textInputDialog.getEditor()
                .setStyle("-fx-prompt-text-fill: derive(-fx-control-inner-background, -30%);");//NON_NLS 

        /*
         * Create a ValidationSupport to validate that a report with the
         * entered name doesn't exist on disk already. Disable ok button if
         * report name is not validated.
         */
        ValidationSupport validationSupport = new ValidationSupport();
        validationSupport.registerValidator(textInputDialog.getEditor(), false, new Validator<String>() {
            @Override
            public ValidationResult apply(Control textField, String enteredReportName) {
                String reportName = StringUtils.defaultIfBlank(enteredReportName, defaultReportName);
                boolean exists = Files.exists(Paths.get(currentCase.getReportDirectory(), reportName));
                return ValidationResult.fromErrorIf(textField,
                        Bundle.SaveSnapShotAsReport_duplicateReportNameError_text(), exists);
            }
        });
        textInputDialog.getDialogPane().lookupButton(ButtonType.OK).disableProperty()
                .bind(validationSupport.invalidProperty());

        //show dialog and handle result
        textInputDialog.showAndWait().ifPresent(enteredReportName -> {
            //reportName defaults to case name + timestamp if left blank
            String reportName = StringUtils.defaultIfBlank(enteredReportName, defaultReportName);
            Path reportFolderPath = Paths.get(currentCase.getReportDirectory(), reportName,
                    "Timeline Snapshot"); //NON_NLS
            Path reportMainFilePath;

            try {
                //generate and write report
                reportMainFilePath = new SnapShotReportWriter(currentCase, reportFolderPath, reportName,
                        controller.getEventsModel().getZoomParamaters(), generationDate, snapshot)
                                .writeReport();
            } catch (IOException ex) {
                LOGGER.log(Level.SEVERE, "Error writing report to disk at " + reportFolderPath, ex); //NON_NLS
                new Alert(Alert.AlertType.ERROR,
                        Bundle.SaveSnapShotAsReport_ErrorWritingReport(reportFolderPath)).show();
                return;
            }

            try {
                //add main file as report to case
                Case.getCurrentCase().addReport(reportMainFilePath.toString(), Bundle.Timeline_ModuleName(),
                        reportName);
            } catch (TskCoreException ex) {
                LOGGER.log(Level.WARNING,
                        "Failed to add " + reportMainFilePath.toString() + " to case as a report", ex); //NON_NLS
                new Alert(Alert.AlertType.ERROR, Bundle.SaveSnapShotAsReport_FailedToAddReport()).show();
                return;
            }

            //notify user of report location
            final Alert alert = new Alert(Alert.AlertType.INFORMATION, null, OPEN, OK);
            alert.setTitle(Bundle.SaveSnapShotAsReport_action_dialogs_title());
            alert.setHeaderText(Bundle.SaveSnapShotAsReport_Success());

            //make action to open report, and hyperlinklable to invoke action
            final OpenReportAction openReportAction = new OpenReportAction(reportMainFilePath);
            HyperlinkLabel hyperlinkLabel = new HyperlinkLabel(
                    Bundle.SaveSnapShotAsReport_ReportSavedAt(reportMainFilePath.toString()));
            hyperlinkLabel.setOnAction(openReportAction);
            alert.getDialogPane().setContent(hyperlinkLabel);

            alert.showAndWait().filter(OPEN::equals).ifPresent(buttonType -> openReportAction.handle(null));
        });
    });
}

From source file:uk.ac.bris.cs.scotlandyard.ui.controller.BaseGame.java

BaseGame(ResourceManager manager, Stage stage) {
    this.resourceManager = manager;
    this.stage = stage;
    Controller.bind(this);

    // initialise all controllers
    travelLog = new TravelLog(resourceManager, config);
    ticketsCounter = new TicketsCounter(resourceManager, config);
    notifications = new Notifications(resourceManager, config);
    status = new Status(resourceManager, config);
    board = new Board(resourceManager, notifications, config);

    Rectangle clip = new Rectangle();
    clip.widthProperty().bind(gamePane.widthProperty());
    clip.heightProperty().bind(gamePane.heightProperty());
    gamePane.setClip(clip);//from  w  ww  .  j  a v  a2  s.c om

    // system menu
    menu.setUseSystemMenuBar(true);

    // add all views
    mapPane.getChildren().add(board.root());
    roundsPane.getChildren().add(travelLog.root());
    playersPane.getChildren().add(ticketsCounter.root());
    notificationPane.getChildren().add(notifications.root());
    statusPane.getChildren().add(status.root());

    close.setOnAction(e -> stage.close());
    debug.setOnAction(evt -> {
        try {
            Debug.showDebugger(stage);
        } catch (Exception e) {
            Utils.handleFatalException(e);
        }
    });
    about.setOnAction(e -> {
        Alert alert = new Alert(AlertType.INFORMATION,
                "ScotlandYard is part of the CW-MODEL coursework prepared for University of Bristol course COMS100001",
                ButtonType.OK);
        ImageView logo = new ImageView(resourceManager.getImage(ImageResource.UOB_LOGO));
        logo.setPreserveRatio(true);
        logo.setSmooth(true);
        logo.setFitHeight(100);
        alert.setGraphic(logo);
        alert.setTitle("About ScotlandYard");
        alert.setHeaderText("ScotlandYard v0.1");
        alert.show();
    });

    findNode.setOnAction(e -> {
        Stage s = new Stage();
        s.setTitle("Find node");
        s.setScene(new Scene(new FindNode(config, s, resourceManager).root()));
        s.show();
    });
    manual.setOnAction(e -> {
        Stage s = new Stage();
        s.setTitle("Manual");
        s.setScene(new Scene(new Manual(s).root()));
        s.show();
    });

    license.setOnAction(e -> {
        Stage s = new Stage();
        s.setTitle("License");
        s.setScene(new Scene(new License(s).root()));
        s.show();
    });

    // bind all menu values
    resetViewport.setOnAction(e -> {
        board.resetViewport();
    });

    setAndBind(travelLog.root().visibleProperty(), travelLogToggle.selectedProperty());
    setAndBind(ticketsCounter.root().visibleProperty(), ticketToggle.selectedProperty());
    setAndBind(config.scrollPanProperty(), scrollToggle.selectedProperty());
    setAndBind(config.historyProperty(), historyToggle.selectedProperty());
    setAndBind(config.focusPlayerProperty(), focusToggle.selectedProperty());

    if (SystemUtils.IS_OS_WINDOWS)
        config.scrollPanProperty().setValue(false);

}

From source file:account.management.controller.inventory.AllProductWiseReportController.java

@FXML
private void onShowReportClick(ActionEvent event) {
    this.show.setDisable(true);
    try {/*from   w  w w.j  a  v a 2 s .c  om*/
        String start_date = "1980-01-01", end_date = "2050-12-31";
        start_date = new SimpleDateFormat("yyyy-MM-dd")
                .format(new SimpleDateFormat("yyyy-MM-dd").parse(this.start.getValue().toString()));
        end_date = new SimpleDateFormat("yyyy-MM-dd")
                .format(new SimpleDateFormat("yyyy-MM-dd").parse(this.end.getValue().toString()));
        HttpResponse<JsonNode> res = Unirest.get(MetaData.baseUrl + "report/product/all/sellPurchase")
                .queryString("start", start_date).queryString("end", end_date).asJson();
        JSONArray array = res.getBody().getArray();
        Vector v = new Vector();
        HashMap params = new HashMap();
        params.put("date",
                "From " + new SimpleDateFormat("dd-MM-yyyy")
                        .format(new SimpleDateFormat("yyyy-MM-dd").parse(start_date)) + " To "
                        + new SimpleDateFormat("dd-MM-yyyy")
                                .format(new SimpleDateFormat("yyyy-MM-dd").parse(end_date)));
        for (int i = 0; i < array.length(); i++) {
            JSONObject obj = array.getJSONObject(i);
            String id = obj.get("id").toString().equals("null") ? "-" : obj.get("id").toString();
            String name = obj.get("name").toString().equals("null") ? "-" : obj.get("name").toString();
            String ob = obj.get("ob").toString().equals("null") ? "-" : obj.get("ob").toString();
            String p_qty = obj.get("p_qty").toString().equals("null") ? "-" : obj.get("p_qty").toString();
            String p_rate = obj.get("p_rate").toString().equals("null") ? "-" : obj.get("p_rate").toString();
            String p_total = obj.get("p_total").toString().equals("null") ? "-" : obj.get("p_total").toString();
            String s_qty = obj.get("s_qty").toString().equals("null") ? "-" : obj.get("s_qty").toString();
            String s_rate = obj.get("s_rate").toString().equals("null") ? "-" : obj.get("s_rate").toString();
            String s_total = obj.get("s_total").toString().equals("null") ? "-" : obj.get("s_total").toString();
            v.add(new AllProductWiseReport(id, name, ob, p_qty, p_rate, p_total, s_qty, s_rate, s_total));

        }
        Report report = new Report();
        report.getReport("src\\report\\AllProductPurchaseSellReport.jrxml", new JRBeanCollectionDataSource(v),
                params, "Products Report");
    } catch (ParseException ex) {
        Logger.getLogger(AllProductWiseReportController.class.getName()).log(Level.SEVERE, null, ex);
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setHeaderText(null);
        alert.setContentText("Please Enter date correctly.");
        alert.setGraphic(new ImageView(new Image("resources/error.jpg")));
        alert.showAndWait();
    } catch (UnirestException ex) {
        Logger.getLogger(AllProductWiseReportController.class.getName()).log(Level.SEVERE, null, ex);
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setHeaderText(null);
        alert.setContentText("Sorry!! there is an error in the server. Please try again.");
        alert.setGraphic(new ImageView(new Image("resources/error.jpg")));
        alert.showAndWait();
    } finally {
        this.show.setDisable(false);
    }

}

From source file:org.pdfsam.merge.MergeModule.java

public Node graphic() {
    return new ImageView("merge.png");
}