< prev index next >

application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/common/DataPageToolkit.java

Print this page




  94 import org.eclipse.swt.widgets.FileDialog;
  95 import org.eclipse.swt.widgets.Label;
  96 import org.eclipse.ui.forms.widgets.Form;
  97 import org.eclipse.ui.forms.widgets.FormText;
  98 import org.eclipse.ui.forms.widgets.FormToolkit;
  99 import org.openjdk.jmc.common.item.IAggregator;
 100 import org.openjdk.jmc.common.item.IAttribute;
 101 import org.openjdk.jmc.common.item.ICanonicalAccessorFactory;
 102 import org.openjdk.jmc.common.item.IItem;
 103 import org.openjdk.jmc.common.item.IItemCollection;
 104 import org.openjdk.jmc.common.item.IItemFilter;
 105 import org.openjdk.jmc.common.item.IItemIterable;
 106 import org.openjdk.jmc.common.item.IItemQuery;
 107 import org.openjdk.jmc.common.item.IMemberAccessor;
 108 import org.openjdk.jmc.common.item.IType;
 109 import org.openjdk.jmc.common.item.ItemFilters;
 110 import org.openjdk.jmc.common.item.ItemToolkit;
 111 import org.openjdk.jmc.common.unit.IQuantity;
 112 import org.openjdk.jmc.common.unit.IRange;
 113 import org.openjdk.jmc.common.unit.KindOfQuantity;

 114 import org.openjdk.jmc.common.unit.QuantityRange;
 115 import org.openjdk.jmc.common.unit.RangeContentType;
 116 import org.openjdk.jmc.common.unit.UnitLookup;
 117 import org.openjdk.jmc.common.util.ColorToolkit;
 118 import org.openjdk.jmc.common.util.CompositeKey;
 119 import org.openjdk.jmc.flightrecorder.JfrAttributes;

 120 import org.openjdk.jmc.flightrecorder.jdk.JdkAttributes;
 121 import org.openjdk.jmc.flightrecorder.jdk.JdkFilters;
 122 import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
 123 import org.openjdk.jmc.flightrecorder.rules.Result;
 124 import org.openjdk.jmc.flightrecorder.rules.Severity;
 125 import org.openjdk.jmc.flightrecorder.ui.FlightRecorderUI;
 126 import org.openjdk.jmc.flightrecorder.ui.IPageContainer;
 127 import org.openjdk.jmc.flightrecorder.ui.ItemCollectionToolkit;
 128 import org.openjdk.jmc.flightrecorder.ui.ItemIterableToolkit;

 129 import org.openjdk.jmc.flightrecorder.ui.common.ItemHistogram.CompositeKeyHistogramBuilder;
 130 import org.openjdk.jmc.flightrecorder.ui.common.ItemList.ItemListBuilder;
 131 import org.openjdk.jmc.flightrecorder.ui.messages.internal.Messages;
 132 import org.openjdk.jmc.flightrecorder.ui.overview.ResultOverview;


 133 import org.openjdk.jmc.flightrecorder.ui.selection.IFilterFlavor;
 134 import org.openjdk.jmc.flightrecorder.ui.selection.SelectionStore.SelectionStoreEntry;
 135 import org.openjdk.jmc.flightrecorder.ui.selection.SelectionStoreActionToolkit;
 136 import org.openjdk.jmc.ui.charts.AWTChartToolkit.IColorProvider;
 137 import org.openjdk.jmc.ui.charts.IQuantitySeries;
 138 import org.openjdk.jmc.ui.charts.ISpanSeries;
 139 import org.openjdk.jmc.ui.charts.IXDataRenderer;
 140 import org.openjdk.jmc.ui.charts.QuantitySeries;
 141 import org.openjdk.jmc.ui.charts.RendererToolkit;
 142 import org.openjdk.jmc.ui.charts.SpanRenderer;
 143 import org.openjdk.jmc.ui.charts.SubdividedQuantityRange;
 144 import org.openjdk.jmc.ui.charts.XYChart;
 145 import org.openjdk.jmc.ui.charts.XYDataRenderer;
 146 import org.openjdk.jmc.ui.charts.XYQuantities;
 147 import org.openjdk.jmc.ui.column.ColumnMenusFactory;
 148 import org.openjdk.jmc.ui.column.TableSettings;
 149 import org.openjdk.jmc.ui.column.TableSettings.ColumnSettings;
 150 import org.openjdk.jmc.ui.handlers.ActionToolkit;
 151 import org.openjdk.jmc.ui.handlers.MCContextMenuManager;
 152 import org.openjdk.jmc.ui.misc.ChartCanvas;


 546                 for (IAction action : extraActions) {
 547                         mm.add(action);
 548                 }
 549         }
 550 
 551         public static IXDataRenderer buildSizeRow(
 552                 String title, String description, IItemCollection items, IAggregator<IQuantity, ?> a, Color color,
 553                 IColorProvider<IItem> cp) {
 554                 return RendererToolkit.layers(buildSpanRenderer(items, cp),
 555                                 buildTimestampHistogram(title, description, items, a, color));
 556         }
 557 
 558         public static ItemRow buildDurationHistogram(
 559                 String title, String description, IItemCollection items, IAggregator<IQuantity, ?> a, Color color) {
 560                 IQuantitySeries<IQuantity[]> allocationSeries = BucketBuilder.aggregatorSeries(items, a,
 561                                 JfrAttributes.DURATION);
 562                 XYDataRenderer renderer = new XYDataRenderer(getKindOfQuantity(a).getDefaultUnit().quantity(0), title,
 563                                 description);
 564                 renderer.addBarChart(a.getName(), allocationSeries, color);
 565                 return new ItemRow(title, description, renderer, items);

























 566         }
 567 
 568         // FIXME: Make something that can use something other than time as x-axis?
 569         public static IXDataRenderer buildSpanRenderer(IItemCollection pathItems, IColorProvider<IItem> cp) {
 570                 ISpanSeries<IItem> dataSeries = QuantitySeries.max(pathItems, JfrAttributes.START_TIME, JfrAttributes.END_TIME);
 571                 return SpanRenderer.withBoundaries(dataSeries, cp);
 572         }
 573 
 574         public static boolean addEndTimeLines(
 575                 XYDataRenderer renderer, IItemCollection items, boolean fill, Stream<IAttribute<IQuantity>> yAttributes) {
 576                 // FIXME: JMC-4520 - Handle multiple item iterables
 577                 Iterator<IItemIterable> ii = items.iterator();
 578                 if (ii.hasNext()) {
 579                         IItemIterable itemStream = ii.next();
 580                         IType<IItem> type = itemStream.getType();
 581                         // FIXME: A better way to ensure sorting by endTime
 582                         return yAttributes.peek(a -> addEndTimeLine(renderer, itemStream.iterator(), type, a, fill))
 583                                         .mapToLong(a -> 1L).sum() > 0;
 584                 }
 585                 return false;




  94 import org.eclipse.swt.widgets.FileDialog;
  95 import org.eclipse.swt.widgets.Label;
  96 import org.eclipse.ui.forms.widgets.Form;
  97 import org.eclipse.ui.forms.widgets.FormText;
  98 import org.eclipse.ui.forms.widgets.FormToolkit;
  99 import org.openjdk.jmc.common.item.IAggregator;
 100 import org.openjdk.jmc.common.item.IAttribute;
 101 import org.openjdk.jmc.common.item.ICanonicalAccessorFactory;
 102 import org.openjdk.jmc.common.item.IItem;
 103 import org.openjdk.jmc.common.item.IItemCollection;
 104 import org.openjdk.jmc.common.item.IItemFilter;
 105 import org.openjdk.jmc.common.item.IItemIterable;
 106 import org.openjdk.jmc.common.item.IItemQuery;
 107 import org.openjdk.jmc.common.item.IMemberAccessor;
 108 import org.openjdk.jmc.common.item.IType;
 109 import org.openjdk.jmc.common.item.ItemFilters;
 110 import org.openjdk.jmc.common.item.ItemToolkit;
 111 import org.openjdk.jmc.common.unit.IQuantity;
 112 import org.openjdk.jmc.common.unit.IRange;
 113 import org.openjdk.jmc.common.unit.KindOfQuantity;
 114 import org.openjdk.jmc.common.unit.QuantitiesToolkit;
 115 import org.openjdk.jmc.common.unit.QuantityRange;
 116 import org.openjdk.jmc.common.unit.RangeContentType;
 117 import org.openjdk.jmc.common.unit.UnitLookup;
 118 import org.openjdk.jmc.common.util.ColorToolkit;
 119 import org.openjdk.jmc.common.util.CompositeKey;
 120 import org.openjdk.jmc.flightrecorder.JfrAttributes;
 121 import org.openjdk.jmc.flightrecorder.jdk.JdkAggregators;
 122 import org.openjdk.jmc.flightrecorder.jdk.JdkAttributes;
 123 import org.openjdk.jmc.flightrecorder.jdk.JdkFilters;
 124 import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
 125 import org.openjdk.jmc.flightrecorder.rules.Result;
 126 import org.openjdk.jmc.flightrecorder.rules.Severity;
 127 import org.openjdk.jmc.flightrecorder.ui.FlightRecorderUI;
 128 import org.openjdk.jmc.flightrecorder.ui.IPageContainer;
 129 import org.openjdk.jmc.flightrecorder.ui.ItemCollectionToolkit;
 130 import org.openjdk.jmc.flightrecorder.ui.ItemIterableToolkit;
 131 import org.openjdk.jmc.flightrecorder.ui.PageManager;
 132 import org.openjdk.jmc.flightrecorder.ui.common.ItemHistogram.CompositeKeyHistogramBuilder;
 133 import org.openjdk.jmc.flightrecorder.ui.common.ItemList.ItemListBuilder;
 134 import org.openjdk.jmc.flightrecorder.ui.messages.internal.Messages;
 135 import org.openjdk.jmc.flightrecorder.ui.overview.ResultOverview;
 136 import org.openjdk.jmc.flightrecorder.ui.pages.itemhandler.ItemHandlerPage;
 137 import org.openjdk.jmc.flightrecorder.ui.pages.itemhandler.ItemHandlerPage.ItemHandlerUiStandIn;
 138 import org.openjdk.jmc.flightrecorder.ui.selection.IFilterFlavor;
 139 import org.openjdk.jmc.flightrecorder.ui.selection.SelectionStore.SelectionStoreEntry;
 140 import org.openjdk.jmc.flightrecorder.ui.selection.SelectionStoreActionToolkit;
 141 import org.openjdk.jmc.ui.charts.AWTChartToolkit.IColorProvider;
 142 import org.openjdk.jmc.ui.charts.IQuantitySeries;
 143 import org.openjdk.jmc.ui.charts.ISpanSeries;
 144 import org.openjdk.jmc.ui.charts.IXDataRenderer;
 145 import org.openjdk.jmc.ui.charts.QuantitySeries;
 146 import org.openjdk.jmc.ui.charts.RendererToolkit;
 147 import org.openjdk.jmc.ui.charts.SpanRenderer;
 148 import org.openjdk.jmc.ui.charts.SubdividedQuantityRange;
 149 import org.openjdk.jmc.ui.charts.XYChart;
 150 import org.openjdk.jmc.ui.charts.XYDataRenderer;
 151 import org.openjdk.jmc.ui.charts.XYQuantities;
 152 import org.openjdk.jmc.ui.column.ColumnMenusFactory;
 153 import org.openjdk.jmc.ui.column.TableSettings;
 154 import org.openjdk.jmc.ui.column.TableSettings.ColumnSettings;
 155 import org.openjdk.jmc.ui.handlers.ActionToolkit;
 156 import org.openjdk.jmc.ui.handlers.MCContextMenuManager;
 157 import org.openjdk.jmc.ui.misc.ChartCanvas;


 551                 for (IAction action : extraActions) {
 552                         mm.add(action);
 553                 }
 554         }
 555 
 556         public static IXDataRenderer buildSizeRow(
 557                 String title, String description, IItemCollection items, IAggregator<IQuantity, ?> a, Color color,
 558                 IColorProvider<IItem> cp) {
 559                 return RendererToolkit.layers(buildSpanRenderer(items, cp),
 560                                 buildTimestampHistogram(title, description, items, a, color));
 561         }
 562 
 563         public static ItemRow buildDurationHistogram(
 564                 String title, String description, IItemCollection items, IAggregator<IQuantity, ?> a, Color color) {
 565                 IQuantitySeries<IQuantity[]> allocationSeries = BucketBuilder.aggregatorSeries(items, a,
 566                                 JfrAttributes.DURATION);
 567                 XYDataRenderer renderer = new XYDataRenderer(getKindOfQuantity(a).getDefaultUnit().quantity(0), title,
 568                                 description);
 569                 renderer.addBarChart(a.getName(), allocationSeries, color);
 570                 return new ItemRow(title, description, renderer, items);
 571         }
 572         
 573         public static ItemRow buildSizeHistogram(
 574                 String title, String description, IItemCollection items, IAggregator<IQuantity, ?> a, Color color, IAttribute<IQuantity> attribute) {
 575                 
 576                 IQuantitySeries<IQuantity[]> allocationSeries = BucketBuilder.aggregatorSeries(items, a,
 577                                 JdkAttributes.IO_SIZE);
 578                 XYDataRenderer renderer = new XYDataRenderer(getKindOfQuantity(a).getDefaultUnit().quantity(0), title,
 579                                 description);
 580                 renderer.addBarChart(a.getName(), allocationSeries, color);
 581                 return new ItemRow(title, description, renderer, items);
 582         }
 583         
 584         public static IRange<IQuantity> buildSizeRange(IItemCollection items, boolean isSocket){
 585                 IQuantity end = null;
 586                 if(isSocket) {
 587                         end = QuantitiesToolkit.maxPresent(items.getAggregate(JdkAggregators.SOCKET_READ_LARGEST),
 588                                         items.getAggregate(JdkAggregators.SOCKET_WRITE_LARGEST)); 
 589                                                 
 590                 } else {
 591                         end = QuantitiesToolkit.maxPresent(items.getAggregate(JdkAggregators.FILE_READ_LARGEST),
 592                                         items.getAggregate(JdkAggregators.FILE_WRITE_LARGEST));
 593                 }
 594                 end = end == null ? UnitLookup.BYTE.quantity(1024) : end;
 595                 return QuantityRange.createWithEnd(UnitLookup.BYTE.quantity(0), end);
 596         }
 597 
 598         // FIXME: Make something that can use something other than time as x-axis?
 599         public static IXDataRenderer buildSpanRenderer(IItemCollection pathItems, IColorProvider<IItem> cp) {
 600                 ISpanSeries<IItem> dataSeries = QuantitySeries.max(pathItems, JfrAttributes.START_TIME, JfrAttributes.END_TIME);
 601                 return SpanRenderer.withBoundaries(dataSeries, cp);
 602         }
 603 
 604         public static boolean addEndTimeLines(
 605                 XYDataRenderer renderer, IItemCollection items, boolean fill, Stream<IAttribute<IQuantity>> yAttributes) {
 606                 // FIXME: JMC-4520 - Handle multiple item iterables
 607                 Iterator<IItemIterable> ii = items.iterator();
 608                 if (ii.hasNext()) {
 609                         IItemIterable itemStream = ii.next();
 610                         IType<IItem> type = itemStream.getType();
 611                         // FIXME: A better way to ensure sorting by endTime
 612                         return yAttributes.peek(a -> addEndTimeLine(renderer, itemStream.iterator(), type, a, fill))
 613                                         .mapToLong(a -> 1L).sum() > 0;
 614                 }
 615                 return false;


< prev index next >