Crainiate Community

Support and discussion for users of Crainiate component software products
Welcome to Crainiate Community Sign in | Join | Help
in Search

How redraw line ?

Last post 11-26-2007 1:16 AM by M.Sekine. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 08-02-2007 12:28 AM

    How redraw line ?

    I can draw a line in a diagram, then I can select it and drag/drog these small circle on the line. During I do this, Some new points will be inserted to the line. I can read these points and save to save to database.

    But the problem is how to redraw the line base on these points that saved ? Actually I use ComplexLine.AddSegment to do it, but I want to know who can give me a better way ? 

    Thanks a lot

    • 64.59.144.88
  • 08-02-2007 8:25 AM In reply to

    Re: How redraw line ?

    I'm not sure, but you can probably achieve that by overriding CalculatePoints method of the Connector class. The documentation says that it "Calculates the points the line will contain using a Route object.", so it should do the trick. The return value is an ArrayList, but I don't know if the type is a Point(F) or sth else, but you can easily check that.
    • 83.3.189.82
  • 08-02-2007 7:36 PM In reply to

    Re: How redraw line ?

    But the problem is how to redraw the line base on these points that saved ?

    Sorry Im not quite following here, can you explain further or link a diagram etc. Many thanks.

    Filed under:
    • 86.155.94.155
  • 08-02-2007 9:22 PM In reply to

    Re: How redraw line ?

    • there is a line in diagram that include 2 points, stat point and end point.  The start point is (10, 10), the end point is (50, 10), show the line below:
    •  
    •                   ------------------->         pic1
    •  
    • Then, I can use mouse to change the line , like below:
    •  
    •                  |               ^
    •                  |               |               pic2
    •                  |               |
    •                  --------------
    • the position of stat point and end point is not changed, and 2 new points is inserted to the line automatically. Then user save this diagram and quit program. Next time when use open this diagram again I hope program can display pic2. For this purpose I already saved 4 points to database, my question is how to use these 4 points to show pic2.
    • 64.59.144.88
  • 11-22-2007 10:32 AM In reply to

    Re: How redraw line ?

    I am being not able to do the same operation as CanadaProgrammer, too.

    I hope the sample source.

    Please teach the method of the re-drawing in the connector.

     

    • 202.228.139.181
  • 11-22-2007 10:54 AM In reply to

    Re: How redraw line ?

    You can use the CalculatePoints method I wrote about above.

    Simple example for you:

    protected override System.Collections.ArrayList CalculatePoints() {
            //  calculate only when the elements are already placed 
            if (Line.Model.IsArranged) {
                ArrayList al = new ArrayList(2);
                if (Line.Start.Arrangement == Arrangement.Horizontal) {
                    //  one point just below the start element (in the middle)
                    al.Add(new PointF(Line.Start.X 
                                        + Line.Start.Width / 2, Line.Start.Y 
                                        + Line.Start.Height + Line.Model.ElementPadding.Height));
                    //  and one just above the end element (in the middle as well)
                    al.Add(new PointF(Line.End.X 
                                        + Line.Start.Width / 2, 
                                          Line.End.Y - Line.Model.ElementPadding.Height));
                }
                else if (Line.Start.Arrangement == Arrangement.Vertical) {
                    al.Add(new PointF(Line.Start.X+Line.Model.Indent / 2.0F, 
                                      Line.Start.Y + Line.Start.Height + Line.Model.ElementPadding.Height));
                    al.Add(new PointF(Line.Start.X+Line.Model.Indent / 2.0F, 
                                      Line.End.Y + Line.End.Height / 2));
                }
                return al;
            }
            else {
                return base.CalculatePoints();
            }
        }
    


    You have to override the Connector class with your own, place the code above in it and make sure the diagram will use your class, not the original Connector by overriding the CreateConnector method in Runtime class.
    • 87.105.212.19
  • 11-26-2007 1:16 AM In reply to

    Re: How redraw line ?

    hi,Ireneusz Patalas.

    It was possible to correspond referring to the sample.

    Thank you.

    • 202.228.139.181
Page 1 of 1 (7 items)