private void DrawBaseTypes()
        {
            var offset = _leftMargin;
            for (int i = 0; i < _classDiagram.BaseTypes.Count; i++)
            {
                var diagram = _classDiagramSvgRenderer.RenderDiagram(_classDiagram.BaseTypes[i]);
                var diagramSize = new Size(
                    _classDiagramSvgRenderer.CalculateDiagramWidth(_classDiagram.BaseTypes[i]),
                    _classDiagramSvgRenderer.CalculateDiagramHeight(_classDiagram.BaseTypes[i]));

                var positionX = (i * 50) + offset;
                var positionY = 0;

                var translate = diagram.CreateAttribute("transform");
                translate.Value = string.Format("translate({0}, {1})", positionX.ToString("0.00", CultureInfo.InvariantCulture), positionY.ToString("0.00", CultureInfo.InvariantCulture));
                diagram["svg"]["g"].Attributes.Append(translate);

                _mainDiagram.ImportAdd((SvgElement)diagram["svg"]["g"]);

                offset += diagramSize.Width;

                var pathGraphic = new SvgGraphic(_mainDiagram);

                //line
                if (i == 0)
                {
                    var path = new SvgPath(_mainDiagram, string.Format("M{0},{1}L{0},{2}",
                        (positionX + 50).ToString("0.00", CultureInfo.InvariantCulture),
                        (positionY + diagramSize.Height).ToString("0.00", CultureInfo.InvariantCulture),
                        _topMargin.ToString("0.00", CultureInfo.InvariantCulture)));
                    path.StrokeWidth = 1;
                    path.Stroke = "#979797";
                    pathGraphic.Add(path);
                }

                //arrow
                var startX = positionX + 50;
                var startY = diagramSize.Height;

                var points = string.Format("{0},{1} {2},{3} {4},{3}",
                    startX.ToString("0.00", CultureInfo.InvariantCulture),
                    startY.ToString("0.00", CultureInfo.InvariantCulture),
                    (startX - 5).ToString("0.00", CultureInfo.InvariantCulture),
                    (startY + 10).ToString("0.00", CultureInfo.InvariantCulture),
                    (startX + 5).ToString("0.00", CultureInfo.InvariantCulture));
                var arrow = new SvgPolygon(_mainDiagram, points);
                arrow.Stroke = "#979797";
                arrow.Fill = "#FFFFFF";

                pathGraphic.Add(arrow);

                _mainDiagram.Add(pathGraphic);
            }
        }
Ejemplo n.º 2
0
        private double RenderHeader(ClassDiagram classDiagram, double position)
        {
            var accessibility = new SvgText(_svgRoot, classDiagram.Accessibility, (_diagramWidth - classDiagram.Accessibility.GetWidth(11, Fonts.FontItalic)) / 2, position);
            accessibility.FontSize = 11;

            var name = new SvgLink(_svgRoot, classDiagram.Name, string.Format("{{{{type-link:{0}}}}}", classDiagram.TypeIdentifier), (_diagramWidth - classDiagram.Name.GetWidth(14, Fonts.FontLight)) / 2, position += 20);
            name.Text.FontSize = 14;

            position += 15;

            var path = new SvgPath(_svgRoot, string.Format("M0.5,{0}L{1},{0}", position.ToString("0.00", CultureInfo.InvariantCulture), _diagramWidth.ToString("0.00", CultureInfo.InvariantCulture)));
            path.StrokeWidth = 1;
            path.Stroke = "#979797";

            _svgRoot.AppendChild(accessibility.XmlElement);
            _svgRoot.AppendChild(name.XmlElement);
            _svgRoot.AppendChild(path.XmlElement);

            return position + 25;
        }
Ejemplo n.º 3
0
        private void DrawVerticalLines(SequenceDiagram sequenceDiagram)
        {
            foreach (var node in _nodeMiddlePoints)
            {
                var path = new SvgPath(_svgRoot, string.Format("M{0},{1}L{0},{2}", 
                    node.Value.ToString("0.50", CultureInfo.InvariantCulture), 
                    45, 
                    _diagramSize.Height.ToString("0.50", CultureInfo.InvariantCulture)));
                path.StrokeWidth = 1;
                path.Stroke = "#979797";

                _svgGraphic.Add(path);
            }
        }
Ejemplo n.º 4
0
        private void DrawReturnConnection(SequenceDiagramConnection connection)
        {
            var callerNodeMiddlePoint = _nodeMiddlePoints[connection.CallerId];
            var calledNodeMiddlePoint = connection.CalledId == Guid.Empty ? 0 : _nodeMiddlePoints[connection.CalledId];

            var textWidth = ("return " + connection.Text).GetWidth(12, Fonts.FontLight);
            var text = new SvgText(_svgRoot, "return " + connection.Text, calledNodeMiddlePoint + 10, _diagramSize.Height + 10);
            text.FontSize = 12;
            _svgGraphic.Add(text);

            if ((textWidth + calledNodeMiddlePoint + 10) > _diagramSize.Width)
            {
                _diagramSize.Width = textWidth + calledNodeMiddlePoint + 20;
            }

            var path = new SvgPath(_svgRoot, string.Format("M{0},{1}L{2},{1}",
                    calledNodeMiddlePoint.ToString("0.00", CultureInfo.InvariantCulture),
                    (_diagramSize.Height + 20).ToString("0.00", CultureInfo.InvariantCulture),
                    callerNodeMiddlePoint.ToString("0.00", CultureInfo.InvariantCulture)));
            path.StrokeWidth = 1;
            path.Stroke = "#979797";
            _svgGraphic.Add(path);

            var startX = (int)calledNodeMiddlePoint;
            var startY = (int)_diagramSize.Height + 20;

            var points = string.Format("{0},{1} {2},{3} {2},{4}", startX, startY, startX + 5, startY + 5, startY - 5);
            var arrow = new SvgPolygon(_svgRoot, points);
            arrow.Stroke = arrow.Fill = "#979797";

            _svgGraphic.Add(arrow);

            _diagramSize.Height += 35;
        }
Ejemplo n.º 5
0
        private void DrawConnectionLine(SequenceDiagramConnection connection, double callerNodeMiddlePoint, double calledNodeMiddlePoint)
        {
            if (connection.CallerId == connection.CalledId)
            {
                double x1 = callerNodeMiddlePoint;
                double x2 = callerNodeMiddlePoint - 10;
                double y1 = _diagramSize.Height + 10;
                double y2 = _diagramSize.Height + 20;

                var path = new SvgPath(_svgRoot, string.Format("M{0},{1}L{2},{1}",
                    x1.ToString("0.00", CultureInfo.InvariantCulture),
                    y1.ToString("0.00", CultureInfo.InvariantCulture),
                    x2.ToString("0.00", CultureInfo.InvariantCulture)));
                path.StrokeWidth = 1;
                path.Stroke = "#979797";

                var path2 = new SvgPath(_svgRoot, string.Format("M{0},{1}L{0},{2}",
                    x2.ToString("0.00", CultureInfo.InvariantCulture),
                    y1.ToString("0.00", CultureInfo.InvariantCulture),
                    y2.ToString("0.00", CultureInfo.InvariantCulture)));
                path2.StrokeWidth = 1;
                path2.Stroke = "#979797";

                var path3 = new SvgPath(_svgRoot, string.Format("M{0},{1}L{2},{1}",
                    x2.ToString("0.00", CultureInfo.InvariantCulture),
                    y2.ToString("0.00", CultureInfo.InvariantCulture),
                    x1.ToString("0.00", CultureInfo.InvariantCulture)));
                path3.StrokeWidth = 1;
                path3.Stroke = "#979797";

                _svgGraphic.Add(path);
                _svgGraphic.Add(path2);
                _svgGraphic.Add(path3);
            }
            else
            {
                var path = new SvgPath(_svgRoot, string.Format("M{0},{2}L{1},{2}",
                    callerNodeMiddlePoint.ToString("0.00", CultureInfo.InvariantCulture),
                    calledNodeMiddlePoint.ToString("0.00", CultureInfo.InvariantCulture), 
                    (_diagramSize.Height + 20).ToString("0.00", CultureInfo.InvariantCulture)));
                path.StrokeWidth = 1;
                path.Stroke = "#979797";

                _svgGraphic.Add(path);
            }

            _diagramSize.Height += 20;
        }
        private void DrawUses()
        {
            var leftOffset = _leftMargin + _classDiagramSvgRenderer.CalculateDiagramWidth(_classDiagram);
            var offset = leftOffset;
            for (int i = 0; i < _classDiagram.Uses.Count; i++)
            {
                var diagram = _classDiagramSvgRenderer.RenderDiagram(_classDiagram.Uses[i]);
                var diagramSize = new Size(
                    _classDiagramSvgRenderer.CalculateDiagramWidth(_classDiagram.Uses[i]),
                    _classDiagramSvgRenderer.CalculateDiagramHeight(_classDiagram.Uses[i]));

                var positionX = (i * 50) + offset + 50;
                var positionY = _topMargin + 50;

                var translate = diagram.CreateAttribute("transform");
                translate.Value = string.Format("translate({0}, {1})", positionX.ToString("0.00", CultureInfo.InvariantCulture), positionY.ToString("0.00", CultureInfo.InvariantCulture));
                diagram["svg"]["g"].Attributes.Append(translate);

                _mainDiagram.ImportAdd((SvgElement)diagram["svg"]["g"]);

                var pathGraphic = new SvgGraphic(_mainDiagram);

                var path = new SvgPath(_mainDiagram, string.Format("M{0},{1}L{0},{2}",
                    (positionX + (diagramSize.Width / 2)).ToString("0.00", CultureInfo.InvariantCulture),
                    positionY.ToString("0.00", CultureInfo.InvariantCulture),
                    (positionY - 25).ToString("0.00", CultureInfo.InvariantCulture)));
                path.StrokeWidth = 1;
                path.Stroke = "#979797";
                pathGraphic.Add(path);

                path = new SvgPath(_mainDiagram, string.Format("M{0},{1}L{2},{3}",
                    (positionX + (diagramSize.Width / 2) - 5).ToString("0.00", CultureInfo.InvariantCulture),
                    (positionY - 10).ToString("0.00", CultureInfo.InvariantCulture),
                    (positionX + (diagramSize.Width / 2)).ToString("0.00", CultureInfo.InvariantCulture),
                    positionY.ToString("0.00", CultureInfo.InvariantCulture)));
                path.StrokeWidth = 1;
                path.Stroke = "#979797";
                pathGraphic.Add(path);

                path = new SvgPath(_mainDiagram, string.Format("M{0},{1}L{2},{3}",
                    (positionX + (diagramSize.Width / 2) + 5).ToString("0.00", CultureInfo.InvariantCulture),
                    (positionY - 10).ToString("0.00", CultureInfo.InvariantCulture),
                    (positionX + (diagramSize.Width / 2)).ToString("0.00", CultureInfo.InvariantCulture),
                    positionY.ToString("0.00", CultureInfo.InvariantCulture)));
                path.StrokeWidth = 1;
                path.Stroke = "#979797";
                pathGraphic.Add(path);

                if (i == _classDiagram.Uses.Count - 1)
                {
                    path = new SvgPath(_mainDiagram, string.Format("M{0},{2}L{1},{2}",
                        (positionX + (diagramSize.Width / 2)).ToString("0.00", CultureInfo.InvariantCulture),
                        leftOffset.ToString("0.00", CultureInfo.InvariantCulture),
                        (positionY - 25.5d).ToString("0.00", CultureInfo.InvariantCulture)));
                    path.StrokeWidth = 1;
                    path.Stroke = "#979797";
                    pathGraphic.Add(path);
                }

                _mainDiagram.Add(pathGraphic);
                offset += diagramSize.Width;
            }
        }
