Пример #1
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));
        }
Пример #2
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));
        }