Esempio n. 1
0
        public virtual void SeveralTabsInRowTest()
        {
            String   fileName    = "severalTabsInRowTest.pdf";
            String   outFileName = destinationFolder + fileName;
            String   cmpFileName = sourceFolder + "cmp_" + fileName;
            Document doc         = InitDocument(outFileName);
            float    tabInterval = doc.GetPdfDocument().GetDefaultPageSize().GetWidth() / 8;

            float[]        positions  = new float[] { tabInterval * 2, tabInterval * 4, tabInterval * 6 };
            TabAlignment[] alignments = new TabAlignment[] { TabAlignment.RIGHT, TabAlignment.CENTER, TabAlignment.CENTER };
            //        Drawable[] leaders = {null, null, null};
            ILineDrawer[] leaders = new ILineDrawer[] { new DottedLine(), new DashedLine(.5f), new SolidLine(.5f) };
            Paragraph     p       = new Paragraph();

            p.SetFontSize(8);
            IList <TabStop> tabStops = new List <TabStop>();

            for (int i = 0; i < positions.Length; ++i)
            {
                TabStop tabStop = new TabStop(positions[i], alignments[i], leaders[i]);
                tabStops.Add(tabStop);
            }
            p.AddTabStops(tabStops);
            p.Add(new Tab()).Add("ttttttttttttttttttttttttttttttttttttttttttttt").Add(new Tab()).Add(new Tab()).Add("ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\n"
                                                                                                                    );
            p.Add(new Tab()).Add(new Tab()).Add(new Tab()).Add("ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\n"
                                                               );
            p.Add(new Tab()).Add(new Tab()).Add("ttttttttttttttttttttttttttttttttttttttttttttt").Add(new Tab()).Add("ttttttttttttttttttttttttttttttttttttttttttt"
                                                                                                                    );
            doc.Add(p);
            DrawTabStopsPositions(positions, doc, 1, 0, 120);
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff" + outFileName));
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a TabStop at the appropriate position, with a specified tab
 /// alignment and an explicitly given line pattern.
 /// </summary>
 /// <remarks>
 /// Creates a TabStop at the appropriate position, with a specified tab
 /// alignment and an explicitly given line pattern. A tab alignment defines
 /// the way the textual content should be positioned with regards to this tab
 /// stop. The line pattern defines a pattern that should be repeated until
 /// the TabStop is reached. If null, the space leading up to the TabStop will
 /// be empty.
 /// </remarks>
 /// <param name="tabPosition">a <code>float</code>, measured in points</param>
 /// <param name="tabAlignment">
 /// a
 /// <see cref="iText.Layout.Properties.TabAlignment"/>
 /// value
 /// </param>
 /// <param name="tabLeader">
 /// the
 /// <see cref="iText.Kernel.Pdf.Canvas.Draw.ILineDrawer"/>
 /// value, a pattern drawing object
 /// </param>
 public TabStop(float tabPosition, TabAlignment tabAlignment, ILineDrawer tabLeader)
 {
     this.tabPosition  = tabPosition;
     this.tabAlignment = tabAlignment;
     this.tabLeader    = tabLeader;
     this.tabAnchor    = '.';
 }
Esempio n. 3
0
        public override void Draw(DrawContext drawContext)
        {
            if (occupiedArea == null)
            {
                ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.TabRenderer));
                logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED,
                                                      "Drawing won't be performed."));
                return;
            }
            ILineDrawer leader = this.GetProperty <ILineDrawer>(Property.TAB_LEADER);

            if (leader == null)
            {
                return;
            }
            bool isTagged = drawContext.IsTaggingEnabled();

            if (isTagged)
            {
                drawContext.GetCanvas().OpenTag(new CanvasArtifact());
            }
            BeginElementOpacityApplying(drawContext);
            leader.Draw(drawContext.GetCanvas(), occupiedArea.GetBBox());
            EndElementOpacityApplying(drawContext);
            if (isTagged)
            {
                drawContext.GetCanvas().CloseTag();
            }
        }
