Soyez le premier à donner votre avis sur cette source.
Snippet vu 11 498 fois - Téléchargée 19 fois
//Programmed by Billal BEGUERADJ //Bejaia University //www.begueradj.50megs.com import java.applet.*; import java.awt.*; public class SimulationVideo extends Applet implements Runnable { Image mesimges[];int nombreImages;Thread myThread;String dossier;int compteur;int tempsdattente = 100;Image imagehorsecran;Graphics graph; boolean envoyee = true;int px,py,pp; int pox[],poy[]; int arrete = 0; // Si animation arretee public void init() { int i; String chaine; chaine = getParameter("file"); dossier = (chaine != null) ? chaine : ""; chaine = getParameter("speed"); tempsdattente = 1000 / ((chaine == null) ? 4 : Integer.valueOf(chaine).intValue()); chaine = getParameter("nombreImages"); nombreImages = (chaine == null) ? 16 : Integer.valueOf(chaine).intValue(); imagehorsecran = createImage(size().width, size().height); graph = imagehorsecran.getGraphics(); // Chargement mesimges = new Image[nombreImages]; for ( i = 0 ; i < nombreImages ; i++ ) { mesimges[i] = getImage(getDocumentBase(), dossier + (i+1) + ".jpeg"); } // Valeurs de initiales py = size().height - 16; px = 32; pp = size().width - 32 - 6; pox = new int[4]; poy = new int[4]; pox[0] = 10 ; poy[0] = py+7; pox[1] = 6 ; poy[1] = py+3; pox[2] = 6 ; poy[2] = py+11; } public void start() { if (myThread == null) { myThread = new Thread(this); myThread.start(); } } public void stop() { if (myThread != null) { myThread.stop(); myThread = null; } } public void run() { while (true) { try {Thread.currentThread().sleep(tempsdattente);} catch (InterruptedException e){} if (arrete==1) repaint(); } } public void update(Graphics g) { paint(g); } public void paint(Graphics g) { int i,j; j = pp*compteur/(nombreImages-1); graph.setColor(Color.gray); graph.fillRect(0, 0, size().width, size().height); graph.fill3DRect(0, py, 16, 16, true); // commencer boutton graph.fill3DRect(16, py, 16, 16, true); // arrêter boutton graph.draw3DRect(px, py, pp+5, 14, true); graph.draw3DRect(0,0, size().width-1, py-1, true); graph.setColor(Color.white); graph.fillRect(px+3+j, py+3, pp-j, 9); graph.setColor(Color.darkGray); graph.fillRect(px+3, py+3, j, 9); graph.fillPolygon(pox, poy, 3); graph.fillRect(20, py+4, 7, 7); graph.drawImage(mesimges[compteur], 1, 1, this); // photo g.drawImage(imagehorsecran, 0, 0, this); if (envoyee) { compteur++; if (compteur >= nombreImages) { compteur = nombreImages - 1; envoyee = false; } } else { compteur--; if (compteur < 0) { compteur = 0; envoyee = true; } } } public boolean mouseDown(java.awt.Event evt, int jx, int jy) { if ((jx >= 0)&&(jx <= 15)&&(jy >= py)) { getGraphics().setColor(Color.lightGray); getGraphics().fillRect(0, py, 15, 15); } if ((jx >= 16)&&(jx <= 31)&&(jy >= py)) { getGraphics().setColor(Color.lightGray); getGraphics().fillRect(16, py, 15, 15); } return(true); } public boolean mouseUp(java.awt.Event evt, int jx, int jy) { if ((jx >= 0)&&(jx <= 15)&&(jy >= py)) { arrete = 0; } if ((jx >= 16)&&(jx <= 31)&&(jy >= py)) { arrete = 1; } repaint(); return(true); } public boolean mouseDrag(java.awt.Event evt, int jx, int jy) { if ((jx >= px)&&(jx <= px+pp)&&(jy >= py)&&(arrete==1)) { compteur = (jx - px)*nombreImages/pp; if (compteur>=nombreImages) compteur = nombreImages-1; if (compteur<0) compteur = 0; repaint(); } return(true); } public boolean mouseMove(java.awt.Event evt, int jx, int jy) { if ((jx >= 0)&&(jx <= 15)&&(jy >= py)) { getAppletContext().showStatus("Commencer la video"); } else { if ((jx >= 16)&&(jx <= 31)&&(jy >= py)) { getAppletContext().showStatus("Arret video"); } else { if ((jx >= px)&&(jx <= px+pp)&&(jy >= py)&&(arrete==1)) { getAppletContext().showStatus("Control"); } else { getAppletContext().showStatus(""); } } } return(true); } public boolean mouseExit(java.awt.Event evt, int jx, int jy) { getAppletContext().showStatus(""); return(true); } }
6 mai 2008 à 09:32
25 janv. 2008 à 17:24
28 juil. 2007 à 18:01
je n'ai rien compris à ton application, et je ne souhaites pas y arriver juste en passant des heures (peut être pas autant) à décortiquer ton code : plus d'explications m'auraient aidées. En attend, je ne télécharge ni ne note ton programme .
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.