欧美成人午夜免费全部完,亚洲午夜福利精品久久,а√最新版在线天堂,另类亚洲综合区图片小说区,亚洲欧美日韩精品色xxx

扣丁學堂Java在線視頻之SWT(JFace)體驗之圖片的動態(tài)漸變效果

2018-06-01 14:02:22 1206瀏覽

SWT(JFace)體驗之圖片的動態(tài)漸變效果有不少喜歡Java開發(fā)或者是正在參加Java培訓的小伙伴還不是很清楚,本篇文章扣丁學堂Java培訓小編就帶大家一起來看一下扣丁學堂Java在線視頻之SWT(JFace)體驗之圖片的動態(tài)漸變效果,想要學習的小伙伴隨小編一起來吧。



扣丁學堂Java在線視頻之SWT(JFace)體驗之圖片的動態(tài)漸變效果



1、漸變:



package swt_jface.demo10; 
import org.eclipse.swt.SWT; 
import org.eclipse.swt.events.PaintEvent; 
import org.eclipse.swt.events.PaintListener; 
import org.eclipse.swt.graphics.Image; 
import org.eclipse.swt.graphics.ImageData; 
import org.eclipse.swt.layout.FillLayout; 
import org.eclipse.swt.widgets.Canvas; 
import org.eclipse.swt.widgets.Display; 
import org.eclipse.swt.widgets.Shell; 
public class AlphaFadeIn { 
    Display display = new Display(); 
    Shell shell = new Shell(display); 
    public AlphaFadeIn() { 

        shell.setLayout(new FillLayout()); 
        final Canvas canvas = new Canvas(shell, SWT.NULL); 

        ImageData imageData = new ImageData("C:/icons/eclipse.jpg"); 
        byte[] alphaValues = new byte[imageData.height * imageData.width]; 
        for(int j=0; j<imageData.height; j++) { 
            for(int i=0; i<imageData.width; i++) { 
                alphaValues[j*imageData.width + i] = (byte) (255 - 255 * i / imageData.width); 
            } 
        } 
        imageData.alphaData = alphaValues; 

        final Image image = new Image(display, imageData); 

        canvas.addPaintListener(new PaintListener() { 
            public void paintControl(PaintEvent e) { 
                e.gc.drawImage(image, 10, 10); 
            } 
        }); 
        shell.setSize(200, 100); 
        shell.open(); 

        while (!shell.isDisposed()) { 
            if (!display.readAndDispatch()) { 
                display.sleep(); 
            } 
        } 
        display.dispose(); 
    } 
    public static void main(String[] args) { 
        new AlphaFadeIn(); 
    } 
}



2、動態(tài):



package swt_jface.demo10; 
import org.eclipse.swt.SWT; 
import org.eclipse.swt.events.PaintEvent; 
import org.eclipse.swt.events.PaintListener; 
import org.eclipse.swt.events.ShellAdapter; 
import org.eclipse.swt.events.ShellEvent; 
import org.eclipse.swt.graphics.GC; 
import org.eclipse.swt.graphics.Image; 
import org.eclipse.swt.graphics.ImageData; 
import org.eclipse.swt.graphics.ImageLoader; 
import org.eclipse.swt.layout.FillLayout; 
import org.eclipse.swt.widgets.Canvas; 
import org.eclipse.swt.widgets.Display; 
import org.eclipse.swt.widgets.Shell; 
public class Animations { 

    Display display = new Display(); 
    Shell shell = new Shell(display); 
    public Animations() { 

        shell.setLayout(new FillLayout()); 
        ImageLoader imageLoader = new ImageLoader(); 
        final ImageData[] imageDatas = imageLoader.load("C:/icons/eclipse-ani.gif"); 
        final Image image = new Image(display, imageDatas[0].width, imageDatas[0].height); 
        final Canvas canvas = new Canvas(shell, SWT.NULL); 
        canvas.addPaintListener(new PaintListener() { 
            public void paintControl(PaintEvent e) { 
                e.gc.drawImage(image, 0, 0); 
            } 
        }); 
        final GC gc = new GC(image); 
        final Thread thread = new Thread() { 
            int frameIndex = 0; 
            public void run() { 
                while (!isInterrupted()) { 
                    frameIndex %= imageDatas.length; 
                    final ImageData frameData = imageDatas[frameIndex]; 
                    display.asyncExec(new Runnable() { 
                        public void run() { 
                            Image frame = 
                                new Image(display, frameData); 
                            gc.drawImage(frame, frameData.x, frameData.y); 
                            frame.dispose(); 
                            canvas.redraw(); 
                        } 
                    }); 
                    try { 
                        Thread.sleep(imageDatas[frameIndex].delayTime * 10); 
                    } catch (InterruptedException e) { 
                        return; 
                    } 
                    frameIndex += 1; 
                } 
            } 
        }; 

        shell.addShellListener(new ShellAdapter() { 
            public void shellClosed(ShellEvent e) { 
                thread.interrupt(); 
            } 
        }); 
        shell.setSize(400, 200); 
        shell.open(); 

        thread.start(); 
        while (!shell.isDisposed()) { 
            if (!display.readAndDispatch()) { 
                display.sleep(); 
            } 
        } 
        display.dispose(); 
    } 
    public static void main(String[] args) { 
        new Animations(); 
    } 
}



以上就是扣丁學堂Java在線學習小編給大家分享的SWT(JFace)體驗之圖片的動態(tài)漸變效果,希望對小伙伴們有所幫助,想要學習Java開發(fā)的小伙伴可以選擇專業(yè)的Java培訓機構(gòu)扣丁學堂進行學習??鄱W堂不僅有專業(yè)的老師和與時俱進的課程體系,還有大量的Java在線視頻供學員觀看學習,小伙伴們快快行動吧。Java技術(shù)交流群:670348138。


扣丁學堂微信公眾號

【關(guān)注微信公眾號獲取更多學習資料】



查看更多關(guān)于“Java開發(fā)資訊的相關(guān)文章>>




標簽: 扣丁學堂Java在線視頻 SWT(JFace)體驗之圖片的動態(tài)漸變效果 Java培訓 Java基礎(chǔ)教程 Java學習視頻 Java教學視頻 java入門教程 Java教程視頻 java在線學習 java在線視頻 java在線教程

熱門專區(qū)

暫無熱門資訊

課程推薦

微信
微博
15311698296

全國免費咨詢熱線

郵箱:codingke@1000phone.com

官方群:148715490

北京千鋒互聯(lián)科技有限公司版權(quán)所有   北京市海淀區(qū)寶盛北里西區(qū)28號中關(guān)村智誠科創(chuàng)大廈4層
京ICP備2021002079號-2   Copyright ? 2017 - 2022
返回頂部 返回頂部