Draws the text.
The coordinate passed are the positions of the barcode.
$x1 and $y1 represent the top left corner.
$x2 and $y2 represent the bottom right corner.

@param resource $im
@param int $x1
@param int $y1
@param int $x2
@param int $y2
977180
public /*internal*/ function draw($im, $x1, $y1, $x2, $y2) {
        $x = 0;
        $y = 0;

        $fontDimension = $this->font->getDimension();

        if ($this->position === self::POSITION_TOP || $this->position === self::POSITION_BOTTOM) {
            if ($this->position === self::POSITION_TOP) {
                $y = $y1 - $this->spacing - $fontDimension[1];
            } elseif ($this->position === self::POSITION_BOTTOM) {
                $y = $y2 + $this->spacing;
            }

            if ($this->alignment === self::ALIGN_CENTER) {
                $x = ($x2 - $x1) / 2 + $x1 - $fontDimension[0] / 2 + $this->offset;
            } elseif ($this->alignment === self::ALIGN_LEFT)  {
                $x = $x1 + $this->offset;
            } else {
                $x = $x2 + $this->offset - $fontDimension[0];
            }
        } else {
            if ($this->position === self::POSITION_LEFT) {
                $x = $x1 - $this->spacing - $fontDimension[0];
            } elseif ($this->position === self::POSITION_RIGHT) {
                $x = $x2 + $this->spacing;
            }

            if ($this->alignment === self::ALIGN_CENTER) {
                $y = ($y2 - $y1) / 2 + $y1 - $fontDimension[1] / 2 + $this->offset;
            } elseif ($this->alignment === self::ALIGN_TOP)  {
                $y = $y1 + $this->offset;
            } else {
                $y = $y2 + $this->offset - $fontDimension[1];
            }
        }

        $this->font->setText($this->text);
        $this->font->draw($im, $x, $y);
    }
1209972
protected void drawText(Graphics2D g, String text)
    {
        // top left corner
        int x = getAbsoluteContentX();
        int y = getAbsoluteContentY();

        //Align Y with baseline
        FontMetrics fm = g.getFontMetrics();
        Rectangle2D rect = fm.getStringBounds(text, g);
        int ofs = getFirstInlineBoxBaseline();
        if (ofs == -1)
            ofs = ctx.getBaselineOffset(); //use the font baseline
        
        // Draw the string
        g.drawString(text,
                     x + ((int) rect.getX()) - ((int) Math.round(rect.getWidth())),
                     y + ofs);
    }
499778
public function draw($X, $Y, $Width, $Height, array $Format = [])
    {
        $Values = isset($Format["Values"]) ? $Format["Values"] : VOID;
        $IndicatorSections = isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : null;
        $ValueDisplay = isset($Format["ValueDisplay"]) ? $Format["ValueDisplay"] : INDICATOR_VALUE_BUBBLE;
        $SectionsMargin = isset($Format["SectionsMargin"]) ? $Format["SectionsMargin"] : 4;
        $DrawLeftHead = isset($Format["DrawLeftHead"]) ? $Format["DrawLeftHead"] : true;
        $DrawRightHead = isset($Format["DrawRightHead"]) ? $Format["DrawRightHead"] : true;
        $HeadSize = isset($Format["HeadSize"]) ? $Format["HeadSize"] : floor($Height / 4);
        $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 4;
        $CaptionLayout = isset($Format["CaptionLayout"]) ? $Format["CaptionLayout"] : INDICATOR_CAPTION_EXTENDED;
        $CaptionPosition = isset($Format["CaptionPosition"]) ? $Format["CaptionPosition"] : INDICATOR_CAPTION_INSIDE;
        $CaptionColorFactor = isset($Format["CaptionColorFactor"]) ? $Format["CaptionColorFactor"] : null;
        $CaptionR = isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255;
        $CaptionG = isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255;
        $CaptionB = isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255;
        $CaptionAlpha = isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100;
        $SubCaptionColorFactor = isset($Format["SubCaptionColorFactor"]) ? $Format["SubCaptionColorFactor"] : null;
        $SubCaptionR = isset($Format["SubCaptionR"]) ? $Format["SubCaptionR"] : 50;
        $SubCaptionG = isset($Format["SubCaptionG"]) ? $Format["SubCaptionG"] : 50;
        $SubCaptionB = isset($Format["SubCaptionB"]) ? $Format["SubCaptionB"] : 50;
        $SubCaptionAlpha = isset($Format["SubCaptionAlpha"]) ? $Format["SubCaptionAlpha"] : 100;
        $ValueFontName = isset($Format["ValueFontName"]) ? $Format["ValueFontName"] : $this->pChartObject->FontName;
        $ValueFontSize = isset($Format["ValueFontSize"]) ? $Format["ValueFontSize"] : $this->pChartObject->FontSize;
        $CaptionFontName = isset($Format["CaptionFontName"])
            ? $Format["CaptionFontName"] : $this->pChartObject->FontName
        ;
        $CaptionFontSize = isset($Format["CaptionFontSize"])
            ? $Format["CaptionFontSize"] : $this->pChartObject->FontSize
        ;
        $Unit = isset($Format["Unit"]) ? $Format["Unit"] : "";

        /* Convert the Values to display to an array if needed */
        if (!is_array($Values)) {
            $Values = [$Values];
        }

        /* No section, let's die */
        if ($IndicatorSections == null) {
            return 0;
        }

        /* Determine indicator visual configuration */
        $OverallMin = $IndicatorSections[0]["End"];
        $OverallMax = $IndicatorSections[0]["Start"];
        foreach ($IndicatorSections as $Key => $Settings) {
            if ($Settings["End"] > $OverallMax) {
                $OverallMax = $Settings["End"];
            }
            if ($Settings["Start"] < $OverallMin) {
                $OverallMin = $Settings["Start"];
            }
        }
        $RealWidth = $Width - (count($IndicatorSections) - 1) * $SectionsMargin;
        $XScale = $RealWidth / ($OverallMax - $OverallMin);

        $X1 = $X;
        $ValuesPos = [];
        foreach ($IndicatorSections as $Key => $Settings) {
            $Color = ["R" => $Settings["R"], "G" => $Settings["G"], "B" => $Settings["B"]];
            $Caption = $Settings["Caption"];
            $SubCaption = $Settings["Start"] . " - " . $Settings["End"];

            $X2 = $X1 + ($Settings["End"] - $Settings["Start"]) * $XScale;

            if ($Key == 0 && $DrawLeftHead) {
                $Poly = [];
                $Poly[] = $X1 - 1;
                $Poly[] = $Y;
                $Poly[] = $X1 - 1;
                $Poly[] = $Y + $Height;
                $Poly[] = $X1 - 1 - $HeadSize;
                $Poly[] = $Y + ($Height / 2);
                $this->pChartObject->drawPolygon($Poly, $Color);
                $this->pChartObject->drawLine($X1 - 2, $Y, $X1 - 2 - $HeadSize, $Y + ($Height / 2), $Color);
                $this->pChartObject->drawLine(
                    $X1 - 2,
                    $Y + $Height,
                    $X1 - 2 - $HeadSize,
                    $Y + ($Height / 2),
                    $Color
                );
            }

            /* Determine the position of the breaks */
            $Break = [];
            foreach ($Values as $iKey => $Value) {
                if ($Value >= $Settings["Start"] && $Value <= $Settings["End"]) {
                    $XBreak = $X1 + ($Value - $Settings["Start"]) * $XScale;
                    $ValuesPos[$Value] = $XBreak;
                    $Break[] = floor($XBreak);
                }
            }

            if ($ValueDisplay == INDICATOR_VALUE_LABEL) {
                if (!count($Break)) {
                    $this->pChartObject->drawFilledRectangle($X1, $Y, $X2, $Y + $Height, $Color);
                } else {
                    sort($Break);
                    $Poly = [];
                    $Poly[] = $X1;
                    $Poly[] = $Y;
                    $LastPointWritten = false;
                    foreach ($Break as $iKey => $Value) {
                        if ($Value - 5 >= $X1) {
                            $Poly[] = $Value - 5;
                            $Poly[] = $Y;
                        } elseif ($X1 - ($Value - 5) > 0) {
                            $Offset = $X1 - ($Value - 5);
                            $Poly = [$X1, $Y + $Offset];
                        }

                        $Poly[] = $Value;
                        $Poly[] = $Y + 5;

                        if ($Value + 5 <= $X2) {
                            $Poly[] = $Value + 5;
                            $Poly[] = $Y;
                        } elseif (($Value + 5) > $X2) {
                            $Offset = ($Value + 5) - $X2;
                            $Poly[] = $X2;
                            $Poly[] = $Y + $Offset;
                            $LastPointWritten = true;
                        }
                    }
                    if (!$LastPointWritten) {
                        $Poly[] = $X2;
                        $Poly[] = $Y;
                    }
                    $Poly[] = $X2;
                    $Poly[] = $Y + $Height;
                    $Poly[] = $X1;
                    $Poly[] = $Y + $Height;

                    $this->pChartObject->drawPolygon($Poly, $Color);
                }
            } else {
                $this->pChartObject->drawFilledRectangle($X1, $Y, $X2, $Y + $Height, $Color);
            }

            if ($Key == count($IndicatorSections) - 1 && $DrawRightHead) {
                $Poly = [];
                $Poly[] = $X2 + 1;
                $Poly[] = $Y;
                $Poly[] = $X2 + 1;
                $Poly[] = $Y + $Height;
                $Poly[] = $X2 + 1 + $HeadSize;
                $Poly[] = $Y + ($Height / 2);
                $this->pChartObject->drawPolygon($Poly, $Color);
                $this->pChartObject->drawLine($X2 + 1, $Y, $X2 + 1 + $HeadSize, $Y + ($Height / 2), $Color);
                $this->pChartObject->drawLine(
                    $X2 + 1,
                    $Y + $Height,
                    $X2 + 1 + $HeadSize,
                    $Y + ($Height / 2),
                    $Color
                );
            }

            $YOffset = 0;
            $XOffset = 0;
            if ($CaptionPosition == INDICATOR_CAPTION_INSIDE) {
                $TxtPos = $this->pChartObject->getTextBox(
                    $X1,
                    $Y + $Height + $TextPadding,
                    $CaptionFontName,
                    $CaptionFontSize,
                    0,
                    $Caption
                );
                $YOffset = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding;

                if ($CaptionLayout == INDICATOR_CAPTION_EXTENDED) {
                    $TxtPos = $this->pChartObject->getTextBox(
                        $X1,
                        $Y + $Height + $TextPadding,
                        $CaptionFontName,
                        $CaptionFontSize,
                        0,
                        $SubCaption
                    );
                    $YOffset = $YOffset + ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding * 2;
                }
                $XOffset = $TextPadding;
            }

            if ($CaptionColorFactor == null) {
                $CaptionColor = [
                    "Align" => TEXT_ALIGN_TOPLEFT,
                    "FontName" => $CaptionFontName,
                    "FontSize" => $CaptionFontSize,
                    "R" => $CaptionR,
                    "G" => $CaptionG,
                    "B" => $CaptionB,
                    "Alpha" => $CaptionAlpha
                ];
            } else {
                $CaptionColor = [
                    "Align" => TEXT_ALIGN_TOPLEFT,
                    "FontName" => $CaptionFontName,
                    "FontSize" => $CaptionFontSize,
                    "R" => $Settings["R"] + $CaptionColorFactor,
                    "G" => $Settings["G"] + $CaptionColorFactor,
                    "B" => $Settings["B"] + $CaptionColorFactor
                ];
            }

            if ($SubCaptionColorFactor == null) {
                $SubCaptionColor = [
                    "Align" => TEXT_ALIGN_TOPLEFT,
                    "FontName" => $CaptionFontName,
                    "FontSize" => $CaptionFontSize,
                    "R" => $SubCaptionR,
                    "G" => $SubCaptionG,
                    "B" => $SubCaptionB,
                    "Alpha" => $SubCaptionAlpha
                ];
            } else {
                $SubCaptionColor = [
                    "Align" => TEXT_ALIGN_TOPLEFT,
                    "FontName" => $CaptionFontName,
                    "FontSize" => $CaptionFontSize,
                    "R" => $Settings["R"] + $SubCaptionColorFactor,
                    "G" => $Settings["G"] + $SubCaptionColorFactor,
                    "B" => $Settings["B"] + $SubCaptionColorFactor
                ];
            }

            $RestoreShadow = $this->pChartObject->Shadow;
            $this->pChartObject->Shadow = false;

            if ($CaptionLayout == INDICATOR_CAPTION_DEFAULT) {
                $this->pChartObject->drawText($X1, $Y + $Height + $TextPadding, $Caption, $CaptionColor);
            } elseif ($CaptionLayout == INDICATOR_CAPTION_EXTENDED) {
                $TxtPos = $this->pChartObject->getTextBox(
                    $X1,
                    $Y + $Height + $TextPadding,
                    $CaptionFontName,
                    $CaptionFontSize,
                    0,
                    $Caption
                );
                $CaptionHeight = $TxtPos[0]["Y"] - $TxtPos[2]["Y"];

                $this->pChartObject->drawText(
                    $X1 + $XOffset,
                    $Y + $Height - $YOffset + $TextPadding,
                    $Caption,
                    $CaptionColor
                );
                $this->pChartObject->drawText(
                    $X1 + $XOffset,
                    $Y + $Height - $YOffset + $CaptionHeight + $TextPadding * 2,
                    $SubCaption,
                    $SubCaptionColor
                );
            }

            $this->pChartObject->Shadow = $RestoreShadow;

            $X1 = $X2 + $SectionsMargin;
        }

        $RestoreShadow = $this->pChartObject->Shadow;
        $this->pChartObject->Shadow = false;

        foreach ($Values as $Key => $Value) {
            if ($Value >= $OverallMin && $Value <= $OverallMax) {
                foreach ($IndicatorSections as $Key => $Settings) {
                    if ($Value >= $Settings["Start"] && $Value <= $Settings["End"]) {
                        $X1 = $ValuesPos[$Value]; //$X + $Key*$SectionsMargin + ($Value - $OverallMin) * $XScale;

                        if ($ValueDisplay == INDICATOR_VALUE_BUBBLE) {
                            $TxtPos = $this->pChartObject->getTextBox(
                                $X1,
                                $Y,
                                $ValueFontName,
                                $ValueFontSize,
                                0,
                                $Value . $Unit
                            );
                            $Radius = floor(($TxtPos[1]["X"] - $TxtPos[0]["X"] + $TextPadding * 4) / 2);

                            $this->pChartObject->drawFilledCircle(
                                $X1,
                                $Y,
                                $Radius + 4,
                                [
                                    "R" => $Settings["R"] + 20,
                                    "G" => $Settings["G"] + 20,
                                    "B" => $Settings["B"] + 20
                                ]
                            );
                            $this->pChartObject->drawFilledCircle(
                                $X1,
                                $Y,
                                $Radius,
                                ["R" => 255, "G" => 255, "B" => 255]
                            );

                            $TextSettings = [
                                "Align" => TEXT_ALIGN_MIDDLEMIDDLE,
                                "FontName" => $ValueFontName,
                                "FontSize" => $ValueFontSize
                            ];
                            $this->pChartObject->drawText($X1 - 1, $Y - 1, $Value . $Unit, $TextSettings);
                        } elseif ($ValueDisplay == INDICATOR_VALUE_LABEL) {
                            $Caption = [
                                [
                                    "Format" => [
                                        "R" => $Settings["R"],
                                        "G" => $Settings["G"],
                                        "B" => $Settings["B"],
                                        "Alpha" => 100
                                    ],
                                    "Caption" => $Value . $Unit
                                ]
                            ];
                            $this->pChartObject->drawLabelBox(
                                floor($X1),
                                floor($Y) + 2,
                                "Value - " . $Settings["Caption"],
                                $Caption
                            );
                        }
                    }
                    $X1 = $X2 + $SectionsMargin;
                }
            }
        }
        $this->pChartObject->Shadow = $RestoreShadow;
    }
808123
public function draw2DRing($X, $Y, array $Format = [])
    {
        $OuterRadius = isset($Format["Radius"]) ? $Format["Radius"] : 60; // For compatibility
        $OuterRadius = isset($Format["OuterRadius"]) ? $Format["OuterRadius"] : $OuterRadius;
        $Precision = isset($Format["Precision"]) ? $Format["Precision"] : 0;
        $InnerRadius = isset($Format["InnerRadius"]) ? $Format["InnerRadius"] : 30;
        $Border = isset($Format["Border"]) ? $Format["Border"] : false;
        $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : 255;
        $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : 255;
        $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : 255;
        $BorderAlpha = isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : 100;
        $Shadow = isset($Format["Shadow"]) ? $Format["Shadow"] : false;
        $DrawLabels = isset($Format["DrawLabels"]) ? $Format["DrawLabels"] : false;
        $LabelStacked = isset($Format["LabelStacked"]) ? $Format["LabelStacked"] : false;
        $LabelColor = isset($Format["LabelColor"]) ? $Format["LabelColor"] : PIE_LABEL_COLOR_MANUAL;
        $LabelR = isset($Format["LabelR"]) ? $Format["LabelR"] : 0;
        $LabelG = isset($Format["LabelG"]) ? $Format["LabelG"] : 0;
        $LabelB = isset($Format["LabelB"]) ? $Format["LabelB"] : 0;
        $LabelAlpha = isset($Format["LabelAlpha"]) ? $Format["LabelAlpha"] : 100;
        $WriteValues = isset($Format["WriteValues"]) ? $Format["WriteValues"] : null; //PIE_VALUE_PERCENTAGE
        $ValuePadding = isset($Format["ValuePadding"]) ? $Format["ValuePadding"] : 5;
        $ValuePosition = isset($Format["ValuePosition"]) ? $Format["ValuePosition"] : PIE_VALUE_OUTSIDE;
        $ValueSuffix = isset($Format["ValueSuffix"]) ? $Format["ValueSuffix"] : "";
        $ValueR = isset($Format["ValueR"]) ? $Format["ValueR"] : 255;
        $ValueG = isset($Format["ValueG"]) ? $Format["ValueG"] : 255;
        $ValueB = isset($Format["ValueB"]) ? $Format["ValueB"] : 255;
        $ValueAlpha = isset($Format["ValueAlpha"]) ? $Format["ValueAlpha"] : 100;
        $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : false;

        /* Data Processing */
        $Data = $this->pDataObject->getData();
        $Palette = $this->pDataObject->getPalette();

        /* Do we have an abscissa serie defined? */
        if ($Data["Abscissa"] == "") {
            return PIE_NO_ABSCISSA;
        }

        /* Try to find the data serie */
        $DataSerie = null;
        foreach ($Data["Series"] as $SerieName => $SerieData) {
            if ($SerieName != $Data["Abscissa"]) {
                $DataSerie = $SerieName;
            }
        }

        /* Do we have data to compute? */
        if (!$DataSerie) {
            return PIE_NO_DATASERIE;
        }

        /* Remove unused data */
        list($Data, $Palette) = $this->clean0Values($Data, $Palette, $DataSerie, $Data["Abscissa"]);

        /* Compute the pie sum */
        $SerieSum = $this->pDataObject->getSum($DataSerie);

        /* Do we have data to draw? */
        if ($SerieSum == 0) {
            return PIE_SUMISNULL;
        }

        /* Dump the real number of data to draw */
        $Values = [];
        foreach ($Data["Series"][$DataSerie]["Data"] as $Key => $Value) {
            if ($Value != 0) {
                $Values[] = $Value;
            }
        }

        /* Compute the wasted angular space between series */
        if (count($Values) == 1) {
            $WastedAngular = 0;
        } else {
            $WastedAngular = 0;
        } // count($Values)

        /* Compute the scale */
        $ScaleFactor = (360 - $WastedAngular) / $SerieSum;

        $RestoreShadow = $this->pChartObject->Shadow;
        if ($this->pChartObject->Shadow) {
            $this->pChartObject->Shadow = false;

            $ShadowFormat = $Format;
            $ShadowFormat["Shadow"] = true;
            $this->draw2DRing(
                $X + $this->pChartObject->ShadowX,
                $Y + $this->pChartObject->ShadowY,
                $ShadowFormat
            );
        }

        /* Draw the polygon pie elements */
        $Step = 360 / (2 * PI * $OuterRadius);
        $Offset = 0;
        $ID = 0;
        foreach ($Values as $Key => $Value) {
            if ($Shadow) {
                $Settings = [
                    "R" => $this->pChartObject->ShadowR,
                    "G" => $this->pChartObject->ShadowG,
                    "B" => $this->pChartObject->ShadowB,
                    "Alpha" => $this->pChartObject->Shadowa
                ];
                $BorderColor = $Settings;
            } else {
                if (!isset($Palette[$ID]["R"])) {
                    $Color = $this->pChartObject->getRandomColor();
                    $Palette[$ID] = $Color;
                    $this->pDataObject->savePalette($ID, $Color);
                }
                $Settings = [
                    "R" => $Palette[$ID]["R"],
                    "G" => $Palette[$ID]["G"],
                    "B" => $Palette[$ID]["B"],
                    "Alpha" => $Palette[$ID]["Alpha"]
                ];

                if ($Border) {
                    $BorderColor = [
                        "R" => $BorderR,
                        "G" => $BorderG,
                        "B" => $BorderB,
                        "Alpha" => $BorderAlpha
                    ];
                } else {
                    $BorderColor = $Settings;
                }
            }

            $Plots = [];
            $Boundaries = [];
            $AAPixels = [];
            $EndAngle = $Offset + ($Value * $ScaleFactor);
            if ($EndAngle > 360) {
                $EndAngle = 360;
            }
            for ($i = $Offset; $i <= $EndAngle; $i = $i + $Step) {
                $Xc = cos(($i - 90) * PI / 180) * $OuterRadius + $X;
                $Yc = sin(($i - 90) * PI / 180) * $OuterRadius + $Y;

                if (!isset($Boundaries[0]["X1"])) {
                    $Boundaries[0]["X1"] = $Xc;
                    $Boundaries[0]["Y1"] = $Yc;
                }
                $AAPixels[] = [$Xc, $Yc];

                if ($i < 90) {
                    $Yc++;
                }
                if ($i > 180 && $i < 270) {
                    $Xc++;
                }
                if ($i >= 270) {
                    $Xc++;
                    $Yc++;
                }

                $Plots[] = $Xc;
                $Plots[] = $Yc;
            }
            $Boundaries[1]["X1"] = $Xc;
            $Boundaries[1]["Y1"] = $Yc;
            $Lasti = $EndAngle;

            for ($i = $EndAngle; $i >= $Offset; $i = $i - $Step) {
                $Xc = cos(($i - 90) * PI / 180) * ($InnerRadius - 1) + $X;
                $Yc = sin(($i - 90) * PI / 180) * ($InnerRadius - 1) + $Y;

                if (!isset($Boundaries[1]["X2"])) {
                    $Boundaries[1]["X2"] = $Xc;
                    $Boundaries[1]["Y2"] = $Yc;
                }
                $AAPixels[] = [$Xc, $Yc];

                $Xc = cos(($i - 90) * PI / 180) * $InnerRadius + $X;
                $Yc = sin(($i - 90) * PI / 180) * $InnerRadius + $Y;

                if ($i < 90) {
                    $Yc++;
                }
                if ($i > 180 && $i < 270) {
                    $Xc++;
                }
                if ($i >= 270) {
                    $Xc++;
                    $Yc++;
                }

                $Plots[] = $Xc;
                $Plots[] = $Yc;
            }
            $Boundaries[0]["X2"] = $Xc;
            $Boundaries[0]["Y2"] = $Yc;

            /* Draw the polygon */
            $this->pChartObject->drawPolygon($Plots, $Settings);
            if ($RecordImageMap && !$Shadow) {
                $this->pChartObject->addToImageMap(
                    "POLY",
                    $this->arraySerialize($Plots),
                    $this->pChartObject->toHTMLColor(
                        $Palette[$ID]["R"],
                        $Palette[$ID]["G"],
                        $Palette[$ID]["B"]
                    ),
                    $Data["Series"][$Data["Abscissa"]]["Data"][$Key],
                    $Value
                );
            }

            /* Smooth the edges using AA */
            foreach ($AAPixels as $Pos) {
                $this->pChartObject->drawAntialiasPixel($Pos[0], $Pos[1], $BorderColor);
            }
            $this->pChartObject->drawLine(
                $Boundaries[0]["X1"],
                $Boundaries[0]["Y1"],
                $Boundaries[0]["X2"],
                $Boundaries[0]["Y2"],
                $BorderColor
            );
            $this->pChartObject->drawLine(
                $Boundaries[1]["X1"],
                $Boundaries[1]["Y1"],
                $Boundaries[1]["X2"],
                $Boundaries[1]["Y2"],
                $BorderColor
            );

            if ($DrawLabels && !$Shadow) {
                if ($LabelColor == PIE_LABEL_COLOR_AUTO) {
                    $Settings = [
                        "FillR" => $Palette[$ID]["R"],
                        "FillG" => $Palette[$ID]["G"],
                        "FillB" => $Palette[$ID]["B"],
                        "Alpha" => $Palette[$ID]["Alpha"]
                    ];
                } else {
                    $Settings = [
                        "FillR" => $LabelR,
                        "FillG" => $LabelG,
                        "FillB" => $LabelB,
                        "Alpha" => $LabelAlpha
                    ];
                }

                $Angle = ($EndAngle - $Offset) / 2 + $Offset;
                $Xc = cos(($Angle - 90) * PI / 180) * $OuterRadius + $X;
                $Yc = sin(($Angle - 90) * PI / 180) * $OuterRadius + $Y;

                $Label = $Data["Series"][$Data["Abscissa"]]["Data"][$Key];

                if ($LabelStacked) {
                    $this->writePieLabel($Xc, $Yc, $Label, $Angle, $Settings, true, $X, $Y, $OuterRadius);
                } else {
                    $this->writePieLabel($Xc, $Yc, $Label, $Angle, $Settings, false);
                }
            }

            $Offset = $Lasti;
            $ID++;
        }

        if ($DrawLabels && $LabelStacked) {
            $this->writeShiftedLabels();
        }

        if ($WriteValues && !$Shadow) {
            $Step = 360 / (2 * PI * $OuterRadius);
            $Offset = 0;
            foreach ($Values as $Key => $Value) {
                $EndAngle = $Offset + ($Value * $ScaleFactor);
                if ($EndAngle > 360) {
                    $EndAngle = 360;
                }

                $Angle = $Offset + ($Value * $ScaleFactor) / 2;
                if ($ValuePosition == PIE_VALUE_OUTSIDE) {
                    $Xc = cos(($Angle - 90) * PI / 180) * ($OuterRadius + $ValuePadding) + $X;
                    $Yc = sin(($Angle - 90) * PI / 180) * ($OuterRadius + $ValuePadding) + $Y;
                    if ($Angle >= 0 && $Angle <= 90) {
                        $Align = TEXT_ALIGN_BOTTOMLEFT;
                    }
                    if ($Angle > 90 && $Angle <= 180) {
                        $Align = TEXT_ALIGN_TOPLEFT;
                    }
                    if ($Angle > 180 && $Angle <= 270) {
                        $Align = TEXT_ALIGN_TOPRIGHT;
                    }
                    if ($Angle > 270) {
                        $Align = TEXT_ALIGN_BOTTOMRIGHT;
                    }
                } else {
                    $Xc = cos(($Angle - 90) * PI / 180)
                        * (($OuterRadius - $InnerRadius) / 2 + $InnerRadius)
                        + $X
                    ;
                    $Yc = sin(($Angle - 90) * PI / 180)
                        * (($OuterRadius - $InnerRadius) / 2 + $InnerRadius)
                        + $Y
                    ;
                    $Align = TEXT_ALIGN_MIDDLEMIDDLE;
                }

                if ($WriteValues == PIE_VALUE_PERCENTAGE) {
                    $Display = round((100 / $SerieSum) * $Value, $Precision) . "%";
                } elseif ($WriteValues == PIE_VALUE_NATURAL) {
                    $Display = $Value . $ValueSuffix;
                } else {
                    $Display = "";
                }
                $this->pChartObject->drawText(
                    $Xc,
                    $Yc,
                    $Display,
                    ["Align" => $Align, "R" => $ValueR, "G" => $ValueG, "B" => $ValueB]
                );
                $Offset = $EndAngle;
            }
        }

        $this->pChartObject->Shadow = $RestoreShadow;

        return PIE_RENDERED;
    }
776190
@Override
    public void drawText(Graphics2D graphics, int width, int height) {
        if(StringUtils.isBlank(text) || StringUtils.isBlank(domainName)) {
            return ;
        }
        
        int x = 0, y = 0; 
        int fontsize = ((int)(width * textWidthPercent)) / domainName.length();
        if (fontsize < minFontSize) {
            return;
        }
        
        float fsize = (float)fontsize;
        Font font = domainFont.deriveFont(fsize);
        graphics.setFont(font);
        FontRenderContext context = graphics.getFontRenderContext();
        int sw = (int) font.getStringBounds(domainName, context).getWidth();

        x = width - sw - fontsize;
        y = height - fontsize;
        if(x <= 0 || y <= 0) {
            return ;
        }

        if (fontShadowColor != null) {
            graphics.setColor(fontShadowColor);
            graphics.drawString(domainName, x + getShadowTranslation(fontsize), y + getShadowTranslation(fontsize));
        }
        graphics.setColor(fontColor);
        graphics.drawString(domainName, x, y);
        
        //draw company name
        fsize = (float)fontsize;
        font = defaultFont.deriveFont(fsize);
        graphics.setFont(font);
        context = graphics.getFontRenderContext();
        sw = (int) font.getStringBounds(text, context).getWidth();
        x = width - sw - fontsize;
        y = height - (int)(fontsize * 2.5);
        if(x <= 0 || y <= 0) {
            return ;
        }
        
        if (fontShadowColor != null) {
            graphics.setColor(fontShadowColor);
            graphics.drawString(text, x + getShadowTranslation(fontsize), y + getShadowTranslation(fontsize));
        }
        graphics.setColor(fontColor);
        graphics.drawString(text, x, y);
    }
970515
public function draw($im) {
        // The following code is exactly the same as EAN13. We just add a 0 in front of the code !
        $this->text = '0' . $this->text; // We will remove it at the end... don't worry

        parent::draw($im);

        // We remove the 0 in front, as we said :)
        $this->text = substr($this->text, 1);
    }
371454
function drawText( &$font, $textColor, $text, $x, $y, $angle,
                       $imageObject = null )
    {
        if ( !$font )
        {
            eZDebug::writeWarning( 'Cannot render text, no font is set', __METHOD__ );
            return false;
        }
        if ( !$textColor )
        {
            eZDebug::writeWarning( 'Cannot render text, no text color is set', __METHOD__ );
            return false;
        }
        if ( is_string( $textColor ) )
            $textColor = $this->color( $textColor );
        if ( $textColor === null )
        {
            eZDebug::writeWarning( 'Cannot render text, invalid text color', __METHOD__ );
            return false;
        }

        $x += $font->xAdjustment();
        $y += $font->yAdjustment();

        if ( $imageObject === null )
            $imageObject = $this->ImageObject;

        ImageTTFText( $imageObject, $font->pointSize(), $angle, $x, $y,
                      $textColor, $font->realFile(), $text );
    }
535730
public static function xym(float $x, float $y, float $m, int $srid = 0) : Point
    {
        return new Point(CoordinateSystem::xym($srid), $x, $y, $m);
    }
910315
public function createTextWatermark($text, $width, $height, $prefix = 'wm_', $textAngle = -30.0, $textOpacity = 0.4) {
		$imagick = new Imagick($this->dir.$this->filename);
	 	
 	 	$draw = new ImagickDraw();
	 	
	 	//set font size proportional to target image size
	 	$fontSize = min($imagick->getImageWidth(), $imagick->getImageHeight()) * 0.12;
	 	$draw->setFontSize($fontSize);
	 	
	 	//text transparency
	 	$draw->setFillOpacity($textOpacity);
	 	
	 	//write text in specified positions
	 	$draw->setGravity(Imagick::GRAVITY_CENTER);
	 	$imagick->annotateImage($draw, 0, 0, $textAngle, $text);
	 	$draw->setGravity(Imagick::GRAVITY_NORTH);
	 	$imagick->annotateImage($draw, 0, 0, $textAngle, $text);
	 	$draw->setGravity(Imagick::GRAVITY_SOUTH);
	 	
	 	$imagick->annotateImage($draw, 0, 0, $textAngle, $text);
 	
	 	//if image width or height is smaller than requested dimensions, then use the source image size
	 	$width = min($width, $imagick->getImageWidth());
	 	$height = min($height, $imagick->getImageHeight());
	 	if($width < 0 && $height < 0) {
	 		$width = $imagick->getImageWidth();
	 		$height = $imagick->getImageHeight();
	 	}
	 	
 		$bestfit = true;
		if($this->defaultDimension == 'width') {
			$height = 0;
			$bestfit = false;
		} else if($this->defaultDimension == 'height') {
			$width = 0;
			$bestfit = false;
		}
		
		$result = $imagick->thumbnailImage($width, $height, $bestfit);
		if ($result) {
			$thumbName = $this->createThumbName($this->filename, $prefix);
			$imagick->writeImage($this->dir.$thumbName);
			$imagick->clear();
			$imagick->destroy();
		
			return $thumbName;
		}
		
		return false;
	}