Ejemplo n.º 7
0
        private double RenderLine(double position)
        {
            var path = new SvgPath(_svgRoot, string.Format("M0.5,{0}L{1},{0}", position.ToString("0.00", CultureInfo.InvariantCulture), _diagramWidth.ToString("0.00", CultureInfo.InvariantCulture)));
            path.StrokeWidth = 1;
            path.Stroke = "#979797";
            _svgRoot.AppendChild(path.XmlElement);

            return position + 20;
        }
Ejemplo n.º 8
0
        private void RenderHeader()
        {
            var accessibility = new SvgText(
                _svgRoot, 
                _classDiagram.Accessibility, 
                (_diagramSize.Width - _classDiagram.Accessibility.GetWidth(11, Fonts.FontItalic)) / 2,
                ACCESSIBILITY_LABEL_Y);
            accessibility.FontSize = 11;

            SvgElement name;
            if (_classDiagram.IsProjectStranger)
            {
                name = new SvgText(
                    _svgRoot,
                    _classDiagram.Name,
                    (_diagramSize.Width - _classDiagram.Name.GetWidth(14, Fonts.FontLight)) / 2,
                    CLASSLABEL_Y);
                ((SvgText)name).FontSize = 14;
            }
            else
            {
                name = new SvgLink(
                    _svgRoot,
                    _classDiagram.Name,
                    string.Format("{{{{type-link:{0}}}}}", _classDiagram.TypeIdentifier),
                    (_diagramSize.Width - _classDiagram.Name.GetWidth(14, Fonts.FontLight)) / 2,
                    CLASSLABEL_Y);
                ((SvgLink)name).Text.FontSize = 14;
            }

            var path = new SvgPath(
                _svgRoot, 
                string.Format("M0.5,{0}L{1},{0}", 
                    (CLASSLABEL_Y + 10).ToString("0.00", CultureInfo.InvariantCulture),
                    _diagramSize.Width.ToString("0.00", CultureInfo.InvariantCulture)));
            path.StrokeWidth = 1;
            path.Stroke = "#979797";

            _svgGraphic.Add(accessibility);
            _svgGraphic.Add(name);
            _svgGraphic.Add(path);
        }
Ejemplo n.º 9
0
 private void RenderLine(double position)
 {
     var path = new SvgPath(
         _svgRoot, 
         string.Format("M0.5,{0}L{1},{0}", 
             position.ToString("0.00", CultureInfo.InvariantCulture),
             _diagramSize.Width.ToString("0.00", CultureInfo.InvariantCulture)));
     path.StrokeWidth = 1;
     path.Stroke = "#979797";
     _svgGraphic.Add(path);
 }