Skip to main content



      Home
Home » Eclipse Projects » GEF » RectilinearBendpointRouter - If the ManhattanConnectionRouter had bendpoints...
RectilinearBendpointRouter - If the ManhattanConnectionRouter had bendpoints... [message #84631] Fri, 20 June 2003 15:56 Go to next message
Eclipse UserFriend
Originally posted by: peterarmstrong.shaw.ca

Hi,

I have read a couple threads on this newsgroup that were started when
someone wished that the ManhattanConnectionRouter had bendpoints. I
also had that wish, and while I am a GEF and Eclipse plugin developer
newbie I might be able to help by contributing a class which does this.

I wrote the code to do this in a currently existing (non-GEF) tool, and
I have received preliminary approval from my manager to donate the code
to GEF once I have finished porting it (hopefully very soon).

What I want to know is:

1) Would this be welcomed in org.eclipse.draw2d?

2) Is someone else working on this right now (and expecting to finish in
the next couple days)?

3) Assuming it is welcome, how do I go about contributing it once it's
done? Do I send the code to the newsgroup? To Randy Hudson?

4) The current class name is RectilinearBendpointRouter. This is kind
of clunky, but I didn't want to confuse people looking for the
ManhattanConnectionRouter. Do any of the GEF or Draw2D developers have
an opinion on what they would like this class to be named?

5) The code that I wrote in the non-GEF tool worked with connector
handles that were somewhat smart (they knew if they were a corner handle
or a side handle on the rectilinear connector polyline). This helped
with setting the cursor type (to a move cursor, a horizontal resize
cursor or a vertical resize cursor), and in determining how the
connector would react to the handle being dragged. There doesn't seem
to be anything like this in Draw2D or GEF. Am I missing something? If
not, would a similar approach be welcomed even if it resulted in more
top-level classes?

6) I currently have the following property in RectilinearBendpointRouter:

/**
* This is the IFigure that all Connection routing is done
* within. The route(Connection) method will stay within its
* bounds. Typically, this IFigure is the ConnectionLayer, but
* it can be more restricted if desired--however, this IFigure
* MUST be an ancestor of both the source and target IFigure
* owners of the ConnectionAnchors that the Connection is
* between.
*/
private IFigure _routeBoundsFigure;

Is this a good approach to take, or is it too simplistic/brittle?

Any feedback is welcome.

Thanks,
Peter Armstrong
Re: RectilinearBendpointRouter - If the ManhattanConnectionRouter had bendpoints... [message #84652 is a reply to message #84631] Fri, 20 June 2003 16:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

> I have read a couple threads on this newsgroup that were started when
> someone wished that the ManhattanConnectionRouter had bendpoints. I
> also had that wish, and while I am a GEF and Eclipse plugin developer
> newbie I might be able to help by contributing a class which does this.
>
> I wrote the code to do this in a currently existing (non-GEF) tool, and
> I have received preliminary approval from my manager to donate the code
> to GEF once I have finished porting it (hopefully very soon).
>
> What I want to know is:
>
> 1) Would this be welcomed in org.eclipse.draw2d?

Absolutely! The connection router with constraint support would go in
draw2d, and any handles/editpolicies would go in GEF. Thanks.

> 2) Is someone else working on this right now (and expecting to finish in
> the next couple days)?
No, all work items are listed in the plan:
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/gef- home/plan/plan.h
tml?cvsroot=Tools_Project

> 3) Assuming it is welcome, how do I go about contributing it once it's
> done? Do I send the code to the newsgroup? To Randy Hudson?

Preferably, open a bugzilla and attach the code. Make sure you read the
policy of Eclipse.org. Any code posted here, on the mailing list, or in a
bugzilla can be adopted by us. If you mail it personally to me, I can't
look at it.

> 4) The current class name is RectilinearBendpointRouter. This is kind
> of clunky, but I didn't want to confuse people looking for the
> ManhattanConnectionRouter. Do any of the GEF or Draw2D developers have
> an opinion on what they would like this class to be named?

We'll work on class names later :-)

> 5) The code that I wrote in the non-GEF tool worked with connector
> handles that were somewhat smart (they knew if they were a corner handle
> or a side handle on the rectilinear connector polyline). This helped
> with setting the cursor type (to a move cursor, a horizontal resize
> cursor or a vertical resize cursor), and in determining how the
> connector would react to the handle being dragged. There doesn't seem
> to be anything like this in Draw2D or GEF. Am I missing something? If
> not, would a similar approach be welcomed even if it resulted in more
> top-level classes?

Actually, there is something like this already.
ConnectionBendpointEditPolicy adds each of the handles for the connection.
You could write a similar class which adds rectilinear handles. Hint:
handles don't have to actually paint to be functional. Also, each handle
can provide its own cursor.

> 6) I currently have the following property in RectilinearBendpointRouter:
>
> /**
> * This is the IFigure that all Connection routing is done
> * within. The route(Connection) method will stay within its
> * bounds. Typically, this IFigure is the ConnectionLayer, but
> * it can be more restricted if desired--however, this IFigure
> * MUST be an ancestor of both the source and target IFigure
> * owners of the ConnectionAnchors that the Connection is
> * between.
> */
> private IFigure _routeBoundsFigure;
>
> Is this a good approach to take, or is it too simplistic/brittle?

This is probably too restrictive. A "freeform" connection layer can grow in
all directions to accomodate the bends of the connections it contains, so
sometime there is no need to limit the bendpoints. How is this figure being
used? I'm just guessing.

> Any feedback is welcome.

We will provide more feedback in the bugzilla report. Make sure you include
a simple draw2d standalone example. i.e., create a Shell and lightweight
system, and a few figures which show how the router works.

> Thanks,
> Peter Armstrong
>
Re: RectilinearBendpointRouter - If the ManhattanConnectionRouter had bendpoints... [message #84660 is a reply to message #84652] Fri, 20 June 2003 17:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: peterarmstrong.shaw.ca

> Preferably, open a bugzilla and attach the code. Make sure you read the
> policy of Eclipse.org. Any code posted here, on the mailing list, or in a
> bugzilla can be adopted by us. If you mail it personally to me, I can't
> look at it.

Sounds good. I'll do that when the code is good enough to release
(sometime next week hopefully).

>>5) The code that I wrote in the non-GEF tool worked with connector
>>handles that were somewhat smart (they knew if they were a corner handle
>>or a side handle on the rectilinear connector polyline). This helped
>>with setting the cursor type (to a move cursor, a horizontal resize
>>cursor or a vertical resize cursor), and in determining how the
>>connector would react to the handle being dragged. There doesn't seem
>>to be anything like this in Draw2D or GEF. Am I missing something? If
>>not, would a similar approach be welcomed even if it resulted in more
>>top-level classes?
>
>
> Actually, there is something like this already.
> ConnectionBendpointEditPolicy adds each of the handles for the connection.
> You could write a similar class which adds rectilinear handles. Hint:
> handles don't have to actually paint to be functional. Also, each handle
> can provide its own cursor.

Ok, cool, that's really helpful. Like I said, I'm a total GEF newbie so
chances are the first cut of the code I post in the bugzilla will do
some stupid GEF or Draw2D-related things :-)

>>6) I currently have the following property in RectilinearBendpointRouter:
>>
>>/**
>>* This is the IFigure that all Connection routing is done
>>* within. The route(Connection) method will stay within its
>>* bounds. Typically, this IFigure is the ConnectionLayer, but
>>* it can be more restricted if desired--however, this IFigure
>>* MUST be an ancestor of both the source and target IFigure
>>* owners of the ConnectionAnchors that the Connection is
>> * between.
>>*/
>>private IFigure _routeBoundsFigure;
>>
>>Is this a good approach to take, or is it too simplistic/brittle?
>
>
> This is probably too restrictive. A "freeform" connection layer can grow in
> all directions to accomodate the bends of the connections it contains, so
> sometime there is no need to limit the bendpoints. How is this figure being
> used? I'm just guessing.

Actually, what I'm trying to do is minimize intersecting other
non-Connection IFigures, that's all. Currently I'm trying to do
something like this (which does *not* work):

private int getNumIntersectedShapes(Polygon bounds) {
int numShapesIntersected = 0;
Iterator shapes = _routeBoundsFigure.getChildren().iterator();
IFigure shape;
while (shapes.hasNext()) {
shape = (IFigure)shapes.next();
if (!(shape instanceof Connection) &&
bounds.intersects(shape.getBounds())) {
numShapesIntersected++;
}
}
return numShapesIntersected;
}

The routing algorithm will not totally avoid crossing IFigures since
that would be too slow to do on large diagrams (and who wants a
connector that looks like it went through a maze anyway), but it will
figure out a couple alternate paths and pick the one which crosses fewer
non-Connection IFigures. In my experience this handles normal usage
just fine. However, right now this method above is returning 0 all the
time. (I'm in the process of debugging it :-)

So, this is all I wanted the _routeBoundsFigure for:

_routeBoundsFigure.getChildren().iterator();

Do you have any recommendations about how to obtain an Iterator of
IFigures that a given Connection being routed should try to avoid? I am
trying to do this in a way which is generic enough for the
RectilinearBendpointRouter to be useful as a generic AbstractRouter...

Thanks again,
Peter Armstrong
Re: RectilinearBendpointRouter - If the ManhattanConnectionRouter had bendpoints... [message #84672 is a reply to message #84660] Fri, 20 June 2003 17:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

"Peter Armstrong" <peterarmstrong@shaw.ca> wrote in message
news:bcvt59$dg7$1@rogue.oti.com...
> > Preferably, open a bugzilla and attach the code. Make sure you read the
> > policy of Eclipse.org. Any code posted here, on the mailing list, or in
a
> > bugzilla can be adopted by us. If you mail it personally to me, I can't
> > look at it.
>
> Sounds good. I'll do that when the code is good enough to release
> (sometime next week hopefully).
>
> >>5) The code that I wrote in the non-GEF tool worked with connector
> >>handles that were somewhat smart (they knew if they were a corner handle
> >>or a side handle on the rectilinear connector polyline). This helped
> >>with setting the cursor type (to a move cursor, a horizontal resize
> >>cursor or a vertical resize cursor), and in determining how the
> >>connector would react to the handle being dragged. There doesn't seem
> >>to be anything like this in Draw2D or GEF. Am I missing something? If
> >>not, would a similar approach be welcomed even if it resulted in more
> >>top-level classes?
> >
> >
> > Actually, there is something like this already.
> > ConnectionBendpointEditPolicy adds each of the handles for the
connection.
> > You could write a similar class which adds rectilinear handles. Hint:
> > handles don't have to actually paint to be functional. Also, each
handle
> > can provide its own cursor.
>
> Ok, cool, that's really helpful. Like I said, I'm a total GEF newbie so
> chances are the first cut of the code I post in the bugzilla will do
> some stupid GEF or Draw2D-related things :-)
>
> >>6) I currently have the following property in
RectilinearBendpointRouter:
> >>
> >>/**
> >>* This is the IFigure that all Connection routing is done
> >>* within. The route(Connection) method will stay within its
> >>* bounds. Typically, this IFigure is the ConnectionLayer, but
> >>* it can be more restricted if desired--however, this IFigure
> >>* MUST be an ancestor of both the source and target IFigure
> >>* owners of the ConnectionAnchors that the Connection is
> >> * between.
> >>*/
> >>private IFigure _routeBoundsFigure;
> >>
> >>Is this a good approach to take, or is it too simplistic/brittle?
> >
> >
> > This is probably too restrictive. A "freeform" connection layer can
grow in
> > all directions to accomodate the bends of the connections it contains,
so
> > sometime there is no need to limit the bendpoints. How is this figure
being
> > used? I'm just guessing.
>
> Actually, what I'm trying to do is minimize intersecting other
> non-Connection IFigures, that's all. Currently I'm trying to do
> something like this (which does *not* work):
>
> private int getNumIntersectedShapes(Polygon bounds) {
> int numShapesIntersected = 0;
> Iterator shapes = _routeBoundsFigure.getChildren().iterator();
> IFigure shape;
> while (shapes.hasNext()) {
> shape = (IFigure)shapes.next();
> if (!(shape instanceof Connection) &&
> bounds.intersects(shape.getBounds())) {
> numShapesIntersected++;
> }
> }
> return numShapesIntersected;
> }
>
> The routing algorithm will not totally avoid crossing IFigures since
> that would be too slow to do on large diagrams (and who wants a
> connector that looks like it went through a maze anyway), but it will
> figure out a couple alternate paths and pick the one which crosses fewer
> non-Connection IFigures. In my experience this handles normal usage
> just fine. However, right now this method above is returning 0 all the
> time. (I'm in the process of debugging it :-)
>
> So, this is all I wanted the _routeBoundsFigure for:
>
> _routeBoundsFigure.getChildren().iterator();
>
> Do you have any recommendations about how to obtain an Iterator of
> IFigures that a given Connection being routed should try to avoid? I am
> trying to do this in a way which is generic enough for the
> RectilinearBendpointRouter to be useful as a generic AbstractRouter...

You might need to calculate this per connection. For example, if a
connection starts inside a node inside a container, and spans to another
node ouside the container, then the container's bounds can be ignore,
because the connection has to cross through it somewhere.

> Thanks again,
> Peter Armstrong
>
Re: RectilinearBendpointRouter - If the ManhattanConnectionRouter had bendpoints... [message #84936 is a reply to message #84652] Mon, 23 June 2003 20:12 Go to previous message
Eclipse UserFriend
Randy Hudson wrote:
> We will provide more feedback in the bugzilla report. Make sure you include
> a simple draw2d standalone example. i.e., create a Shell and lightweight
> system, and a few figures which show how the router works.

I have now created two classes, RectilinearRouter and
RelativeConnectionAnchor, which are both pure Draw2D. RectilinearRouter
has all the connection routing code, and RelativeConnectionAnchor is a
useful anchor whose location is based on a double x and y ratio in its
parent IFigure. I have also created a standalone test class (based on
the Connections and Anchors Demo in the Draw2D Developers Guide) called
RectilinearRouterTest which tests both of these classes.

The RectilinearRouter has no bendpoints support. I am working on
subclassing it with a RectilinearBendpointRouter class, which will go in
GEF along with the rectilinear bendpoints, policies, etc. This isn't
done yet...

Questions:
1. Should I submit the RectilinearRouter, RelativeConnectionAnchor and
RectilinearRouterTest classes now (as they are standalone and useful by
themselves), or wait until the RectilinearBendpointRouter class is done?
I want to submit them now in keeping with the "release early, release
often" philosophy, as if I am doing anything blatantly wrong it can be
corrected earlier before I do too much work on the
RectilinearBendpointRouter class.

2. Creating the standalone RectilinearRouterTest class was easy, as it
only tested Draw2D. But since GEF isn't intended to be used outside of
Eclipse, how should I create a test class to test the
RectilinearBendpointRouter class and its supporting classes (which will
use GEF) once they're done? Should I post an entire test plugin?

3. When I post the code in the bugzilla, can I attach the following header?
/*********************************************************** ********************
* Copyright (c) 2000, 2003 Intalio, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Intalio, Inc. - initial API and implementation

************************************************************ ******************/

Thanks again,
Peter Armstrong
Previous Topic:ColorConstants - disposing of Colors
Next Topic:createConnection missing?
Goto Forum:
  


Current Time: Wed Nov 12 11:16:55 EST 2025

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

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

Back to the top