Java Code Examples for javafx.scene.image.Image

The following are top voted examples for showing how to use javafx.scene.image.Image. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Squid   File: SquidUI.java   Source Code and License 10 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {

    this.primaryStage = primaryStage;
    Parent root = new AnchorPane();
    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.getIcons().add(new Image(SQUID_LOGO_SANS_TEXT_URL));
    primaryStage.setTitle("Squid 3.0 pre-release");

    // this produces non-null window after .show()
    primaryStageWindow = primaryStage.getScene().getWindow();

    primaryStage.setOnCloseRequest((WindowEvent e) -> {
        Platform.exit();
        System.exit(0);
    });

    // postpone loading to allow for stage creation and use in controller
    scene.setRoot(FXMLLoader.load(getClass().getResource("SquidUIController.fxml")));
    primaryStage.show();
    primaryStage.setMinHeight(scene.getHeight() + 15);
    primaryStage.setMinWidth(scene.getWidth());

    squidAboutWindow = new SquidAboutWindow(primaryStage);
}
 
Example 2
Project: rsam-gui   File: StoreController.java   Source Code and License 8 votes vote down vote up
@FXML
private void loadImageArchiveEditor() {
	try {
		FXMLLoader loader = new FXMLLoader(App.class.getResource("/ImageArchiveUI.fxml"));

		Parent root = loader.load();

		ImageArchiveController controller = loader.getController();

		Stage stage = new Stage();

		controller.setStage(stage);
		stage.setTitle("Image Archive Editor");
		Scene scene = new Scene(root);
		scene.getStylesheets().add(App.class.getResource("/style.css").toExternalForm());
		stage.getIcons().add(new Image(getClass().getResourceAsStream("/icons/app_icon_128.png")));
		stage.setScene(scene);
		stage.initStyle(StageStyle.TRANSPARENT);
		stage.setResizable(false);
		stage.centerOnScreen();
		stage.setTitle("Archive Editor");
		stage.show();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example 3
Project: Money-Manager   File: GoToOperation.java   Source Code and License 7 votes vote down vote up
public void goToTransactionHistory(double positionX, double positionY) {
	try {
		Stage TransactionHistoryStage = new Stage();
		Parent root = FXMLLoader.load(getClass().getResource("/view/TransactionHistory.fxml"));
		Scene scene = new Scene(root,800,550);
		TransactionHistoryStage.setScene(scene);
		TransactionHistoryStage.setResizable(false);
		TransactionHistoryStage.getIcons().add(new Image(getClass().getResourceAsStream("/imges/purse.png")));
		TransactionHistoryStage.setTitle("Transaction History");
		TransactionHistoryStage.setX(positionX);
		TransactionHistoryStage.setY(positionY);
		TransactionHistoryStage.show();
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example 4
Project: Planchester   File: PlanchesterGUI.java   Source Code and License 6 votes vote down vote up
private static void showPlanchesterGUI() {
    try {
        primaryStage = new Stage();
        primaryStage.setTitle("Planchester");
        //primaryStage.setResizable(false);
        primaryStage.setMaximized(true);

        primaryStage.setOnCloseRequest(t -> {
            closePlanchester();
        });

        scene = new Scene(FXMLLoader.load(PlanchesterGUI.class.getResource("PlanchesterFrame.fxml")));

        URL url = PlanchesterGUI.class.getResource("CSS/stylesheet.css");
        if (url == null) {
            throw new UnexpectedException("CSS Resource not found. Aborting.");
        }
        String css = url.toExternalForm();
        scene.getStylesheets().add(css);

        primaryStage.setScene(scene);
        primaryStage.getIcons().add(new Image("file:src/Presentation/Images/logoplanchester.png"));
        primaryStage.show();
    } catch (IOException exception) {
        exception.printStackTrace();
    }
}
 
Example 5
Project: Suji   File: WebHelper.java   Source Code and License 6 votes vote down vote up
public static void requestImage(String url, Consumer<Image> callback) {
	Thread thread = new Thread(() -> {
		WebTarget target = getClient().target(url);
		Response response = target.request(MediaType.WILDCARD_TYPE).get();

		if ( response.getStatus() != 200 ) {
			LogHelper.severe("Failed : HTTP error code : " + response.getStatus());
		}

		InputStream output = response.readEntity(InputStream.class);
		Image image = new Image(output);

		response.close();

		callback.accept(image);
	});
	thread.start();
}
 
Example 6
Project: Artatawe   File: ProfileScene.java   Source Code and License 6 votes vote down vote up
/**
 * Constructor for ProfileScene
 *
 * @param p profile to be displayed
 * @param dc information about system
 * @param loggedInProfile current user
 */
public ProfileScene(DataController dc, Profile p, Profile loggedInProfile) {
    super(dc,p,loggedInProfile);
    this.loggedInProfile = loggedInProfile;
    this.p = p;
    if(loggedInProfile.getUsername().equals(p.getUsername())){
        this.p = this.loggedInProfile;
    }
    this.dc = dc;

    profImage = new Image(p.getProfileImg().getPath());


    setNameLabel(p.getFirstname() + " " + p.getSurname());
    setContentPane();

    combo.setPromptText("Sample avatars");
    combo.getItems().addAll("img1.png",
            "img2.png",
            "img3.png",
            "img4.png",
            "img5.png",
            "img6.png");
}
 
Example 7
Project: szoftlab   File: TrainView.java   Source Code and License 6 votes vote down vote up
/**
 * Instantiates a new Train view.
 *
 * @param graphicsContext the graphics context
 */
public TrainView(GraphicsContext graphicsContext) {
    this.graphicsContext = graphicsContext;
    try {
        trainCarts = new HashMap<>();
        for (String color: model.util.Color.getValidColors()) {
            try (FileInputStream fi = new FileInputStream("sprites/cart_" + color + ".png")) {
                trainCarts.put(color, new Image(fi));
            }
        }
        trainParts = new HashMap<>();
        for (String type: trainPartTypes) {
            try (FileInputStream fi = new FileInputStream("sprites/" + type + ".png")) {
                trainParts.put(type, new Image(fi));
            }
        }
    } catch (IOException e) {
        System.err.println("TrainView.TrainView(): File error: " + e.getMessage());
    }
}
 
Example 8
Project: candlelight   File: Renderer.java   Source Code and License 6 votes vote down vote up
public static void drawShadow(Image image, double scale, GraphicsContext dst)
{
	final double shadowSize = scale * SHADOW_SIZE;
	final double shadowBlur = scale * SHADOW_BLUR;

	GaussianBlur blur = new GaussianBlur(shadowBlur);
	dst.drawImage(image, shadowSize * 2 / 3, shadowSize);
	dst.applyEffect(blur);

	ColorAdjust colorAdjust = new ColorAdjust();
	colorAdjust.setBrightness(SHADOW_BRIGHTNESS);
	dst.applyEffect(colorAdjust);

	dst.drawImage(image, 0, shadowSize);
	dst.applyEffect(colorAdjust);
}
 
Example 9
Project: Money-Manager   File: GoToOperation.java   Source Code and License 6 votes vote down vote up
public void goToSignIn(double positionX, double positionY) {
	try {
		Stage SignInStage = new Stage();
		Parent root = FXMLLoader.load(getClass().getResource("/view/SignIn.fxml"));
		Scene scene = new Scene(root,800,550);
		scene.getStylesheets().add(getClass().getResource("/css/SignIn.css").toExternalForm());
		SignInStage.setScene(scene);
		SignInStage.setResizable(false);
		SignInStage.getIcons().add(new Image(getClass().getResourceAsStream("/imges/purse.png")));
		SignInStage.setTitle("Money Manager");
		SignInStage.setX(positionX);
		SignInStage.setY(positionY);
		SignInStage.show();
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example 10
Project: CapsLock   File: CharPanelGenerator.java   Source Code and License 6 votes vote down vote up
/**
 * Generates a panel image form char.
 * <p>First, this function converts ch to upper case if ch is lower case.</p>
 * <p>Then, this generates javafx's image from ch.And return it.</p>
 * You can fix the resolution of image through {@link capslock.CharPanelGenerator#PANEL_IMAGE_SIZE}
 * and {@link capslock.CharPanelGenerator#FONT_SIZE}.
 * @param ch パネルの生成に使う1文字.
 * @param color 背景色.
 * @return 生成されたパネル.
 */
static final Image generate(char ch, Color color){
    final Label label = new Label(Character.toString(Character.toUpperCase(ch)));
    label.setMinSize(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE);
    label.setMaxSize(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE);
    label.setPrefSize(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE);
    label.setFont(Font.font(FONT_SIZE));
    label.setAlignment(Pos.CENTER);
    label.setTextFill(Color.WHITE);
    label.setBackground(new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY)));
    final Scene scene = new Scene(new Group(label));
    final WritableImage img = new WritableImage(PANEL_IMAGE_SIZE, PANEL_IMAGE_SIZE);
    scene.snapshot(img);
    return img ;
}
 
Example 11
Project: gatepass   File: OfficeRecords.java   Source Code and License 6 votes vote down vote up
@Override public void start(Stage primaryStage) throws Exception {
    init(primaryStage);
    primaryStage.initModality(Modality.APPLICATION_MODAL);
    primaryStage.getIcons().add(new Image("/pic/slogo.png"));
    primaryStage.setX(337);
    primaryStage.setY(27);
    primaryStage.show();
}
 
Example 12
Project: gatepass   File: ErrorMessage.java   Source Code and License 6 votes vote down vote up
public static void display(String title, String message)
{
	Stage window= new Stage();
	window.initModality(Modality.APPLICATION_MODAL);
	//window.setAlwaysOnTop(true);
	window.getIcons().add(new Image("/pic/slogo.png"));
	window.setTitle(title);
	Label label= new Label();
	label.setText(message);
	label.setStyle("-fx-font-size:14px;");
	
	ImageView imageView = new ImageView(ICON);
	imageView.setFitWidth(40);
	imageView.setFitHeight(40);
       Label labelimage = new Label("",imageView);
	
	// two buttons
	Button okbtn= new Button("Ok");
	okbtn.setOnAction(e -> {
		answer= false;
		window.close();
	});
	okbtn.setId("red");
	HBox hbox= new HBox(10);
	hbox.setAlignment(Pos.CENTER_LEFT);
	hbox.setPadding(new Insets(10,5,10,5));
	hbox.getChildren().addAll(labelimage,label);
	VBox layout= new VBox(15);
	layout.setAlignment(Pos.CENTER_RIGHT);
	layout.setPadding(new Insets(10,5,10,5));
	layout.getChildren().addAll(hbox,okbtn);
	layout.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672);");
	Scene scene= new Scene(layout);
	scene.getStylesheets().add(ErrorMessage.class.getResource("confirm.css").toExternalForm());
	window.setScene(scene);
	window.setResizable(false);
	window.showAndWait();
}
 
Example 13
Project: jmonkeybuilder   File: JavaFXImageManager.java   Source Code and License 6 votes vote down vote up
@FXThread
private @NotNull Image readJMETexture(final int width, final int height, @NotNull final String externalForm,
                                      @NotNull final Path cacheFile) {

    final Editor editor = Editor.getInstance();
    final AssetManager assetManager = editor.getAssetManager();
    final Texture texture = assetManager.loadTexture(externalForm);

    final BufferedImage textureImage;
    try {
        textureImage = ImageToAwt.convert(texture.getImage(), false, true, 0);
    } catch (final UnsupportedOperationException e) {
        EditorUtil.handleException(LOGGER, this, e);
        return Icons.IMAGE_512;
    }

    final int imageWidth = textureImage.getWidth();
    final int imageHeight = textureImage.getHeight();

    return scaleAndWrite(width, height, cacheFile, textureImage, imageWidth, imageHeight);
}
 
Example 14
Project: alchem   File: UserDrawerController.java   Source Code and License 6 votes vote down vote up
public void addOrChangePhoto() throws MalformedURLException {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Select Image File");
    fileChooser.getExtensionFilters().addAll(
            new FileChooser.ExtensionFilter("Image Files",
                    "*.bmp", "*.png", "*.jpg", "*.gif")); // limit fileChooser options to image files
    File selectedFile = fileChooser.showOpenDialog(user_image.getScene().getWindow());

    if (selectedFile != null) {

        imageFile = selectedFile.toURI().toURL().toString();

        Image image = new Image(imageFile);
        user_image.setImage(image);
    } else {
        new AlertBox(((Stage) user_image.getScene().getWindow()),
                new FXMLLoader(getClass().getResource("../../../Resources/Layouts/alert_stage.fxml")),
                false,
                "Could not load image!");
    }


}
 
Example 15
Project: marathonv5   File: DataAppPreloader.java   Source Code and License 6 votes vote down vote up
@Override public void init() throws Exception {
    root = new StackPane();
    background = new StackPane();
    background.setId("Window");
    background.setCache(true);
    ImageView carImageView = new ImageView(new Image(
            DataAppPreloader.class.getResourceAsStream("images/car.png")));
    raceTrack = new RaceTrack();
    root.getChildren().addAll(background, raceTrack, carImageView);
    Platform.runLater(new Runnable() {
        @Override public void run() {
            preloaderScene = new Scene(root,1250,750);
            preloaderScene.getStylesheets().add(
                    DataAppPreloader.class.getResource("preloader.css").toExternalForm());
        }
    });
}
 
Example 16
Project: Conan   File: InferenceRuleView.java   Source Code and License 6 votes vote down vote up
/**
 * Adds the content for showing the inference rules to the TabPane in the proof
 * @param tabPane
 *
 */
public InferenceRuleView(TabPane tabPane) {


    //load the image
    Image image = new Image("inferenceRules.png");
    ImageView iv1 = new ImageView();
    iv1.setImage(image);
    iv1.setSmooth(true);
    iv1.setPreserveRatio(true);

    //putting the image on a scrollpane
    ScrollPane sp=new ScrollPane();
    sp.getStyleClass().add("rulesView");
    tab = new ViewTab("Inference Rules",this);
    sp.setContent(iv1);
    tabPane.getTabs().add(tab);
    tab.setContent(sp);
    tabPane.getSelectionModel().select(tab);

    //used for getting screensize
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //Avoids scaling too much
    double w=primaryScreenBounds.getWidth()/2;
    iv1.setFitWidth(w);
}
 
Example 17
Project: Conan   File: Main.java   Source Code and License 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
	Parent root = FXMLLoader.load(getClass().getResource("sketch.fxml"));
	Scene scene = new Scene(root, 1200, 700);
	Preferences prefs = Preferences.userRoot().node("General");
	switch (prefs.getInt("theme",0)) {
	case 0:
		scene.getStylesheets().add("minimalistStyle.css");
		break;
	case 1:
		scene.getStylesheets().add("gruvjan.css");
		break;
	}
	stage.setTitle("Conan");
	stage.getIcons().add(new Image("icon.png"));
	stage.setScene(scene);
	stage.show();
	
	stage.setOnCloseRequest(confirmCloseEventHandler);
	
	//Button closeButton = new Button("Close Application");
	//closeButton.setOnAction(event ->
	  //      stage.fireEvent( new WindowEvent(stage, WindowEvent.WINDOW_CLOSE_REQUEST)));
}
 
Example 18
Project: gatepass   File: StudentsReports.java   Source Code and License 6 votes vote down vote up
@Override public void start(Stage primaryStage) throws Exception {
    init(primaryStage);
    primaryStage.getIcons().add(new Image("/pic/slogo.png"));
    primaryStage.initModality(Modality.APPLICATION_MODAL);
    primaryStage.setX(225);
    primaryStage.setY(27);
    primaryStage.show();
}
 
Example 19
Project: LCL   File: Main.java   Source Code and License 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    Main.primaryStage = primaryStage;
    GuiBase mainGui = new GuiBase("Frame", primaryStage);
    mainGui.getScene().setFill(Color.TRANSPARENT);
    mainGui.getStage().setTitle("LoginCraftLaunch-0.0.1Demo");
    mainGui.getStage().getIcons().add(new Image(Main.class.getResourceAsStream("/css/images/LCL.png")));
    mainGui.getStage().initStyle(StageStyle.TRANSPARENT);
    mainGui.getStage().setResizable(true);
    mainGui.getStage().setOnCloseRequest((e) -> {
        Config.save();
        System.exit(0);
    });
    mainGui.getStage().setScene(mainGui.getScene());
    mainGui.getStage().show();
    load("MainPage", "主界面", new Image(ZipUtils.getInputStream(new File(Util.getBaseDir(), Config.instance.skin), "MainPage.png")), true);
    load("Settings", "设置", new Image(ZipUtils.getInputStream(new File(Util.getBaseDir(), Config.instance.skin), "Settings.png")), false);
    load("ResourceManagement", "资源管理", new Image(ZipUtils.getInputStream(new File(Util.getBaseDir(), Config.instance.skin), "ResourceManagement.png")), false);
    load("ResourceManagement", "服务器信息", new Image(ZipUtils.getInputStream(new File(Util.getBaseDir(), Config.instance.skin), "ResourceManagement.png")), false);
    load("Skin", "启动器皮肤", new Image(ZipUtils.getInputStream(new File(Util.getBaseDir(), Config.instance.skin), "Skin.png")), false);
    load("Resources", "资源获取", new Image(ZipUtils.getInputStream(new File(Util.getBaseDir(), Config.instance.skin), "loginImg.png")), false);
}
 
Example 20
Project: puzzlefx   File: Controller.java   Source Code and License 6 votes vote down vote up
public void newGame(){
    FileChooser fileChooser = new FileChooser();
    FileChooser.ExtensionFilter extensionFilter = new FileChooser.ExtensionFilter("Image Files",AppConstants.SUPPORTED_IMAGE_EXTENSION);
    fileChooser.getExtensionFilters().add(extensionFilter);

    File selectedFile = fileChooser.showOpenDialog(null);

    if(selectedFile != null) {
        String selectedPath = selectedFile.getAbsolutePath();

        try {
            InputStream newImageStream = new FileInputStream(selectedPath);
            Image newImage = getResizedImage(newImageStream);
            changeImage(newImage);
        } catch (FileNotFoundException e) {
            LOG.error("Image could not be loaded:", e);
        }
    }
}
 
Example 21
Project: campingsimulator2017   File: MapCreatorView.java   Source Code and License 6 votes vote down vote up
ItemMap(SpotType type) {
    this.type = type;

    String filename = null;

    switch (type) {
        case HOUSE: filename = "cabin.png"; break;
        case TRAILER: filename = "trailer.png"; break;
        case RESTAURANT: filename = "cutlery.png"; break;
        case PARKING: filename = "parking.png"; break;
        case POOL: filename = "swimming-pool.png"; break;
        case SPORT: filename = "kayak.png"; break;
        case TENT: filename = "tent.png"; break;
    }

    smallImage = new Image(new File("res/items/x32/" + filename).toURI().toString());
    bigImage = new Image(new File("res/items/x64/" + filename).toURI().toString());
}
 
Example 22
Project: CardGame   File: GameOverviewController.java   Source Code and License 5 votes vote down vote up
private void updateDisplayKingdom() { // adapt the code to work with Human or AI
    int[] list = this.game.getCurrentPlayer().getBoard().getKingdom();
    String[] listURL = new String[6];
    int points = 0;
    //retrieve the url
    for (int i = 0; i < list.length; i++) {

        listURL[i] = getClass().getClassLoader().getResource(hash_image_path.get(i)).toString();

        int n = this.game.getCurrentPlayer().getBoard().getKingdom()[i];
        points += n;

        if (n != 0) {

            if (this.game.getCurrentPlayer() instanceof Human) {

                this.hash_hkncard.get(i).setText(String.valueOf(n));
                this.hash_hkcard.get(i).setImage(new Image(listURL[i]));
            } else { // "AI"
                this.hash_akncard.get(i).setText(String.valueOf(n));
                this.hash_akcard.get(i).setImage((new Image(listURL[i])));
            }

        } else {
            String image_URL = getClass().getClassLoader().getResource("images/empty.jpg").toString();

            if (this.game.getCurrentPlayer() instanceof Human) {
                hash_hkncard.get(i).setText("0");
                this.hash_hkcard.get(i).setImage(new Image(image_URL));
            } else {
                hash_akncard.get(i).setText(("0"));
                this.hash_akcard.get(i).setImage((new Image(image_URL)));
            }
        }

    }
}
 
Example 23
Project: rsam-gui   File: StoreController.java   Source Code and License 5 votes vote down vote up
@FXML
private void openArchive() {
	StoreEntryWrapper wrapper = tableView.getSelectionModel().getSelectedItem();

	if (wrapper == null) {
		return;
	}

	try {
		
		FileStore store = cache.getStore(0);
		
		// this is to check if the archive could be read before adding it to the archive viewer

		ByteBuffer dataBuffer = store.readFile(wrapper.getId());

		if (dataBuffer == null) {
			Dialogue.showWarning(String.format("Failed to open archive=%s", wrapper.getName())).showAndWait();
			return;
		}

				try {
					Archive archive = Archive.decode(dataBuffer);
				} catch (IOException ex) {
					Dialogue.showWarning(String.format("Failed to open archive=%s", wrapper.getName())).showAndWait();
					return;
				}

		FXMLLoader loader = new FXMLLoader(App.class.getResource("/ArchiveUI.fxml"));

		Parent root = (Parent) loader.load();

		if (archiveController == null || !archiveController.getStage().isShowing()) {
			archiveController = (ArchiveController) loader.getController();

			archiveController.cache = cache;
			archiveController.initArchive(wrapper.getId());

			Stage stage = new Stage();

			archiveController.setStage(stage);
			stage.setTitle("Archive Editor");
			Scene scene = new Scene(root);
			scene.getStylesheets().add(App.class.getResource("/style.css").toExternalForm());
			stage.getIcons().add(new Image(getClass().getResourceAsStream("/icons/app_icon_128.png")));
			stage.setScene(scene);
			stage.initStyle(StageStyle.TRANSPARENT);
			stage.setResizable(false);
			stage.centerOnScreen();
			stage.setTitle("Archive Editor");
			stage.show();
		} else {
			archiveController.initArchive(wrapper.getId());
		}
	} catch (IOException e) {
		e.printStackTrace();
		Dialogue.showWarning(String.format("Failed to read archive=%s", wrapper.getName())).showAndWait();
	}

}
 
Example 24
Project: jmonkeybuilder   File: RigidBodyControlTreeNode.java   Source Code and License 5 votes vote down vote up
@Override
@FXThread
public @Nullable Image getIcon() {

    final RigidBodyControl element = getElement();

    if (element.getMass() == 0F) {
        return Icons.STATIC_RIGID_BODY_16;
    }

    return Icons.RIGID_BODY_16;
}
 
Example 25
Project: file-transfer   File: SendNetPane.java   Source Code and License 5 votes vote down vote up
private void createWindow() {
    VBox root = new VBox();
    Label label = new Label("Enter the destination ID.");
    root.getChildren().addAll(label, id, sendButton);
    root.setPadding(new Insets(NetPane.GENERAL_PADDING));
    root.setSpacing(NetPane.GENERAL_SPACING);
    root.setAlignment(Pos.CENTER);
    Scene scene = new Scene(root);
    scene.getStylesheets().add(getClass().getResource(".." + File.separator + "styles" + File.separator + "Style.css").toExternalForm());
    setScene(scene);
    setResizable(false);
    initModality(Modality.APPLICATION_MODAL);
    getIcons().add(new Image(getClass().getResourceAsStream(".." + File.separator + "images" + File.separator + "logo.png")));
    setTitle("FileSend - Send");
}
 
Example 26
Project: vars-annotation   File: ImageViewController.java   Source Code and License 5 votes vote down vote up
public ComboBox<ImageReference> getComboBox() {
    if (comboBox == null) {
        comboBox = new JFXComboBox<>();
        comboBox.setCellFactory(param ->  new ListCell<ImageReference>() {
            @Override
            protected void updateItem(ImageReference item, boolean empty) {
                super.updateItem(item, empty);
                if (item == null || empty) {
                    setText(null);
                }
                else {
                    String text = item.getDescription() + " [" + item.getFormat() + "]";
                    setText(text);
                }
            }
        });
        comboBox.setConverter(new StringConverter<ImageReference>() {
            @Override
            public String toString(ImageReference object) {
                return object.getDescription() + " [" + object.getFormat() + "]";
            }

            @Override
            public ImageReference fromString(String string) {
                return null;
            }
        });

        comboBox.getSelectionModel()
                .selectedItemProperty()
                .addListener((obs, oldv, newv) -> {
                    Image image = newv == null ? null : new Image(newv.getUrl().toExternalForm());
                    getImageView().setImage(image);
                });
        comboBox.setMaxWidth(Double.MAX_VALUE);
        //comboBox.setEditable(false);
    }
    return comboBox;
}
 
Example 27
Project: GazePlay   File: Circles_handler2.java   Source Code and License 5 votes vote down vote up
public ImagePattern createGridPattern() {
    Collections.shuffle(array_sizes);
    index = array_sizes.get(0);
    size = arraypts[ index ].length;
    //size = 10;
    indicator = new ProgressIndicator(0);
    double w = gridSize;
    double h = gridSize;

    circle = new Circle();
    circle.setRadius(45.0f);

    circle.setOpacity(1);
    circle.setFill(Color.LIGHTBLUE);
    circle.setVisible(true);
    canvas.setGridLinesVisible(true);

    GazeUtils.addEventFilter(circle);
    enterEvent = buildEvent();
    circle.addEventFilter(MouseEvent.ANY, enterEvent);
    circle.addEventFilter(GazeEvent.ANY, enterEvent);


    indicator.setOpacity(0.0);
    canvas.add(indicator, arraypts[index][count], arraypts[index][count+1]);
    canvas.add(circle,arraypts[index][count], arraypts[index][count+1]);
    Image image = canvas.snapshot(new SnapshotParameters(), null);
    ImagePattern pattern = new ImagePattern(image, 0, 0, w, h, false);

    return pattern;

}
 
Example 28
Project: rsam-gui   File: AppData.java   Source Code and License 5 votes vote down vote up
public static void load() {
	try {
		datIcon = new Image(App.class.getResourceAsStream("/icons/dat_icon.png"));
		idxIcon = new Image(App.class.getResourceAsStream("/icons/idx_icon.png"));
		txtIcon = new Image(App.class.getResourceAsStream("/icons/txt_icon.png"));
		fileStoreIcon = new Image(App.class.getResourceAsStream("/icons/file_store_icon.png"));
		midiIcon = new Image(App.class.getResourceAsStream("/icons/midi_icon.png"));
		pngIcon = new Image(App.class.getResourceAsStream("/icons/png_icon.png"));
		file32Icon = new Image(App.class.getResourceAsStream("/icons/file_32.png"));
		gzipIcon = new Image(App.class.getResourceAsStream("/icons/gzip_icon.png"));
		addIcon = new Image(App.class.getResourceAsStream("/icons/action_add.png"));
		deleteIcon = new Image(App.class.getResourceAsStream("/icons/action_delete.png"));
		clearIcon16 = new Image(App.class.getResourceAsStream("/icons/clear_icon_16.png"));
		clearIcon24 = new Image(App.class.getResourceAsStream("/icons/clear_icon_24.png"));
		saveIcon16 = new Image(App.class.getResourceAsStream("/icons/save_16.png"));
		renameIcon16 = new Image(App.class.getResourceAsStream("/icons/rename_16.png"));
		import16Icon = new Image(App.class.getResourceAsStream("/icons/import_16.png"));
		openFolder16Icon = new Image(App.class.getResourceAsStream("/icons/open_folder_16.png"));
		replace16Icon = new Image(App.class.getResourceAsStream("/icons/replace_16.png"));
		identify16Icon = new Image(App.class.getResourceAsStream("/icons/identify_16.png"));
		view16Icon = new Image(App.class.getResourceAsStream("/icons/view_16.png"));
		jag32Icon = new Image(App.class.getResourceAsStream("/icons/jag_32.png"));
		checksum16Icon = new Image(App.class.getResourceAsStream("/icons/checksum_16.png"));
		plus16Icon = new Image(App.class.getResourceAsStream("/icons/plus_16.png"));
	} catch (Exception ex) {
		ex.printStackTrace();
		System.out.println("Failed to load icons.");
	}
}
 
Example 29
Project: GazePlay   File: Circles_points_handler.java   Source Code and License 5 votes vote down vote up
public ImagePattern createGridPattern() {
    Collections.shuffle(array_sizes);
    index = array_sizes.get(0);
    size = arraypts[ index ].length;
    //size = 10;
    indicator = new ProgressIndicator(0);
    double w = gridSize;
    double h = gridSize;

    circle = new Circle();
    circle.setRadius(45.0f);

    circle.setOpacity(1);
    circle.setFill(Color.BLUE);
    circle.setVisible(true);
    canvas.setGridLinesVisible(true);

    GazeUtils.addEventFilter(circle);
    enterEvent = buildEvent();
    circle.addEventFilter(MouseEvent.ANY, enterEvent);
    circle.addEventFilter(GazeEvent.ANY, enterEvent);

    indicator.setOpacity(0.0);
    canvas.add(indicator, arraypts[index][count], arraypts[index][count+1]);
    canvas.add(circle,arraypts[index][count], arraypts[index][count+1]);
    Image image = canvas.snapshot(new SnapshotParameters(), null);
    ImagePattern pattern = new ImagePattern(image, 0, 0, w, h, false);

    return pattern;

}
 
Example 30
Project: CSLMusicModStationCreator   File: ControlsHelper.java   Source Code and License 5 votes vote down vote up
public static Stage createModalStageFor(Node parent, Parent content, String title) {
    Stage stage = new Stage();
    stage.setTitle(title);
    stage.initModality(Modality.WINDOW_MODAL);
    stage.initOwner(parent.getScene().getWindow());
    stage.setScene(new Scene(content));
    stage.getIcons().add(new Image("/cslmusicmod/stationeditor/icon.png"));
    return stage;
}
 
Example 31
Project: marathonv5   File: Bonus.java   Source Code and License 5 votes vote down vote up
public Bonus(int type) {
    content = new ImageView();
    getChildren().add(content);
    this.type = type;
    Image image = Config.getBonusesImages().get(type);
    width = (int)image.getWidth() - Config.SHADOW_WIDTH;
    height = (int)image.getHeight() - Config.SHADOW_HEIGHT;
    content.setImage(image);
    setMouseTransparent(true);
}
 
Example 32
Project: ExoVisix   File: FaceDetectionController.java   Source Code and License 5 votes vote down vote up
/**
 * Get a frame from the opened video stream (if any)
 * 
 * @return the {@link Image} to show
 */
private Image grabFrame()
{
	// init everything
	Image imageToShow = null;
	Mat frame = new Mat();
	
	// check if the capture is open
	if (this.capture.isOpened())
	{
		try
		{
			// read the current frame
			this.capture.read(frame);
			
			// if the frame is not empty, process it
			if (!frame.empty())
			{
				// face detection
				this.detectAndDisplay(frame);
				
				// convert the Mat object (OpenCV) to Image (JavaFX)
				imageToShow = mat2Image(frame);
			}
			
		}
		catch (Exception e)
		{
			// log the (full) error
			System.err.println("ERROR: " + e);
		}
	}
	
	return imageToShow;
}
 
Example 33
Project: marathonv5   File: TitledPaneSample.java   Source Code and License 5 votes vote down vote up
@Override public void start(Stage stage) {
    stage.setTitle("TitledPane");
    Scene scene = new Scene(new Group(), 450, 250);

    TitledPane gridTitlePane = new TitledPane();
    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("First Name: "), 0, 0);
    grid.add(new TextField(), 1, 0);
    grid.add(new Label("Last Name: "), 0, 1);
    grid.add(new TextField(), 1, 1);
    grid.add(new Label("Email: "), 0, 2);
    grid.add(new TextField(), 1, 2);        
    grid.add(new Label("Attachment: "), 0, 3);
    grid.add(label,1, 3);
    gridTitlePane.setText("Grid");
    gridTitlePane.setContent(grid);

    final Accordion accordion = new Accordion ();      
    
    for (int i = 0; i < imageNames.length; i++) {
        images[i] = 
            new Image(getClass().getResourceAsStream(imageNames[i]+".jpg"));
        pics[i] = new ImageView(images[i]);
        tps[i] = new TitledPane(imageNames[i],pics[i]); 
    }   
    accordion.getPanes().addAll(tps);
    

    accordion.expandedPaneProperty().addListener(
        (ObservableValue<? extends TitledPane> ov, TitledPane old_val, 
        TitledPane new_val) -> {
            if (new_val != null) {
                label.setText(accordion.getExpandedPane().getText()
                        + ".jpg");
            }
    });
    
    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(gridTitlePane, accordion);

    Group root = (Group)scene.getRoot();
    root.getChildren().add(hbox);
    stage.setScene(scene);
    stage.show();
}
 
Example 34
Project: hygene   File: GraphController.java   Source Code and License 5 votes vote down vote up
/**
 * Displays a welcome image on the canvas.
 */
private void drawWelcomeImage() {
    graphCanvas.getGraphicsContext2D().clearRect(0, 0, graphCanvas.getWidth(), graphCanvas.getHeight());

    final Image image = new Image(getClass().getResource("/icons/welcome.png").toString());
    graphCanvas.getGraphicsContext2D().drawImage(image,
            graphCanvas.getWidth() / 2 - image.getWidth() / 4,
            graphCanvas.getHeight() / 2 - image.getHeight() / 4,
            image.getWidth() / 2,
            image.getHeight() / 2);
}
 
Example 35
Project: CSLMusicModStationCreator   File: App.java   Source Code and License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws IOException {

    mainStage = primaryStage;

    primaryStage.setOnCloseRequest(confirmCloseEventHandler);
    primaryStage.getIcons().add(new Image("/cslmusicmod/stationeditor/icon.png"));
    Parent root = FXMLLoader.load(getClass().getResource("MainWindow.fxml"));
    Scene scene = new Scene(root);
    primaryStage.setTitle("CSL Music Mod Station Editor");
    primaryStage.setScene(scene);
    primaryStage.show();

}
 
Example 36
Project: incubator-netbeans   File: PaginationDemo.java   Source Code and License 5 votes vote down vote up
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setScene(new Scene(root));
    VBox outerBox = new VBox();
    outerBox.setAlignment(Pos.CENTER);
    //Images for our pages
    for (int i = 0; i < 7; i++) {
        images[i] = new Image(PaginationDemo.class.getResource("animal" + (i + 1) + ".jpg").toExternalForm(), false);
    }

    pagination = PaginationBuilder.create().pageCount(7).pageFactory(new Callback<Integer, Node>() {           
        @Override public Node call(Integer pageIndex) {
            return createAnimalPage(pageIndex);
        }
    }).build();
    //Style can be numeric page indicators or bullet indicators
    Button styleButton = ButtonBuilder.create().text("Toggle pagination style").onAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent me) {
            if (!pagination.getStyleClass().contains(Pagination.STYLE_CLASS_BULLET)) {
                pagination.getStyleClass().add(Pagination.STYLE_CLASS_BULLET);
            } else {
                pagination.getStyleClass().remove(Pagination.STYLE_CLASS_BULLET);
            }
        }
    }).build();

    outerBox.getChildren().addAll(pagination, styleButton);
    root.getChildren().add(outerBox);
}
 
