@Override public void draw(Canvas canvas) { String file = getEnvObject().getCurrentRepresentation().getIcon(); Path objectPath = DrawingUtils.freedomPolygonToPath( (FreedomPolygon) getEnvObject().getCurrentRepresentation().getShape()); RectF box = new RectF(); objectPath.computeBounds(box, true); System.out.print("GPT box: box widht:" + box.width() + " box heigh" + box.height()); drawingMatrix = new Matrix(); float rotation = (float) getEnvObject().getCurrentRepresentation().getRotation(); drawingMatrix.postRotate(rotation); drawingMatrix.postTranslate( getEnvObject().getCurrentRepresentation().getOffset().getX(), getEnvObject().getCurrentRepresentation().getOffset().getY()); Bitmap bmp = null; if (file != null) { // TODO: Asign the bmp in the setEnvObject bmp = BitmapUtils.getImage(file, (int) box.width(), (int) box.height()); } if (bmp != null) { ghostBitmap = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Config.ARGB_8888); canvas.drawBitmap(bmp, drawingMatrix, null); } else { // TODO: Cache path Paint paint = new Paint(); paint.setStyle(Style.FILL); ghostPath = new Path(); objectPath.transform(drawingMatrix, ghostPath); int fillColor = -1; try { fillColor = Color.parseColor(getEnvObject().getCurrentRepresentation().getFillColor()); paint.setColor(fillColor); canvas.drawPath(ghostPath, paint); } catch (IllegalArgumentException ex) { System.out.println("ParseColor exception in fill"); } int borderColor = -1; try { borderColor = Color.parseColor(getEnvObject().getCurrentRepresentation().getBorderColor()); paint.setColor(borderColor); paint.setStyle(Style.STROKE); canvas.drawPath(ghostPath, paint); } catch (IllegalArgumentException ex) { System.out.println("ParseColor exception in border"); } } }