Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Attached boxes - arrows routing problem (Read 2677 times)
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Attached boxes - arrows routing problem
Jan 7th, 2008 at 1:51pm
Print Post  
Hi,
I have a program where I have a box "a" attached to another "b" and an arrow connecting them. "b" can be resized programatically at different intervals. When this happens, the arrow sometimes is left dangling, not connected to "b". Even calling arrow.route() doesn't fix the problem.

If the box "a" is not attached to "b", it works fine.

Below is a code sample to highlight the problem.

[code]

private FlowChart flowChart;

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

initialize();
testArrow2();
}

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);

flowChart.setMeasureUnit(GraphicsUnit.Pixel);

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

Box two;

private void testArrow2() {
Box one = new Box(flowChart);
one.setBounds(new Rectangle2D.Float(10, 10, 100, 100));

two = new Box(flowChart);
two.setBounds(new Rectangle2D.Float(10, 160, 500, 100));

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

one.attachTo(two, AttachToNode.TopRight);

flowChart.addFlowChartListener(new FlowChartAdapter() {

@Override
public void itemSelected(ItemEvent e) {
resizeTwo();
}
});

Arrow con = new Arrow(flowChart, one, two);
flowChart.add(con);
}

public void resizeTwo() {
two.setBounds(400, 160, 100, 100);
}

[/code]

1. When the applet loads, you will see that there are two boxes, a small and a large.

2. Now click the small box - the code handles the event and resizes the bottom large box.

You will see that the arrow head is now dangling, not connected to the bottom box.

Remove the line:
[code]
one.attachTo(two, AttachToNode.TopRight);
[/code]
from the example, and run it again. You will see that the arrow is now connected properly.

Can I get around this problem somehow?

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


Java Happens

Posts: 136
Joined: May 13th, 2007
Re: Attached boxes - arrows routing problem
Reply #1 - Jan 10th, 2008 at 6:47am
Print Post  
Hi,

This was kind of urgent for me, so if you have some idea, that will be really helpful.

If you tell me it is going to take long, maybe I will start looking at ways around this.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Attached boxes - arrows routing problem
Reply #2 - Jan 10th, 2008 at 7:22am
Print Post  
Hi,

Our developer is looking into this right now. I will post here the fix or workaround when he finds out what happens.

Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Attached boxes - arrows routing problem
Reply #3 - Jan 11th, 2008 at 7:52am
Print Post  
Hi,

Find the "void setRect(Rectangle2D rc)" method in Node.java and there replace

Code
Select All
visitArrows(
	new MethodCallVisitor(AV_UpdPosOutgoing),
	new MethodCallVisitor(AV_UpdPosIncoming),
	getExcludedArrows());
 



with

Code
Select All
// do a simple translation of arrow points when the node is only moved
boolean translateArrowPoints =
	rcOld.getWidth() == bounds.getWidth() &&
	rcOld.getHeight() == bounds.getHeight();

// this clears the arrows selected for translation by beginModification
if (!translateArrowPoints)
	subordinateGroup.getArrowsToMove().clear();

// update the point positions of arrows that are not handled through simple translation
visitArrows(
	new MethodCallVisitor(AV_UpdPosOutgoing),
	new MethodCallVisitor(AV_UpdPosIncoming),
	translateArrowPoints ? getExcludedArrows() : null);
 



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 - arrows routing problem
Reply #4 - Jan 11th, 2008 at 11:06am
Print Post  
Works, and right in time, thanks.

Praveen
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint