Exemplo n.º 1
0
  @Override
  public void drawGhost(Context2d context) {
    double rotation = getEnvObject().getCurrentRepresentation().getRotation();
    double dx = getEnvObject().getCurrentRepresentation().getOffset().getX();
    double dy = getEnvObject().getCurrentRepresentation().getOffset().getY();
    context.translate(dx, dy);
    context.rotate(rotation);
    Color c = new Color(getIndexColor());
    WebGraphics g = new WebGraphics(context);
    g.setColor(c);
    g.fill(ghostPath);
    //		if (ghostBitmap!= null)
    //		{
    //			ghostBitmap.eraseColor(indexColor);
    //			canvas.drawBitmap(ghostBitmap,drawingMatrix, null);
    //		}
    //		else
    //		{
    //			canvas.drawPath(ghostPath, ghostPaint);
    //		}

    context.rotate(-rotation);
    context.translate(-dx, -dy);
  }
Exemplo n.º 2
0
  @Override
  public void draw(Context2d context) {
    String file = getEnvObject().getCurrentRepresentation().getIcon();
    Path2D objectPath =
        DrawingUtils.freedomPolygonToPath(
            (FreedomPolygon) getEnvObject().getCurrentRepresentation().getShape());
    Rectangle2D box = objectPath.getBounds2D();
    objectBounds = objectPath.getBounds();

    rotation = getEnvObject().getCurrentRepresentation().getRotation();
    dx = getEnvObject().getCurrentRepresentation().getOffset().getX();
    dy = getEnvObject().getCurrentRepresentation().getOffset().getY();
    context.translate(dx, dy);
    context.rotate(rotation);
    WebGraphics g = new WebGraphics(context);
    if (ImageUtils.CachedImages.containsKey(OBJECT_PATH + file)) {
      Image im = ImageUtils.CachedImages.get(OBJECT_PATH + file);
      ImageElement ie = ImageElement.as(im.getElement());
      // ghostPath = new Rectangle(ie.getWidth(),ie.getHeight());
      ghostPath = objectBounds;
      context.drawImage(ie, 0, 0, box.getWidth(), box.getHeight());

      // draw box surronding object
      // draw the border
      context.setLineWidth(1);
      g.setColor(new Color(137, 174, 32));
      g.draw(box);

    } 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");
      //    		}
    }
    context.rotate(-rotation);
    context.translate(-dx, -dy);
  }