Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 255131

Summary: Allow drawing curved Lines in GEF using draw2d
Product: [Tools] GEF Reporter: joseph <josephinto_20>
Component: GEF-Legacy Draw2dAssignee: gef-inbox <gef-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: enhancement    
Priority: P3 CC: ahunter.eclipse, hudsonr, irbull
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description joseph CLA 2008-11-12 23:33:37 EST
GEF does not allow to draw curved lines in GEF.To allow the plugin Editor for a good look and feel GUI ,GEF really needs this enhancement.
Comment 1 Ian Bull CLA 2008-11-13 14:36:16 EST
Sounds like Bug# 234808.
Comment 2 joseph CLA 2008-11-13 23:02:51 EST
(In reply to comment #1)
> Sounds like Bug# 234808.

The solution given for 234808 does not solve the problem and it allows to draw polyine with sharp edges only.

we want to have edges with rounded arc instead of sharp edges..


Comment 3 joseph CLA 2008-12-12 07:37:40 EST
I just wondering whether its possible to have lines with curved edges in GEF..
GEF really needs this feauture......
Comment 4 Anthony Hunter CLA 2008-12-12 10:26:35 EST
(In reply to comment #2)
> 
> we want to have edges with rounded arc instead of sharp edges..
> 

Can you provide a screen shot / example of why this is different from Bug 234808?

Like the rounded bendpoints in http://www.eclipse.org/bpmn/images/due_diligence.gif ?
Comment 5 joseph CLA 2008-12-15 23:05:01 EST
Yes,we want to have rounded rectangles like due_diligence diagram.The solution for the bug 234808 is not allowing us to draw curved lines like the one we saw in due_diligence diagram. can you please tell us how to get the curved lines like due_diligence in GEF?
Comment 6 Randy Hudson CLA 2008-12-16 14:32:08 EST
Here's one way to do it quick and dirty. You probably want to use arcs rather than cubic splines. Determining the maximum arc radius at each bend shouldn't be too hard, then you just need to find the location of the tangent circle and the start and end angles.

public class HelloWorld {

	static PointList list = new PointList(new int[]{10,10, 50,10, 50,50, 100, 50, 100,100});
	public static void main(String[] args) {

		Display d = new Display();
		Shell shell = new Shell(d);
		shell.setLayout(new FillLayout());

		FigureCanvas canvas = new FigureCanvas(shell, SWT.NONE);
		canvas.setContents(new Figure() {
			public void paintFigure(Graphics g) {
				g.setAntialias(SWT.ON);
				g.drawRectangle(getBounds().getResized(-1,-1));
				g.translate(.5f, .5f);
				Path path = new Path(null);
				
				float roundness = 0.7f;
				float straightness = 1-roundness;
				Point last = list.getFirstPoint(), current, next = null;
				path.moveTo(last.x, last.y);
				for (int i=1;i<list.size()-1;i++) {
					last = list.getPoint(i-1);
					current = list.getPoint(i);
					next = list.getPoint(i+1);
					path.lineTo(last.x * straightness + current.x * roundness,
							last.y * straightness + current.y * roundness);
					path.cubicTo(
							current.x, current.y,
							current.x, current.y,
							next.x * straightness + current.x * roundness,
							next.y * straightness + current.y * roundness);
				}
				path.lineTo(next.x, next.y);
				g.drawPath(path);
				path.dispose();
			}
		});

		shell.open();
		while (!shell.isDisposed())
			while (!d.readAndDispatch())
				d.sleep();

	}
	
	

}
Comment 7 joseph CLA 2008-12-18 23:21:42 EST
The solution given works for me..I could allow to draw curved lines now...Thanks...
Comment 8 Anthony Hunter CLA 2008-12-19 13:49:34 EST
(In reply to comment #7)
> The solution given works for me..I could allow to draw curved lines
> now...Thanks...
> 

Resolving as worksforme then.