Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Autonumber, or display the tags (Read 2160 times)
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Autonumber, or display the tags
Jul 22nd, 2011 at 10:50am
Print Post  
I would like to autonumber the shapes that are being added to the diagram (using the java applet).

So, for example, I would like the first shape to be 1, and its children to be 1.1, 1.2, 1.3, and their children to be 1.1.1, 1.1.2, 1.2.1, etc.

I am trying to get this numbering sorted and saved in the Tag property. I was just wondering whether there is an easy way to display this Tag property. I would like it displayed in the upper left corner, outside the shape.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Autonumber, or display the tags
Reply #1 - Jul 22nd, 2011 at 12:54pm
Print Post  
You could set the node's CustomDraw property to Additional and set this function as DrawNodeScript:

Code
Select All
function onDrawNode(sender, args)
{
	var applet = <%= diagramView.AppletElement %>;
	var diagram = applet.getDiagram();
	var helper = applet.getScriptHelper();

	var node = args.getNode();
	var gfx = args.getGraphics();
	var rect = node.getBounds();
	var black = helper.createSolidBrush(0,0,0);
	var format = helper.createTextFormat(0,0,false,false);

	diagram.drawString(node.getTag(), gfx, node.getFont(), black, rect, format);
}
 



I'm not sure how fast it will be to draw from JavaScript though. You might be better of using attached nodes to display the Tag value of other nodes. If you set Transparent = true for the attached nodes, only their text remains visible.

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


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: Autonumber, or display the tags
Reply #2 - Aug 1st, 2011 at 1:05pm
Print Post  
Hi stoyo,

would creating a transparent shape work, even when I have a Tree Layout?

For example, I am trying to use the following code which doesnt do what I am looking for.

Also, would the transparent shape have the correct layout when I add more shapes - i.e. will the shape move along with its relevant node?

Code
Select All
	  function addNodeLabel(node, text) {
		var label = diagram.getFactory().createShapeNode(node.getBounds().getX(),
				node.getBounds().getY(),
				node.getBounds().getWidth(),
				4);
		label.setBrush(script.createSolidBrush(0, 0, 0));
		label.setText('This is a test');

		var group = node.getSubordinateGroup();
		if (group == null) {
		alert('creating group');
		    group = diagram.getFactory().createGroup(node);
		}
		group.attachToCorner(label, 3);
	  }

 

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Autonumber, or display the tags
Reply #3 - Aug 1st, 2011 at 1:55pm
Print Post  
I've modified your code to attach a transparent 'label' at the top of the specified node, lock the label and set its IgnoreLayout to false to ensure that the label won't be modified by subsequent automatic layouts and that it will retain its position relative to its master node.

Code
Select All
var label = diagram.getFactory().createShapeNode(
      node.getBounds().getX(),
      node.getBounds().getY() - 4,
      node.getBounds().getWidth(),
      4);
label.setTransparent(true);
label.setText(text);
label.setIgnoreLayout(true);
label.setLocked(true);

var group = node.getSubordinateGroup();
if (group == null)
      group = diagram.getFactory().createGroup(node);
group.attachToCorner(label, 0); 


I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint