Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Some basic help needed please! (Read 5297 times)
nzmike
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Oct 8th, 2006
Some basic help needed please!
Oct 8th, 2006 at 5:23am
Print Post  
Hi,

I'm using the demo version of Diagram.net to see if it will allow us to create starschema diagrams which represent a data-warehosue cube. 

Using C# and VS2005 I dragged a FlowChart control onto a form and set some basic options.  I then used the code below to create 2 Facts (root objects) and 4 Dimensions (child objects).  The Facts are the root nodes and any Dimension (the child nodes) can be related to any Fact.

After much playing around I've got it to work pretty well using a spring layout but I have a few issues and questions I need help with... so here goes:

My main problem is that after the diagram displays and I then try to create new boxes or arrows on my FlowChart control it will only do it in (roughly) the upper left hand fifth of the control.   For example, my FlowChart control is 1000x800 but it will only allow me to create new objects in about the upper left 200x150.  If I add a ruler the problem goes away but  I don't want a ruler... so why is this happening and how can I avoid it?

Another question - once a box or arrow is created why can't I then grab it and move the whole object?  If I try to click on an existing object and drag  it I just end up with a new box... I've checked every option I can find but there does not seem to be a way to move objects - am I right or am I missing something?

Also, what is the best way to get my Facts to be the most important boxes and therefore have the Dimensions (child nodes) arranged around the Facts?  Do I need to use Groups or soemthing?  The problem with the documentation is there are no examples - and the code for the automated layouts is so minimal is gives you very little idea.

I also wanted to know how to enable my Box objects to have custom text styles - eg: a Bold heading in a bigger font with all the remaining text iin a smaller font.

Finally, how can I get the diagram to be laid out in the centre of a FlowChart object?  Whenever I call the Arrange() method the diagram is laid out from the upper left - is it possible to have it laid out from the centre of the FlowChart object?

Sorry to ask so many questions - I have read much of the help and documenation, played with rhe examples and tried many many options in my app so a bit of help would be really appreciated. 

TIA....

Mike

PS: The code made the post too long so I've replied to myself with the code so you can see it.
  
Back to top
 
IP Logged
 
nzmike
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Oct 8th, 2006
CODE FOR ABOVE POST!!
Reply #1 - Oct 8th, 2006 at 5:24am
Print Post  
       private void Form1_Load(object sender, EventArgs e)
       {

           CreateStarSchemaObjects();
           DoSpringLayout();
       }

       private void CreateStarSchemaObjects()
       {
           Box boxFact1 = CreateFact("Fact1",100, 100, 100, 100);
           Box boxFact2 = CreateFact("Fact2",250, 100, 100, 100);

           Box boxDim1 = CreateDimension("Dim1", 100, 300, 100, 100);
           Box boxDim2 = CreateDimension("Dim2", 250, 300, 100, 100);
           Box boxDim3 = CreateDimension("Dim3", 400, 300, 100, 100);
           Box boxDim4 = CreateDimension("Dim4", 550, 300, 100, 100);

           //Create some relationships (arrows)
           Arrow arwFact1Dim1 = flowChart1.CreateArrow(boxFact1, boxDim1);
           Arrow arwFact1Dim2 = flowChart1.CreateArrow(boxFact1, boxDim2);
           Arrow arwFact1Dim3 = flowChart1.CreateArrow(boxFact1, boxDim3);
           Arrow arwFact1Dim4 = flowChart1.CreateArrow(boxFact1, boxDim4);

           Arrow arwFact2Dim1 = flowChart1.CreateArrow(boxFact2, boxDim1);
           Arrow arwFact2Dim2 = flowChart1.CreateArrow(boxFact2, boxDim2);
           Arrow arwFact2Dim4 = flowChart1.CreateArrow(boxFact2, boxDim4);

       }

       private Box CreateFact(string FactName, float x, float y, float width, float height)
       {
           Box fact = flowChart1.CreateBox(x,y,width,height);

           fact.Font = new Font("Verdana", 8);
           fact.Text = FactName.ToUpper() + CRLF;

           for (int i = 0; i <= 10; i++ )
               fact.Text += CRLF + "Column" + i.ToString();
           fact.Text += CRLF + CRLF;

           fact.FitSizeToText(FitSize.KeepWidth);

           fact.Brush = new MindFusion.FlowChartX.LinearGradientBrush(Color.FromArgb(255, 128, 0), Color.FromArgb(255, 255, 0), 315);
           return fact;
       }


       private Box CreateDimension(string DimName, float x, float y, float width, float height)
       {
           Box dim = flowChart1.CreateBox(x, y, width, height);

           dim.Font = new Font("Verdana", 8);

           dim.Text = DimName.ToUpper() + CRLF;

           for (int i = 0; i <= 5; i++)
               dim.Text += CRLF + "Column" + i.ToString();
           dim.Text += CRLF + CRLF;

           dim.FitSizeToText(FitSize.KeepWidth);

           //dim.Brush = new LinearGradientBrush(Color.AliceBlue, Color.CadetBlue, 45);
           dim.Brush = new MindFusion.FlowChartX.LinearGradientBrush(Color.FromArgb(0, 128, 255), Color.FromArgb(0, 255, 255), 315);

           return dim;
       }

       private void DoSpringLayout()
       {

           // Create the layouter object
           SpringLayout layout = new SpringLayout();

           // Adjust the attributes of the layouter
           layout.IterationCount = Int32.Parse(txtIterations.Text);    //textbox
           layout.NodeDistance = Int32.Parse(txtNodeSpace.Text);    //textbox
           layout.MinimizeCrossings = cboMinimiseCrossings.Checked;    //checkbox
           layout.RepulsionFactor = 100;
           layout.EnableClusters = true;

           // Perform the actual arrangement
           layout.Arrange(flowChart1);

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some basic help needed please!
Reply #2 - Oct 8th, 2006 at 12:33pm
Print Post  
Hello Mike,

Quote:
My main problem is that after the diagram displays and I then try to create new boxes or arrows on my FlowChart control it will only do it in (roughly) the upper left hand fifth of the control.   For example, my FlowChart control is 1000x800 but it will only allow me to create new objects in about the upper left 200x150.  If I add a ruler the problem goes away but  I don't want a ruler... so why is this happening and how can I avoid it?


Probably the document size is too small. You can either set a larger DocExtents rectangle, or enable the AutoSizeDoc property.

Quote:
Another question - once a box or arrow is created why can't I then grab it and move the whole object?  If I try to click on an existing object and drag  it I just end up with a new box... I've checked every option I can find but there does not seem to be a way to move objects - am I right or am I missing something?


Usually you must first select the box or arrow so they display their modification handles, and then drag one of the handles. You can set the ModificationStart property to AutoHandles = true; that will make the handles appear automatically and let you start moving the box or arrow immediately.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some basic help needed please!
Reply #3 - Oct 8th, 2006 at 12:56pm
Print Post  
Quote:
Also, what is the best way to get my Facts to be the most important boxes and therefore have the Dimensions (child nodes) arranged around the Facts?  Do I need to use Groups or something?  The problem with the documentation is there are no examples - and the code for the automated layouts is so minimal is gives you very little idea.


The EnableClusters property would do that if each Dimension node is connected to only one Fact node. Since the Dimensions are connected to both Facts, the EnableClusters property won't help you much here. You might play with the arrow Weight values - the SpringLayout uses them to determine how much it can relax the corresponding springs in the simulated system. E.g. try a larger Weight for arrows that connect Facts and smaller ones for arrows that connect a Fact with a Dimension.

Quote:
I also wanted to know how to enable my Box objects to have custom text styles - e.g.: a Bold heading in a bigger font with all the remaining text iin a smaller font.


At this time you can use only one font in a box. You can still make the header bold by settings the box.EnableStyledText property and adding <b></b> tags around the header text.

Quote:
Finally, how can I get the diagram to be laid out in the centre of a FlowChart object?  Whenever I call the Arrange() method the diagram is laid out from the upper left - is it possible to have it laid out from the centre of the FlowChart object?


At this time only the AnnealLayout lets you do that via the LayoutArea property. We can copy that feature the SpringLayout too in the next few days.

Stoyan
  
Back to top
 
IP Logged
 
nzmike
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Oct 8th, 2006
Re: Some basic help needed please!
Reply #4 - Oct 8th, 2006 at 10:05pm
Print Post  
Thanks Stoyan... I appreciate the very fast repsonse.

It may take me a few days to get back to it now as I'm trying to do this stuff in between other priorities,  but when I do I'll try your suggestions and come back with more Q's if I have them.

Cheers,

Mike
  
Back to top
 
IP Logged
 
nzmike
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Oct 8th, 2006
Re: Some basic help needed please!
Reply #5 - Oct 9th, 2006 at 11:51pm
Print Post  
Stoyo wrote on Oct 8th, 2006 at 12:33pm:
Usually you must first select the box or arrow so they display their modification handles, and then drag one of the handles. You can set the ModificationStart property to AutoHandles = true; That will make the handles appear automatically and let you start moving the box or arrow immediately.

Stoyan, I've done that and I still do not see any way to move an object... the "handles" are tiny squares and when you hover over them all you get is the resize cursor and there is no way that I can see to actually grab an object - I've cursored over every pixel of the objects while the handles are displayed and there does not appear to be any way to move them.  Do you have any example code or simple projects I could see where you are doing this because I just can't get this to work.

Stoyo wrote on Oct 8th, 2006 at 12:33pm:
At this time you can use only one font in a box. You can still make the header bold by settings the box.EnableStyledText property and adding <b></b> tags around the header text.

I did this as well - set box.EnableStyledText to true and added "<b>" and "</b>" around my header text and both tags were displayed instead of the formatting happening... any ideas?  Also, what formatting can I use - where is the help on this topic and how do I know what markup tags/styles I can use?  It would be really cool to have a formattable object (such as a Panel or RTF textbox) that the developer could overlay on each Box to get a nicer display - any chance of something this being added any time soon?

Stoyo wrote on Oct 8th, 2006 at 12:33pm:
...try a larger Weight for arrows that connect Facts and smaller ones for arrows that connect a Fact with a Dimension.

Thanks - we don't need to join Facts to Facts though, only Dimensions to one or more Fact... would EnableClusters do this for me after all?  I don't think arrow weight would work as all arrows would have equal importance.

Stoyo wrote on Oct 8th, 2006 at 12:33pm:
At this time only the AnnealLayout lets you do that via the LayoutArea property. We can copy that feature the SpringLayout too in the next few days.

Thanks - although this one isn't a show-stopper it'd be nice to see that in each layout if possible, or at least in Spring if not.

Cheers,

Mike


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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some basic help needed please!
Reply #6 - Oct 10th, 2006 at 4:34am
Print Post  
Quote:
Stoyan, I've done that and I still do not see any way to move an object... the "handles" are tiny squares and when you hover over them all you get is the resize cursor and there is no way that I can see to actually grab an object - I've cursored over every pixel of the objects while the handles are displayed and there does not appear to be any way to move them.  Do you have any example code or simple projects I could see where you are doing this because I just can't get this to work.


Set the HandlesStyle property of boxes to MoveOnly or EasyMove. That will let you move boxes by grabbing any point of the box interior. The default style is SquareHandles and it lets you move a box via the middle square handle. If you find the squares too tiny, you can increase their size through the SelHandleSize property of the flowchart.

Cheers,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some basic help needed please!
Reply #7 - Oct 10th, 2006 at 4:41am
Print Post  
Quote:
I did this as well - set box.EnableStyledText to true and added "<b>" and "</b>" around my header text and both tags were displayed instead of the formatting happening... any ideas?  Also, what formatting can I use - where is the help on this topic and how do I know what markup tags/styles I can use?  It would be really cool to have a formattable object (such as a Panel or RTF textbox) that the developer could overlay on each Box to get a nicer display - any chance of something this being added any time soon? 


You might also have to enable the PolyTextLayout property. You can find more about the formatting tags in the "API Overview\Appearance\Text attributes" topic in the help file.

You can overlay a RichTextBox control on a box by creating a ControlHost node to contain the control, and calling AttachTo to attach the ControlHost to the Box.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some basic help needed please!
Reply #8 - Oct 10th, 2006 at 4:51am
Print Post  
Quote:
Thanks - we don't need to join Facts to Facts though, only Dimensions to one or more Fact... would EnableClusters do this for me after all?  I don't think arrow weight would work as all arrows would have equal importance.


In that case EnableClusters would try to arrange the Facts around the Dimensions, so it won't help at all. I don't think the arrows can have the same importance in the layout you need - if you need the Dimensions arranged around the Facts, there will be two sets of arrows - the ones that connect Facts to Dimensions, and the ones that connect Dimensions to Dimensions. Try setting the "Dimensions to Dimensions" arrow weights to be 2-3 times larger than the "Facts to Dimensions" ones.

Stoyan
  
Back to top
 
IP Logged
 
nzmike
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Oct 8th, 2006
Re: Some basic help needed please!
Reply #9 - Oct 10th, 2006 at 5:31am
Print Post  
Stoyan, thanks again for the info... I can now shift the boxes (though I end up with strange "bent" arrows - but I guess that might be another option I've not found) and the text styles are working. (I was using a box style with rounded edges so the PolyTextLayout property obviously did the trick.)

Thanks also for pointing out about the ControlHost stuff - if I can get my layout problems sorted I will look into doing that.

I guess now my last problem is also biggest problem - the layout.  Just to be clear here - Facts do not link to other Facts and Dimensions never link to other Dimensions but a single Dimension can link to multiple facts.  Logically, these diagrams are usually pretty simple but it's a matter of the layout also being logical which at present it is not.  What I'm finding is that often dimensions partially or entirely obstruct each other and nothing I've tried makes much difference and (naturally) it depends entirely on the complexity of the star schema. 

Ideally what I want is my Facts as close to the center of the diagram and my Dimensions arranged around those in the most logical fashion but it appears your product does not yet support this concept (Nevron also has trouble doing this) but most Star Schema diagrams will have this requirement so maybe it's something you can think about how to support in the future.  It's really just extending the spring or clustered layout to have multiple roots - but I understand how complex that would be to implement.

If it helps to illustrate what I'm trying to do (and where I'm up to) I can zip up my small winforms app and email it to you - but I totally understand you may not have the time to look at it.

Many thanks again for the very rapid support (unlike Nevron who haven't answered my email of a similiar nature from 5 days ago.)

Mike

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some basic help needed please!
Reply #10 - Oct 10th, 2006 at 6:30am
Print Post  
Mike,

This seems to work fine with the diagram your code generates, but I haven't tried it with larger ones:

AnnealLayout layout = new AnnealLayout();
layout.Stages = 10;
layout.TemperatureScale = 0.7;
layout.InitialTemperature = 10;
layout.IterationsPerStage = 1000;
layout.DistributionFactor = 500000;
layout.ArrowLengthFactor = 0.001f;
layout.BoundaryFactor = 0;
layout.CrossingArrowsCost = 150000000;
layout.Randomize = false;

// Perform the actual arrangement
layout.Arrange(fc);

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


I love YaBB 1G - SP1!

Posts: 6
Joined: Oct 8th, 2006
Re: Some basic help needed please!
Reply #11 - Oct 10th, 2006 at 10:20pm
Print Post  
Thanks again Stoyan... that seems to work better so I will read up about each of those properties and experiment further.

Mike
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint