Exemplo n.º 1
0
        public void AddLeader(int leaderPattern, int leaderLengthMinimum,
                              int leaderLengthOptimum, int leaderLengthMaximum,
                              int ruleStyle, int ruleThickness,
                              int leaderPatternWidth, int leaderAlignment)
        {
            WordArea leaderPatternArea;
            int leaderLength = 0;
            char dotIndex = '.';
            int dotWidth =
                currentFontState.GetWidth(currentFontState.MapCharacter(dotIndex));
            char whitespaceIndex = ' ';
            int whitespaceWidth =
                currentFontState.GetWidth(currentFontState.MapCharacter(whitespaceIndex));

            int remainingWidth = this.getRemainingWidth();

            if ((remainingWidth <= leaderLengthOptimum)
                || (remainingWidth <= leaderLengthMaximum))
            {
                leaderLength = remainingWidth;
            }
            else if ((remainingWidth > leaderLengthOptimum)
                && (remainingWidth > leaderLengthMaximum))
            {
                leaderLength = leaderLengthMaximum;
            }
            else if ((leaderLengthOptimum > leaderLengthMaximum)
                && (leaderLengthOptimum < remainingWidth))
            {
                leaderLength = leaderLengthOptimum;
            }

            if (leaderLength <= 0)
            {
                return;
            }

            switch (leaderPattern)
            {
                case LeaderPattern.SPACE:
                    InlineSpace spaceArea = new InlineSpace(leaderLength);
                    pendingAreas.Add(spaceArea);
                    break;
                case LeaderPattern.RULE:
                    LeaderArea leaderArea = new LeaderArea(fontState, red, green,
                                                           blue, "", leaderLength,
                                                           leaderPattern,
                                                           ruleThickness, ruleStyle);
                    leaderArea.setYOffset(placementOffset);
                    pendingAreas.Add(leaderArea);
                    break;
                case LeaderPattern.DOTS:
                    if (leaderPatternWidth < dotWidth)
                    {
                        leaderPatternWidth = 0;
                    }
                    if (leaderPatternWidth == 0)
                    {
                        pendingAreas.Add(this.buildSimpleLeader(dotIndex,
                                                                leaderLength));
                    }
                    else
                    {
                        if (leaderAlignment == LeaderAlignment.REFERENCE_AREA)
                        {
                            int spaceBeforeLeader =
                                this.getLeaderAlignIndent(leaderLength,
                                                          leaderPatternWidth);
                            if (spaceBeforeLeader != 0)
                            {
                                pendingAreas.Add(new InlineSpace(spaceBeforeLeader,
                                                                 false));
                                pendingWidth += spaceBeforeLeader;
                                leaderLength -= spaceBeforeLeader;
                            }
                        }

                        InlineSpace spaceBetweenDots =
                            new InlineSpace(leaderPatternWidth - dotWidth, false);

                        leaderPatternArea = new WordArea(currentFontState, this.red,
                                                         this.green, this.blue,
                                                         ".", dotWidth);
                        leaderPatternArea.setYOffset(placementOffset);
                        int dotsFactor =
                            (int)Math.Floor(((double)leaderLength)
                                / ((double)leaderPatternWidth));

                        for (int i = 0; i < dotsFactor; i++)
                        {
                            pendingAreas.Add(leaderPatternArea);
                            pendingAreas.Add(spaceBetweenDots);
                        }
                        pendingAreas.Add(new InlineSpace(leaderLength
                            - dotsFactor
                                * leaderPatternWidth));
                    }
                    break;
                case LeaderPattern.USECONTENT:
                    FonetDriver.ActiveDriver.FireFonetError(
                        "leader-pattern=\"use-content\" not supported by this version of FO.NET");
                    return;
            }
            pendingWidth += leaderLength;
            prev = TEXT;
        }
Exemplo n.º 2
0
        /**
         * render leader area
         *
         * @param area area to render
         */

        public void RenderLeaderArea(LeaderArea area) {
            int rx = this.currentXPosition;
            int ry = this.currentYPosition;
            int w = area.getContentWidth();
            int h = area.GetHeight();
            int th = area.getRuleThickness();
            int st = area.getRuleStyle();

            // checks whether thickness is = 0, because of bug in pdf (or where?),
            // a line with thickness 0 is still displayed
            if (th != 0) {
                switch (st) {
                    case RuleStyle.DOUBLE:
                        AddLine(rx, ry, rx + w, ry, th/3, st,
                                new PdfColor(area.getRed(), area.getGreen(),
                                             area.getBlue()));
                        AddLine(rx, ry + (2*th/3), rx + w, ry + (2*th/3),
                                th/3, st,
                                new PdfColor(area.getRed(), area.getGreen(),
                                             area.getBlue()));
                        break;
                    case RuleStyle.GROOVE:
                        AddLine(rx, ry, rx + w, ry, th/2, st,
                                new PdfColor(area.getRed(), area.getGreen(),
                                             area.getBlue()));
                        AddLine(rx, ry + (th/2), rx + w, ry + (th/2), th/2, st,
                                new PdfColor(255, 255, 255));
                        break;
                    case RuleStyle.RIDGE:
                        AddLine(rx, ry, rx + w, ry, th/2, st,
                                new PdfColor(255, 255, 255));
                        AddLine(rx, ry + (th/2), rx + w, ry + (th/2), th/2, st,
                                new PdfColor(area.getRed(), area.getGreen(),
                                             area.getBlue()));
                        break;
                    default:
                        AddLine(rx, ry, rx + w, ry, th, st,
                                new PdfColor(area.getRed(), area.getGreen(),
                                             area.getBlue()));
                        break;
                }
                this.currentXPosition += area.getContentWidth();
                this.currentYPosition += th;
            }
        }