Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic link.getPen() vs link.getEffectivePen()?? (Read 3750 times)
RickSalut
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Location: CANADA
Joined: Dec 10th, 2014
link.getPen() vs link.getEffectivePen()??
Jul 24th, 2015 at 4:30pm
Print Post  
Hi,

I'm trying to figure out what is the difference between DiagramLink methods getPen() and getEffectivePen().

Actually, I'm facing a problem where I'm trying to change a link width but keeping its color and style, and when I use getPen() to do so, it returns null and this is not what I'm expecting...

Could anyone tell me the differences between these two methods, and/or letting me know how I could solve my problem.

Here is an example to help you understand my problem.
link.setPen(new Pen(link.getPen().getWidth()+1, link.getPen().getColor(), link.getPen().getDashStyle()));

In my case getPen() returns null, and getEffectivePen() has some bad side effects (changes link colors when I select a node or scroll down my diagram).

Thank's in advance.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: link.getPen() vs link.getEffectivePen()??
Reply #1 - Jul 24th, 2015 at 5:09pm
Print Post  
Hi,

The control uses a styling system where pens and brushes could be specified by a global theme, item's style or a property. getEffectivePen returns the Pen instance that should be used for drawing, first probing for the local Pen property defined via setPen/getPen. If its value is null as by default, it looks for pen attributes in styles (DiagramItem.setStyle/getStyle) and diagram's theme. You could clone Pen from EffectivePen when you need to change thickness, and set it back to null to display the theme's pen again.

Code
Select All
Pen pen = (Pen)link.getEffectivePen().clone();
pen.setWidth(pen.getWidth() + 1);
link.setPen(pen); // now getEffectivePen returns this one

// later...
link.setPen(null); // getEffectivePen returns default pen from theme 



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


I Love MindFusion!

Posts: 10
Location: CANADA
Joined: Dec 10th, 2014
Re: link.getPen() vs link.getEffectivePen()??
Reply #2 - Jul 24th, 2015 at 5:24pm
Print Post  
Thank's a lot for the quick reply.  It did solve my problem.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint