makeSVGDoc :: M.Map String String
           -> [Shape] -- ^ A list of the Nodes that will be included
                      --   in the graph. This includes both Hybrids and
                      --   course nodes.
           -> [Shape] -- ^ A list of the Ellipses that will be included
                      --   in the graph.
           -> [Path]  -- ^ A list of the Edges that will be included
                      --   in the graph.
           -> [Path]  -- ^ A list of the Regions that will be included
                      --   in the graph.
           -> [Text]  -- ^ A list of the 'Text' elements that will be included
                      --   in the graph.
           -> Bool    -- ^ Whether to include inline styles in the graph.
           -> Double  -- ^ The width dimension of the graph.
           -> Double  -- ^ The height dimension of the graph.
           -> S.Svg   -- ^ The completed SVG document.
makeSVGDoc courseMap rects ellipses edges regions regionTexts styled width height =
    S.docTypeSvg ! A.width "100%"
                 ! A.height "100%"
                 ! A.preserveaspectratio "xMinYMin"
                 ! A.viewbox (stringValue $ "0 0 " ++ (show width) ++ " " ++ (show height))
                 ! S.customAttribute "xmlns:svg" "http://www.w3.org/2000/svg"
                 ! S.customAttribute "xmlns:dc" "http://purl.org/dc/elements/1.1/"
                 ! S.customAttribute "xmlns:cc" "http://creativecommons.org/ns#"
                 ! S.customAttribute "xmlns:rdf"
                                     "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                 ! A.version "1.1" $ do
                      makeSVGDefs
                      S.g ! A.id_ "regions" $
                          sequence_ $ map (regionToSVG styled)
                                          regions
                      S.g ! A.id_ "nodes"
                          ! A.stroke "black" $
                          sequence_ $ map (rectToSVG styled courseMap)
                                           rects
                      S.g ! A.id_ "bools" $
                          sequence_ $ map (ellipseToSVG styled)
                                          ellipses
                      S.g ! A.id_ "edges"
                          ! A.stroke "black" $
                              sequence_ $ map (edgeToSVG styled)
                                              edges
                      S.g ! A.id_ "region-labels" $
                          sequence_ $ map (textToSVG styled Region 0)
                                          regionTexts

-- | Builds the SVG defs. Currently, we only use a single one, for the arrowheads.
makeSVGDoc :: M.Map String String
           -> [Shape] -- ^ A list of the Nodes that will be included
                      --   in the graph. This includes both Hybrids and
                      --   course nodes.
           -> [Shape] -- ^ A list of the Ellipses that will be included
                      --   in the graph.
           -> [Path]  -- ^ A list of the Edges that will be included
                      --   in the graph.
           -> [Path]  -- ^ A list of the Regions that will be included
                      --   in the graph.
           -> [Text]  -- ^ A list of the 'Text' elements that will be included
                      --   in the graph.
           -> Bool    -- ^ Whether to include inline styles in the graph.
           -> Double  -- ^ The width dimension of the graph.
           -> Double  -- ^ The height dimension of the graph.
           -> S.Svg
makeSVGDoc courseMap rects ellipses edges regions regionTexts styled width height =
    S.docTypeSvg ! A.width "100%"
                 ! A.height "100%"
                 ! A.preserveaspectratio "xMinYMin"
                 ! A.viewbox (stringValue $ "0 0 " ++ (show width) ++ " " ++ (show height))
                 ! S.customAttribute "xmlns:svg" "http://www.w3.org/2000/svg"
                 ! S.customAttribute "xmlns:dc" "http://purl.org/dc/elements/1.1/"
                 ! S.customAttribute "xmlns:cc" "http://creativecommons.org/ns#"
                 ! S.customAttribute "xmlns:rdf"
                                     "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                 ! A.version "1.1" $ do
                      makeSVGDefs
                      S.g ! A.id_ "regions" $
                          sequence_ $ map (regionToSVG styled)
                                          regions
                      S.g ! A.id_ "nodes"
                          ! A.stroke "black" $
                          sequence_ $ map (rectToSVG styled courseMap)
                                           rects
                      S.g ! A.id_ "bools" $
                          sequence_ $ map (ellipseToSVG styled)
                                          ellipses
                      S.g ! A.id_ "edges"
                          ! A.stroke "black" $
                              sequence_ $ map (edgeToSVG styled)
                                              edges
                      S.g ! A.id_ "region-labels" $
                          sequence_ $ map (textToSVG styled Region 0)
                                          regionTexts

-- | Builds the SVG defs. Currently, we only use a single one, for the arrowheads.
makeSVGDoc courseMap rects ellipses edges regions regionTexts styled width height =
    S.docTypeSvg ! A.width "100%"
                 ! A.height "100%"
                 ! A.preserveaspectratio "xMinYMin"
                 ! A.viewbox (stringValue $ "0 0 " ++ (show width) ++ " " ++ (show height))
                 ! S.customAttribute "xmlns:svg" "http://www.w3.org/2000/svg"
                 ! S.customAttribute "xmlns:dc" "http://purl.org/dc/elements/1.1/"
                 ! S.customAttribute "xmlns:cc" "http://creativecommons.org/ns#"
                 ! S.customAttribute "xmlns:rdf"
                                     "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                 ! A.version "1.1" $ do
                      makeSVGDefs
                      S.g ! A.id_ "regions" $
                          sequence_ $ map (regionToSVG styled)
                                          regions
                      S.g ! A.id_ "nodes"
                          ! A.stroke "black" $
                          sequence_ $ map (rectToSVG styled courseMap)
                                           rects
                      S.g ! A.id_ "bools" $
                          sequence_ $ map (ellipseToSVG styled)
                                          ellipses
                      S.g ! A.id_ "edges"
                          ! A.stroke "black" $
                              sequence_ $ map (edgeToSVG styled)
                                              edges
                      S.g ! A.id_ "region-labels" $
                          sequence_ $ map (textToSVG styled Region 0)
                                          regionTexts

-- | Builds the SVG defs. Currently, we only use a single one, for the arrowheads.