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


Java SwingFXUtils.toFXImage方法代码示例

本文整理汇总了Java中javafx.embed.swing.SwingFXUtils.toFXImage方法的典型用法代码示例。如果您正苦于以下问题:Java SwingFXUtils.toFXImage方法的具体用法?Java SwingFXUtils.toFXImage怎么用?Java SwingFXUtils.toFXImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.embed.swing.SwingFXUtils的用法示例。


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

示例1: buildData

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
public void buildData() throws SQLException, IOException {
	data = FXCollections.observableArrayList();
	c = database.SqliteConnection.getConnection();
	String SQL = "SELECT * from Employee";
	ResultSet rs = c.createStatement().executeQuery(SQL);

	while (rs.next()) {
		byte[] imageInbyte = rs.getBytes(9);
		BufferedImage img1 = ImageIO.read(new ByteArrayInputStream(imageInbyte));
		Image image = SwingFXUtils.toFXImage(img1, null);
		EmployeeClass ec = new EmployeeClass(rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5),
				rs.getString(6), rs.getString(7), rs.getString(8), new ImageView(image));
		data.add(ec);
	}
	c.close();

	wrapText();
	table.setItems(data);
}
 
开发者ID:djdivix,项目名称:IDBuilderFX,代码行数:20,代码来源:ViewMuliParsedController.java

示例2: viewSingle

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
public void viewSingle() throws SQLException, IOException {
	Connection c;
	c = database.SqliteConnection.getConnection();
	String SQL = "SELECT * from Employee";
	ResultSet rs = c.createStatement().executeQuery(SQL);
	while (rs.next()) {
		namelbl.setText(rs.getString(2));
		emaillbl.setText(rs.getString(3));
		moblbl.setText(rs.getString(4));
		addlbl.setText(rs.getString(5));
		addlbl.setWrapText(true);
		doblbl.setText(rs.getString(6));
		sexlbl.setText(rs.getString(7));
		fnamelbl.setText(rs.getString(8));
		byte[] imageInbyte = rs.getBytes(9);
		BufferedImage img1 = ImageIO.read(new ByteArrayInputStream(imageInbyte));
		Image image = SwingFXUtils.toFXImage(img1, null);
		photo.setImage(image);
		photo.setPreserveRatio(true);
	}
	c.close();
}
 
开发者ID:djdivix,项目名称:IDBuilderFX,代码行数:23,代码来源:ViewSingleParsedController.java

示例3: retriveImageFromFileAndFitToBox

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
private void retriveImageFromFileAndFitToBox(final VBox vboxPhotoList, final File singleFileFromOpenedDialog) {
    LOGGER.info("Open image: ", singleFileFromOpenedDialog.toURI().getPath());
    BufferedImage bufferedImage = null;
    try {
        bufferedImage = ImageIO.read(singleFileFromOpenedDialog);
    } catch (IOException e) {
        e.printStackTrace();
    }
    final Image image = SwingFXUtils.toFXImage(bufferedImage, null);
    final ImageView imageView = new ImageView(image);
    vboxPhotoList.getChildren().clear();
    vboxPhotoList.getChildren().add(imageView);
    vboxPhotoList.setAlignment(Pos.CENTER);
    imageView.setPreserveRatio(true);
    if (imageView.getImage().getHeight() > vboxPhotoList.getHeight() ||
            imageView.getImage().getWidth() > vboxPhotoList.getWidth()) {
        imageView.fitHeightProperty().bind(vboxPhotoList.heightProperty());
        imageView.fitWidthProperty().bind(vboxPhotoList.widthProperty());
    }
    LOGGER.info("Image opened");

}
 
开发者ID:Evegen55,项目名称:main_carauto_board,代码行数:23,代码来源:ImageViewController.java

示例4: openFile

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
private void openFile(File file) {
    try {

        myImageView = new ImageView();
        BufferedImage bufferedImage = ImageIO.read(file);
        Image image = SwingFXUtils.toFXImage(bufferedImage, null);
        myImageView.setImage(image);
        controller.createPictureView(myImageView, image, point);


    } catch (Exception ex) {
        Logger.getLogger(InsertIMG.class.getName()).log(
                Level.SEVERE, null, ex
        );
    }
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:17,代码来源:InsertIMG.java

示例5: asImageViewFX

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
/**
 * convert AWT imageIcon to JavaFX image
 *
 * @param imageIcon
 * @return javaFX image
 */
public static ImageView asImageViewFX(ImageIcon imageIcon) {
    java.awt.Image awtImage = imageIcon.getImage();
    if (awtImage != null) {
        final BufferedImage bImg;
        if (awtImage instanceof BufferedImage) {
            bImg = (BufferedImage) awtImage;
        } else {
            bImg = new BufferedImage(awtImage.getWidth(null), awtImage.getHeight(null), BufferedImage.TYPE_INT_ARGB);
            Graphics2D graphics = bImg.createGraphics();
            graphics.drawImage(awtImage, 0, 0, null);
            graphics.dispose();
        }
        return new ImageView(SwingFXUtils.toFXImage(bImg, null));
    } else
        return null;
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:23,代码来源:CommandManagerFX.java

示例6: getImage

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
/**
 * Get an Image Instance for Use in JavaFX.
 *
 * @return javafx image
 */
public WritableImage getImage() {
    Settings s = new Settings();

    java.awt.Color paper = fxToAWTColor(background);
    java.awt.Color ink = fxToAWTColor(foreground);

    BufferedImage image = new BufferedImage((barcode.getWidth() * zoom) + (2 * border),
            (barcode.getHeight() * zoom) + (2 * border), BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = image.createGraphics();
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.fillRect(0, 0, (barcode.getWidth() * zoom) + (2 * border),
            (barcode.getHeight() * zoom) + (2 * border));

    Java2DRenderer renderer = new Java2DRenderer(g2d, zoom, border, paper, ink);
    renderer.render(barcode);

    return SwingFXUtils.toFXImage(image, null);
}
 
开发者ID:innFactory,项目名称:JFXC,代码行数:24,代码来源:BarcodeFX.java

示例7: handleSaveImageButtonAction

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
private void handleSaveImageButtonAction(ActionEvent event) {
    BufferedImage saveImage = mMenuTerrain.isSelected() ? mTerrainImage : mFantasyImage;

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle(mSaveImageButton.getText());
    fileChooser.setInitialDirectory(new File(System.getProperty("user.home"), "Pictures"));
    FileChooser.ExtensionFilter extensionFilter = new FileChooser.ExtensionFilter("PNG", "*.png");
    fileChooser.getExtensionFilters().add(extensionFilter);
    File file = fileChooser.showSaveDialog(mStage);
    if (file != null) {
        try {
            WritableImage writableImage = new WritableImage(saveImage.getWidth(),
                    saveImage.getHeight());
            SwingFXUtils.toFXImage(saveImage, writableImage);
            ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), "png", file);
        } catch (IOException ioe) {
            Logger.getLogger(TAG).log(Level.SEVERE, null, ioe);
        }
    }
}
 
开发者ID:JelloRanger,项目名称:MapGenerator,代码行数:21,代码来源:UiController.java

示例8: getScaledRGBInstance

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
/**
 * Get a scaled (RGB or ARGB) image, achieving reasonable quality even when scaling down by a considerably amount.
 * 
 * Code is based on https://today.java.net/article/2007/03/30/perils-imagegetscaledinstance
 * 
 * @param img
 * @param targetWidth
 * @param targetHeight
 * @return
 */
static WritableImage getScaledRGBInstance(BufferedImage img, int targetWidth, int targetHeight) {
	int type = (img.getTransparency() == Transparency.OPAQUE) ?
			BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
	
	BufferedImage imgResult = (BufferedImage)img;
	int w = img.getWidth();
	int h = img.getHeight();

	while (w > targetWidth || h > targetHeight) {
		
		w = Math.max(w / 2, targetWidth);
		h = Math.max(h / 2, targetHeight);

		BufferedImage imgTemp = new BufferedImage(w, h, type);
		Graphics2D g2 = imgTemp.createGraphics();
		g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
		g2.drawImage(imgResult, 0, 0, w, h, null);
		g2.dispose();

		imgResult = imgTemp;			
	}
	return SwingFXUtils.toFXImage(imgResult, null);
}
 
开发者ID:qupath,项目名称:qupath,代码行数:34,代码来源:ImageOverview.java

示例9: onUpdateCardAction

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
@FXML
public void onUpdateCardAction(ActionEvent event) throws Exception {
	layerBox[0] = layer1Box;
	layerBox[1] = layer2Box;
	layerBox[2] = layer3Box;
	layerBox[3] = layer4Box;
	layerBox[4] = layer5Box;
	layerBox[5] = layer6Box;
	layerBox[6] = layer7Box;
	layerBox[7] = layer8Box;
	layerBox[8] = layer9Box;

	int unitId = Integer.parseInt(idLb.getText());
	boolean[] layerFlag = new boolean[9];
	for(int i = 0; i < layerFlag.length; i++) {
		layerFlag[i] = layerBox[i].isSelected();
	}
	CardImage normalCard = imageService.getNormalCard(unitId, layerFlag);
	CardImage idolizeCard = imageService.getIdolizedCard(unitId, layerFlag);
	WritableImage normalImage = SwingFXUtils.toFXImage(normalCard.getImage(), null);
	WritableImage idolizeImage = SwingFXUtils.toFXImage(idolizeCard.getImage(), null);
	normalCardImage.setImage(normalImage);
	idolizeCardImage.setImage(idolizeImage);
}
 
开发者ID:xwang1024,项目名称:SIF-Resource-Explorer,代码行数:25,代码来源:UnitPreviewStageController.java

示例10: copyBackground

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
private Image copyBackground(Stage stage) {
	final int X = (int) stage.getX();
	final int Y = (int) stage.getY();
	final int W = (int) stage.getWidth();
	final int H = (int) stage.getHeight();

	try {
		java.awt.Robot robot = new java.awt.Robot();
		java.awt.image.BufferedImage image = robot.createScreenCapture(new java.awt.Rectangle(X, Y, W, H));

		return SwingFXUtils.toFXImage(image, null);
	} catch (java.awt.AWTException e) {
		System.out.println("The robot of doom strikes!");
		e.printStackTrace();

		return null;
	}
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:19,代码来源:CrewEditorFX.java

示例11: initCard

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
private void initCard() throws SQLException, IOException {
	boolean[] layerFlag = new boolean[9];
	for (int i = 0; i < layerFlag.length; i++) {
		layerFlag[i] = layerBox[i].isSelected();
	}
	CardImage normalCard = imageService.getNormalCard(unit.getId(), layerFlag);
	CardImage idolizeCard = imageService.getIdolizedCard(unit.getId(), layerFlag);
	// ------ Init layer box ------
	LayerStatus[] normalStatus = normalCard.getLayerStatus();
	LayerStatus[] idolizeStatus = idolizeCard.getLayerStatus();
	for (int i = 0; i < layerFlag.length; i++) {
		if (normalStatus[i] == LayerStatus.DISABLED && idolizeStatus[i] == LayerStatus.DISABLED) {
			layerBox[i].setDisable(true);
		}
	}
	// ----------------------------
	WritableImage normalImage = SwingFXUtils.toFXImage(normalCard.getImage(), null);
	WritableImage idolizeImage = SwingFXUtils.toFXImage(idolizeCard.getImage(), null);
	normalCardImage.setImage(normalImage);
	idolizeCardImage.setImage(idolizeImage);
}
 
开发者ID:xwang1024,项目名称:SIF-Resource-Explorer,代码行数:22,代码来源:UnitPreviewStageBuilder.java

示例12: addKeyImage

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
private void addKeyImage(File imgPath){
	BufferedImage buffer;
	Image img=null;

	if (imgPath!=null){
		try {
			buffer = ImageIO.read(imgPath);
			img=SwingFXUtils.toFXImage(buffer, null);
		} catch (IOException e) {
			new MessagePopUp().showMessageDialog("Couldn't upload Image");
			return;
		}
	}
	ImageView myView=setImageStyle(img);
	myView.relocate(picturePane.getPrefWidth()/2-myView.getFitWidth()/2, picturePane.getPrefHeight()/2-myView.getFitHeight()/2);
	picturePane.getChildren().clear();
	picturePane.getChildren().add(myView);
	setCurrentKeyImage(myView.getImage(), imgPath);
}
 
开发者ID:ngbalk,项目名称:VOOGASalad,代码行数:20,代码来源:KeyFramePopUpPane.java

示例13: drawImage

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
/**
 * Draws the image into the rectangle defined by {@code (x, y, w, h)}.  
 * Note that the {@code observer} is ignored (it is not useful in this
 * context).
 * 
 * @param img  the image ({@code null} permitted...draws nothing).
 * @param x  the x-coordinate.
 * @param y  the y-coordinate.
 * @param w  the width.
 * @param h  the height.
 * @param observer  ignored.
 * 
 * @return {@code true} if there is no more drawing to be done. 
 */
@Override
public boolean drawImage(final Image img, int x, int y, 
        int w, int h, ImageObserver observer) {
    final BufferedImage buffered;
    if (img instanceof BufferedImage) {
        buffered = (BufferedImage) img;
    } else {
        buffered = new BufferedImage(w, h, 
                BufferedImage.TYPE_INT_ARGB);
        final Graphics2D g2 = buffered.createGraphics();
        g2.drawImage(img, 0, 0, w, h, null);
        g2.dispose();
    }
    javafx.scene.image.WritableImage fxImage = SwingFXUtils.toFXImage(
            buffered, null);
    this.gc.drawImage(fxImage, x, y, w, h);
    return true;
}
 
开发者ID:jfree,项目名称:fxgraphics2d,代码行数:33,代码来源:FXGraphics2D.java

示例14: load

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
public static Image load(NsImageIcon icon) {
    System.setProperty("java.awt.headless", "false");
    java.awt.Image awtImage = Toolkit.getDefaultToolkit().getImage(
            "NSImage://" + icon.getName());
    BufferedImage bufferedImage = null;
    if (awtImage instanceof BufferedImage) {
        bufferedImage = (BufferedImage) awtImage;
    } else {
        bufferedImage = new BufferedImage(awtImage.getWidth(null),
                awtImage.getHeight(null), BufferedImage.TYPE_INT_ARGB);
        Graphics g = bufferedImage.createGraphics();
        g.drawImage(awtImage, 0, 0, null);
        g.dispose();
    }
    return SwingFXUtils.toFXImage(bufferedImage, null);
}
 
开发者ID:cis422s14team5,项目名称:WatchlistPro,代码行数:17,代码来源:NsImageIconLoader.java

示例15: handle

import javafx.embed.swing.SwingFXUtils; //导入方法依赖的package包/类
@Override
public void handle(ActionEvent t) {
    FileChooser fileChooser = new FileChooser();

    //Set extension filter
    FileChooser.ExtensionFilter extFilterJPG = new FileChooser.ExtensionFilter("JPG files (*.jpg)", "*.JPG");
    FileChooser.ExtensionFilter extFilterPNG = new FileChooser.ExtensionFilter("PNG files (*.png)", "*.PNG");
    fileChooser.getExtensionFilters().addAll(extFilterJPG, extFilterPNG);

    //Show open file dialog
    File file = fileChooser.showOpenDialog(null);

    try {
        BufferedImage bufferedImage = ImageIO.read(file);
        Image image = SwingFXUtils.toFXImage(bufferedImage, null);
        myImageView.setImage(image);
    } catch (IOException ex) {
        Logger.getLogger(JavaFXPixel.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
开发者ID:fedevelatec,项目名称:Pruebas,代码行数:22,代码来源:JavaFXPixel.java


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