Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic JDiagram 4.0 Multiple Manipulators (Read 4114 times)
Jasef
YaBB Newbies
*
Offline



Posts: 26
Joined: Jul 17th, 2011
JDiagram 4.0 Multiple Manipulators
Feb 3rd, 2013 at 9:42pm
Print Post  
I have a custom object that extends ShapeNode. This object uses two manipulators, both custom made. With the new changes in 4.0, making the coordinate system to be localized has caused these to malfunction. I have figured out what the problem is.

The DiagramNode class contains the following two methods:
Code (Java)
Select All
@Override
Manipulator manipulatorEnacted(Point2D pt)
{
    	if (manipulators == null)
    		return null;
	for (Manipulator manipulator : manipulators)
	{
		if (manipulator.drawsInLocalCoordinates())
			pt = translatePointToLocal(pt);

		if (manipulator.hitTest(pt))
			return manipulator;
	}

	return null;
}

@Override
boolean ptInManipulator(Point2D pt)
{
    	if (manipulators == null)
    		return false;
	for (Manipulator manipulator : manipulators)
	{
		if (manipulator.drawsInLocalCoordinates())
			pt = translatePointToLocal(pt);

		if (manipulator.ptInManipulator(pt))
			return true;
	}

	return false;
} 



The manipulator.drawsInLocalCoordinates() check is overwriting the Point2D pt object multiple times with a newer local coordinate and hence causing the subsequent manipulators tests to fail.

I am currently overriding these methods in my custom object with the following code:
Code (Java)
Select All
@Override
Manipulator manipulatorEnacted(Point2D pt)
{
    	if (manipulators == null)
    		return null;
	for (Manipulator manipulator : manipulators)
	{
		Point2D testPt = pt;
		if (manipulator.drawsInLocalCoordinates())
			testPt = translatePointToLocal(testPt);

		if (manipulator.hitTest(testPt))
			return manipulator;
	}

	return null;
}

@Override
boolean ptInManipulator(Point2D pt)
{
    	if (manipulators == null)
    		return false;
	for (Manipulator manipulator : manipulators)
	{
		Point2D testPt = pt;
		if (manipulator.drawsInLocalCoordinates())
			testPt = translatePointToLocal(testPt);

		if (manipulator.hitTest(testPt))
			return manipulator;
	}

	return false;
} 



I hope this helps!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: JDiagram 4.0 Multiple Manipulators
Reply #1 - Feb 4th, 2013 at 6:47am
Print Post  
Thanks for letting us know Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint