Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How does ShortestPath routing algorithm work?
How does ShortestPath routing algorithm work? [message #219797] Fri, 21 July 2006 17:01 Go to next message
Eclipse UserFriend
Originally posted by: pilgrim.us.ibm.com

The shortest path routing algorithm seems to do nothing different than
manual routing in my application. I've used the logic example as a base
and see the difference there. Switching to Manhattan in my application
does result in the same routing as the logic example. However, shortest
path does not. I have updated the value returned by getPreferredSize for
my figures. Any suggestions? Thanks!
Re: How does ShortestPath routing algorithm work? [message #219866 is a reply to message #219797] Sat, 22 July 2006 13:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cricard.businessobjects.com

Have you tried to set your ConnectionLayer's router to a FanRouter, on which
you would have called setNextRouter(myShortestPathConnectionRouter)
beforehand ?

"Jeff" <pilgrim@us.ibm.com> wrote in message
news:8d5d999fd2a898450a32fe618b9c7730$1@www.eclipse.org...
> The shortest path routing algorithm seems to do nothing different than
> manual routing in my application. I've used the logic example as a base
> and see the difference there. Switching to Manhattan in my application
> does result in the same routing as the logic example. However, shortest
> path does not. I have updated the value returned by getPreferredSize for
> my figures. Any suggestions? Thanks!
>
Re: How does ShortestPath routing algorithm work? [message #219969 is a reply to message #219866] Mon, 24 July 2006 15:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pilgrim.us.ibm.com

I've retained the same call in my diagrameditpart as the logic example
uses:
protected void refreshVisuals() {
ConnectionLayer cLayer = (ConnectionLayer) getLayer(CONNECTION_LAYER);
cLayer.setAntialias(SWT.ON);

if
(getLogicDiagram().getConnectionRouter().equals(LogicDiagram .ROUTER_MANUAL))
{
AutomaticRouter router = new FanRouter();
router.setNextRouter(new BendpointConnectionRouter());
cLayer.setConnectionRouter(router);
} else if
(getLogicDiagram().getConnectionRouter().equals(LogicDiagram .ROUTER_MANHATTAN))
cLayer.setConnectionRouter(new ManhattanConnectionRouter());
else
cLayer.setConnectionRouter(new
ShortestPathConnectionRouter(getFigure()));
}

and I also tried:
protected void refreshVisuals() {
ConnectionLayer cLayer = (ConnectionLayer) getLayer(CONNECTION_LAYER);
cLayer.setAntialias(SWT.ON);

if
(getProcessingElementCollectionDiagram().getConnectionRouter ().equals(ProcessingElementCollectionDiagram.ROUTER_MANUAL))
{
AutomaticRouter router = new FanRouter();
router.setNextRouter(new BendpointConnectionRouter());
cLayer.setConnectionRouter(router);
} else if
(getProcessingElementCollectionDiagram().getConnectionRouter ().equals(ProcessingElementCollectionDiagram.ROUTER_MANHATTA N))
cLayer.setConnectionRouter(new ManhattanConnectionRouter());
else {
AutomaticRouter router = new FanRouter();
router.setNextRouter(new ShortestPathConnectionRouter(getFigure()));
cLayer.setConnectionRouter(router);
}
}

both editparts have the same 'createFigure' method:
protected IFigure createFigure() {
Figure f = new FreeformLayer();
// f.setBorder(new GroupBoxBorder("Diagram"));
f.setLayoutManager(new FreeformLayout());
f.setBorder(new MarginBorder(5));
return f;
}

one thing I can think of that is different between my application and the
logic example is I'm using a triangle decorator on the connection lines.
Re: How does ShortestPath routing algorithm work? [message #220030 is a reply to message #219969] Tue, 25 July 2006 11:31 Go to previous messageGo to next message
Sebu Thomas is currently offline Sebu ThomasFriend
Messages: 12
Registered: July 2009
Junior Member
Here is the code that is working for me. This code is in the root
EditPart's activate() method, after super.activate() call.

ScalableRootEditPart root =
(ScalableRootEditPart)getViewer().getRootEditPart();
ConnectionLayer connLayer =
(ConnectionLayer)root.getLayer(LayerConstants.CONNECTION_LAY ER);
GraphicalEditPart contentEditPart =
(GraphicalEditPart)root.getContents();
FanRouter router = new FanRouter();
router.setSeparation(20);
ShortestPathConnectionRouter spRouter = new
ShortestPathConnectionRouter(contentEditPart.getFigure());
router.setNextRouter(spRouter);
connLayer.setConnectionRouter(router);

If all else fails, step through your code. Make sure that the calls are
made correctly.

Sebu.

Jeff wrote:
> I've retained the same call in my diagrameditpart as the logic example
> uses:
> protected void refreshVisuals() {
> ConnectionLayer cLayer = (ConnectionLayer) getLayer(CONNECTION_LAYER);
> cLayer.setAntialias(SWT.ON);
>
> if
> (getLogicDiagram().getConnectionRouter().equals(LogicDiagram .ROUTER_MANUAL))
> {
> AutomaticRouter router = new FanRouter();
> router.setNextRouter(new BendpointConnectionRouter());
> cLayer.setConnectionRouter(router);
> } else if
> (getLogicDiagram().getConnectionRouter().equals(LogicDiagram .ROUTER_MANHATTAN))
>
> cLayer.setConnectionRouter(new ManhattanConnectionRouter());
> else
> cLayer.setConnectionRouter(new
> ShortestPathConnectionRouter(getFigure()));
> }
>
> and I also tried:
> protected void refreshVisuals() {
> ConnectionLayer cLayer = (ConnectionLayer) getLayer(CONNECTION_LAYER);
> cLayer.setAntialias(SWT.ON);
>
> if
> (getProcessingElementCollectionDiagram().getConnectionRouter ().equals(ProcessingElementCollectionDiagram.ROUTER_MANUAL))
> {
> AutomaticRouter router = new FanRouter();
> router.setNextRouter(new BendpointConnectionRouter());
> cLayer.setConnectionRouter(router);
> } else if
> (getProcessingElementCollectionDiagram().getConnectionRouter ().equals(ProcessingElementCollectionDiagram.ROUTER_MANHATTA N))
>
> cLayer.setConnectionRouter(new ManhattanConnectionRouter());
> else {
> AutomaticRouter router = new FanRouter();
> router.setNextRouter(new
> ShortestPathConnectionRouter(getFigure()));
> cLayer.setConnectionRouter(router);
> }
> }
>
> both editparts have the same 'createFigure' method:
> protected IFigure createFigure() {
> Figure f = new FreeformLayer();
> // f.setBorder(new GroupBoxBorder("Diagram"));
> f.setLayoutManager(new FreeformLayout());
> f.setBorder(new MarginBorder(5));
> return f;
> }
>
> one thing I can think of that is different between my application and
> the logic example is I'm using a triangle decorator on the connection
> lines.
>
Re: How does ShortestPath routing algorithm work? [message #220203 is a reply to message #220030] Wed, 26 July 2006 14:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pilgrim.us.ibm.com

Yup, it definitely walks through the code. It will change from manhattan
to manual and vice versa too. I'll look in more depth at the figure used
to construct the sp router. It must be there somewhere since that's
really the difference between my app and the logic example. One
difference between my app and Sebu's post is that my editpart is a
ScalableFreeFormEditPart rather than a ScalableRootEditPart I notice.
Could that be not applicable to the shortest path router, its extra layer
for zooming be causing a problem? I'll check but I believe that to be the
same part in the logic example.

Thanks for the tips, will post back with what I find.
Re: How does ShortestPath routing algorithm work? [message #222045 is a reply to message #219797] Thu, 24 August 2006 15:37 Go to previous message
Eclipse UserFriend
Originally posted by: pilgrim.us.ibm.com

Still a concern... The preferred size of my editparts are 40x40.
Depending on how many editparts are on the canvas, their relative
placement, and how many connections exist, I do indeed see that some of
the connecting lines are segmented and drawn around the editpart's figure.
However, there are also lines which cross it. That doesn't seem to be
the case with the logic example - never see the lines cross the gates
there when the shortest path routing option is used. I've tried various
values of the router spacing including values of 5, 10, 60, and 120. The
first line between the parts always crosses. Could this be because of the
size of the figures, inherent to the routing algorithm?
Previous Topic:Selecting anchors (based on logic example)
Next Topic:Placing Decorations
Goto Forum:
  


Current Time: Wed Feb 05 16:01:35 GMT 2025

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

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

Back to the top