Unusual ellipse painting issue


#1

Hi,

We have just come across a strange issue when using JGo version 5.21.

When drawing a JGoEllipse VERY far away from {0, 0}, the symbol doesn’t look quite right. For example:

The code to make this issue is:


public class SymbolsTest {

<span style="line-height: 1.4;">  public static void main(String[] args) {</span>
<span style="line-height: 1.4;">    JFrame frame = new JFrame();</span>
<span style="line-height: 1.4;">    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);</span>
<span style="line-height: 1.4;">
</span>
<span style="line-height: 1.4;">    JGoDocument document = new JGoDocument();</span>
<span style="line-height: 1.4;">    JGoView view = new JGoView(document);</span>
<span style="line-height: 1.4;">    view.setIncludingNegativeCoords(true);</span>
<span style="line-height: 1.4;">    frame.add(view);</span>
<span style="line-height: 1.4;">
</span>
<span style="line-height: 1.4;">    </span><span style="line-height: 1.4;">Point ellipseLocation = new Point(-150000000, 0);</span>
<span style="line-height: 1.4;">    </span><span style="line-height: 1.4;">JGoEllipse ellipse = new JGoEllipse(ellipseLocation, new Dimension(30, 30));</span>
<span style="line-height: 1.4;">    document.add(ellipse);</span>
<span style="line-height: 1.4;">    view.setViewPosition(ellipseLocation);</span>
<span style="line-height: 1.4;">
</span>
<span style="line-height: 1.4;">    frame.setPreferredSize(new Dimension(500, 500));</span>
<span style="line-height: 1.4;">    frame.pack();</span>
<span style="line-height: 1.4;">    frame.setLocationRelativeTo(null);</span>
<span style="line-height: 1.4;">    frame.setVisible(true);</span>
<span style="line-height: 1.4;">  }</span>
<span style="line-height: 1.4;">
</span>
<span style="line-height: 1.4;">}</span>

Has this issue been fixed in later versions?
< id="_npwlo" =“applicationpwlo” height=“0”>


#2

Well I have to admit, that is very odd! I haven’t seen that before.

However the bug has to be in AWT rather than JGo. The JGoEliipse painting code is as follows:

public static void drawEllipse(Graphics2D g, JGoPen pen, JGoBrush brush, int x, int y, int width, int height)
{
// Fill the shape
if (brush != null) {
Paint paint = brush.getPaint();
if (paint != null) {
g.setPaint(paint);
g.fillOval(x, y, width, height);
}
}
// Draw the shape
if (pen != null) {
Stroke stroke = pen.getStroke();
if (stroke != null) {
g.setStroke(stroke);
g.setColor(pen.getColor());
g.drawOval(x, y, width, height);
}
}
}


#3

It was only by chance that we noticed it as well. Generally there isn’t much use for JGoDocuments of that size!

Good call though, it is a Java problem rather than JGo.

Cheers for looking into it anyway.
< id="_npwlo" =“applicationpwlo” height=“0”>