當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。