⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 affichematrice.java

📁 All the tool for build a network able to reconize any shapes. Very complete, a good base for anythi
💻 JAVA
字号:
package mouse;

import sdljava.SDLException;
import sdljava.SDLMain;
import sdljava.event.SDLEvent;
import sdljava.event.SDLEventType;
import sdljava.image.SDLImage;
import sdljava.video.SDLRect;
import sdljava.video.SDLSurface;
import sdljava.video.SDLVideo;


public class AfficheMatrice 
{

	private int xResolution;
	private int yResolution;
	private SDLSurface ecran;
	private SDLRect positionPixel;
	private SDLEvent event;
	private SDLSurface pixel0 = null;
	private SDLSurface pixel1 = null;
	private SDLSurface pixel2 = null;
	private SDLSurface pixel3 = null;
	
	
	public AfficheMatrice(int xR,int yR)
	{
		this.xResolution = xR;
		this.yResolution = yR;
		
		// On charge la librairie graphique SDL
		System.loadLibrary("SDLjava");
		System.out.println("Started...");
		positionPixel = new SDLRect();
		try 
		{
			pixel0 = SDLImage.load("pix0.png");
			pixel1 = SDLImage.load("pix1.png");
			pixel2 = SDLImage.load("pix2.png");
			pixel3 = SDLImage.load("pix3.png");
		} 
		catch (SDLException e) {e.printStackTrace();}
	}
	
	
	public void Display(double[][] uneMatrice) throws SDLException
	{
		SDLMain.init(SDLMain.SDL_INIT_VIDEO);
		ecran = SDLVideo.setVideoMode(this.xResolution, this.yResolution, 32,SDLVideo.SDL_HWSURFACE);
		ecran.fillRect(ecran.mapRGB(255, 255, 255));
		boolean continuer=true;
		while(continuer)
		{
			//Si on click sur la croix, on ferme la fenetre
			event = SDLEvent.pollEvent();
			if (event != null) 
			{
				if (event.getType()==SDLEventType.QUIT)
				{	
					continuer = false;
					break;
				}
			}
			
			//efface ecran (en blanc)
			//ecran.fillRect(ecran.mapRGB(255, 255, 255));
			
			for(int i=0; i<this.xResolution; i++)
			{
				for(int j=0; j<this.yResolution; j++)
				{
					if(uneMatrice[i][j]>60 && uneMatrice[i][j]<=225)
					{	
						this.positionPixel.x = i; this.positionPixel.y = j;
						pixel3.blitSurface(ecran, this.positionPixel);
					}
					else if(uneMatrice[i][j]>225 && uneMatrice[i][j]<=251){
						this.positionPixel.x = i; this.positionPixel.y = j;
						pixel2.blitSurface(ecran, this.positionPixel);	
					}
					else if(uneMatrice[i][j]>251 && uneMatrice[i][j]<=272){
						this.positionPixel.x = i; this.positionPixel.y = j;
						pixel1.blitSurface(ecran, this.positionPixel);
					}
					else if(uneMatrice[i][j]>272){
						this.positionPixel.x = i; this.positionPixel.y = j;
						pixel0.blitSurface(ecran, this.positionPixel);
					}
				}
			}
			
			//Refresh ecran
			ecran.flip();
			
		}	
		
		// Fermeture de la fenetre
		SDLMain.quit();
	}
	
	public int maxModified(int x, int y) {
		if (x > y)
			return x;
		else
			return y;
	}
	
	private double pythagore (int x, int y){
		return Math.sqrt(Math.pow(Math.abs(x),2)+Math.pow(Math.abs(y),2))*25;
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -