public static void PolygonTex(this Polygon polygon, SBMLExtension.LayoutExtension.GraphicalObject glyph, IndentedTextWriter writer, RenderInformation rendinfo, Group refgroup, RectangleF refbounds, double scale)
        {
            writer.WriteLine("{");
            writer.Indent += 1;
            CommentTex(glyph, polygon, writer);
            RectangleF bound_rectangle = glyph.Bounds.toRect();
            if (!refbounds.IsEmpty)
                bound_rectangle = refbounds;
            FillColor fill = polygon.GetFillColor(rendinfo, bound_rectangle, refgroup);

            RotateAndShift(polygon, bound_rectangle, writer);

            if (fill == null)
            {
                fill = new FillColor(Color.Empty);
            }

            if (fill.gradient && !fill.radial && fill.colorList.Count > 1)
            {
                polygon.LinearGradientPolygon(bound_rectangle, fill, writer, rendinfo, refgroup, scale);
            }
            else if (fill.gradient && fill.colorList.Count > 1)
            {
                polygon.PathGradientPolygon(bound_rectangle, fill, writer, rendinfo, refgroup, scale);
            }
            else
            {
                polygon.SolidColorPolygon(bound_rectangle, fill, writer, rendinfo, refgroup, scale);
            }

            writer.Indent -= 1;
            writer.WriteLine("}");
        }
        // adapted from EmlRenderExtension.Rectangle.draw
        public static void RectangleTex(this SBMLExtension.EmlRenderExtension.Rectangle rectangle, SBMLExtension.LayoutExtension.GraphicalObject glyph, IndentedTextWriter writer, RenderInformation rendinfo, Group refgroup, RectangleF refbounds, double scale)
        {
            writer.WriteLine("{");
            writer.Indent += 1;
            CommentTex(glyph, rectangle, writer);
            // Check what kind of filling
            RectangleF bound_rectangle = glyph.Bounds.toRect();
            if (!refbounds.IsEmpty)
                bound_rectangle = refbounds;
            FillColor fill = rectangle.GetFillColor(rendinfo, bound_rectangle, refgroup);

            RotateAndShift(rectangle, bound_rectangle, writer);

            if (fill == null)
            {
                fill = new FillColor(Color.Empty);
            }
            if (fill.gradient && !fill.radial && fill.colorList.Count > 1)
            {
                rectangle.LinearGradTex(bound_rectangle, fill, writer, rendinfo, refgroup, scale);
            }
            else if (fill.gradient && fill.colorList.Count > 1)
            {
                rectangle.RadialGradTex(bound_rectangle, fill, writer, rendinfo, refgroup, scale);
            }
            else
            {
                rectangle.SolidColorTex(bound_rectangle, fill, writer, rendinfo, refgroup, scale);
            }

            writer.Indent -= 1;
            writer.WriteLine("}");
        }
        //draws a solid color rectangle
        private static void SolidColorTex(this SBMLExtension.EmlRenderExtension.Rectangle rectangle, RectangleF bound_rectangle, FillColor fillcolor, IndentedTextWriter writer, RenderInformation rendinfo, Group refgroup, double scale)
        {
            //define the overall shape
            rectangle.DefineTex(bound_rectangle, writer);

            // draw the filling
            Color curSolidColor = fillcolor.colorList[0];

            // refer solidfill information to a ColorDefinition ID or assign a new colordefinition to "curSolidColor"
            string solidRef = FillColor.getColorRef(rectangle, rendinfo, refgroup);
            if (fillcolor.colorList[0].Equals(Color.Empty))
            {
                solidRef = "none";
            }
            else if (!FillColor.isColorID(solidRef, rendinfo.ColorDefinitions))
            {
                solidRef = "curSolidColor";
                FillColor.AssignColorRGBTex(curSolidColor, "curSolidColor", writer);
            }

            if (string.IsNullOrEmpty(rectangle.RX) || (SBMLExtension.Util.readSingle(rectangle.RX) == 0f))
            {
                writer.WriteLine("\\fill[fill = {1}{0}] \\wholeShape;",
                    FillColor.AlphaValTex(curSolidColor),
                    solidRef);
            }

            else
            {
                float fRadiusX = rectangle.RX.Contains("%") ? ((bound_rectangle.Width * SBMLExtension.Util.readSingle(rectangle.RX)) / 100f) : SBMLExtension.Util.readSingle(rectangle.RX);
                float fRadiusY = rectangle.RY.Contains("%") ? ((bound_rectangle.Height * SBMLExtension.Util.readSingle(rectangle.RY)) / 100f) : SBMLExtension.Util.readSingle(rectangle.RY);
                // In actuality PGF/TikZ does not round with x and y parameters, so we need to fudge
                // Also note that PGF/TikZ does not scale rounding

                float fRadius = (fRadiusX + fRadiusY) / (2f * (float)scale);
                writer.WriteLine("\\draw[rounded corners = {0}pt, fill = {2}{1}] \\wholeShape;",
                        fRadius,
                        FillColor.AlphaValTex(curSolidColor),
                        solidRef);
            }
            // draw the outline
            rectangle.OutlineTex(bound_rectangle, "wholeShape", writer, rendinfo, refgroup, scale);
        }
        private static void SolidColorTex(this Ellipses ellipse, RectangleF bound_rectangle, FillColor fillcolor, IndentedTextWriter writer, RenderInformation rendinfo, Group refgroup, double scale)
        {
            PointF position = EllipsePositionInBounds(ellipse, bound_rectangle);
            PointF radii = CorrectEllipseRadii(ellipse, bound_rectangle); ;

            //define the overall shape
            ellipse.DefineTex(position, radii, writer);

            // obtain fill color information
            Color curSolidColor = fillcolor.colorList[0];

            // refer solidfill information to a ColorDefinition ID or assign a new colordefinition to "curSolidColor"
            string solidRef = FillColor.getColorRef(ellipse, rendinfo, refgroup);
            if (fillcolor.colorList[0].Equals(Color.Empty))
            {
                solidRef = "none";
            }
            else if (!FillColor.isColorID(solidRef, rendinfo.ColorDefinitions))
            {
                solidRef = "curSolidColor";
                FillColor.AssignColorRGBTex(curSolidColor, "curSolidColor", writer);
            }

            writer.WriteLine("\\fill[color = {1}{0}] \\wholeShape;",
                FillColor.AlphaValTex(curSolidColor),
                solidRef);

            //draw the outline
            ellipse.OutlineTex(bound_rectangle, "wholeShape", writer, rendinfo, refgroup, scale);
        }
        private static void RadialGradTex(this Ellipses ellipse, RectangleF bound_rectangle, FillColor fillcolor, IndentedTextWriter writer, RenderInformation rendinfo, Group refgroup, double scale)
        {
            PointF position = EllipsePositionInBounds(ellipse, bound_rectangle);
            PointF radii = CorrectEllipseRadii(ellipse, bound_rectangle); ;

            //define the overall shape
            ellipse.DefineTex(position, radii, writer);

            if (fillcolor.colorList.Count == fillcolor.positionList.Count)
            {
                if (!FillColor.isGradientID(fillcolor.ID, rendinfo.GradientDefinitions))
                {
                    FillColor.AssignGradientTex(fillcolor, fillcolor.ID, writer);
                }

                writer.WriteLine("\\fill[shading = {0}, shading angle = {1}] \\wholeShape;",
                fillcolor.ID,
                -180 + fillcolor.gradient_rotation);
            }

            //draw the outline
            ellipse.OutlineTex(bound_rectangle, "wholeShape", writer, rendinfo, refgroup, scale);
        }
        private static void SolidColorPolygon(this Polygon polygon, RectangleF bound_rectangle, FillColor fillColor, IndentedTextWriter writer, RenderInformation rendinfo, Group refgroup, double scale)
        {
            string strokewidth = polygon.GetStrokeWidth(rendinfo, refgroup, scale);
            string dashed = "";
            if (!string.IsNullOrEmpty(polygon.GetDashType(refgroup)))
            {
                dashed = ", " + polygon.DashTex(polygon.GetDashType(refgroup));
            }
            // obtain stroke color and filling color
            Color linecolor = polygon.GetStrokeColor(rendinfo, refgroup);
            Color curSolidColor = fillColor.colorList[0];

            // refer stroke information to a ColorDefinition ID or assign a new colordefinition to "curLineColor"
            string strokeRef = FillColor.getStrokeRef(polygon, rendinfo, refgroup);
            if (linecolor.Equals(Color.Empty))
            {
                strokeRef = "none";
            }
            else if (!FillColor.isColorID(strokeRef, rendinfo.ColorDefinitions))
            {
                strokeRef = "curSolidColor";
                FillColor.AssignColorRGBTex(curSolidColor, "curSolidColor", writer);
            }

            // refer solidfill information to a ColorDefinition ID or assign a new colordefinition to "curSolidColor"
            string solidRef = FillColor.getColorRef(polygon, rendinfo, refgroup);
            if (curSolidColor.Equals(Color.Empty))
            {
                solidRef = "none";
            }
            else if (!FillColor.isColorID(solidRef, rendinfo.ColorDefinitions))
            {
                solidRef = "curSolidColor";
                FillColor.AssignColorRGBTex(curSolidColor, "curSolidColor", writer);
            }

            writer.WriteLine("\\draw [line width = {0}pt, color = {4}{1}, fill = {5}{2} {3}] ",
                strokewidth,
                FillColor.AlphaValTex(linecolor),
                FillColor.AlphaValTex(curSolidColor),
                dashed,
                strokeRef,
                solidRef);

            PolygonSegmentsTex(polygon.CurveSegments, bound_rectangle, writer, false);
            PolygonElementsTex(polygon.ListOfElements, writer, bound_rectangle,false);
        }
        private static void RadialGradTex(this SBMLExtension.EmlRenderExtension.Rectangle rectangle, RectangleF bound_rectangle, FillColor fillcolor, IndentedTextWriter writer, RenderInformation rendinfo, Group refgroup, double scale)
        {
            // define the overall shape
            rectangle.DefineTex(bound_rectangle, writer);

            // draw the filling
            if (fillcolor.colorList.Count == fillcolor.positionList.Count)
            {
                if (!FillColor.isGradientID(fillcolor.ID, rendinfo.GradientDefinitions))
                {
                    FillColor.AssignGradientTex(fillcolor, fillcolor.ID, writer);
                }

                if (string.IsNullOrEmpty(rectangle.RX) || (SBMLExtension.Util.readSingle(rectangle.RX) == 0f))
                {
                    writer.WriteLine("\\fill[shading = {0}] \\wholeShape;", fillcolor.ID);
                }

                else
                {
                    float fRadiusX = rectangle.RX.Contains("%") ? ((bound_rectangle.Width * SBMLExtension.Util.readSingle(rectangle.RX)) / 100f) : SBMLExtension.Util.readSingle(rectangle.RX);
                    float fRadiusY = rectangle.RY.Contains("%") ? ((bound_rectangle.Height * SBMLExtension.Util.readSingle(rectangle.RY)) / 100f) : SBMLExtension.Util.readSingle(rectangle.RY);
                    // In actuality PGF/TikZ does not round with x and y parameters, so we need to fudge
                    // Also note that PGF/TikZ does not scale rounding

                    float fRadius = (fRadiusX + fRadiusY) / (2f * (float)scale);
                    writer.WriteLine("\\fill[rounded corners = {0}pt, shading = {1}] \\wholeShape;",
                            fRadius, fillcolor.ID);
                }
            }
            // draw the outline
            rectangle.OutlineTex(bound_rectangle, "wholeShape", writer, rendinfo, refgroup, scale);
        }
        private static void PathGradientPolygon(this Polygon polygon, RectangleF bound_rectangle, FillColor fillcolor, IndentedTextWriter writer, RenderInformation rendinfo, Group refgroup, double scale)
        {
            string strokewidth = polygon.GetStrokeWidth(rendinfo, refgroup, scale);
            string dashed = "";
            if (!string.IsNullOrEmpty(polygon.GetDashType(refgroup)))
            {
                dashed = ", " + polygon.DashTex(polygon.GetDashType(refgroup));
            }
            Color linecolor = polygon.GetStrokeColor(rendinfo, refgroup);

            // refer stroke information to a ColorDefinition or assign a new colordefinition to "curLineColor"
            string strokeRef = FillColor.getStrokeRef(polygon, rendinfo, refgroup);
            if (String.IsNullOrEmpty(strokeRef) || !FillColor.isColorID(strokeRef, rendinfo.ColorDefinitions))
            {
                strokeRef = "curLineColor";
                FillColor.AssignColorRGBTex(linecolor, "curLineColor", writer);
            }

            if (!FillColor.isGradientID(fillcolor.ID, rendinfo.GradientDefinitions))
            {
                FillColor.AssignGradientTex(fillcolor, fillcolor.ID, writer);
            }

            // draw the filling
            if (fillcolor.colorList.Count == fillcolor.positionList.Count)
            {
                writer.WriteLine("\\draw [line width = {0}pt, color = {5}{1}, shading = {4}, shading angle = {2} {3}] ",
                    strokewidth,
                    FillColor.AlphaValTex(linecolor),
                    dashed,
                    fillcolor.ID,
                    strokeRef);

                PolygonSegmentsTex(polygon.CurveSegments, bound_rectangle, writer, false);
                PolygonElementsTex(polygon.ListOfElements, writer, bound_rectangle, false);
            }
        }
Example #9
0
        private static void AssignRadialGradientTex(FillColor fillcolor, String assignedName, float gradLength, IndentedTextWriter writer)
        {
            for (int ii = 0; ii < fillcolor.colorList.Count; ii++)
            {
                Color curcol = fillcolor.colorList[ii];
                FillColor.AssignColorRGBTex(curcol, "color" + ii.ToString(), writer);
            }

            Color firstcol = fillcolor.colorList[0];

            writer.Write("\\pgfdeclareradialshading {{{4}}} {{\\pgfpoint{{{0}pt}}{{{1}pt}}}} {{color({2}pt)=({3})",
                (fillcolor.focalPoint.X-50) * gradLength/100f , //50% is center
                (50 - fillcolor.focalPoint.Y) * gradLength / 100f,
                fillcolor.positionList[0] * gradLength / 100f,
                "color0!" + AlphaValTex(firstcol),
                assignedName);

            for (int ii = 1; ii < fillcolor.colorList.Count; ii++)
            {
                Color curcol = fillcolor.colorList[ii];
                writer.Write("; color({0}pt)=({1})",
                    fillcolor.positionList[ii] * gradLength / 100f,
                    "color" + ii.ToString() + AlphaValTex(curcol));
            }

            writer.WriteLine("}");
        }
Example #10
0
        private static void AssignLinearGradientTex(FillColor fillcolor, String assignedName, float gradwidth, float gradlength, IndentedTextWriter writer)
        {
            for (int ii = 0; ii < fillcolor.colorList.Count; ii++)
            {
                Color curcol = fillcolor.colorList[ii];
                FillColor.AssignColorRGBTex(curcol, "color" + ii.ToString(), writer);
            }

            Color firstcol = fillcolor.colorList[0];
            writer.Write("\\pgfdeclareverticalshading {{{3}}} {{ {0}pt }} {{color({1}pt)=({2})",
                gradwidth,
                fillcolor.positionList[0] * gradlength / 100f,
                "color0" + AlphaValTex(firstcol),
                assignedName);

            for (int ii = 1; ii < fillcolor.colorList.Count; ii++)
            {
                Color curcol = fillcolor.colorList[ii];
                writer.Write("; color({0}pt)=({1})",
                    fillcolor.positionList[ii] * gradlength / 100f,
                    "color" + ii.ToString() + AlphaValTex(curcol));
            }

            writer.WriteLine("}");
        }
Example #11
0
 public static void AssignGradientTex(FillColor fillcolor, String assignedName, IndentedTextWriter writer)
 {
     if (fillcolor.gradient)
     {
         if (fillcolor.radial)
         {
             float gradLength = fillcolor.FindRadialGradientLength();
             AssignRadialGradientTex(fillcolor, assignedName, gradLength, writer);
         }
         else
         {
             float gradLength = fillcolor.FindLinearGradientLength();
             float gradWidth = fillcolor.FindLinearGradientWidth();
             AssignLinearGradientTex(fillcolor, assignedName, gradWidth, gradLength, writer);
         }
     }
 }