Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Change the appearance of a onclicked Node (Read 3323 times)
zhang
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: May 28th, 2014
Change the appearance of a onclicked Node
Jun 18th, 2014 at 1:36pm
Print Post  
hello, with the following code can I realize the effect of the picture I sent.My question is, wenn I click on Node(T002), the Color of the Node(T002) will be red, but which nodes I clicked before(V005,V004) is still  remain red. What I want is, wenn I click a Node, it's color will be red, and meanwhile the other clicked nodes' color will return to be it's original color . In other word, always there is only one red node.
Could you tell how can I fix this problem? thank you indeed.

diagram2.addDiagramListener(new DiagramAdapter() {
        public void nodeClicked(NodeEvent e)
        {   
            
              Pen dashedPen2 = new Pen(0.8f, Color.RED,DashStyle.Solid);
              e.getNode().setPen(dashedPen2);
              Toast.makeText(getApplicationContext(), e.getNode().getId().toString(), Toast.LENGTH_SHORT).show();
        }
      });
  

2014-06-18_14-39-49.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Change the appearance of a onclicked Node
Reply #1 - Jun 18th, 2014 at 1:55pm
Print Post  
Hi,
Keep a redNode field in your activity and reset its color to black before setting the new red node:

Code
Select All
DiagramNode redNode;

diagram2.addDiagramListener(new DiagramAdapter() {
         public void nodeClicked(NodeEvent e)
         {

               if (redNode != null)
                   redNode.setPen(null);
               Pen dashedPen2 = new Pen(0.8f, Color.RED,DashStyle.Solid);
               redNode = e.getNode();
               redNode.setPen(dashedPen2);
               Toast.makeText(getApplicationContext(), e.getNode().getId().toString(), Toast.LENGTH_SHORT).show();
         }
       }); 



or alternatively just loop over all nodes in diagram.getNodes() list to reset their pen before setting new red node.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
zhang
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 14
Joined: May 28th, 2014
Re: Change the appearance of a onclicked Node
Reply #2 - Jun 18th, 2014 at 3:06pm
Print Post  
very very very helpful!!!  Grin Grin Grin
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint