9 Replies Latest reply: Nov 10, 2013 11:27 PM by anusanraj RSS

    GraphicsContext Translate not work properly with fillPolygon

    986088
      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