Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Attached Boxes and arrow routing (Read 6508 times)
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Attached Boxes and arrow routing
Oct 17th, 2007 at 5:02am
Print Post  
Hi,

I have two boxes on the flowchart that are attached to another bigger box.

I have set the autoroute on the flowchart to true. and routingoption to during create and modify.

Also, the create lines orthogonally property is set.

So, when I run  the application, the applet comes up with these three boxes.

Now I drag a line to connect the two smaller boxes. There should be at least 3 control points created.

Now, if I move the bigger box, the smaller boxes also move with him, but the arrow position is not retained.

Once I release the mouse after repositioning, the arrow is redrawn.

Is there a way I can make the arrow retain state during the drag of the master box?

Code
Select All
private void initialize() {
flowChart.setSelectionOnTop(false);

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

private void routeTest() {
flowChart = new FlowChart();
initialize();

this.getContentPane().add(flowChart);

Box one = new Box(flowChart);
one.setBounds(5, 5, 10, 10);

Box two = new Box(flowChart);
two.setBounds(20, 20, 10, 10);

Box three = new Box(flowChart);
three.setBounds(2, 2, 50, 50);

flowChart.add(three);
flowChart.add(two);
flowChart.add(one);

one.attachTo(three, AttachToNode.TopCenter);
two.attachTo(three, AttachToNode.TopCenter);
}

private FlowChart flowChart;

 



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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Attached Boxes and arrow routing
Reply #1 - Oct 18th, 2007 at 8:43am
Print Post  
Hi,

That's a bug. You can fix it by adding the following to the end of the Group.mustTranslateArrow() method, before the final return false:

Code
Select All
	if (arrow.getOrigin().getModifying() &&
		arrow.getDestination().getModifying())
		return true;
 



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


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Attached Boxes and arrow routing
Reply #2 - Nov 29th, 2007 at 1:10am
Print Post  
Hi Stoyan,

There is another problem I see with this. If I add this line in the initialize method, to go into the pixel mode:
[code]
flowChart.setMeasureUnit(GraphicsUnit.Pixel);

[/code]

I see that everytime I move the outer containing box, the arrows change their routing. Can this be avoided somehow?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Attached Boxes and arrow routing
Reply #3 - Nov 29th, 2007 at 7:16am
Print Post  
Hi Praveen,

Actually the control resets the routing-options properties to some defaults when you change the measure unit. You will need to set them back to your values, scaled for the appropriate unit, after calling setMeasureUnit.

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


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Attached Boxes and arrow routing
Reply #4 - Nov 29th, 2007 at 7:35am
Print Post  
Hi,

I do not frequently change the MeasureUnit. I always use Pixels.

Are there some standard routing-options for Pixels that will make it work like inches to?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Attached Boxes and arrow routing
Reply #5 - Nov 29th, 2007 at 10:49am
Print Post  
Hi,

There are a few routing properties affected by the unit, e.g. GridSize and NodeVicinitySize. You could multiply the values you are using with inches by the Pixel value from the Constants.unitsPerInch array. Then the routing algorithm, when used with pixels, should behave the same as it did with inches.

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


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Attached Boxes and arrow routing
Reply #6 - Jan 31st, 2008 at 4:34am
Print Post  
Hi Stoyan,

I tried the following code

[code]
float gridSize = this.getRoutingOptions().getGridSize();
float nvs = this.getRoutingOptions().getNodeVicinitySize();

this.setMeasureUnit(GraphicsUnit.Pixel);

this.getRoutingOptions().setGridSize(gridSize * Toolkit.getDefaultToolkit().getScreenResolution());
this.getRoutingOptions().setNodeVicinitySize(nvs * Toolkit.getDefaultToolkit().getScreenResolution());

[/code]

and it does't work, actually makes it a lot worse.
Or, I guess I didn't understand what you were saying down there correctly. Should I be trying something else?

Thanks,
Praveen
  
Back to top
 
IP Logged
 
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Attached Boxes and arrow routing
Reply #7 - Feb 21st, 2008 at 6:59am
Print Post  
Hi Stoyan,

Do you have any workaround for this? I was just checking again because you haven't replied for long.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Attached Boxes and arrow routing
Reply #8 - Feb 22nd, 2008 at 4:04pm
Print Post  
Hi Praveen,

That code converts from inches to pixels, while the default unit is points, so you probably need point-to-pixel conversion? To get that, divide the result from the above code by 72.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Attached Boxes and arrow routing
Reply #9 - Feb 29th, 2008 at 1:05am
Print Post  
Hi Stoyan,

I tried the following (dividing by 72):

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

[/code]

Now the lines come up alright, but again, when I move the container, the arrows re-route. Should I be doing it some other way then?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Attached Boxes and arrow routing
Reply #10 - Feb 29th, 2008 at 11:47am
Print Post  
Hi,

Do not enable the AutoRoute property if you need the arrows to be routed only once, but call the Route() method just after creating an arrow.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint