Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) CompositeNode or ContainerNode or .... (Read 14852 times)
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
CompositeNode or ContainerNode or ....
Jan 23rd, 2015 at 3:35pm
Print Post  
We would like to create our nodes, which appear to the user to be a unit, but consist of some text, with an image below and zero or more lines of text below that, as shown in the attached imagefile. The grey boxes show the conceptual make up of the node, which may or may not be visible to the user as actual boxes - ideally we would see at least the outer box. The lower text box, and the overall Node should grow as more text is added to it, but ideally only downwards, not getting wider.

I found you have both CompositeNode and ContainerNode but am not sure which would be best to use for this.

I tried an example with Container node but the empty text is not displayed below the image - as shown in the screenshot jpg. It should look like 'initial view'.

Which would be best to use to get this effect/functionality? Or is there another type of node you would recommend?
  

ExampleNodes2.png ( 6 KB | 154 Downloads )
ExampleNodes2.png
ContainerNode.jpg ( 10 KB | 143 Downloads )
ContainerNode.jpg
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: CompositeNode or ContainerNode or ....
Reply #1 - Jan 23rd, 2015 at 4:19pm
Print Post  
CompositeNode should be good if you don't need users moving the separate parts as actual nodes. Try modifying Tutorial 4 to use only a StackPanel in the layout:

Code
Select All
<SimplePanel>

    <Shape Name="Shape" Shape="Rectangle" />

    <Border Padding="2">

       <StackPanel Orientation="Vertical">
           <Text Name="Title" Font="Arial-6" TextAlignment="Near" />
           <Image Name="Image" />
           <Text Name="Text" Font="Arial-4" TextAlignment="Near" />
       </StackPanel>

    </Border>

</SimplePanel>
 



and removing references to the deleted FullName text component from the Java code. You should be able to implement multiple lines by appending them with /r/n to second text component.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: CompositeNode or ContainerNode or ....
Reply #2 - Jan 26th, 2015 at 11:50am
Print Post  
Thanks, that gives me exactly what I wanted.

It would be even better if I could set it 'transparent' so any background image set on the diagram would show through.
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: CompositeNode or ContainerNode or ....
Reply #3 - Jan 26th, 2015 at 4:02pm
Print Post  
Your suggested changes to tutorial4 work brilliantly except:

If I change the image to a smaller one, and resize the CompositeNode the individual items within the CompositeNode are rearranged so that the image ends up over the title text (if that goes on to a second line) and looses the 'space' around it. See attached before (BeforeMoveOrResize.jpg) and after (badRearrangeOnStretch.jpg) images. Is there any way to prevent this?

Also is there any way to cause the CompositeNode to resize itself so all the text is always visible - even if more text is added by the user?
  

BeforeMoveOrResize.JPG ( 16 KB | 156 Downloads )
BeforeMoveOrResize.JPG
badRearrangeOnStretch.JPG ( 17 KB | 151 Downloads )
badRearrangeOnStretch.JPG
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: CompositeNode or ContainerNode or ....
Reply #4 - Jan 26th, 2015 at 7:00pm
Print Post  
Quote:
It would be even better if I could set it 'transparent' so any background image set on the diagram would show through.


You could either remove the Shape component from the node's template, which would also hide the border, or set its Brush property to a transparent color:

// in OrgChartNode constructor
setFill(new SolidBrush(new Color(0, 0, 0, 0)));

Quote:
Also is there any way to cause the CompositeNode to resize itself so all the text is always visible - even if more text is added by the user?


After changing text you could calculate new height for the node by summing the heights returned by getDesiredSize() method of components (title + image + text) and assigning it back to node's Bounds.

Quote:
If I change the image to a smaller one, and resize the CompositeNode the individual items within the CompositeNode are rearranged so that the image ends up over the title text (if that goes on to a second line) and looses the 'space' around it.


TextComonent.getDesiredSize() did not consider width limits, returning size for non-wrapped single line of text; this build should fix it:
https://mindfusion.eu/_beta/jdiag.4.1.2.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: CompositeNode or ContainerNode or ....
Reply #5 - Jan 27th, 2015 at 12:09pm
Print Post  
Quote:
you could calculate new height for the node by summing the heights returned by getDesiredSize() method of components (title + image + text) and assigning it back to node's Bounds.


I can't work out how to call the getDesiredSize() method - where do I get the values that must be passed in from??
(The documentation supplied with the trial download does not include any JavaDoc for the Component types and the chm file never displays anything except an index on the left for me)

Quote:
TextComonent.getDesiredSize() did not consider width limits, returning size for non-wrapped single line of text; this build should fix it:
https://mindfusion.eu/_beta/jdiag.4.1.2.zip


This site is blocked as 'malware' for me - don't you just love big corporations!!

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: CompositeNode or ContainerNode or ....
Reply #6 - Jan 27th, 2015 at 1:55pm
Print Post  
What malware-blocking tool are you using? Can you download the new jar from this link instead?
https://mindfusion.eu/jdiag.4.1.2.zip

As for help file, click the Unblock button if there's one in its Properties window shown from Windows Explorer's context menu / Properties command.
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: CompositeNode or ContainerNode or ....
Reply #7 - Jan 27th, 2015 at 2:31pm
Print Post  
No that link doesn't work either - says site has been explicitly blocked by corporation - but your trial download from www.mindfusion.eu (rather than just mindfusion.eu) is fine.

