#914 The function body of fillPolygon is empty.

1.0.x
closed-fixed
General (896)
5
2009-02-27
2009-02-10
Ronnie Duan
No

Now i am working with CompassPlot, when i draw a polygon and fill it, it can work well in Swing, but cant't work in SWT.

I found that the function body of fillPolygon in org.jfree.experimental.swt.SWTGraphics2D.java of jfreechart-1.1.12-swt.jar and in org.jfree.experimental.swt.SWTGraphics2D.java of swtgraphics2d.jar is empty. It likes this:

public void fillPolygon(int ai[], int ai1[], int i)
{
}

So if you want to fill a polygon in SWT, it can't work:
The following code comes from the function draw in org.jfree.chart.plot.CompassPlot.java.
Polygon p = new Polygon();
p.addPoint(x2, y2);
p.addPoint(x3, y3);
p.addPoint(x4, y4);
g2.fillPolygon(p); // can't work

I suggest to modify the function like this:
public void fillPolygon(int ai[], int ai1[], int i)
{
int[] pts = new int[2 * i];
for (int j = 0; j < i; j++) {
pts[2 * j] = ai[j];
pts[2 * j + 1] = ai1[j];
}
switchColors();
gc.fillPolygon(pts);
switchColors();
}

It can work well with Swing because if it runs in Swing, it uses the function fillPolygon in sun.java2d.SunGraphics2D.java of rt.jar, and the function is implemented.
Maybe you will have a better solution, i'm looking forward to this, thank you.

Discussion

  • David Gilbert

    David Gilbert - 2009-02-27
    • assigned_to: nobody --> mungady
    • status: open --> closed-fixed
     
  • David Gilbert

    David Gilbert - 2009-02-27

    Thanks for the report. I've committed the method implementation to Subversion for inclusion in the 1.0.13 release.

    Best regards,

    Dave Gilbert
    JFreeChart Project Leader

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks