当前位置: 首页>>代码示例>>Java>>正文


Java Image类代码示例

本文整理汇总了Java中javafx.scene.image.Image的典型用法代码示例。如果您正苦于以下问题:Java Image类的具体用法?Java Image怎么用?Java Image使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Image类属于javafx.scene.image包,在下文中一共展示了Image类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import javafx.scene.image.Image; //导入依赖的package包/类
@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);
}
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:27,代码来源:SquidUI.java

示例2: loadImageArchiveEditor

import javafx.scene.image.Image; //导入依赖的package包/类
@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();
	}
}
 
开发者ID:nshusa,项目名称:rsam-gui,代码行数:27,代码来源:StoreController.java

示例3: goToTransactionHistory

import javafx.scene.image.Image; //导入依赖的package包/类
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();
	}
}
 
开发者ID:krHasan,项目名称:Money-Manager,代码行数:17,代码来源:GoToOperation.java

示例4: showPlanchesterGUI

import javafx.scene.image.Image; //导入依赖的package包/类
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();
    }
}
 
开发者ID:ITB15-S4-GroupD,项目名称:Planchester,代码行数:28,代码来源:PlanchesterGUI.java

示例5: requestImage

import javafx.scene.image.Image; //导入依赖的package包/类
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();
}
 
开发者ID:GoSuji,项目名称:Suji,代码行数:19,代码来源:WebHelper.java

示例6: ProfileScene

import javafx.scene.image.Image; //导入依赖的package包/类
/**
 * 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");
}
 
开发者ID:hadalhw17,项目名称:Artatawe,代码行数:31,代码来源:ProfileScene.java

示例7: TrainView

import javafx.scene.image.Image; //导入依赖的package包/类
/**
 * 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());
    }
}
 
开发者ID:AdjustmentBeaver,项目名称:szoftlab,代码行数:25,代码来源:TrainView.java

示例8: drawShadow

import javafx.scene.image.Image; //导入依赖的package包/类
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);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:17,代码来源:Renderer.java

示例9: goToSignIn

import javafx.scene.image.Image; //导入依赖的package包/类
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();
	}
}
 
开发者ID:krHasan,项目名称:Money-Manager,代码行数:18,代码来源:GoToOperation.java

示例10: generate

import javafx.scene.image.Image; //导入依赖的package包/类
/**
 * 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 ;
}
 
开发者ID:chrootRISCassembler,项目名称:CapsLock,代码行数:25,代码来源:CharPanelGenerator.java

示例11: start

import javafx.scene.image.Image; //导入依赖的package包/类
@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();
}
 
开发者ID:mikemacharia39,项目名称:gatepass,代码行数:9,代码来源:OfficeRecords.java

示例12: display

import javafx.scene.image.Image; //导入依赖的package包/类
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();
}
 
开发者ID:mikemacharia39,项目名称:gatepass,代码行数:39,代码来源:ErrorMessage.java

示例13: readJMETexture

import javafx.scene.image.Image; //导入依赖的package包/类
@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);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:22,代码来源:JavaFXImageManager.java

示例14: addOrChangePhoto

import javafx.scene.image.Image; //导入依赖的package包/类
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!");
    }


}
 
开发者ID:alchemsynergy,项目名称:alchem,代码行数:24,代码来源:UserDrawerController.java

示例15: init

import javafx.scene.image.Image; //导入依赖的package包/类
@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());
        }
    });
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:DataAppPreloader.java


注:本文中的javafx.scene.image.Image类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。