/// <summary> /// This method updates child views and clears the batch of events. /// </summary> protected void SendBatch() { // If there are child views and the batch was filled, fireStatementStopped update method if (child != null) { // Convert to object arrays EventBean[] newData = null; EventBean[] oldData = null; if (!currentBatch.IsEmpty()) { newData = currentBatch.ToArray(); } if (lastBatch != null && !lastBatch.IsEmpty()) { oldData = lastBatch.ToArray(); } // Post new data (current batch) and old data (prior batch) if (newData != null || oldData != null) { agentInstanceContext.InstrumentationProvider.QViewIndicate( lengthBatchViewFactory, newData, oldData); child.Update(newData, oldData); agentInstanceContext.InstrumentationProvider.AViewIndicate(); } } lastBatch = currentBatch; currentBatch = new LinkedHashSet<EventBean>(); }
public override void Update(EventBean[] newData, EventBean[] oldData) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QViewProcessIRStream(this, _timeBatchViewFactory.ViewName, newData, oldData); } if (oldData != null) { for (int i = 0; i < oldData.Length; i++) { _currentBatch.Remove(oldData[i]); InternalHandleRemoved(oldData[i]); } } // we don't care about removed data from a prior view if ((newData == null) || (newData.Length == 0)) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AViewProcessIRStream(); } return; } // If we have an empty window about to be filled for the first time, schedule a callback if (_currentBatch.IsEmpty()) { if (_currentReferencePoint == null) { _currentReferencePoint = _initialReferencePoint; if (_currentReferencePoint == null) { _currentReferencePoint = _agentInstanceContext.StatementContext.SchedulingService.Time; } } // Schedule the next callback if there is none currently scheduled if (!_isCallbackScheduled) { ScheduleCallback(); _isCallbackScheduled = true; } } // add data points to the timeWindow foreach (EventBean newEvent in newData) { _currentBatch.Add(newEvent); } // We do not update child views, since we batch the events. if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AViewProcessIRStream(); } }
private bool RectanglesEqualWithEps(IList <Rectangle> cacheRects, IList <Rectangle> keyRects) { if (keyRects == null || cacheRects.Count != keyRects.Count) { return(false); } ICollection <Rectangle> cacheRectsSet = new LinkedHashSet <Rectangle>(cacheRects); foreach (Rectangle keyArea in keyRects) { bool found = false; foreach (Rectangle cacheArea in cacheRectsSet) { if (keyArea.EqualsWithEpsilon(cacheArea)) { found = true; cacheRectsSet.Remove(cacheArea); break; } } if (!found) { break; } } return(cacheRectsSet.IsEmpty()); }
/// <summary> /// This method updates child views and clears the batch of events. /// We schedule a new callback at this time if there were events in the batch. /// </summary> protected void SendBatch() { _isCallbackScheduled = false; // If there are child views and the batch was filled, fireStatementStopped update method if (HasViews) { // Convert to object arrays EventBean[] newData = null; EventBean[] oldData = null; if (!_currentBatch.IsEmpty()) { newData = _currentBatch.ToArray(); } if ((_lastBatch != null) && (!_lastBatch.IsEmpty())) { oldData = _lastBatch.ToArray(); } if ((newData != null) || (oldData != null) || _isForceOutput) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QViewIndicate(this, _timeBatchViewFactory.ViewName, newData, oldData); } UpdateChildren(newData, oldData); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AViewIndicate(); } } } // Only if forceOutput is enabled or // there have been any events in this or the last interval do we schedule a callback, // such as to not waste resources when no events arrive. if ((!_currentBatch.IsEmpty()) || ((_lastBatch != null) && (!_lastBatch.IsEmpty())) || _isForceOutput) { ScheduleCallback(); _isCallbackScheduled = true; } _lastBatch = _currentBatch; _currentBatch = new LinkedHashSet <EventBean>(); }
public override void Update( EventBean[] newData, EventBean[] oldData) { agentInstanceContext.AuditProvider.View(newData, oldData, agentInstanceContext, factory); agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(factory, newData, oldData); if (oldData != null) { for (var i = 0; i < oldData.Length; i++) { currentBatch.Remove(oldData[i]); } } // we don't care about removed data from a prior view if (newData == null || newData.Length == 0) { agentInstanceContext.InstrumentationProvider.AViewProcessIRStream(); return; } // If we have an empty window about to be filled for the first time, schedule a callback if (currentBatch.IsEmpty()) { if (currentReferencePoint == null) { currentReferencePoint = factory.optionalReferencePoint; if (currentReferencePoint == null) { currentReferencePoint = agentInstanceContext.StatementContext.SchedulingService.Time; } } // Schedule the next callback if there is none currently scheduled if (!isCallbackScheduled) { ScheduleCallback(); isCallbackScheduled = true; } } // add data points to the timeWindow foreach (var newEvent in newData) { currentBatch.Add(newEvent); } // We do not update child views, since we batch the events. agentInstanceContext.InstrumentationProvider.AViewProcessIRStream(); }
public IEnumerator <EventBean> GetEnumerator() { if (NullKeyedValues.IsEmpty()) { return(PropertySortedEventTableEnumerator.Create(PropertyIndex)); } return(PropertySortedEventTableEnumerator.CreateEnumerable(PropertyIndex) .Merge(NullKeyedValues) .Where(t => t.A != null && t.B != null) .Select(t => t.B) .GetEnumerator()); }
/// <summary> /// This method updates child views and clears the batch of events. /// We schedule a new callback at this time if there were events in the batch. /// </summary> protected void SendBatch() { isCallbackScheduled = false; // If there are child views and the batch was filled, fireStatementStopped update method if (Child != null) { // Convert to object arrays EventBean[] newData = null; EventBean[] oldData = null; if (!currentBatch.IsEmpty()) { newData = currentBatch.ToArray(); } if (lastBatch != null && !lastBatch.IsEmpty()) { oldData = lastBatch.ToArray(); } if (newData != null || oldData != null || factory.isForceUpdate) { agentInstanceContext.InstrumentationProvider.QViewIndicate(factory, newData, oldData); Child.Update(newData, oldData); agentInstanceContext.InstrumentationProvider.AViewIndicate(); } } // Only if forceOutput is enabled or // there have been any events in this or the last interval do we schedule a callback, // such as to not waste resources when no events arrive. if (!currentBatch.IsEmpty() || lastBatch != null && !lastBatch.IsEmpty() || factory.isForceUpdate) { ScheduleCallback(); isCallbackScheduled = true; } lastBatch = currentBatch; currentBatch = new LinkedHashSet<EventBean>(); }
/// <summary> /// Finds the running element that has particular name and should appear on specific page with given occurrence /// options. /// </summary> /// <remarks> /// Finds the running element that has particular name and should appear on specific page with given occurrence /// options. This would work only if page content was already layouted and flushed (drawn). /// </remarks> /// <param name="runningElemName">the running element name.</param> /// <param name="occurrenceOption"> /// an option defining which running element should be chosen in case there are multiple /// running elements with the same name on the given page. /// </param> /// <param name="pageNum">the 1-based index of the page for which running element is requested.</param> /// <returns> /// /// <see cref="iText.Html2pdf.Attach.Impl.Layout.RunningElementContainer"/> /// with corresponding running element, or /// <see langword="null"/> /// if no running /// element should be displayed for the given page with the given name or occurrence option. /// </returns> public virtual RunningElementContainer GetRunningElement(String runningElemName, String occurrenceOption, int pageNum) { LinkedHashSet <RunningElementContainer> runningElementContainers = runningElements.Get(runningElemName); if (runningElementContainers == null || runningElementContainers.IsEmpty()) { return(null); } bool isLast = CssConstants.LAST.Equals(occurrenceOption); bool isFirstExcept = CssConstants.FIRST_EXCEPT.Equals(occurrenceOption); bool isStart = CssConstants.START.Equals(occurrenceOption); RunningElementContainer runningElementContainer = null; foreach (RunningElementContainer container in runningElementContainers) { if (container.GetOccurrencePage() == 0 || container.GetOccurrencePage() > pageNum) { // Imagine that floating element is before some normal element, but is drawn on the next page, // while this normal element is drawn on previous page. // This example covers both the cases when zero and bigger page nums are required to be skipped, // rather than breaking here. continue; } if (container.GetOccurrencePage() < pageNum) { runningElementContainer = container; } if (container.GetOccurrencePage() == pageNum) { if (isFirstExcept) { return(null); } if (!isStart || container.IsFirstOnPage()) { runningElementContainer = container; } if (!isLast) { break; } } } return(runningElementContainer); }
private void ActualizeNamespacesInStructTreeRoot() { if (namespaces.Count > 0) { PdfStructTreeRoot structTreeRoot = GetDocument().GetStructTreeRoot(); PdfArray rootNamespaces = structTreeRoot.GetNamespacesObject(); ICollection <PdfDictionary> newNamespaces = new LinkedHashSet <PdfDictionary>(namespaces); for (int i = 0; i < rootNamespaces.Size(); ++i) { newNamespaces.Remove(rootNamespaces.GetAsDictionary(i)); } foreach (PdfDictionary newNs in newNamespaces) { rootNamespaces.Add(newNs); } if (!newNamespaces.IsEmpty()) { structTreeRoot.SetModified(); } } }
/// <summary> /// Returns an indication of whether there are any callbacks or index nodes at all in this set. /// NOTE: the client to this method must use the read-write lock of this object to lock, if /// required by the client code. /// </summary> /// <returns> /// true if there are neither indizes nor filter callbacks stored, false if either exist. /// </returns> public bool IsEmpty() { return(_callbackSet.IsEmpty() && _indizes.Count == 0); }