Esempio n. 4
0
        public virtual void AnchorTabStopsTest01()
        {
            String   fileName    = "anchorTabStopsTest01.pdf";
            String   outFileName = destinationFolder + fileName;
            String   cmpFileName = sourceFolder + "cmp_" + fileName;
            Document doc         = InitDocument(outFileName);
            float    tabInterval = doc.GetPdfDocument().GetDefaultPageSize().GetWidth() / 8;

            float[] positions1 = new float[] { tabInterval * 2, tabInterval * 3, tabInterval * 4, tabInterval * 5, tabInterval
                                               * 6 };
            TabAlignment[] alignments1 = new TabAlignment[] { TabAlignment.ANCHOR, TabAlignment.CENTER, TabAlignment.ANCHOR
                                                              , TabAlignment.RIGHT, TabAlignment.ANCHOR };
            ILineDrawer[] leaders1 = new ILineDrawer[] { new DottedLine(), null, new DashedLine(.5f), null, new SolidLine
                                                             (.5f) };
            char?[]   anchors1 = new char?[] { ' ', null, '\\', null, '.' };
            Paragraph p        = new Paragraph();

            p.SetFontSize(8);
            AddTabbedTextToParagraph(p, text2, positions1, alignments1, leaders1, anchors1);
            doc.Add(p);
            DrawTabStopsPositions(positions1, doc, 1, 0, 120);
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff" + outFileName));
        }
Esempio n. 5
0
        public override void Draw(DrawContext drawContext)
        {
            base.Draw(drawContext);
            ILineDrawer lineDrawer = this.GetProperty <ILineDrawer>(Property.LINE_DRAWER);

            if (lineDrawer != null)
            {
                lineDrawer.Draw(drawContext.GetCanvas(), occupiedArea.GetBBox());
            }
        }
Esempio n. 6
0
        /// <summary><inheritDoc/></summary>
        public override void DrawChildren(DrawContext drawContext)
        {
            ILineDrawer lineDrawer = this.GetProperty <ILineDrawer>(Property.LINE_DRAWER);

            if (lineDrawer != null)
            {
                Rectangle area = GetOccupiedAreaBBox();
                ApplyMargins(area, false);
                lineDrawer.Draw(drawContext.GetCanvas(), area);
            }
        }
Esempio n. 7
0
        public override LayoutResult Layout(LayoutContext layoutContext)
        {
            ILineDrawer lineDrawer = this.GetProperty <ILineDrawer>(Property.LINE_DRAWER);
            float       height     = lineDrawer != null?lineDrawer.GetLineWidth() : 0;

            occupiedArea = layoutContext.GetArea().Clone();
            ApplyMargins(occupiedArea.GetBBox(), false);
            if (occupiedArea.GetBBox().GetHeight() < height)
            {
                return(new LayoutResult(LayoutResult.NOTHING, null, null, this));
            }
            occupiedArea.GetBBox().MoveUp(occupiedArea.GetBBox().GetHeight() - height).SetHeight(height);
            ApplyMargins(occupiedArea.GetBBox(), true);
            return(new LayoutResult(LayoutResult.FULL, occupiedArea, this, null));
        }
        protected void AddLine(ILineDrawer lineDrawer)
        {
            lineDrawer.Parent = this;
            _lines.Add(new LineConfiguration(this)
            {
                Drawer    = lineDrawer,
                LinePaint = LinePaintProvider.GetNextPaint()
            });

            UpdateLineData();

            // Trigger TimeViewer selected time for the new line
            _context.SetSelectedTimeRange(_context.SelectedTimeFrom, _context.SelectedTimeTo);

            InvalidateSurface();
        }
 public MazeUiBuilder(
     ILoadCellPrefab loadCellPrefab,
     IMazeHelper mazeHelper,
     IDoorwayLoader doorwayLoader,
     ILineDrawer lineDrawer,
     ICellInformationProvider cellInformation,
     ICircleLoader circleLoader,
     IPointsAndDirectionsRetriever pointsAndDirectionsRetriever)
 {
     _loadCellPrefab  = loadCellPrefab;
     _mazeHelper      = mazeHelper;
     _doorwayLoader   = doorwayLoader;
     _lineDrawer      = lineDrawer;
     _cellInformation = cellInformation;
     _circleLoader    = circleLoader;
     _pointsAndDirectionsRetriever = pointsAndDirectionsRetriever;
 }
