public void startApp() { // } public void pauseApp() { // , , SMS .. } public void destroyApp(boolean unconditional) { // , . // ... }
public void destroyApp(boolean unconditional) { notifyDestroyed(); // }
Display dsp = Display.getDisplay(this); // ...
import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Graphics; public class OurCanvas extends Canvas { // Canvas public void paint(Graphics g) { int w = getWidth(); // int h = getHeight(); // g.setColor(0xffffff); // g.fillRect(0,0,w,h); // } }
import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Graphics; public class OurCanvas extends GameCanvas implements Runnable { // GameCanvas Runnable, Thread public void run() { Graphics g = getGraphics(); // Graphics // int w = getWidth(); // int h = getHeight(); // g.setColor(0xffffff); // g.fillRect(0,0,w,h); // } }
import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Graphics; public class OurCanvas extends GameCanvas implements Runnable { Graphics g = getGraphics(); int w = getWidth(); int h = getHeight(); public void run() { g.setColor(0xffffff); g.fillRect(0,0,w,h); isSomethingDone(); } public void isSomethingDone() { g.setColor(0xababab); g.drawLine(25,25,125,125); } }
import javax.microedition.midlet.MIDlet; import javax.microedition.lcdui.*; import java.util.Timer; public class midlet extends MIDlet { Timer timer; midletTimerTask task; midletCanvas canvas; public midlet () { canvas = new midletCanvas(this); // timer = new Timer (); task = new midletTimerTask (canvas); // , timer.scheduleAtFixedRate(task,10,10); // 10 // 10 - . repaint , // , in } protected void startApp() { // Display.getDisplay(this).setCurrent (canvas); } protected void pauseApp() {} protected void destroyApp(boolean unconditional) {} public void exitMIDlet() { notifyDestroyed(); } }
import javax.microedition.lcdui.*; class midletCanvas extends Canvas { midlet midlet; random Random; static int [] PlasmaTab = { // - 256 32,32,33,34,35,35,36,37,38,39,39,40,41,42,42,43, 44,45,45,46,47,47,48,49,49,50,51,51,52,52,53,54, 54,55,55,56,56,57,57,58,58,59,59,59,60,60,60,61, 61,61,62,62,62,62,63,63,63,63,63,63,63,63,63,63, 63,63,63,63,63,63,63,63,63,63,62,62,62,62,62,61, 61,61,60,60,60,59,59,58,58,58,57,57,56,56,55,54, 54,53,53,52,52,51,50,50,49,48,48,47,46,46,45,44, 43,43,42,41,40,40,39,38,37,37,36,35,34,33,33,32, 31,30,30,29,28,27,26,26,25,24,23,23,22,21,20,20, 19,18,17,17,16,15,15,14,13,13,12,11,11,10,10, 9, 9, 8, 7, 7, 6, 6, 5, 5, 5, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10,11,11,12,12,13,14,14,15,16,16,17,18,18,19, 20,21,21,22,23,24,24,25,26,27,28,28,29,30,31,31 }; //, , // 32* (1+ sin (x*(2*pi/255)), static int Delta = 6; // static int Yold_pos=0, Yold_asp=0, Xold_pos=0, Xold_asp=0; int Ynew_pos, Ynew_asp, Xnew_pos, Xnew_asp, x, y, Color; static int Width, Height; // static boolean in = false; // Graphics gbuffer; // Image screen; // public midletCanvas (midlet midlet) { this.midlet = midlet; Random = new random (); setFullScreenMode (true); // MIDP 2.0 Width = getWidth (); Height = getHeight (); screen=Image.createImage(Width,Height); gbuffer=screen.getGraphics(); // gbuffer, draw (gbuffer); // ! } void draw (Graphics g) { // in = true; Ynew_pos = Yold_pos; Ynew_asp = Yold_asp; for (y=0; y<Height; y+=Delta) { Xnew_pos = Xold_pos; Xnew_asp = Xold_asp; for (x=0; x<Width; x+=Delta) { Color = PlasmaTab[Ynew_pos]+ PlasmaTab[Ynew_asp]+ PlasmaTab[Xnew_pos]+ PlasmaTab[Xnew_asp]; g.setColor(((255-Color)<<16 | Color<<8 | 128+(Color>>1))); g.fillRect (x,y,Delta,Delta); Xnew_pos += 1; if (Xnew_pos > 255) Xnew_pos=0; Xnew_asp += 7; if (Xnew_asp > 255) Xnew_asp=0; } Ynew_pos += 2; if (Ynew_pos > 255) Ynew_pos=0; Ynew_asp += 1; if (Ynew_asp > 255) Ynew_asp=0; } Xold_pos -= 2; if (Xold_pos<0) Xold_pos=255; Xold_asp += Random.get(8); if (Xold_asp > 255) Xold_asp=0; Yold_pos += 4; if (Yold_pos > 255) Yold_pos=0; Yold_asp -= Random.get(6); if (Yold_asp<0) Yold_asp=255; in = false; } protected void paint (Graphics g) { if (in == true) return; // g.drawImage(screen,0,0,0); draw (gbuffer); } public void keyPressed(int keyCode) { switch (keyCode) { // # case Canvas.KEY_POUND: midlet.exitMIDlet(); break; } } }
import java.util.TimerTask; import javax.microedition.midlet.MIDlet; class midletTimerTask extends TimerTask { midletCanvas canvas; public midletTimerTask (midletCanvas canvas) { this.canvas = canvas; } public final void run() { canvas.repaint(); } }
import java.util.Date; import java.util.Random; class random { //- private Random r; private Date d; public random () { d = new Date (); r = new Random (d.getTime()); } public int get (int max) { // [0,max-1] int n=r.nextInt()%max; return (n<0 ? -n : n); } }
SEMC-StandbyApplication: Y
Source: https://habr.com/ru/post/135672/
All Articles