697152
public function drawLabelBox($X, $Y, $Title, array $Captions, array $Format = [])
    {
        $NoTitle = isset($Format["NoTitle"]) ? $Format["NoTitle"] : null;
        $BoxWidth = isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 50;
        $DrawSerieColor = isset($Format["DrawSerieColor"]) ? $Format["DrawSerieColor"] : true;
        $SerieBoxSize = isset($Format["SerieBoxSize"]) ? $Format["SerieBoxSize"] : 6;
        $SerieBoxSpacing = isset($Format["SerieBoxSpacing"]) ? $Format["SerieBoxSpacing"] : 4;
        $VerticalMargin = isset($Format["VerticalMargin"]) ? $Format["VerticalMargin"] : 10;
        $HorizontalMargin = isset($Format["HorizontalMargin"]) ? $Format["HorizontalMargin"] : 8;
        $R = isset($Format["R"]) ? $Format["R"] : $this->FontColorR;
        $G = isset($Format["G"]) ? $Format["G"] : $this->FontColorG;
        $B = isset($Format["B"]) ? $Format["B"] : $this->FontColorB;
        $FontName = isset($Format["FontName"]) ? $this->loadFont($Format["FontName"], 'fonts') : $this->FontName;
        $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
        $TitleMode = isset($Format["TitleMode"]) ? $Format["TitleMode"] : LABEL_TITLE_NOBACKGROUND;
        $TitleR = isset($Format["TitleR"]) ? $Format["TitleR"] : $R;
        $TitleG = isset($Format["TitleG"]) ? $Format["TitleG"] : $G;
        $TitleB = isset($Format["TitleB"]) ? $Format["TitleB"] : $B;
        $TitleBackgroundR = isset($Format["TitleBackgroundR"]) ? $Format["TitleBackgroundR"] : 0;
        $TitleBackgroundG = isset($Format["TitleBackgroundG"]) ? $Format["TitleBackgroundG"] : 0;
        $TitleBackgroundB = isset($Format["TitleBackgroundB"]) ? $Format["TitleBackgroundB"] : 0;
        $GradientStartR = isset($Format["GradientStartR"]) ? $Format["GradientStartR"] : 255;
        $GradientStartG = isset($Format["GradientStartG"]) ? $Format["GradientStartG"] : 255;
        $GradientStartB = isset($Format["GradientStartB"]) ? $Format["GradientStartB"] : 255;
        $GradientEndR = isset($Format["GradientEndR"]) ? $Format["GradientEndR"] : 220;
        $GradientEndG = isset($Format["GradientEndG"]) ? $Format["GradientEndG"] : 220;
        $GradientEndB = isset($Format["GradientEndB"]) ? $Format["GradientEndB"] : 220;
        $BoxAlpha = isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 100;

        if (!$DrawSerieColor) {
            $SerieBoxSize = 0;
            $SerieBoxSpacing = 0;
        }

        $TxtPos = $this->getTextBox($X, $Y, $FontName, $FontSize, 0, $Title);
        $TitleWidth = ($TxtPos[1]["X"] - $TxtPos[0]["X"]) + $VerticalMargin * 2;
        $TitleHeight = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]);

        if ($NoTitle) {
            $TitleWidth = 0;
            $TitleHeight = 0;
        }

        $CaptionWidth = 0;
        $CaptionHeight = -$HorizontalMargin;
        foreach ($Captions as $Key => $Caption) {
            $TxtPos = $this->getTextBox(
                $X,
                $Y,
                $FontName,
                $FontSize,
                0,
                $Caption["Caption"]
            );
            $CaptionWidth = max(
                $CaptionWidth,
                ($TxtPos[1]["X"] - $TxtPos[0]["X"]) + $VerticalMargin * 2
            );
            $CaptionHeight = $CaptionHeight
                + max(($TxtPos[0]["Y"] - $TxtPos[2]["Y"]), ($SerieBoxSize + 2))
                + $HorizontalMargin
            ;
        }

        if ($CaptionHeight <= 5) {
            $CaptionHeight = $CaptionHeight + $HorizontalMargin / 2;
        }

        if ($DrawSerieColor) {
            $CaptionWidth = $CaptionWidth + $SerieBoxSize + $SerieBoxSpacing;
        }

        $BoxWidth = max($BoxWidth, $TitleWidth, $CaptionWidth);

        $XMin = $X - 5 - floor(($BoxWidth - 10) / 2);
        $XMax = $X + 5 + floor(($BoxWidth - 10) / 2);

        $RestoreShadow = $this->Shadow;
        if ($this->Shadow == true) {
            $this->Shadow = false;

            $Poly = [];
            $Poly[] = $X + $this->ShadowX;
            $Poly[] = $Y + $this->ShadowX;
            $Poly[] = $X + 5 + $this->ShadowX;
            $Poly[] = $Y - 5 + $this->ShadowX;
            $Poly[] = $XMax + $this->ShadowX;
            $Poly[] = $Y - 5 + $this->ShadowX;

            if ($NoTitle) {
                $Poly[] = $XMax + $this->ShadowX;
                $Poly[] = $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2 + $this->ShadowX;
                $Poly[] = $XMin + $this->ShadowX;
                $Poly[] = $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2 + $this->ShadowX;
            } else {
                $Poly[] = $XMax + $this->ShadowX;
                $Poly[] = $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3 + $this->ShadowX;
                $Poly[] = $XMin + $this->ShadowX;
                $Poly[] = $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3 + $this->ShadowX;
            }

            $Poly[] = $XMin + $this->ShadowX;
            $Poly[] = $Y - 5 + $this->ShadowX;
            $Poly[] = $X - 5 + $this->ShadowX;
            $Poly[] = $Y - 5 + $this->ShadowX;
            $this->drawPolygon(
                $Poly,
                [
                    "R" => $this->ShadowR,
                    "G" => $this->ShadowG,
                    "B" => $this->ShadowB,
                    "Alpha" => $this->Shadowa
                ]
            );
        }

        /* Draw the background */
        $GradientSettings = [
            "StartR" => $GradientStartR,
            "StartG" => $GradientStartG,
            "StartB" => $GradientStartB,
            "EndR" => $GradientEndR,
            "EndG" => $GradientEndG,
            "EndB" => $GradientEndB,
            "Alpha" => $BoxAlpha
        ];
        if ($NoTitle) {
            $this->drawGradientArea(
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMax,
                $Y - 6,
                DIRECTION_VERTICAL,
                $GradientSettings
            );
        } else {
            $this->drawGradientArea(
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMax,
                $Y - 6,
                DIRECTION_VERTICAL,
                $GradientSettings
            );
        }
        $Poly = [];
        $Poly[] = $X;
        $Poly[] = $Y;
        $Poly[] = $X - 5;
        $Poly[] = $Y - 5;
        $Poly[] = $X + 5;
        $Poly[] = $Y - 5;
        $this->drawPolygon(
            $Poly,
            [
                "R" => $GradientEndR,
                "G" => $GradientEndG,
                "B" => $GradientEndB,
                "Alpha" => $BoxAlpha,
                "NoBorder" => true
            ]
        );

        /* Outer border */
        $OuterBorderColor = $this->allocateColor($this->Picture, 100, 100, 100, $BoxAlpha);
        imageline($this->Picture, $XMin, $Y - 5, $X - 5, $Y - 5, $OuterBorderColor);
        imageline($this->Picture, $X, $Y, $X - 5, $Y - 5, $OuterBorderColor);
        imageline($this->Picture, $X, $Y, $X + 5, $Y - 5, $OuterBorderColor);
        imageline($this->Picture, $X + 5, $Y - 5, $XMax, $Y - 5, $OuterBorderColor);
        if ($NoTitle) {
            imageline(
                $this->Picture,
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMin,
                $Y - 5,
                $OuterBorderColor
            );
            imageline(
                $this->Picture,
                $XMax,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMax,
                $Y - 5,
                $OuterBorderColor
            );
            imageline(
                $this->Picture,
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMax,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $OuterBorderColor
            );
        } else {
            imageline(
                $this->Picture,
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMin,
                $Y - 5,
                $OuterBorderColor
            );
            imageline(
                $this->Picture,
                $XMax,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMax,
                $Y - 5,
                $OuterBorderColor
            );
            imageline(
                $this->Picture,
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMax,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $OuterBorderColor
            );
        }

        /* Inner border */
        $InnerBorderColor = $this->allocateColor($this->Picture, 255, 255, 255, $BoxAlpha);
        imageline($this->Picture, $XMin + 1, $Y - 6, $X - 5, $Y - 6, $InnerBorderColor);
        imageline($this->Picture, $X, $Y - 1, $X - 5, $Y - 6, $InnerBorderColor);
        imageline($this->Picture, $X, $Y - 1, $X + 5, $Y - 6, $InnerBorderColor);
        imageline($this->Picture, $X + 5, $Y - 6, $XMax - 1, $Y - 6, $InnerBorderColor);
        if ($NoTitle) {
            imageline(
                $this->Picture,
                $XMin + 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMin + 1,
                $Y - 6,
                $InnerBorderColor
            );
            imageline(
                $this->Picture,
                $XMax - 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMax - 1,
                $Y - 6,
                $InnerBorderColor
            );
            imageline(
                $this->Picture,
                $XMin + 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $XMax - 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 2,
                $InnerBorderColor
            );
        } else {
            imageline(
                $this->Picture,
                $XMin + 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMin + 1,
                $Y - 6,
                $InnerBorderColor
            );
            imageline(
                $this->Picture,
                $XMax - 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMax - 1,
                $Y - 6,
                $InnerBorderColor
            );
            imageline(
                $this->Picture,
                $XMin + 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMax - 1,
                $Y - 4 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $InnerBorderColor
            );
        }

        /* Draw the separator line */
        if ($TitleMode == LABEL_TITLE_NOBACKGROUND && !$NoTitle) {
            $YPos = $Y - 7 - $CaptionHeight - $HorizontalMargin - $HorizontalMargin / 2;
            $XMargin = $VerticalMargin / 2;
            $this->drawLine(
                $XMin + $XMargin,
                $YPos + 1,
                $XMax - $XMargin,
                $YPos + 1,
                [
                    "R" => $GradientEndR,
                    "G" => $GradientEndG,
                    "B" => $GradientEndB,
                    "Alpha" => $BoxAlpha
                ]
            );
            $this->drawLine(
                $XMin + $XMargin,
                $YPos,
                $XMax - $XMargin,
                $YPos,
                [
                    "R" => $GradientStartR,
                    "G" => $GradientStartG,
                    "B" => $GradientStartB,
                    "Alpha" => $BoxAlpha
                ]
            );
        } elseif ($TitleMode == LABEL_TITLE_BACKGROUND) {
            $this->drawFilledRectangle(
                $XMin,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin * 3,
                $XMax,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin + $HorizontalMargin / 2,
                [
                    "R" => $TitleBackgroundR,
                    "G" => $TitleBackgroundG,
                    "B" => $TitleBackgroundB,
                    "Alpha" => $BoxAlpha
                ]
            );
            imageline(
                $this->Picture,
                $XMin + 1,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin + $HorizontalMargin / 2 + 1,
                $XMax - 1,
                $Y - 5 - $TitleHeight - $CaptionHeight - $HorizontalMargin + $HorizontalMargin / 2 + 1,
                $InnerBorderColor
            );
        }

        /* Write the description */
        if (!$NoTitle) {
            $this->drawText(
                $XMin + $VerticalMargin,
                $Y - 7 - $CaptionHeight - $HorizontalMargin * 2,
                $Title,
                [
                    "Align" => TEXT_ALIGN_BOTTOMLEFT,
                    "R" => $TitleR,
                    "G" => $TitleG,
                    "B" => $TitleB
                ]
            );
        }

        /* Write the value */
        $YPos = $Y - 5 - $HorizontalMargin;
        $XPos = $XMin + $VerticalMargin + $SerieBoxSize + $SerieBoxSpacing;
        foreach ($Captions as $Key => $Caption) {
            $CaptionTxt = $Caption["Caption"];
            $TxtPos = $this->getTextBox($XPos, $YPos, $FontName, $FontSize, 0, $CaptionTxt);
            $CaptionHeight = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]);

            /* Write the serie color if needed */
            if ($DrawSerieColor) {
                $BoxSettings = [
                    "R" => $Caption["Format"]["R"],
                    "G" => $Caption["Format"]["G"],
                    "B" => $Caption["Format"]["B"],
                    "Alpha" => $Caption["Format"]["Alpha"],
                    "BorderR" => 0,
                    "BorderG" => 0,
                    "BorderB" => 0
                ];
                $this->drawFilledRectangle(
                    $XMin + $VerticalMargin,
                    $YPos - $SerieBoxSize,
                    $XMin + $VerticalMargin + $SerieBoxSize,
                    $YPos,
                    $BoxSettings
                );
            }

            $this->drawText($XPos, $YPos, $CaptionTxt, ["Align" => TEXT_ALIGN_BOTTOMLEFT]);

            $YPos = $YPos - $CaptionHeight - $HorizontalMargin;
        }

        $this->Shadow = $RestoreShadow;
    }