Esempio n. 10
0
        public virtual void SimpleTabStopsTest()
        {
            String   fileName    = "simpleTabStopsTest.pdf";
            String   outFileName = destinationFolder + fileName;
            String   cmpFileName = sourceFolder + "cmp_" + fileName;
            Document doc         = InitDocument(outFileName);
            float    tabInterval = doc.GetPdfDocument().GetDefaultPageSize().GetWidth() / 8;

            //left alignments
            float[]        positions1  = new float[] { tabInterval * 2, tabInterval * 4, tabInterval * 5 };
            TabAlignment[] alignments1 = new TabAlignment[] { TabAlignment.LEFT, TabAlignment.LEFT, TabAlignment.LEFT };
            ILineDrawer[]  leaders1    = new ILineDrawer[] { null, null, null };
            char?[]        anchors1    = new char?[] { null, null, null };
            Paragraph      p           = new Paragraph();

            p.SetFontSize(8);
            AddTabbedTextToParagraph(p, text1, positions1, alignments1, leaders1, anchors1);
            doc.Add(p);
            doc.Add(new Paragraph("\n"));
            //right alignments
            float[]        positions2  = new float[] { tabInterval * 3, tabInterval * 4, tabInterval * 6 };
            TabAlignment[] alignments2 = new TabAlignment[] { TabAlignment.RIGHT, TabAlignment.RIGHT, TabAlignment.RIGHT };
            ILineDrawer[]  leaders2    = new ILineDrawer[] { null, null, null };
            char?[]        anchors2    = new char?[] { null, null, null };
            p = new Paragraph();
            p.SetFontSize(8);
            AddTabbedTextToParagraph(p, text1, positions2, alignments2, leaders2, anchors2);
            doc.Add(p);
            doc.Add(new Paragraph("\n"));
            //center alignments
            float[]        positions3  = new float[] { tabInterval * 3, tabInterval * 4, tabInterval * 6 };
            TabAlignment[] alignments3 = new TabAlignment[] { TabAlignment.CENTER, TabAlignment.CENTER, TabAlignment.CENTER };
            ILineDrawer[]  leaders3    = new ILineDrawer[] { null, null, null };
            char?[]        anchors3    = new char?[] { null, null, null };
            p = new Paragraph();
            p.SetFontSize(8);
            AddTabbedTextToParagraph(p, text1, positions3, alignments3, leaders3, anchors3);
            doc.Add(p);
            DrawTabStopsPositions(positions1, doc, 1, 0, 120);
            DrawTabStopsPositions(positions2, doc, 1, 125, 95);
            DrawTabStopsPositions(positions3, doc, 1, 235, 95);
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff"));
        }
Esempio n. 11
0
        private static void AddParagraphWithTabs(Document document, ILineDrawer line, float width)
        {
            List <TabStop> tabStops = new List <TabStop>();

            // Create a TabStop at the middle of the page
            tabStops.Add(new TabStop(width / 2, TabAlignment.CENTER, line));

            // Create a TabStop at the end of the page
            tabStops.Add(new TabStop(width, TabAlignment.LEFT, line));

            Paragraph p = new Paragraph().AddTabStops(tabStops);

            p
            .Add(new Tab())
            .Add("Text in the middle")
            .Add(new Tab());
            document.Add(p);
        }
