| Summary: | Allow drawing curved Lines in GEF using draw2d | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | joseph <josephinto_20> |
| Component: | GEF-Legacy Draw2d | Assignee: | 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
Sounds like Bug# 234808. (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.. I just wondering whether its possible to have lines with curved edges in GEF.. GEF really needs this feauture...... (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 ? 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? 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();
}
}
The solution given works for me..I could allow to draw curved lines now...Thanks... (In reply to comment #7) > The solution given works for me..I could allow to draw curved lines > now...Thanks... > Resolving as worksforme then. |