59439
public function drawArrow($X1, $Y1, $X2, $Y2, array $Format = [])
    {
        $FillR = isset($Format["FillR"]) ? $Format["FillR"] : 0;
        $FillG = isset($Format["FillG"]) ? $Format["FillG"] : 0;
        $FillB = isset($Format["FillB"]) ? $Format["FillB"] : 0;
        $BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : $FillR;
        $BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : $FillG;
        $BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : $FillB;
        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
        $Size = isset($Format["Size"]) ? $Format["Size"] : 10;
        $Ratio = isset($Format["Ratio"]) ? $Format["Ratio"] : .5;
        $TwoHeads = isset($Format["TwoHeads"]) ? $Format["TwoHeads"] : false;
        $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : false;

        /* Calculate the line angle */
        $Angle = $this->getAngle($X1, $Y1, $X2, $Y2);

        /* Override Shadow support, this will be managed internally */
        $RestoreShadow = $this->Shadow;
        if ($this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0) {
            $this->Shadow = false;
            $this->drawArrow(
                $X1 + $this->ShadowX,
                $Y1 + $this->ShadowY,
                $X2 + $this->ShadowX,
                $Y2 + $this->ShadowY,
                [
                    "FillR" => $this->ShadowR,
                    "FillG" => $this->ShadowG,
                    "FillB" => $this->ShadowB,
                    "Alpha" => $this->Shadowa,
                    "Size" => $Size,
                    "Ratio" => $Ratio,
                    "TwoHeads" => $TwoHeads,
                    "Ticks" => $Ticks
                ]
            );
        }

        /* Draw the 1st Head */
        $TailX = cos(($Angle - 180) * PI / 180) * $Size + $X2;
        $TailY = sin(($Angle - 180) * PI / 180) * $Size + $Y2;

        $Points = [];
        $Points[] = $X2;
        $Points[] = $Y2;
        $Points[] = cos(($Angle - 90) * PI / 180) * $Size * $Ratio + $TailX;
        $Points[] = sin(($Angle - 90) * PI / 180) * $Size * $Ratio + $TailY;
        $Points[] = cos(($Angle - 270) * PI / 180) * $Size * $Ratio + $TailX;
        $Points[] = sin(($Angle - 270) * PI / 180) * $Size * $Ratio + $TailY;
        $Points[] = $X2;
        $Points[] = $Y2;

        /* Visual correction */
        if ($Angle == 180 || $Angle == 360) {
            $Points[4] = $Points[2];
        }
        if ($Angle == 90 || $Angle == 270) {
            $Points[5] = $Points[3];
        }

        $ArrowColor = $this->allocateColor($this->Picture, $FillR, $FillG, $FillB, $Alpha);
        ImageFilledPolygon($this->Picture, $Points, 4, $ArrowColor);

        $this->drawLine(
            $Points[0],
            $Points[1],
            $Points[2],
            $Points[3],
            ["R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $Alpha]
        );
        $this->drawLine(
            $Points[2],
            $Points[3],
            $Points[4],
            $Points[5],
            ["R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $Alpha]
        );
        $this->drawLine(
            $Points[0],
            $Points[1],
            $Points[4],
            $Points[5],
            ["R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $Alpha]
        );

        /* Draw the second head */
        if ($TwoHeads) {
            $Angle = $this->getAngle($X2, $Y2, $X1, $Y1);

            $TailX2 = cos(($Angle - 180) * PI / 180) * $Size + $X1;
            $TailY2 = sin(($Angle - 180) * PI / 180) * $Size + $Y1;

            $Points = [];
            $Points[] = $X1;
            $Points[] = $Y1;
            $Points[] = cos(($Angle - 90) * PI / 180) * $Size * $Ratio + $TailX2;
            $Points[] = sin(($Angle - 90) * PI / 180) * $Size * $Ratio + $TailY2;
            $Points[] = cos(($Angle - 270) * PI / 180) * $Size * $Ratio + $TailX2;
            $Points[] = sin(($Angle - 270) * PI / 180) * $Size * $Ratio + $TailY2;
            $Points[] = $X1;
            $Points[] = $Y1;

            /* Visual correction */
            if ($Angle == 180 || $Angle == 360) {
                $Points[4] = $Points[2];
            }
            if ($Angle == 90 || $Angle == 270) {
                $Points[5] = $Points[3];
            }

            $ArrowColor = $this->allocateColor($this->Picture, $FillR, $FillG, $FillB, $Alpha);
            ImageFilledPolygon($this->Picture, $Points, 4, $ArrowColor);

            $this->drawLine(
                $Points[0],
                $Points[1],
                $Points[2],
                $Points[3],
                ["R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $Alpha]
            );
            $this->drawLine(
                $Points[2],
                $Points[3],
                $Points[4],
                $Points[5],
                ["R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $Alpha]
            );
            $this->drawLine(
                $Points[0],
                $Points[1],
                $Points[4],
                $Points[5],
                ["R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $Alpha]
            );

            $this->drawLine(
                $TailX,
                $TailY,
                $TailX2,
                $TailY2,
                ["R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $Alpha, "Ticks" => $Ticks]
            );
        } else {
            $this->drawLine(
                $X1,
                $Y1,
                $TailX,
                $TailY,
                ["R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $Alpha, "Ticks" => $Ticks]
            );
        }
        /* Re-enable shadows */
        $this->Shadow = $RestoreShadow;
    }
708456
public function line($x1, $y1, $x2, $y2, $color, $width, $style = array())
    {
        $this->_set_stroke_color($color);
        $this->_set_line_style($width, "butt", "", $style);

        $this->_pdf->line($x1, $this->y($y1),
            $x2, $this->y($y2));
        $this->_set_line_transparency("Normal", $this->_current_opacity);
    }
92424
public function draw($im) {
        // Starting Code
        $this->drawChar($im, '001', true);

        // Code
        for ($i = 0; $i < 2; $i++) {
            $this->drawChar($im, self::inverse($this->findCode($this->text[$i]), $this->codeParity[intval($this->text) % 4][$i]), false);
            if ($i === 0) {
                $this->drawChar($im, '00', false);    // Inter-char
            }
        }

        $this->drawText($im, 0, 0, $this->positionX, $this->thickness);
    }
225315
public function drawLine($X1, $Y1, $X2, $Y2, array $Format = [])
    {
        $R = isset($Format["R"]) ? $Format["R"] : 0;
        $G = isset($Format["G"]) ? $Format["G"] : 0;
        $B = isset($Format["B"]) ? $Format["B"] : 0;
        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
        $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : null;
        $Cpt = isset($Format["Cpt"]) ? $Format["Cpt"] : 1;
        $Mode = isset($Format["Mode"]) ? $Format["Mode"] : 1;
        $Weight = isset($Format["Weight"]) ? $Format["Weight"] : null;
        $Threshold = isset($Format["Threshold"]) ? $Format["Threshold"] : null;

        if ($this->Antialias == false && $Ticks == null) {
            if ($this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0) {
                $ShadowColor = $this->allocateColor(
                    $this->Picture,
                    $this->ShadowR,
                    $this->ShadowG,
                    $this->ShadowB,
                    $this->Shadowa
                );
                imageline(
                    $this->Picture,
                    $X1 + $this->ShadowX,
                    $Y1 + $this->ShadowY,
                    $X2 + $this->ShadowX,
                    $Y2 + $this->ShadowY,
                    $ShadowColor
                );
            }

            $Color = $this->allocateColor($this->Picture, $R, $G, $B, $Alpha);
            imageline($this->Picture, $X1, $Y1, $X2, $Y2, $Color);
            return 0;
        }

        $Distance = sqrt(($X2 - $X1) * ($X2 - $X1) + ($Y2 - $Y1) * ($Y2 - $Y1));
        if ($Distance == 0) {
            return -1;
        }

        /* Derivative algorithm for overweighted lines, re-route to polygons primitives */
        if ($Weight != null) {
            $Angle = $this->getAngle($X1, $Y1, $X2, $Y2);
            $PolySettings = ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "BorderAlpha" => $Alpha];

            if ($Ticks == null) {
                $Points = [];
                $Points[] = cos(deg2rad($Angle - 90)) * $Weight + $X1;
                $Points[] = sin(deg2rad($Angle - 90)) * $Weight + $Y1;
                $Points[] = cos(deg2rad($Angle + 90)) * $Weight + $X1;
                $Points[] = sin(deg2rad($Angle + 90)) * $Weight + $Y1;
                $Points[] = cos(deg2rad($Angle + 90)) * $Weight + $X2;
                $Points[] = sin(deg2rad($Angle + 90)) * $Weight + $Y2;
                $Points[] = cos(deg2rad($Angle - 90)) * $Weight + $X2;
                $Points[] = sin(deg2rad($Angle - 90)) * $Weight + $Y2;

                $this->drawPolygon($Points, $PolySettings);
            } else {
                for ($i = 0; $i <= $Distance; $i = $i + $Ticks * 2) {
                    $Xa = (($X2 - $X1) / $Distance) * $i + $X1;
                    $Ya = (($Y2 - $Y1) / $Distance) * $i + $Y1;
                    $Xb = (($X2 - $X1) / $Distance) * ($i + $Ticks) + $X1;
                    $Yb = (($Y2 - $Y1) / $Distance) * ($i + $Ticks) + $Y1;

                    $Points = [];
                    $Points[] = cos(deg2rad($Angle - 90)) * $Weight + $Xa;
                    $Points[] = sin(deg2rad($Angle - 90)) * $Weight + $Ya;
                    $Points[] = cos(deg2rad($Angle + 90)) * $Weight + $Xa;
                    $Points[] = sin(deg2rad($Angle + 90)) * $Weight + $Ya;
                    $Points[] = cos(deg2rad($Angle + 90)) * $Weight + $Xb;
                    $Points[] = sin(deg2rad($Angle + 90)) * $Weight + $Yb;
                    $Points[] = cos(deg2rad($Angle - 90)) * $Weight + $Xb;
                    $Points[] = sin(deg2rad($Angle - 90)) * $Weight + $Yb;

                    $this->drawPolygon($Points, $PolySettings);
                }
            }

            return 1;
        }

        $XStep = ($X2 - $X1) / $Distance;
        $YStep = ($Y2 - $Y1) / $Distance;

        for ($i = 0; $i <= $Distance; $i++) {
            $X = $i * $XStep + $X1;
            $Y = $i * $YStep + $Y1;

            $Color = ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha];

            if ($Threshold != null) {
                foreach ($Threshold as $Key => $Parameters) {
                    if ($Y <= $Parameters["MinX"] && $Y >= $Parameters["MaxX"]) {
                        if (isset($Parameters["R"])) {
                            $RT = $Parameters["R"];
                        } else {
                            $RT = 0;
                        }
                        if (isset($Parameters["G"])) {
                            $GT = $Parameters["G"];
                        } else {
                            $GT = 0;
                        }
                        if (isset($Parameters["B"])) {
                            $BT = $Parameters["B"];
                        } else {
                            $BT = 0;
                        }
                        if (isset($Parameters["Alpha"])) {
                            $AlphaT = $Parameters["Alpha"];
                        } else {
                            $AlphaT = 0;
                        }
                        $Color = ["R" => $RT, "G" => $GT, "B" => $BT, "Alpha" => $AlphaT];
                    }
                }
            }

            if ($Ticks != null) {
                if ($Cpt % $Ticks == 0) {
                    $Cpt = 0;
                    if ($Mode == 1) {
                        $Mode = 0;
                    } else {
                        $Mode = 1;
                    }
                }

                if ($Mode == 1) {
                    $this->drawAntialiasPixel($X, $Y, $Color);
                }
                $Cpt++;
            } else {
                $this->drawAntialiasPixel($X, $Y, $Color);
            }
        }

        return [$Cpt, $Mode];
    }
744131
public function svgLine($x1, $y1, $x2, $y2)
    {
        // get the Closing operator
        $op='S';

        // drawing
        $this->_Point($x1, $y1, true);
        $this->_Line($x2, $y2, true);
        $this->_out($op);
    }
536976
@Override
	public void draw(Canvas c, Projection pProjection) {
		if (mLocation != null && isMyLocationEnabled()) {
			drawMyLocation(c, pProjection, mLocation);
		}
	}
595160
public function do_text(
        $text,
        $offsetX = 0,
        $offsetY = 0,
        $opacity = 1.0,
        $color = 0x000000,
        $size = 12,
        $font_file = null
    ) {
        $draw = new \ImagickDraw();
        $textColor = sprintf('rgb(%u,%u,%u)', ($color >> 16) & 0xFF, ($color >> 8) & 0xFF, $color & 0xFF);
        $draw->setFillColor(new \ImagickPixel($textColor));
        if ($font_file) {
            $draw->setFont($this->alias->resolve($font_file));
        }
        $draw->setFontSize($size);
        $draw->setFillOpacity($opacity);
        $draw->setGravity(\Imagick::GRAVITY_NORTHWEST);
        $this->_image->annotateImage($draw, $offsetX, $offsetY, 0, $text);
        $draw->destroy();

        return $this;
    }