Can't see any 'unblock' or similar button on the properties of the chm file - can open other chm files from both Microsoft and other suppliers - your chm file is the only one I can't see data in, and also the only one which brings up a safety warning ('unknown publisher') when I open it.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: CompositeNode or ContainerNode or ....
Reply #8 - Jan 27th, 2015 at 4:06pm
Print Post  
The www. domain maps to the same site, so you should be able to download from https://www.mindfusion.eu/_beta/jdiag.4.1.2.zip ?
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: CompositeNode or ContainerNode or ....
Reply #9 - Jan 27th, 2015 at 5:37pm
Print Post  
This is very frustrating - that link is also blocked (also tried without the /_beta and that was blocked too). Almost looks as if the Trial zip file download has been specifically 'unblocked' Exclaim
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: CompositeNode or ContainerNode or ....
Reply #10 - Feb 4th, 2015 at 12:57pm
Print Post  
We have released version 4.1.2 with getDesiredSize fix included, you should be able to download the trial.zip from our main site if it's specifically unblocked.

Quote:
I can't work out how to call the getDesiredSize() method - where do I get the values that must be passed in from??


You will need to pass a Graphics instance with appropriate scale transform applied to let ImageComponent convert from pixels to diagram.MeasureUnit. Assuming your node type has same components as OrgChartNode example:

Code
Select All
// in node class
public void resizeToFitText(Graphics2D g)
{
	Rectangle2D.Float r = this.getBounds();
	XDimension2D.Double availableSize = new XDimension2D.Double(r.width, r.height);

	XDimension2D.Double titleSize = title.getDesiredSize(availableSize, g);
	XDimension2D.Double imageSize = image.getDesiredSize(availableSize, g);
	XDimension2D.Double textSize = text.getDesiredSize(availableSize, g);

	float margin = 4;
	this.resize(r.width,
		(float) (titleSize.height + imageSize.height + textSize.height + margin));
}

// in frame class
public void nodeClicked(NodeEvent e)
{
	if (e.getNode() instanceof OrgChartNode)
	{
		Graphics2D g = (Graphics2D) diagramView.getGraphics();
		double unitScale = MeasureUnit.Millimeter.convert(1, MeasureUnit.Pixel, diagramView);
		g.scale(unitScale, unitScale);

		OrgChartNode orgNode = (OrgChartNode)e.getNode();
		orgNode.resizeToFitText(g);
	}
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: CompositeNode or ContainerNode or ....
Reply #11 - Feb 19th, 2015 at 2:32pm
Print Post  
Unfortunately when trying to add this functionality today I had the following problems:

1. Not sure which XDimension2D to use, the one in com.mindfusion.diagramming or the one in com.mindfusion.diagramming.jlayout (assumed the first but tried both)

2. XDimension2D.Double was not found on either of them.

Do I need that download mentioned earlier in this post which I have been unable to access?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: CompositeNode or ContainerNode or ....
Reply #12 - Feb 19th, 2015 at 3:19pm
Print Post  
The one from the first namespace, I have this import in my test node and the code above compiles fine:

import com.mindfusion.diagramming.XDimension2D;

Quote:
Do I need that download mentioned earlier in this post which I have been unable to access?


That download only contained a fix for getDesiredSize to consider width constraints. It should not affect XDimension2D.Double visibility. Anyway the fix is now available in official release here, which you had access to earlier?

https://www.mindfusion.eu/JDiagramTrial.zip
  
Back to top
 
IP Logged
 
AR
Junior Member
**
Offline


I Love MindFusion!

Posts: 65
Joined: Jan 23rd, 2015
Re: CompositeNode or ContainerNode or ....
Reply #13 - Feb 20th, 2015 at 11:21am
Print Post  
Downloaded and installed the new JDiagram trial - still not finding the XDimension2D.Double (Although I can see it if I open the Jar file in WinZip)

Tried removing the JDiagram jar from dependancies in my IDE and then re-adding it - still doesn't work.

So I wrote a tiny test program (in the directory containing the JDiagram.jar file):

Code
Select All
import com.mindfusion.diagramming.*;
import java.util.*;
import java.awt.geom.Rectangle2D;

public class jarTest
{
	public static void main( String[] args )
	{
		System.out.println("main has started");
		Diagram dia = new Diagram(); // no error on this, so JDiagram jar & contents found ok
		Rectangle2D rect = new Rectangle2D.Double();
		XDimension2D.Double d = XDimension2D.fromRect( rect );
		System.out.println( "d is " + d.toString());
	}
} 



and tried compiling from the command line (to rule out IDE problems), with the following result:

Quote:
C:\Dev\JDiagramTrial>"C:\Program Files (x86)\Java\jdk1.7.0_21\bin\javac" -cp $CLASSPATH;JDiagram.jar jarTest.java
jarTest.java:12: error: cannot find symbol
XDimension2D.Double d = XDimension2D.fromRect( rect );
^
symbol: class Double
location: class XDimension2D
1 error
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: CompositeNode or ContainerNode or ....
Reply #14 - Feb 20th, 2015 at 12:44pm
Print Post  
Ok, I've changed the Build Path settings in Eclipse to use external jar instead of project and it stopped compiling for me too.

Using the Change Type fix from error popup changes the declaration to XDimension2D$Double, which works, so I suppose the obfuscator we use cannot handle nested types correctly Sad Since the type inherits from Dimension2D, you can avoid the ugly name when using fromRect instead of constructor:

Code
Select All
Dimension2D d = XDimension2D.fromRect(rect);
//Dimension2D d = new XDimension2D$Double(...); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint