Page Index Toggle Pages: [1] 2  Send TopicPrint
Very Hot Topic (More than 25 Replies) Arrow routing and creating straight lines (Read 14287 times)
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Arrow routing and creating straight lines
Mar 19th, 2008 at 5:01am
Print Post  
Hi,

When using the applet version, the line routing is painful sometimes. It is very hard to draw a straight line between two symbols. I have attached a sample:

[code]
public class Goop extends JApplet {
private static final long serialVersionUID = 1L;

private FlowChart flowChart;

@Override
public void init() {
super.init();

initialize();
// testArrow2();
// testContainment();
//routeTest();
}

private void initialize() {
flowChart = new FlowChart();
JScrollPane pane = new JScrollPane(flowChart);
this.getContentPane().add(pane);

flowChart.setSelectionOnTop(false);

flowChart.setArrowStyle(ArrowStyle.Cascading);
flowChart.setRouteArrows(true);
flowChart.getRoutingOptions().setTriggerRerouting(
RerouteArrows.WhileCreating | RerouteArrows.WhenModified);

float gridSize = flowChart.getRoutingOptions().getGridSize();
float nvs = flowChart.getRoutingOptions().getNodeVicinitySize();

// flowChart.setMeasureUnit(GraphicsUnit.Pixel);
flowChart.getRoutingOptions().setStartOrientation(Orientation.Auto);
flowChart.getRoutingOptions().setEndOrientation(Orientation.Auto);
flowChart.getRoutingOptions().setAnchoring(Anchoring.Ignore);
flowChart.getRoutingOptions().setTriggerRerouting(RerouteArrows.WhileCreating | RerouteArrows.WhenModified);
flowChart.getRoutingOptions().setDefaultMode();


flowChart.getRoutingOptions().setGridSize(gridSize * Toolkit.getDefaultToolkit().getScreenResolution() / 72);
flowChart.getRoutingOptions().setNodeVicinitySize(nvs * Toolkit.getDefaultToolkit().getScreenResolution() / 72);

TextFormat textFormat = new TextFormat(Align.Center, Align.Near);
textFormat.setWrapAtCharacter(true);
flowChart.setTextFormat(textFormat);
}
}
[/code]

When I draw two boxes that are horizontally aligned, and try to draw an arrow between them, the arrow turns into something like a spoon and the origin of the arrow is always at the vertical center of the first box.
So, it is very hard to draw a straight line (especially one which is not at the center of the vertical side).

Also, the arrow head turns up and down automatically, even when I am drawing the line horizontally.

Is there some way I can change the routing to do this, or is this something you can modify?

The whole point is, it should be easy to draw straight lines.

Thanks,
Praveen
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrow routing and creating straight lines
Reply #1 - Mar 19th, 2008 at 10:09am
Print Post  
We'll add an option to run the routing function for links only when they intersect a node.

Stoyan
  
Back to top
 
IP Logged
 
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Arrow routing and creating straight lines
Reply #2 - Mar 21st, 2008 at 2:02am
Print Post  
Hi,

Can you please tell me if you can provide us this feature anytime soon? We have some users who find not being able to draw straight lines very annoying to the point of not using the tool.

Any help will be greatly appreciated.

Thanks,
Praveen
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrow routing and creating straight lines
Reply #3 - Mar 21st, 2008 at 10:31am
Print Post  
Hi,

You can implement that by calling the route() method in response to the itemModified and itemCreated events instead of using auto-routing. Route arrows only when you detect that they intersect some node. The boolean intersects(Node node) method of the Arrow class should help.

Stoyan
  
Back to top
 
IP Logged
 
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Arrow routing and creating straight lines
Reply #4 - Mar 22nd, 2008 at 8:32am
Print Post  
Hi Stoyan,

Here is a simplified code:

[code]
private void initialize() {
flowChart = new FlowChart();
JScrollPane pane = new JScrollPane(flowChart);
this.getContentPane().add(pane);

flowChart.setArrowStyle(ArrowStyle.Cascading);
flowChart.addFlowChartListener(new FlowChartAdapter(){
@Override
public void itemCreated(ItemEvent e) {
if (e.getItem() instanceof Arrow){
((Arrow)e.getItem()).route();
}
super.itemCreated(e);
}
});
}

[/code]

Now the above doesn't work for me, because
1. When the user starts drawing the arrow, he cannot find out where the arrow will be created when he releases the mouse (generally, the arrow gets created at the center of the side of the box).

2. The user cannot create arrows from where he draws them, so me cannot create arrows like these (the arrows automatically move to the center):

_                      ____
  |-------------->|
  |                    |
  |                    |
--                     -----

3. Calling route will again add few more segments to the arrow when in the orthogonal mode.

