/// <summary>A specialized enum containing alignment properties for list symbols.</summary> /// <remarks> /// A specialized enum containing alignment properties for list symbols. /// <see cref="iText.Layout.Properties.ListSymbolAlignment.LEFT"/> /// means that the items will be aligned as follows: /// 9. Item 9 /// 10. Item 10 /// Whereas /// <see cref="iText.Layout.Properties.ListSymbolAlignment.RIGHT"/> /// means the items will be aligned as follows: /// 9. Item 9 /// 10. Item 10 /// </remarks> public virtual iText.Layout.Element.List SetListSymbolAlignment(ListSymbolAlignment alignment) { SetProperty(Property.LIST_SYMBOL_ALIGNMENT, alignment); return(this); }
public override void Draw(DrawContext drawContext) { bool isTagged = drawContext.IsTaggingEnabled() && GetModelElement() is IAccessibleElement; TagTreePointer tagPointer = null; if (isTagged) { tagPointer = drawContext.GetDocument().GetTagStructureContext().GetAutoTaggingPointer(); IAccessibleElement modelElement = (IAccessibleElement)GetModelElement(); PdfName role = modelElement.GetRole(); if (role != null && !PdfName.Artifact.Equals(role)) { bool lBodyTagIsCreated = tagPointer.IsElementConnectedToTag(modelElement); if (!lBodyTagIsCreated) { tagPointer.AddTag(PdfName.LI); } else { tagPointer.MoveToTag(modelElement).MoveToParent(); } } else { isTagged = false; } } base.Draw(drawContext); // It will be null in case of overflow (only the "split" part will contain symbol renderer. if (symbolRenderer != null) { symbolRenderer.SetParent(parent); float x = occupiedArea.GetBBox().GetX(); if (childRenderers.Count > 0) { float?yLine = ((AbstractRenderer)childRenderers[0]).GetFirstYLineRecursively(); if (yLine != null) { if (symbolRenderer is TextRenderer) { ((TextRenderer)symbolRenderer).MoveYLineTo((float)yLine); } else { symbolRenderer.Move(0, (float)yLine - symbolRenderer.GetOccupiedArea().GetBBox().GetY()); } } else { symbolRenderer.Move(0, occupiedArea.GetBBox().GetY() + occupiedArea.GetBBox().GetHeight() - (symbolRenderer .GetOccupiedArea().GetBBox().GetY() + symbolRenderer.GetOccupiedArea().GetBBox().GetHeight())); } } else { symbolRenderer.Move(0, occupiedArea.GetBBox().GetY() + occupiedArea.GetBBox().GetHeight() - symbolRenderer .GetOccupiedArea().GetBBox().GetHeight() - symbolRenderer.GetOccupiedArea().GetBBox().GetY()); } ListSymbolAlignment listSymbolAlignment = (ListSymbolAlignment)parent.GetProperty <ListSymbolAlignment?>(Property .LIST_SYMBOL_ALIGNMENT, ListSymbolAlignment.RIGHT); float xPosition = x - symbolRenderer.GetOccupiedArea().GetBBox().GetX(); if (listSymbolAlignment == ListSymbolAlignment.RIGHT) { xPosition += symbolAreaWidth - symbolRenderer.GetOccupiedArea().GetBBox().GetWidth(); } symbolRenderer.Move(xPosition, 0); if (isTagged) { tagPointer.AddTag(0, PdfName.Lbl); } symbolRenderer.Draw(drawContext); if (isTagged) { tagPointer.MoveToParent(); } } if (isTagged) { tagPointer.MoveToParent(); } }
public override void Draw(DrawContext drawContext) { if (occupiedArea == null) { ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.ListItemRenderer)); logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.OCCUPIED_AREA_HAS_NOT_BEEN_INITIALIZED, "Drawing won't be performed.")); return; } if (drawContext.IsTaggingEnabled()) { LayoutTaggingHelper taggingHelper = this.GetProperty <LayoutTaggingHelper>(Property.TAGGING_HELPER); if (taggingHelper != null) { if (symbolRenderer != null) { LayoutTaggingHelper.AddTreeHints(taggingHelper, symbolRenderer); } if (taggingHelper.IsArtifact(this)) { taggingHelper.MarkArtifactHint(symbolRenderer); } else { TaggingHintKey hintKey = LayoutTaggingHelper.GetHintKey(this); TaggingHintKey parentHint = taggingHelper.GetAccessibleParentHint(hintKey); if (parentHint != null && !(StandardRoles.LI.Equals(parentHint.GetAccessibleElement().GetAccessibilityProperties ().GetRole()))) { TaggingDummyElement listItemIntermediate = new TaggingDummyElement(StandardRoles.LI); IList <TaggingHintKey> intermediateKid = JavaCollectionsUtil.SingletonList <TaggingHintKey>(LayoutTaggingHelper .GetOrCreateHintKey(listItemIntermediate)); taggingHelper.ReplaceKidHint(hintKey, intermediateKid); if (symbolRenderer != null) { taggingHelper.AddKidsHint(listItemIntermediate, JavaCollectionsUtil.SingletonList <IRenderer>(symbolRenderer )); } taggingHelper.AddKidsHint(listItemIntermediate, JavaCollectionsUtil.SingletonList <IRenderer>(this)); } } } } base.Draw(drawContext); // It will be null in case of overflow (only the "split" part will contain symbol renderer. if (symbolRenderer != null && !symbolAddedInside) { bool isRtl = BaseDirection.RIGHT_TO_LEFT.Equals(this.GetProperty <BaseDirection?>(Property.BASE_DIRECTION)); symbolRenderer.SetParent(this); float x = isRtl ? occupiedArea.GetBBox().GetRight() : occupiedArea.GetBBox().GetLeft(); ListSymbolPosition symbolPosition = (ListSymbolPosition)ListRenderer.GetListItemOrListProperty(this, parent , Property.LIST_SYMBOL_POSITION); if (symbolPosition != ListSymbolPosition.DEFAULT) { float?symbolIndent = this.GetPropertyAsFloat(Property.LIST_SYMBOL_INDENT); if (isRtl) { x += (symbolAreaWidth + (float)(symbolIndent == null ? 0 : symbolIndent)); } else { x -= (symbolAreaWidth + (float)(symbolIndent == null ? 0 : symbolIndent)); } if (symbolPosition == ListSymbolPosition.OUTSIDE) { if (isRtl) { UnitValue marginRightUV = this.GetPropertyAsUnitValue(Property.MARGIN_RIGHT); if (!marginRightUV.IsPointValue()) { ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.ListItemRenderer)); logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property .MARGIN_RIGHT)); } x -= marginRightUV.GetValue(); } else { UnitValue marginLeftUV = this.GetPropertyAsUnitValue(Property.MARGIN_LEFT); if (!marginLeftUV.IsPointValue()) { ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.ListItemRenderer)); logger.Error(MessageFormatUtil.Format(iText.IO.LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property .MARGIN_LEFT)); } x += marginLeftUV.GetValue(); } } } ApplyMargins(occupiedArea.GetBBox(), false); ApplyBorderBox(occupiedArea.GetBBox(), false); if (childRenderers.Count > 0) { float?yLine = null; for (int i = 0; i < childRenderers.Count; i++) { if (childRenderers[i].GetOccupiedArea().GetBBox().GetHeight() > 0) { yLine = ((AbstractRenderer)childRenderers[i]).GetFirstYLineRecursively(); if (yLine != null) { break; } } } if (yLine != null) { if (symbolRenderer is LineRenderer) { symbolRenderer.Move(0, (float)yLine - ((LineRenderer)symbolRenderer).GetYLine()); } else { symbolRenderer.Move(0, (float)yLine - symbolRenderer.GetOccupiedArea().GetBBox().GetY()); } } else { symbolRenderer.Move(0, occupiedArea.GetBBox().GetY() + occupiedArea.GetBBox().GetHeight() - (symbolRenderer .GetOccupiedArea().GetBBox().GetY() + symbolRenderer.GetOccupiedArea().GetBBox().GetHeight())); } } else { if (symbolRenderer is TextRenderer) { ((TextRenderer)symbolRenderer).MoveYLineTo(occupiedArea.GetBBox().GetY() + occupiedArea.GetBBox().GetHeight () - CalculateAscenderDescender()[0]); } else { symbolRenderer.Move(0, occupiedArea.GetBBox().GetY() + occupiedArea.GetBBox().GetHeight() - symbolRenderer .GetOccupiedArea().GetBBox().GetHeight() - symbolRenderer.GetOccupiedArea().GetBBox().GetY()); } } ApplyBorderBox(occupiedArea.GetBBox(), true); ApplyMargins(occupiedArea.GetBBox(), true); ListSymbolAlignment listSymbolAlignment = (ListSymbolAlignment)parent.GetProperty <ListSymbolAlignment?>(Property .LIST_SYMBOL_ALIGNMENT, isRtl ? ListSymbolAlignment.LEFT : ListSymbolAlignment.RIGHT); float dxPosition = x - symbolRenderer.GetOccupiedArea().GetBBox().GetX(); if (listSymbolAlignment == ListSymbolAlignment.RIGHT) { if (!isRtl) { dxPosition += symbolAreaWidth - symbolRenderer.GetOccupiedArea().GetBBox().GetWidth(); } } else { if (listSymbolAlignment == ListSymbolAlignment.LEFT) { if (isRtl) { dxPosition -= (symbolAreaWidth - symbolRenderer.GetOccupiedArea().GetBBox().GetWidth()); } } } if (symbolRenderer is LineRenderer) { if (isRtl) { symbolRenderer.Move(dxPosition - symbolRenderer.GetOccupiedArea().GetBBox().GetWidth(), 0); } else { symbolRenderer.Move(dxPosition, 0); } } else { symbolRenderer.Move(dxPosition, 0); } if (symbolRenderer.GetOccupiedArea().GetBBox().GetRight() > parent.GetOccupiedArea().GetBBox().GetLeft()) { BeginElementOpacityApplying(drawContext); symbolRenderer.Draw(drawContext); EndElementOpacityApplying(drawContext); } } }