Esempio n. 12
0
        public override void Draw(DrawContext drawContext)
        {
            ILineDrawer leader = this.GetProperty <ILineDrawer>(Property.TAB_LEADER);

            if (leader == null)
            {
                return;
            }
            bool isTagged = drawContext.IsTaggingEnabled();

            if (isTagged)
            {
                drawContext.GetCanvas().OpenTag(new CanvasArtifact());
            }
            leader.Draw(drawContext.GetCanvas(), occupiedArea.GetBBox());
            if (isTagged)
            {
                drawContext.GetCanvas().CloseTag();
            }
        }
Esempio n. 13
0
        /// <summary><inheritDoc/></summary>
        public override void DrawChildren(DrawContext drawContext)
        {
            ILineDrawer lineDrawer = this.GetProperty <ILineDrawer>(Property.LINE_DRAWER);

            if (lineDrawer != null)
            {
                PdfCanvas canvas   = drawContext.GetCanvas();
                bool      isTagged = drawContext.IsTaggingEnabled();
                if (isTagged)
                {
                    canvas.OpenTag(new CanvasArtifact());
                }
                Rectangle area = GetOccupiedAreaBBox();
                ApplyMargins(area, false);
                lineDrawer.Draw(canvas, area);
                if (isTagged)
                {
                    canvas.CloseTag();
                }
            }
        }
Esempio n. 14
0
        /// <summary><inheritDoc/></summary>
        public override LayoutResult Layout(LayoutContext layoutContext)
        {
            Rectangle parentBBox = layoutContext.GetArea().GetBBox().Clone();

            if (this.GetProperty <float?>(Property.ROTATION_ANGLE) != null)
            {
                parentBBox.MoveDown(AbstractRenderer.INF - parentBBox.GetHeight()).SetHeight(AbstractRenderer.INF);
            }
            ILineDrawer lineDrawer = this.GetProperty <ILineDrawer>(Property.LINE_DRAWER);
            float       height     = lineDrawer != null?lineDrawer.GetLineWidth() : 0;

            occupiedArea = new LayoutArea(layoutContext.GetArea().GetPageNumber(), parentBBox.Clone());
            ApplyMargins(occupiedArea.GetBBox(), false);
            float?calculatedWidth = RetrieveWidth(layoutContext.GetArea().GetBBox().GetWidth());

            if (calculatedWidth == null)
            {
                calculatedWidth = occupiedArea.GetBBox().GetWidth();
            }
            if ((occupiedArea.GetBBox().GetHeight() < height || occupiedArea.GetBBox().GetWidth() < calculatedWidth) &&
                !HasOwnProperty(Property.FORCED_PLACEMENT))
            {
                return(new LayoutResult(LayoutResult.NOTHING, null, null, this, this));
            }
            occupiedArea.GetBBox().SetWidth((float)calculatedWidth).MoveUp(occupiedArea.GetBBox().GetHeight() - height
                                                                           ).SetHeight(height);
            ApplyMargins(occupiedArea.GetBBox(), true);
            if (this.GetProperty <float?>(Property.ROTATION_ANGLE) != null)
            {
                ApplyRotationLayout(layoutContext.GetArea().GetBBox().Clone());
                if (IsNotFittingLayoutArea(layoutContext.GetArea()))
                {
                    if (!true.Equals(GetPropertyAsBoolean(Property.FORCED_PLACEMENT)))
                    {
                        return(new LayoutResult(LayoutResult.NOTHING, null, null, this, this));
                    }
                }
            }
            return(new LayoutResult(LayoutResult.FULL, occupiedArea, this, null));
        }
Esempio n. 15
0
 public virtual void SetTabLeader(ILineDrawer tabLeader)
 {
     this.tabLeader = tabLeader;
 }
Esempio n. 16
0
 /// <summary>
 /// Creates a custom line separator with line style defined by custom
 /// <see cref="iText.Kernel.Pdf.Canvas.Draw.ILineDrawer"/>
 /// interface instance
 /// </summary>
 /// <param name="lineDrawer">line drawer instance</param>
 public LineSeparator(ILineDrawer lineDrawer)
 {
     SetProperty(Property.LINE_DRAWER, lineDrawer);
 }