Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Javascript Library and classes [SOLVED] (Read 5796 times)
henry k
Junior Member
**
Offline


I Love MindFusion!

Posts: 51
Location: Finland
Joined: Apr 4th, 2012
Javascript Library and classes [SOLVED]
Apr 4th, 2012 at 6:09am
Print Post  
Hi,

I hope I posted this question to correct section of this forum...

I'm evaluating your diagram product for ASP.NET. Though my question is related to javascript.

I'm little confused while using your javascript methods.

I'm trying to create a node to diagramView when [ClickedScript] is fired and within it is set its text alignment, which fails. This is one of your samples:
Code (Javascript)
Select All
function canvas_Clicked(sender, e) {
var palette = <%= diagramView_palette.AppletElement %>.getDiagram();
var canvas = <%= diagramView_canvas.AppletElement %>.getDiagram();

if (prototypeNode == null)
    prototypeNode = palette.getNodes().get(0);

var node = canvas.getFactory().createShapeNode(x - 24, y - 24, 40, 50);
node.setShape(node.getShape().fromId("RoundRect"));
node.setImage(prototypeNode.getImage());
node.setTransparent(true);
node.setEnabledHandles(MindFusion.Diagramming.Handles.Move);
node.setHandlesStyle(MindFusion.Diagramming.HandlesStyle.MoveOnly);
node.setImageAlign(MindFusion.Diagramming.ImageAlign.TopCenter);

// this one fails (this one is not in any of your samples; just found on the internet):
node.SetTextAlignment(MindFusion.Diagramming.SetText(MindFusion.Diagramming.Align.Center, MindFusion.Diagramming.Align.Far));

node.setText("node " + sender.getNodes().size()); // NOTE: [size] is [count] of nodes in canvas...
}
 



One good reason could be that the [MindFusion.Diagramming] class doesn't include "Align" nor "SetText" methods. I checked and confirmed that the class includes all others above, but nether one of these.

Then I found out that [Packages.com.mindfusion.diagramming] class includes these and more.
But [node.SetTextAlignment] method doesn't understand these 'values'.


So long question in short. How to set in javascript, created node(s) text alignment correctly.

I appreciate any of your help.
« Last Edit: Apr 4th, 2012 at 12:31pm by henry k »  
Back to top
 
IP Logged
 
Forum Admin
YaBB Administrator
*****
Offline


Rock and Roll

Posts: 685
Joined: Apr 6th, 2003
Re: Javascript Library and classes
Reply #1 - Apr 4th, 2012 at 6:29am
Print Post  
This Topic was moved here from JavaScript [move by] Forum Admin.
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Javascript Library and classes
Reply #2 - Apr 4th, 2012 at 6:39am
Print Post  
Hi,

Setting text alignment in JavaApplet mode should look like this:

Code
Select All
var scriptHelper = <%= diagramView_canvas.AppletElement %>.getScriptHelper();

var horizontalAlign = 1; // 0=left, 1=center, 2=right
var verticalAlign = 1; // 0=top, 1=middle, 2=bottom
var textFormat = scriptHelper.createTextFormat(horizontalAlign, verticalAlign, false, false);
node.setTextFormat(textFormat);
 



You could also use the ScriptHelper.getCosntant method to get values of enumeration members:
http://www.mindfusion.eu/onlinehelp/netdiagram/index.htm?M_com_mindfusion_diagra...

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


I Love MindFusion!

Posts: 51
Location: Finland
Joined: Apr 4th, 2012
Re: Javascript Library and classes
Reply #3 - Apr 4th, 2012 at 7:56am
Print Post  
Hi, Thank you. It helped...

though I'm still a bit confused of [ShapeNode.setTextAlignment] method. It may be that I've misunderstood something here, but shouldn't this (also) work? (or is it used for something else...?)

- Henry


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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Javascript Library and classes
Reply #4 - Apr 4th, 2012 at 10:18am
Print Post  
Hi,

setTextAlignment is a member of ShapeNode only in our JavaScript diagramming library (and can be used in NetDiagram's Canvas client side mode). We don't want to create that many object instances in the JavaScript runtime environment, so classes like TextFormat have been removed and the object hierarchy is flatter there.

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


I Love MindFusion!

Posts: 51
Location: Finland
Joined: Apr 4th, 2012
Re: Javascript Library and classes [SOLVED]
Reply #5 - Apr 4th, 2012 at 12:29pm
Print Post  
Hi and thank you. This explanes many things. Smiley

... this may be considered as solved.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint