diff --git a/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/common/DataPageToolkit.java b/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/common/DataPageToolkit.java index 529d73a2b..68f0135ee 100644 --- a/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/common/DataPageToolkit.java +++ b/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/common/DataPageToolkit.java @@ -641,13 +641,12 @@ public static IXDataRenderer buildSpanRenderer(IItemCollection pathItems, IColor public static boolean addEndTimeLines( XYDataRenderer renderer, IItemCollection items, boolean fill, Stream> yAttributes) { - // FIXME: JMC-4520 - Handle multiple item iterables - Iterator ii = items.iterator(); - if (ii.hasNext()) { - IItemIterable itemStream = ii.next(); - IType type = itemStream.getType(); - // FIXME: A better way to ensure sorting by endTime - return yAttributes.peek(a -> addEndTimeLine(renderer, itemStream.iterator(), type, a, fill)) + if (items.hasItems()) { + Iterator ii = items.iterator(); + IType type = ii.hasNext() ? ii.next().getType() : null; + List allItems = new ArrayList<>(); + items.forEach(itemStream -> itemStream.forEach(allItems::add)); + return yAttributes.peek(a -> addEndTimeLine(renderer, allItems.iterator(), type, a, fill)) .mapToLong(a -> 1L).sum() > 0; } return false; diff --git a/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/pages/itemhandler/AttributeComponentConfiguration.java b/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/pages/itemhandler/AttributeComponentConfiguration.java index 57a52e968..893b0e080 100644 --- a/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/pages/itemhandler/AttributeComponentConfiguration.java +++ b/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/pages/itemhandler/AttributeComponentConfiguration.java @@ -33,7 +33,6 @@ package org.openjdk.jmc.flightrecorder.ui.pages.itemhandler; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; @@ -73,7 +72,7 @@ public AttributeComponentConfiguration(IItemCollection items) { uncommonChartableAttributes = new HashMap<>(); lineChartableAttributes = new HashMap<>(); forEachType(items); - populateAttributeMaps(isSuitableForLineCharts(items, allTypes)); + populateAttributeMaps(isSuitableForLineCharts(allTypes)); } @SuppressWarnings("deprecation") @@ -117,16 +116,8 @@ private void populateAttributeMaps(boolean allowLineCharts) { } } - private static boolean isSuitableForLineCharts(IItemCollection items, Map> types) { - // NOTE: JMC-4520 - Only allowing line charts for one event type, which only has one event array. - if (types.values().size() == 1) { - Iterator iterator = items.iterator(); - if (iterator.hasNext()) { - iterator.next(); - return !iterator.hasNext(); - } - } - return false; + private static boolean isSuitableForLineCharts(Map> types) { + return types.values().size() == 1; } public Map> getAllAttributes() { diff --git a/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/pages/itemhandler/ItemChart.java b/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/pages/itemhandler/ItemChart.java index 31c45d776..fb1d269cb 100644 --- a/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/pages/itemhandler/ItemChart.java +++ b/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/pages/itemhandler/ItemChart.java @@ -62,6 +62,7 @@ import org.openjdk.jmc.common.item.Aggregators; import org.openjdk.jmc.common.item.IAggregator; import org.openjdk.jmc.common.item.IAttribute; +import org.openjdk.jmc.common.item.IItem; import org.openjdk.jmc.common.item.IItemCollection; import org.openjdk.jmc.common.item.IItemIterable; import org.openjdk.jmc.common.item.IType; @@ -540,19 +541,18 @@ private Collection updateLineChart(IItemCollection itemsToChart) { description); for (IAttribute attribute : attributes) { // TODO: something other than time on x-axis? - Iterator chartItemsWithAttributeSomeType = itemsToChart - .apply(ItemFilters.hasAttribute(attribute)).iterator(); - if (chartItemsWithAttributeSomeType.hasNext() - && attribute.getContentType() instanceof LinearKindOfQuantity) { - IItemIterable is = chartItemsWithAttributeSomeType.next(); - if (chartItemsWithAttributeSomeType.hasNext()) { - // FIXME: JMC-4520 - Add support for multiple item iterables - FlightRecorderUI.getDefault().getLogger().log(Level.INFO, - "Only charting a subset of the events!"); //$NON-NLS-1$ + if (attribute.getContentType() instanceof LinearKindOfQuantity) { + IItemCollection itemsWithAttributeSomeType = itemsToChart + .apply(ItemFilters.hasAttribute(attribute)); + if (itemsWithAttributeSomeType.hasItems()) { + Iterator iterator = itemsWithAttributeSomeType.iterator(); + IType type = iterator.hasNext() ? iterator.next().getType() : null; + List allItems = new ArrayList<>(); + itemsWithAttributeSomeType.forEach(itemStream -> itemStream.forEach(allItems::add)); + @SuppressWarnings("unchecked") + IAttribute qAttribute = (IAttribute) attribute; + DataPageToolkit.addEndTimeLine(xyRenderer, allItems.iterator(), type, qAttribute, fill); } - @SuppressWarnings("unchecked") - IAttribute qAttribute = (IAttribute) attribute; - DataPageToolkit.addEndTimeLine(xyRenderer, is.iterator(), is.getType(), qAttribute, fill); } } rows.add(new ItemRow(name, description, xyRenderer, itemsToChart));