Forum » Programiranje » [Android]Javljanje napak
[Android]Javljanje napak
messi ::
Dober večer, Ob sesutju mi javlja takolo napako ampak jaz rez ne vem kaj je sicer narobe z metodo onDraw ali pa z ostalima napakama če ima kdo kako idejo naj pove kaj je narobe oz kako idejo ..
09-07 07:56:42.896: E/AndroidRuntime(1114): Uncaught handler: thread Thread-9 exiting due to uncaught exception
09-07 07:56:42.906: E/AndroidRuntime(1114): java.lang.NullPointerException
09-07 07:56:42.906: E/AndroidRuntime(1114): at aa.bb.cc.Panel.onDraw(Panel.java:372)
09-07 07:56:42.906: E/AndroidRuntime(1114): at aa.bb.cc.TutorialThread.run(Panel.java:502)
09-07 07:56:42.916: I/dalvikvm(1114): threadid=7: reacting to signal 3
09-07 07:56:42.916: E/dalvikvm(1114): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
09-07 07:56:44.806: I/Process(1114): Sending signal. PID: 1114 SIG: 9
09-07 07:56:42.896: E/AndroidRuntime(1114): Uncaught handler: thread Thread-9 exiting due to uncaught exception
09-07 07:56:42.906: E/AndroidRuntime(1114): java.lang.NullPointerException
09-07 07:56:42.906: E/AndroidRuntime(1114): at aa.bb.cc.Panel.onDraw(Panel.java:372)
09-07 07:56:42.906: E/AndroidRuntime(1114): at aa.bb.cc.TutorialThread.run(Panel.java:502)
09-07 07:56:42.916: I/dalvikvm(1114): threadid=7: reacting to signal 3
09-07 07:56:42.916: E/dalvikvm(1114): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
09-07 07:56:44.806: I/Process(1114): Sending signal. PID: 1114 SIG: 9
package aa.bb.cc; public class Panel extends SurfaceView implements Callback { private Shape currentGraphicObject; DrawPain a; public TutorialThread _thread; public Panel(Context context, AttributeSet attributeSet) { super(context, attributeSet); getHolder().addCallback(this); _thread = new TutorialThread(getHolder(), this); setFocusable(true); setDrawingCacheEnabled(true); } public Panel(Context context) { super(context); getHolder().addCallback(this); _thread = new TutorialThread(getHolder(), this); setFocusable(true); setDrawingCacheEnabled(true); } public ArrayList<Shape> getGraphicObjects(){ return a.graphicobjects; } /*private void setGraphicObject(Shape s){ GraphicObject = s; } private Shape getGraphicObject(){ return GraphicObject; }*/ /*public Canvas getWallPaperCanvas(){ return canvas; }*/ @Override public boolean onTouchEvent(MotionEvent event) { //if(shapemenuclicked == true && erasemenuclicked == false){ synchronized (_thread.getSurfaceHolder()) { if(event.getAction() == MotionEvent.ACTION_DOWN){ if(a.shapemenuclicked == true && a.erasemenuclicked == false){ //if(GraphicObject instanceof Line){ if(a.ShapeObject_to_be_created == a.ShapeLine){ currentGraphicObject = new Line(); ((Line) currentGraphicObject).getBegin().setX(event.getX()); //((Line)(GraphicObject).getBegin().setX(event.getX()));//.setX(event.getX()); //begin.setY(event.getY()); ((Line) currentGraphicObject).getBegin().setY(event.getY()); } //if(GraphicObject instanceof FreeHand){ if(a.ShapeObject_to_be_created == a.ShapeFreehand){ currentGraphicObject = new FreeHand(); ((FreeHand)currentGraphicObject).getPath().moveTo(event.getX(), event.getY()); ((FreeHand)currentGraphicObject).getPath().lineTo(event.getX(), event.getY()); } //if(GraphicObject instanceof Rectangle){ if(a.ShapeObject_to_be_created == a.ShapeRect){ //(Rectangle)GraphicObject.set //It will be later decided whether this end is upper-left/lower-left/upper-right //lower-right currentGraphicObject = new Rectangle(); Point temp = new Point(event.getX(), event.getY()); ((Rectangle) currentGraphicObject).settemppointOfOneEndRectangle(temp); } //if(GraphicObject instanceof Circle){ if(a.ShapeObject_to_be_created == a.ShapeCircle){ currentGraphicObject = new Circle(); ((Circle)currentGraphicObject).getOneEndOfTheCircle().setX(event.getX()); ((Circle)currentGraphicObject).getOneEndOfTheCircle().setY(event.getY()); } //if(GraphicObject instanceof Oval){ if(a.ShapeObject_to_be_created == a.ShapeOval){ currentGraphicObject = new Oval(); ((Oval)currentGraphicObject).getoneEndOfTheOval().setX(event.getX()); ((Oval)currentGraphicObject).getoneEndOfTheOval().setY(event.getY()); } } if(a.shapemenuclicked == false && a.erasemenuclicked == true){ //if(GraphicObject instanceof Erase){ if(a.ShapeObject_to_be_created == a.ShapeErase){ currentGraphicObject = new Erase(); ((Erase)currentGraphicObject).getPath().moveTo(event.getX(), event.getY()); ((Erase)currentGraphicObject).getPath().lineTo(event.getX(), event.getY()); } } } else if(event.getAction() == MotionEvent.ACTION_MOVE){ if(a.shapemenuclicked == true && a.erasemenuclicked == false){ //if(GraphicObject instanceof FreeHand){ if(a.ShapeObject_to_be_created == a.ShapeFreehand){ ((FreeHand)currentGraphicObject).getPath().lineTo(event.getX(), event.getY()); } /*if(GraphicObject instanceof Rectangle){ }*/ if(a.ShapeObject_to_be_created == a.ShapeLine){ } /*if(GraphicObject instanceof Circle){ }*/ if(a.ShapeObject_to_be_created == a.ShapeRect){ } if(a.ShapeObject_to_be_created == a.ShapeCircle){ } /* if(GraphicObject instanceof Oval){ }*/ if(a.ShapeObject_to_be_created == a.ShapeOval){ } } if(a.shapemenuclicked == false && a.erasemenuclicked == true){ //if(GraphicObject instanceof Erase){ if(a.ShapeObject_to_be_created == a.ShapeErase){ ((Erase)currentGraphicObject).getPath().lineTo(event.getX(), event.getY()); } } } else if(event.getAction() == MotionEvent.ACTION_UP){ if(a.shapemenuclicked == true && a.erasemenuclicked == false){ //if(GraphicObject instanceof Line){ if(a.ShapeObject_to_be_created == a.ShapeLine){ //create a new Line... Add it to the ArrayList //currentGraphicObject = new Line(); ((Line) currentGraphicObject).getEnd().setX(event.getX()); ((Line) currentGraphicObject).getEnd().setY(event.getY()); Point temp_begin = ((Line)currentGraphicObject).getBegin(); Point temp_end = ((Line)currentGraphicObject).getEnd(); ((Line) currentGraphicObject).setBegin(temp_begin); ((Line)currentGraphicObject).getPath().moveTo(temp_begin.getX(), temp_begin.getY()); ((Line)currentGraphicObject).getPath().lineTo(temp_end.getX(), temp_end.getY()); //currentGraphicObject.setrgb((int)color[0],(int)color[1],(int)color[2]); } //if(GraphicObject instanceof FreeHand){ if(a.ShapeObject_to_be_created == a.ShapeFreehand){ ((FreeHand)currentGraphicObject).getPath().lineTo(event.getX(), event.getY()); //_graphics.add(((FreeHand)GraphicObject).getPath()); ((FreeHand)currentGraphicObject).getGraphicsPath().add(((FreeHand)currentGraphicObject).getPath()); //currentGraphicObject.setrgb((int)color[0],(int)color[1],(int)color[2]); } //if(GraphicObject instanceof Rectangle){ if(a.ShapeObject_to_be_created == a.ShapeRect){ float tempX = ((Rectangle) currentGraphicObject).gettemppointOfOneEndRectangle().getX(); //the X co-ordinate of the first up float tempY = ((Rectangle) currentGraphicObject).gettemppointOfOneEndRectangle().getY(); float tempX1 = event.getX(); float tempY1 = event.getY(); if(tempX<tempX1 && tempY>tempY1){ ((Rectangle)currentGraphicObject).getPath().addRect(tempX, tempY1, tempX1, tempY, Path.Direction.CW); } if(tempX<tempX1 && tempY<tempY1){ ((Rectangle)currentGraphicObject).getPath().addRect(tempX, tempY, tempX1, tempY1, Path.Direction.CW); } if(tempX>tempX1 && tempY>tempY1){ ((Rectangle)currentGraphicObject).getPath().addRect(tempX1, tempY1, tempX, tempY, Path.Direction.CW); } if(tempX>tempX1 && tempY<tempY1){ ((Rectangle)currentGraphicObject).getPath().addRect(tempX1, tempY, tempX, tempY1, Path.Direction.CW); } //currentGraphicObject.setrgb((int)color[0],(int)color[1],(int)color[2]); } //if(GraphicObject instanceof Circle){ if(a.ShapeObject_to_be_created == a.ShapeCircle){ float tempX1 = ((Circle)currentGraphicObject).getOneEndOfTheCircle().getX(); float tempY1 = ((Circle)currentGraphicObject).getOneEndOfTheCircle().getY(); float tempX2 = event.getX(); float tempY2 = event.getY(); double temp = Math.pow((tempX1-tempX2),2) + Math.pow((tempY1-tempY2),2); float radius = (float)Math.sqrt(temp)/2; ((Circle)currentGraphicObject).getPath().addCircle((tempX1 + tempX2)/2,(tempY1 + tempY2)/2, radius, Path.Direction.CW); //currentGraphicObject.setrgb((int)color[0],(int)color[1],(int)color[2]); } //if(GraphicObject instanceof Oval){ if(a.ShapeObject_to_be_created == a.ShapeOval){ float tempX = ((Oval)currentGraphicObject).getoneEndOfTheOval().getX(); float tempY = ((Oval)currentGraphicObject).getoneEndOfTheOval().getY(); float tempX1 = event.getX(); float tempY1 = event.getY(); if(tempX<=tempX1 && tempY>=tempY1){ ((Oval)currentGraphicObject).getRectangle().set(tempX,tempY1,tempX1,tempY); } if(tempX<=tempX1 && tempY<=tempY1){ ((Oval)currentGraphicObject).getRectangle().set(tempX,tempY,tempX1,tempY1); } if(tempX>=tempX1 && tempY>=tempY1){ ((Oval)currentGraphicObject).getRectangle().set(tempX1,tempY1,tempX,tempY); } if(tempX>=tempX1 && tempY<=tempY1){ ((Oval)currentGraphicObject).getRectangle().set(tempX1,tempY,tempX,tempY1); } //RectF r = ((Oval)GraphicObject).getRectangle(); ((Oval)currentGraphicObject).getPath().addOval(((Oval)currentGraphicObject).getRectangle(), Path.Direction.CW); //((Oval)GraphicObject).getPath().addOval(r, Path.Direction.CW); } } if(a.shapemenuclicked == false && a.erasemenuclicked == true){ //if(GraphicObject instanceof Erase){ if(a.ShapeObject_to_be_created == a.ShapeErase){ ((Erase)currentGraphicObject).getPath().lineTo(event.getX(), event.getY()); //_graphics.add(((FreeHand)GraphicObject).getPath()); ((Erase)currentGraphicObject).getGraphicsPath().add(((Erase)currentGraphicObject).getPath()); //currentGraphicObject.setrgb((int)color[0],(int)color[1],(int)color[2]); } } if(a.colormenuclicked == false && a.shapemenuclicked == true){ currentGraphicObject.setrgb(100,100,100); } if(a.colormenuclicked == true && a.shapemenuclicked == true){ currentGraphicObject.setrgb((int)a.color[0],(int)a.color[1],(int)a.color[2]); } if(a.erasemenuclicked == true && a.colormenuclicked == false){ currentGraphicObject.setrgb(0,0,0); //mPaint.setStrokeWidth(6); } if(a.brushwidthmenuclicked == true){// || erasemenuclicked == true){ currentGraphicObject.setStrokeWidth(a.BrushWidth); } a.graphicobjects.add(currentGraphicObject); a.number_of_graphicObjects++; } if(colormenuclicked == false && shapemenuclicked == true){ currentGraphicObject.setrgb(100,100,100); } if(colormenuclicked == true && shapemenuclicked == true){ currentGraphicObject.setrgb((int)color[0],(int)color[1],(int)color[2]); } if(erasemenuclicked == true && colormenuclicked == false){ currentGraphicObject.setrgb(0,0,0); //mPaint.setStrokeWidth(6); } if(brushwidthmenuclicked == true){// || erasemenuclicked == true){ currentGraphicObject.setStrokeWidth(BrushWidth); } graphicobjects.add(currentGraphicObject); number_of_graphicObjects++;*/ } //} return true; } @Override public void onDraw(Canvas canvas) { for(int i = 0; i<a.number_of_graphicObjects; i++){ Shape currentGraphicObject = a.graphicobjects.get(i); a.mPaint.setColor(Color.rgb(currentGraphicObject.getrgb()[0], currentGraphicObject.getrgb()[1], currentGraphicObject.getrgb()[2])); a.mPaint.setStrokeWidth(currentGraphicObject.getStrokeWidth()); if(currentGraphicObject instanceof FreeHand){ for (Path path : ((FreeHand)currentGraphicObject).getGraphicsPath()) { canvas.drawPath(path,a.mPaint); a.bitmapCanvas.drawPath(path,a.mPaint); } } else if(currentGraphicObject instanceof Erase){ for (Path path : ((Erase)currentGraphicObject).getGraphicsPath()) { canvas.drawPath(path, a.mPaint); a.bitmapCanvas.drawPath(path, a.mPaint); } } else{ canvas.drawPath(currentGraphicObject.getPath(),a.mPaint); a.bitmapCanvas.drawPath(currentGraphicObject.getPath(),a.mPaint); } } } public void surfaceCreated(SurfaceHolder holder) { _thread.setRunning(true); _thread.start(); } public void surfaceDestroyed(SurfaceHolder holder) { boolean retry = true; _thread.setRunning(false); while (retry) { try { _thread.join(); retry = false; } catch (InterruptedException e) { // we will try it again and again... } } } class TutorialThread extends Thread { private SurfaceHolder _surfaceHolder; private Panel _panel; private boolean _run = false; public TutorialThread(SurfaceHolder surfaceHolder, Panel panel) { _surfaceHolder = surfaceHolder; _panel = panel; } public void setRunning(boolean run) { _run = run; } public SurfaceHolder getSurfaceHolder() { return _surfaceHolder; } @Override public void run() { Canvas c; while (_run) { c = null; try { c = _surfaceHolder.lockCanvas(null); synchronized (_surfaceHolder) { _panel.onDraw(c); //_panel.saveScreenshot(); } } finally { if (c != null) { _surfaceHolder.unlockCanvasAndPost(c); } } } //_panel.saveScreenshot(); } }
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | [Android] pomoč pri postavitvi layoutaOddelek: Programiranje | 2232 (1990) | icurk |
» | Programiranje problem androidOddelek: Programiranje | 1176 (941) | g333kk |
» | Android zamenjava pogledovOddelek: Programiranje | 1084 (905) | c00L3r |
» | android črtaOddelek: Programiranje | 2410 (1681) | g333kk |
» | vkljucevanje txt datoteke v ...Oddelek: Programiranje | 1586 (1362) | webblod |