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


Java SwingFXUtils类代码示例

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


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

示例1: take

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
/**
 * Takes a snapshot of a canvas and saves it to the destination.
 * <p>
 * After the screenshot is taken it shows a dialogue to the user indicating the location of the snapshot.
 *
 * @param canvas a JavaFX {@link Canvas} object
 * @return the destination of the screenshot
 */
public String take(final Canvas canvas) {
    final WritableImage writableImage = new WritableImage((int) canvas.getWidth(), (int) canvas.getHeight());
    final WritableImage snapshot = canvas.snapshot(new SnapshotParameters(), writableImage);

    try {
        ImageIO.write(SwingFXUtils.fromFXImage(snapshot, null), FILE_FORMAT, destination);
        new InformationDialogue(
                "Snapshot taken",
                "You can find your snapshot here: " + destination.getAbsolutePath()
        ).show();
    } catch (final IOException e) {
        LOGGER.error("Snapshot could not be taken.", e);
        new ErrorDialogue(e).show();
    }

    return destination.getAbsolutePath();
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:26,代码来源:Snapshot.java

示例2: changed

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
@Override
public void changed(ObservableValue<? extends State> observable, State oldState, State newState) {
	if (newState == Worker.State.SUCCEEDED) {
		try {
			//Determine the full url
			String favIconFullURL = getHostName(webEngine.getLocation()) + "favicon.ico";
			//System.out.println(favIconFullURL)
			
			//Create HttpURLConnection 
			HttpURLConnection httpcon = (HttpURLConnection) new URL(favIconFullURL).openConnection();
			httpcon.addRequestProperty("User-Agent", "Mozilla/5.0");
			List<BufferedImage> image = ICODecoder.read(httpcon.getInputStream());
			
			//Set the favicon
			facIconImageView.setImage(SwingFXUtils.toFXImage(image.get(0), null));
			
		} catch (Exception ex) {
			//ex.printStackTrace()
			facIconImageView.setImage(null);
		}
	}
}
 
开发者ID:goxr3plus,项目名称:JavaFX-Web-Browser,代码行数:23,代码来源:WebBrowserTabController.java

示例3: call

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
@Override
protected Boolean call() throws Exception {
    val fxTimeline = timeLine.getFxTimeline();

    val totalFrames = toFrame(fxTimeline.getTotalDuration());
    int frame = 0;
    while (frame < totalFrames) {
        updateProgress(frame, totalFrames);
        updateMessage(String.format("%d / %d", frame + 1, totalFrames));
        fxTimeline.jumpTo(toDuration(frame));

        val image = newImage();

        val latch = new CountDownLatch(1);
        Platform.runLater(() -> {
            scene.snapshot(image);
            latch.countDown();
        });
        latch.await();

        val file = new File(directory, String.format("frame_%05d.png", frame + 1));
        ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", file);
        frame++;
    }
    return Boolean.TRUE;
}
 
开发者ID:aNNiMON,项目名称:HotaruFX,代码行数:27,代码来源:RenderTask.java

示例4: update

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
/**
 * Receives an image from another node.
 * @param image Input image
 */
@Override
public void update(Image image) {
    imagePeer[ this.emptyPos++ % 2 ] = SwingFXUtils.fromFXImage(image,null);

    if( getInputNumber() == INPUT_MAX ){

        if (imagePeer[0] == null || imagePeer[1] == null )
            System.out.println("Image NULL!");

        String result = MSE(imagePeer[0], imagePeer[1]);

        Graphics2D g2d;
        BufferedImage bImg = new BufferedImage(80 , 60, BufferedImage.TYPE_INT_RGB);
        g2d = bImg.createGraphics();
        g2d.drawString(result,5   ,bImg.getHeight()/2);
        setImage(SwingFXUtils.toFXImage(bImg,null));
        System.out.printf("PSNR: %s\n",result);
        super.update(getImage());
    }
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:25,代码来源:MSE.java

示例5: update

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
/**
 * Whenever the input is changed or a new connection
 * is made this function is called.
 * @param image Current image
 */
@Override
public void update(Image image) {

    imagePeer[ this.emptyPos++ % 2 ] = SwingFXUtils.fromFXImage(image,null);

    if( getInputNumber() == INPUT_MAX ){

        if (imagePeer[0] == null || imagePeer[1] == null )
            System.out.println("Image NULL!");

        int mtxResult [][] = minus(ImageUtil.convertToGreyTone(imagePeer[0]), ImageUtil.convertToGreyTone(imagePeer[1]));
        setImage( ImageUtil.toImage( mtxResult ));
        System.out.println("Sub!");
        super.update(getImage());

    }
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:23,代码来源:ArithmeticOperatorSubt.java

示例6: minus

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
/**
 * Method to do image subtraction between two images.
 * @param A First image.
 * @param B Second image.
 * @return Returns the matrix representing the operation.
 */
private int[][] minus(int [][] A, int [][] B){
    int n = A.length;    /* A lines.   */
    int m = A[0].length; /* A columns. */
    int o = B.length;    /* B lines.   */
    int p = B[0].length; /* B columns. */

    if(n != o || m != p)
        return ImageUtil.convertToGreyTone(SwingFXUtils.fromFXImage(auxImg,null));

    int [][] C = new int[n][m];

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            C[i][j] = ImageUtil.normalize(Math.abs( A[i][j] - B[i][j] ) );
        }
    }
    return C;
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:25,代码来源:ArithmeticOperatorSubt.java

示例7: update

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
/**
 * Receives an image from another node.
 * @param image Input image
 */
@Override
public void update(Image image) {
    imagePeer[ this.emptyPos++ % 2 ] = SwingFXUtils.fromFXImage(image,null);

    if( getInputNumber() == INPUT_MAX ){

        if (imagePeer[0] == null || imagePeer[1] == null )
            System.out.println("Image NULL!");

        int mtxResult [][] = and(ImageUtil.convertToGreyTone(imagePeer[0]), ImageUtil.convertToGreyTone(imagePeer[1]));
        setImage( ImageUtil.toImage( mtxResult ));
        System.out.println("AND!");
        super.update(getImage());
    }
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:20,代码来源:LogicalOperatorAnd.java

示例8: and

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
/**
 * AND two images.
 * @param A First image.
 * @param B Second image.
 * @return Returns a matrix representing the operation.
 */
int[][] and(int [][] A, int [][] B){
    int n = A.length;    /* A lines.   */
    int m = A[0].length; /* A columns  */
    int o = B.length;    /* B lines.   */
    int p = B[0].length; /* B columns. */

    if(n != o || m != p)
        return ImageUtil.convertToGreyTone(SwingFXUtils.fromFXImage(auxImg,null));

    int [][] C = new int[n][m];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            C[i][j] = (byte) (A[i][j] & B[i][j]);
        }
    }
    return C;
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:24,代码来源:LogicalOperatorAnd.java

示例9: update

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
/**
 * Receives an image from another node.
 * @param image Input image
 */
@Override
public void update(Image image) {
    imagePeer[ this.emptyPos++ % 2 ] = SwingFXUtils.fromFXImage(image,null);

    if( getInputNumber() == INPUT_MAX ){

        if (imagePeer[0] == null || imagePeer[1] == null )
            System.out.println("Image NULL!");

        int mtxResult [][] = or(ImageUtil.convertToGreyTone(imagePeer[0]), ImageUtil.convertToGreyTone(imagePeer[1]));
        setImage( ImageUtil.toImage( mtxResult ));
        System.out.println("OR!");
        super.update(getImage());
    }
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:20,代码来源:LogicalOperatorOr.java

示例10: or

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
/**
 * OR two images.
 * @param A First image.
 * @param B Second image.
 * @return Returns a matrix representing the operation.
 */
private int[][] or(int [][] A, int [][] B){
    int n = A.length;    /* A lines.   */
    int m = A[0].length; /* A columns. */
    int o = B.length;    /* B lines.   */
    int p = B[0].length; /* B columns. */

    if(n != o || m != p)
        return ImageUtil.convertToGreyTone(SwingFXUtils.fromFXImage(auxImg,null));

    int [][] C = new int[n][m];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            C[i][j] = (byte) (A[i][j] | B[i][j]);
        }
    }
    return C;
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:24,代码来源:LogicalOperatorOr.java

示例11: sum

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
/**
 * Method to do image sum between two images.
 * @param A First image.
 * @param B Second image.
 * @return Returns the matrix representing the operation.
 */
private int[][] sum(int [][] A, int [][] B){
    int n = A.length;    /* A lines.   */
    int m = A[0].length; /* A columns. */
    int o = B.length;    /* B lines.   */
    int p = B[0].length; /* B columns. */

    if(n != o || m != p)
        return ImageUtil.convertToGreyTone(SwingFXUtils.fromFXImage(auxImg,null));

    int [][] C = new int[n][m];

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            C[i][j] = ImageUtil.normalize(A[i][j] + B[i][j]);
        }
    }
    return C;
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:25,代码来源:ArithmeticOperatorSum.java

示例12: update

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
/**
 * Receives an image from another node.
 * @param image Input image
 */
@Override
public void update(Image image) {
    imagePeer[ this.emptyPos++ % 2 ] = SwingFXUtils.fromFXImage(image,null);

    if( getInputNumber() == INPUT_MAX ){

        if (imagePeer[0] == null || imagePeer[1] == null )
            System.out.println("Image NULL!");

        String result = PSNR(imagePeer[0], imagePeer[1]);

        Graphics2D g2d;

        BufferedImage bImg = new BufferedImage(80 , 60, BufferedImage.TYPE_INT_RGB);
        g2d = bImg.createGraphics();
        g2d.drawString(result+"",5   ,bImg.getHeight()/2);
        setImage(SwingFXUtils.toFXImage(bImg,null));
        System.out.printf("PSNR: %s\n",result);
        super.update(getImage());
    }
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:26,代码来源:PSNR.java

示例13: times

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
/**
 * Method to do image multiplication between two images.
 * @param A First image.
 * @param B Second image.
 * @return Returns the matrix representing the operation.
 */
private int[][] times(int [][] A, int [][] B){
    int n = A.length;    /* A lines.   */
    int m = A[0].length; /* A columns. */
    int o = B.length;    /* B lines.   */
    int p = B[0].length; /* B columns. */

    if(n != o || m != p){
        return ImageUtil.convertToGreyTone(SwingFXUtils.fromFXImage(auxImg,null));
    }

    int [][] C = new int[n][m];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            C[i][j] = ImageUtil.normalize( A[i][j] * B[i][j] );
        }
    }
    return C;
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:26,代码来源:ArithmeticOperatorMult.java

示例14: saveImageCache

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
public void saveImageCache() throws ImageCacheError
{
    File dir = new File("cache/");
    if (!dir.exists())
        throw new ImageCacheError();
    for (Map.Entry<Integer, Image> i : imageCache.entrySet())
    {
        BufferedImage bi = SwingFXUtils.fromFXImage(i.getValue(), null);
        File file = new File("cache/" + i.getKey());
        if (!file.exists() && bi != null)
        {
            try
            {
                ImageIO.write(bi, "png", file);
            } catch (IOException e)
            {
                throw new ImageCacheError();
            }
        }

    }
}
 
开发者ID:Matthieu42,项目名称:Steam-trader-tools,代码行数:23,代码来源:ImageCacheHandler.java

示例15: handleFileSaveAction

import javafx.embed.swing.SwingFXUtils; //导入依赖的package包/类
@FXML
private void handleFileSaveAction(ActionEvent event) {
    FileChooser fileChooser = new FileChooser();
    File file = fileChooser.showSaveDialog(null);
    
    if (file != null) {
        try {
            WritableImage writableImage = new WritableImage((int) drawingCanvas.getWidth(), (int) drawingCanvas.getHeight());
            drawingCanvas.snapshot(null, writableImage);
            RenderedImage renderedImage = SwingFXUtils.fromFXImage(writableImage, null);            
            ImageIO.write(renderedImage, "png", file);
        } catch (IOException ex) {
            Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:17,代码来源:FXMLDocumentController.java


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