package mobileapplication7; import java.util.Random; import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Font; import javax.microedition.lcdui.Graphics; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author Bartosz */ public class Plotno extends Canvas { String napis; long start, stop; public Plotno() { } protected void paint(Graphics g) { Random r = new Random(); start = System.currentTimeMillis(); // start timing for (int i = 0; i < 100; i++) { Triangle t = new Triangle(r.nextInt(getWidth() + 1), r.nextInt(getWidth() + 1), r.nextInt(getWidth() + 1), r.nextInt(getHeight() + 1), r.nextInt(getHeight() + 1), r.nextInt(getHeight() + 1)); g.setColor(r.nextInt(256), r.nextInt(256), r.nextInt(256)); g.fillTriangle(t.getX1(), t.getY1(), t.getX2(), t.getY2(), t.getX3(), t.getY3()); } stop = System.currentTimeMillis(); // stop timing napis = Long.toString(stop - start); g.setColor(0, 0, 0); g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_MEDIUM)); g.drawString("Czas rysowania: " + napis + "ms", this.getWidth() / 2, this.getHeight() / 4, Graphics.BASELINE | Graphics.HCENTER); } // protected void keyPressed(int kod) { // switch (kod) { // case KEY_NUM2: // napis = "góra"; // break; // case KEY_NUM8: // napis = "dół"; // break; // case KEY_NUM4: // napis = "lewo"; // break; // case KEY_NUM6: // napis = "prawo"; // break; // } // this.repaint(); // serviceRepaints(); // } }