Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Temporarily Highlight Links and text in associated Nodes (Read 5328 times)
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Temporarily Highlight Links and text in associated Nodes
Mar 7th, 2016 at 1:28pm
Print Post  
I need to highlight a link, and some of the text in the ShapeNode I am using to label the link. Ideally this highlight should be highly visible, but temporary - not being stored, but only changing/disappearing when I deliberately remove/change them. I am currently trying to do this by setting text and lines to RED.

To highlight the link I am using the following code:

Code (Java)
Select All
if( setHighlight )
          {
            Pen pen  = (Pen)diagramLink.getEffectivePen().clone();
            pen.setColor( Color.RED );
            pen.setWidth( 3.0f );
            diagramLink.setHeadPen( pen );
            diagramLink.setPen(pen);
          } 


This doesn't always seem to work as expected. The 'line' of the link, and outline of the arrowhead always get much thicker, but don't always go red. Even when they do go red, the colour disappears after a few moments even though I have done nothing with the application in the meantime. The lines remain thicker.

Am I changing the line colour in the 'correct' way? Why would I loose colour but not thickness when I am setting them together?

I also change the colour of some of the text in the ShapeNode I am using as the label for the link (attached via the subordinate group of the link), and this change in text colour 'reverts' after a few moments too.

I am doing the same thing with my 'normal' Nodes, and am not having any problems with them at all.

Do DiagramLinks and their subordinate Nodes get updated automatically for any reason?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Temporarily Highlight Links and text in associated Nodes
Reply #1 - Mar 7th, 2016 at 1:46pm
Print Post  
Hi,

This code looks correct. There could be some event handler reverting the pen back to black, e.g. from mouse-related event or a timer. Try searching for getPen and setPen references in the project, or if you have the component's source code, add breakpoints in getPen and setPen and the call-stack will show where they are called from.

There's another possibility, if this does not work only for selected links or if you use AutoHandles selection, and link's HandlesStyle is set to DashFrame,  you might be seeing black color coming from HandlesVisualStyle.DashPen property.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: Temporarily Highlight Links and text in associated Nodes
Reply #2 - Mar 8th, 2016 at 4:42pm
Print Post  
Thanks for your help - I've found and fixed the cause of the colour disappearing - our code was regularly updating the links for another reason.

However, now the link never turns RED. Looking at the variables via my IDE I can see that the pen has been set to Red (as shown in the attached screen shot) but it always draws a thick black line.

I call repaint() on both Diagram and DiagramView after I set the pen to Red.

If I save to XML then reload the image, the line is both thick and Red, however as this highlighting is supposed to be temporary this is not a solution to my problem.

Is there anything else I should be doing to see the link as Red?
  

penRedButShowsBlack.PNG ( 52 KB | 166 Downloads )
penRedButShowsBlack.PNG
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Temporarily Highlight Links and text in associated Nodes
Reply #3 - Mar 8th, 2016 at 5:32pm
Print Post  
Calling setPen is all you need to do, and if you were seeing red for some links in first post, there's no good reason to never see red after removing the updating code. Maybe check if you aren't custom-drawing the links from drawLink event handler, or changing their color from some other custom-draw events like drawBackground.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Temporarily Highlight Links and text in associated Nodes
Reply #4 - Mar 8th, 2016 at 5:35pm
Print Post  
The screenshot shows that the Pen.Brush property is set to a black brush. Set Brush to null to start using the Color property which is set to Color.RED.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: Temporarily Highlight Links and text in associated Nodes
Reply #5 - Mar 8th, 2016 at 5:48pm
Print Post  
Thanks, that works  Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint