Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Modify item on ItemModifying Event (Read 2493 times)
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Modify item on ItemModifying Event
Jul 31st, 2007 at 12:36am
Print Post  
Hi,

1. I wanted to relocate an item programatically as it was being dragged. So I tried some code like this:

private void TestItemModify() {
flowChart = new FlowChart();
this.getContentPane().add(flowChart);

Box test = new Box(flowChart);
test.setBounds(new Rectangle2D.Float(10, 10, 20, 20));
flowChart.add(test);

flowChart.addFlowChartListener(new FlowChartAdapter() {
@Override
public void itemModifying(ValidationEvent e) {
if (e.getSelectionHandle() == 8) {
((Box)e.getItem()).setBounds(new Rectangle2D.Float(50, 50, 130, 130));
}
}
});
}

(I changed the size just for the emphasis), but it looks like programmatically modifying an item during a modifying event is not possible. Is there some way around this? Or, should I just handle mouse drag and do something there?

2. Also, the selection handle from the validation event is not from the Handles constants. Should I be writing 8 for MoveHandle or is there some const field I can use?


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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Modify item on ItemModifying Event
Reply #1 - Jul 31st, 2007 at 5:47am
Print Post  
Hi,

You can't change the item position from that event. It is raised just before the control places the item where it decides according to the current mouse position. We can add some new member to the ValidationEvent class to let you set your a new position for the dragged item.

The selection handle is an integer, because the same event is raised for arrows. You could use the following constants for node handles:

TopLeft = 0;
TopRight = 1;
BottomRight = 2;
BottomLeft = 3;
TopMiddle = 4;
RightMiddle = 5;
BottomMiddle = 6;
LeftMiddle = 7;
Move = 8;
Rotate = 9;

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