private void ParsePlainFile( List<NodeLayout> nodeLayouts, List<EdgeLayout> edgeLayouts )
        {
            using( var reader = new DotPlainReader( new StreamReader( myPlainFile.FullName ) ) )
            {
                var parser = new DotPlainParser( reader );

                parser.Open();

                while( parser.MoveNextEntry( "node" ) )
                {
                    var nodeId = parser.ReadId();

                    var layout = parser.ReadNodeLayout( nodeId );
                    nodeLayouts.Add( layout );
                }

                while( parser.MoveNextEntry( "edge" ) )
                {
                    var sourceNodeId = parser.ReadId();
                    var targetNodeId = parser.ReadId();

                    var layout = parser.ReadEdgeLayout( Edge.CreateId( sourceNodeId, targetNodeId ) );
                    edgeLayouts.Add( layout );
                }
            }
        }
        private void ParsePlainFile( List<NodeLayout> nodeLayouts, List<EdgeLayout> edgeLayouts, IPropertySetModule<Caption> captionModule )
        {
            using( var reader = new DotPlainReader( new StreamReader( myPlainFile.FullName ) ) )
            {
                var parser = new DotPlainParser( reader );

                parser.Open();

                while( parser.MoveNextEntry( "node" ) )
                {
                    var nodeId = parser.ReadId();

                    var layout = parser.ReadNodeLayout( nodeId );
                    nodeLayouts.Add( layout );
                }

                while( parser.MoveNextEntry( "edge" ) )
                {
                    var sourceNodeId = parser.ReadId();
                    var targetNodeId = parser.ReadId();

                    var edgeId = Edge.CreateId( sourceNodeId, targetNodeId );

                    var layout = parser.ReadEdgeLayout( edgeId );
                    var label = parser.ReadLabel( edgeId );
                    layout.LabelPosition = parser.ReadPoint();
                    edgeLayouts.Add( layout );
                }
            }
        }
        protected override void Load()
        {
            Initialize();

            using( var reader = new DotPlainReader( new StreamReader( Filename ) ) )
            {
               var parser = new DotPlainParser( reader );

                parser.Open();

                while( parser.MoveNextEntry( "node" ) )
                {
                    var node = TryAddNode( parser.ReadId() );
                    if( node != null )
                    {
                        var layout = parser.ReadNodeLayout( node.Id );
                        myNodeLayouts.Add( layout );

                        var caption = parser.ReadLabel( node.Id );
                        myCaptions.Add( caption );

                        var style = parser.ReadNodeStyle( node.Id );
                        myNodeStyles.Add( style );
                    }
                }

                while( parser.MoveNextEntry( "edge" ) )
                {
                    var sourceNodeId = parser.ReadId();
                    var targetNodeId = parser.ReadId();

                    var edge = TryAddEdge( sourceNodeId, targetNodeId );
                    if( edge != null )
                    {
                        var layout = parser.ReadEdgeLayout( edge.Id );
                        myEdgeLayouts.Add( layout );

                        // TODO: we should check for labels

                        var style = parser.ReadEdgeStyle( edge.Id );
                        myEdgeStyles.Add( style );
                    }
                }
            }
        }
Beispiel #4
0
        private void ParsePlainFile(List <NodeLayout> nodeLayouts, List <EdgeLayout> edgeLayouts, IPropertySetModule <Caption> captionModule)
        {
            using (var reader = new DotPlainReader(new StreamReader(myPlainFile.FullName)))
            {
                var parser = new DotPlainParser(reader);

                parser.Open();

                while (parser.MoveNextEntry("node"))
                {
                    var nodeId = parser.ReadId();

                    var layout = parser.ReadNodeLayout(nodeId);
                    nodeLayouts.Add(layout);
                }

                while (parser.MoveNextEntry("edge"))
                {
                    var sourceNodeId = parser.ReadId();
                    var targetNodeId = parser.ReadId();

                    var edgeId = Edge.CreateId(sourceNodeId, targetNodeId);

                    var layout = parser.ReadEdgeLayout(edgeId);

                    var label = parser.ReadLabel(edgeId);

                    if (label.Label != "invis")
                    {
                        // no label position
                        layout.LabelPosition = parser.ReadPoint();
                    }

                    edgeLayouts.Add(layout);
                }
            }
        }
        public DotPlainParser( DotPlainReader reader )
        {
            Contract.RequiresNotNull( reader, "reader" );

            myReader = reader;
        }
        public DotPlainParser(DotPlainReader reader)
        {
            Contract.RequiresNotNull(reader, "reader");

            myReader = reader;
        }