Example 37
Project: plep   File: Main.java   Source Code and License 5 votes vote down vote up
@Override
public void start(final Stage primaryStage) throws Exception{
    System.out.println(Main.class.getResource("/interface.fxml"));
    FXMLLoader loader = new FXMLLoader(getClass().getResource
            ("/interface.fxml"));
    
    Parent root = loader.load();
    
    //used to invoke a setup method in controller which needs the stage
    Controller controller = loader.getController();
    controller.setDayChangeListener(primaryStage);
    
    primaryStage.setTitle("Plep");
    primaryStage.setScene(new Scene(root, 0, 0));

    //set a size relative to screen
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    primaryStage.setX(primaryScreenBounds.getMinX());
    primaryStage.setY(primaryScreenBounds.getMinY());
    primaryStage.setWidth(primaryScreenBounds.getWidth()/2);
    primaryStage.setHeight(primaryScreenBounds.getHeight());
    
    String treeViewCSS = this.getClass().getResource("/css/treeview.css").toExternalForm();
    String generalCSS = this.getClass().getResource("/css/general.css").toExternalForm();
    String buttonCSS = this.getClass().getResource("/css/button.css").toExternalForm();
    String spinnerCSS = this.getClass().getResource("/css/spinner.css").toExternalForm();
    String checkboxCSS = this.getClass().getResource("/css/checkbox.css").toExternalForm();
    String dropdownCSS = this.getClass().getResource("/css/dropdown.css").toExternalForm();
    String colorPickerCSS = this.getClass().getResource("/css/colorpicker.css").toExternalForm();

    primaryStage.getScene().getStylesheets().addAll(treeViewCSS, generalCSS, buttonCSS, spinnerCSS, checkboxCSS, dropdownCSS, colorPickerCSS);

    // check if running in debug mode
    // to display the default java icon so we can distinguish between
    // the program we are testing and the one we are actually using
    // (the latter has the plep logo)
    boolean isDebug = java.lang.management.ManagementFactory.getRuntimeMXBean().
            getInputArguments().toString().indexOf("-agentlib:jdwp") > 0;
    if (!isDebug) {
        primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("/icon.png")));
    }

    primaryStage.show();

}
 
Example 38
Project: Hive_Game   File: AnimationTile.java   Source Code and License 5 votes vote down vote up
public void initPlacingAnimation(Image image,CoordGene<Integer> coordEnd){
    CoordGene<Double> start = new CoordGene<>((double) coordEnd.getX(), (double) 0);
    CoordGene<Double> end = new CoordGene<>((double) coordEnd.getX(), (double) coordEnd.getY());
    start = traductor.axialToPixel(start);
    end = traductor.axialToPixel(end);

    panCanvas.getChildren().add(this.getPolygon());
    this.setImagePolygon(image);
    this.setPath(new Path(
            new MoveTo(start.getX() + traductor.getMoveOrigin().getX(), 0),
            new LineTo(end.getX() + traductor.getMoveOrigin().getX(), end.getY() + traductor.getMoveOrigin().getY())));
}
 
Example 39
Project: Cypher   File: LoadingPresenter.java   Source Code and License 5 votes vote down vote up
@Subscribe
private void toggleLoadingScreen(ToggleEvent e) {
	Platform.runLater(() -> {
		if (e == ToggleEvent.SHOW_LOADING) {
			imageView.setImage(new Image(LoadingPresenter.class.getResourceAsStream("/images/loading.gif")));
		} else if (e == ToggleEvent.HIDE_LOADING) {
			imageView.setImage(null);
		}
	});
}
 
Example 40
Project: Shield   File: MainApp.java   Source Code and License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Parent home = FXMLLoader.load(getClass().getResource("/fxml/Home.fxml"));
    Parent launch = FXMLLoader.load(getClass().getResource("/fxml/Scene.fxml"));
    
    StackPane stack = new StackPane();
    stack.getChildren().add(home);
    stack.getChildren().add(launch);
    MainApp.childs = stack.getChildren();
    
    Scene scene = new Scene(stack,1366,768);
    scene.getStylesheets().add("/styles/Styles.css");
    
    stage.setTitle("Shield");
    stage.getIcons().add(new Image(getClass().getResourceAsStream( "/image/logo.png" )));
    stage.minHeightProperty().set(500);
    stage.minWidthProperty().set(650);
    stage.setScene(scene);
    stage.show();
    FadeTransition ft = new FadeTransition(Duration.millis(500),launch);
    ft.setFromValue(1.0);
    ft.setToValue(0.0);
    ft.setDelay(Duration.seconds(3));
    ft.play();
    ft.onFinishedProperty().set(new EventHandler<ActionEvent>(){
        @Override
        public void handle(ActionEvent event){
            MainApp.childs.get(MainApp.childs.size()-1).toBack();
        }
    });
}