This discussion is archived
9 Replies Latest reply: Nov 10, 2013 9:27 PM by anusanraj RSS

GraphicsContext Translate not work properly with fillPolygon

986088 Newbie
Currently Being Moderated
I'm trying to render on a JavaFx Canvas Object, it seems that the translate command doesn't have any effect if used before the fillPolygon.
It works perfectly with other methods (fillOval in the code)

here the code:
public void render(GraphicsContext gc,Gis_Struct gisStruct) {
       
        gc.save();
        gc.translate(gisStruct.rectDest.x, gisStruct.rectDest.y);
        gc.scale(gisStruct.zoomFactor, gisStruct.zoomFactor);
       
        gc.setGlobalAlpha(0.7);
        gc.setFill(Color.BLUE);
        
        gc.fillPolygon(listOfPoint_x, listOfPoint_y, listOfPint.size());
        gc.restore();
        
        gc.save();
        gc.translate(gisStruct.rectDest.x, gisStruct.rectDest.y);
        gc.scale(gisStruct.zoomFactor, gisStruct.zoomFactor);
        
        gc.setGlobalAlpha(0.7);
        gc.setFill(Color.RED);
        
        gc.fillOval(0,0, 100, 100);
        gc.restore();
    }
[Here the result of this code|https://docs.google.com/file/d/0B9FjOvpVbGhacFVFTGgwWlRpcFk/edit]

I can't figure how to fix this.

Thank you in advise

Fabio

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points