I would like to have something where user can draw like in the above figure, during creation of the arrow.
Is there some way this can be done?

Thanks,
Praveen
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrow routing and creating straight lines
Reply #5 - Mar 23rd, 2008 at 8:55am
Print Post  
Hi Praveen,

Can't you do that by adding a few anchor points to each side of the boxes? Then users will be able to draw links between the points they choose. Otherwise, we could modify the SnapToNodeBorders behavior to make it work while drawing new links.

Stoyan
  
Back to top
 
IP Logged
 
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Arrow routing and creating straight lines
Reply #6 - Mar 23rd, 2008 at 9:03am
Print Post  
Hi Stoyan,

I cannot include anchor points as of now, because the Flowchart I am using gets data from another drawing tool, with similar box and line arrangement. THe other tool doesn't have restrictions on where the line can be connected. Without any anchor-points, Mindfusion's arrows also can behave exactly like the other tool. With anchor points, the lines can start to look a little different. Also, maintaining it with more and more shapes coming in could become tricky.

What did you mean by "modifying the SnapToNodeBorders" feature?

Thanks,
Praveen
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrow routing and creating straight lines
Reply #7 - Mar 24th, 2008 at 7:59am
Print Post  
Hi,

SnapToNodeBorders is applied only when modifying arrows. It lets users align the arrow end to any point on the shape border. Check how that works - if you think it will help in your case, we can make it work also when drawing new arrows.

Stoyan
  
Back to top
 
IP Logged
 
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Arrow routing and creating straight lines
Reply #8 - Mar 24th, 2008 at 8:13am
Print Post  
Hi Stoyan,

With the first code I posted ( the bigger one) SnapToNodeBorder seems to be working during the line creation itself. The line doesn't seem to originate from somewhere inside the box, but from the border.

I would like to be able to draw a line as in the image I showed up there, on the first attempt. What I see now is that the origin of the arrow has a tendency to move towards the center of the border where it originates as I drag the arrow to the right. This makes the arrow connect to the destination in a step like manner. If the origin doesn't move, the arrow can get connect as a straight line.

Also, I see in the code that there is an attempt at having at least two segments when the style is cascading. Will this cause a problem when trying to draw a straight line between symbols?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrow routing and creating straight lines
Reply #9 - Mar 24th, 2008 at 3:23pm
Print Post  
There is some difference. SnapToNodeBorders lets you put the arrow end anywhere on the node border during modification. However it is not considered when creating a new arrow, and then the default is to place the arrow end points on the line that connects the node centers. So we'll change our code to apply the SnapToBorders behavior also when creating new arrows.

Stoyan
  
Back to top
 
IP Logged
 
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Arrow routing and creating straight lines
Reply #10 - Mar 24th, 2008 at 3:33pm
Print Post  
Hi Stoyan,

Thank You!

So, what I understand is that with the property set during creation, the origin of the arrow will not move. So, user can draw a one segment line in orthogonal mode. Is my assumption correct?

I am sorry to be so pushy, but can you tell me when you might be able to provide this?

Thanks,
Praveen
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrow routing and creating straight lines
Reply #11 - Mar 25th, 2008 at 8:09am
Print Post  
Hi Praveen,

We are just releasing new versions of most of our controls and can't do that right now. We'll have a developer available to work on it in 7-8 days.

Stoyan
  
Back to top
 
IP Logged
 
rachis
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 18
Joined: May 14th, 2007
Re: Arrow routing and creating straight lines
Reply #12 - Apr 1st, 2008 at 12:53pm
Print Post  
Hi Stoyon,

Hopefully you might have started working on this issue that is critical to us just now. I might be more than willing to provide you with any other inputs if you need more information.

Thanks,
Rachna
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrow routing and creating straight lines
Reply #13 - Apr 2nd, 2008 at 10:06am
Print Post  
To let the user draw an arrow between arbitrary points of the node outlines:

* find the Arrow.startCreate source code, comment out the "org = (Point2D) org.clone();" line, and add "org = orgNode.getNearestOutlinePt(org);" below it.

* find Arrow.completeCreate(), comment out "end = (Point2D) end.clone();", and add the following:

ptEnd = obj.getNearestOutlinePt(end);
end = (Point2D) ptEnd.clone();

and also comment out the "setEndPoints(orgnLink, destLink, end);" line.

We'll add some properties to enable / disable this later.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrow routing and creating straight lines
Reply #14 - Apr 2nd, 2008 at 10:11am
Print Post  
To prevent the arrow routing function from running when not needed, enable the RerouteArrows.WhenIntersectNode flag in RoutingOptions, and add an "if (flowChart.rerouteArrow(this))" statement before calling doRoute() at the end of Arrow.completeCreate().
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint