Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Bug 7075: anti alias of lines using GC
Bug 7075: anti alias of lines using GC [message #448016] Thu, 23 December 2004 23:18 Go to next message
Nick Lerissa is currently offline Nick LerissaFriend
Messages: 6
Registered: July 2009
Junior Member
I've been creating application that needs to draw curved lines.
Since there is no built-in GC support for drawing curved lines, I am
estimating the curve using the java.awt.geom classes::

import java.awt.geom.*;
....
CubicCurve2D curve = new CubicCurve2D.Double(x0,y0, x1,y1,x2,y2,x3,y3);
PathIterator itr = curve.getPathIterator(null, .1f);
float array[] = new float[2];
int last[] = null;

while (!itr.isDone()) {
itr.currentSegment(array);
int x = Math.round(array[0]);
int y = Math.round(array[1]);

if (last != null) {
gc.drawLine(x,y,last[0],last[1]);
}
last = new int[] { x, y}; itr.next();
}

The problem is that some curve look pretty bad since there is no
antialiasing support. I see that
the following bug has been filed. Just incase it doesn't get fixed does
anyone have a suggestion for
drawing a smoother curve.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=7075
Re: Bug 7075: anti alias of lines using GC [message #448040 is a reply to message #448016] Tue, 28 December 2004 11:16 Go to previous message
Markus Kuhn is currently offline Markus KuhnFriend
Messages: 3
Registered: July 2009
Junior Member
As AWT Java 2D supports anti aliasing, you could use Java 2D with the
org.eclipse.swt.awt.SWT_AWT bridge.

Markus

Nick Lerissa wrote:

> I've been creating application that needs to draw curved lines.
> Since there is no built-in GC support for drawing curved lines, I am
> estimating the curve using the java.awt.geom classes::
>
> import java.awt.geom.*;
> ...
> CubicCurve2D curve = new CubicCurve2D.Double(x0,y0, x1,y1,x2,y2,x3,y3);
> PathIterator itr = curve.getPathIterator(null, .1f);
> float array[] = new float[2];
> int last[] = null;
>
> while (!itr.isDone()) {
> itr.currentSegment(array);
> int x = Math.round(array[0]);
> int y = Math.round(array[1]);
>
> if (last != null) {
> gc.drawLine(x,y,last[0],last[1]);
> }
> last = new int[] { x, y}; itr.next();
> }
>
> The problem is that some curve look pretty bad since there is no
> antialiasing support. I see that
> the following bug has been filed. Just incase it doesn't get fixed does
> anyone have a suggestion for
> drawing a smoother curve.
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=7075
>
>
Previous Topic:Are there some tools for test swt app?
Next Topic:Which VM (free !) can i use for Pocket Pc 2003 ?
Goto Forum:
  


Current Time: Tue Oct 27 21:54:25 GMT 2020

Powered by FUDForum. Page generated in 0.02128 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top