use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class FlameGraphVisualTest method populateUi.
@Override
protected void populateUi(@NotNull JPanel mainPanel) {
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
JBPanel controlPanel = new JBPanel();
controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.X_AXIS));
JBPanel buttonsPanel = new JBPanel();
buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.Y_AXIS));
mRecordButton = new JButton("Record");
mRecordButton.setActionCommand(ACTION_START_RECORDING);
mRecordButton.addActionListener(this);
buttonsPanel.add(mRecordButton);
mLoadButton = new JButton("Load");
mLoadButton.setActionCommand(ACTION_LOAD_RECORDING);
mLoadButton.addActionListener(this);
buttonsPanel.add(mLoadButton);
mSaveButton = new JButton("Save");
mSaveButton.setActionCommand(ACTION_SAVE_RECORDING);
mSaveButton.addActionListener(this);
buttonsPanel.add(mSaveButton);
mComboBox = new JComboBox<String>(new String[0]) {
@Override
public Dimension getMaximumSize() {
Dimension max = super.getMaximumSize();
max.height = getPreferredSize().height;
return max;
}
};
mComboBox.addActionListener(this);
mComboBox.setActionCommand(ACTION_THREAD_SELECTED);
JBPanel viewControlPanel = new JBPanel();
viewControlPanel.setLayout(new BoxLayout(viewControlPanel, BoxLayout.Y_AXIS));
JLayeredPane mockTimelinePane = createMockTimeline();
viewControlPanel.add(mockTimelinePane);
viewControlPanel.add(mComboBox);
controlPanel.add(buttonsPanel);
controlPanel.add(viewControlPanel);
mainPanel.add(controlPanel);
JBPanel viewPanel = new JBPanel();
viewPanel.setLayout(new BoxLayout(viewPanel, BoxLayout.X_AXIS));
viewPanel.add(mChart);
mScrollBar = new JScrollBar(JScrollBar.VERTICAL);
mScrollBar.addAdjustmentListener(new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
Range yRange = mChart.getYRange();
int yOffset = mChart.getMaximumHeight() - (e.getValue() + mScrollBar.getVisibleAmount());
yRange.setMin(yOffset);
}
});
viewPanel.add(mScrollBar);
mainPanel.add(viewPanel);
}
use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class ThreadCallsVisualTest method populateUi.
@Override
protected void populateUi(@NotNull JPanel mainPanel) {
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
JBPanel controlPanel = new JBPanel();
controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.X_AXIS));
JBPanel buttonsPanel = new JBPanel();
buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.Y_AXIS));
mRecordButton = new JButton("Record");
mRecordButton.setActionCommand(ACTION_START_RECORDING);
mRecordButton.addActionListener(this);
buttonsPanel.add(mRecordButton);
mLoadButton = new JButton("Load");
mLoadButton.setActionCommand(ACTION_LOAD_RECORDING);
mLoadButton.addActionListener(this);
buttonsPanel.add(mLoadButton);
mSaveButton = new JButton("Save");
mSaveButton.setActionCommand(ACTION_SAVE_RECORDING);
mSaveButton.addActionListener(this);
buttonsPanel.add(mSaveButton);
mComboBox = new JComboBox<String>(new String[0]) {
@Override
public Dimension getMaximumSize() {
Dimension max = super.getMaximumSize();
max.height = getPreferredSize().height;
return max;
}
};
mComboBox.addActionListener(this);
mComboBox.setActionCommand(ACTION_THREAD_SELECTED);
JBPanel viewControlPanel = new JBPanel();
viewControlPanel.setLayout(new BoxLayout(viewControlPanel, BoxLayout.Y_AXIS));
JLayeredPane mockTimelinePane = createMockTimeline();
viewControlPanel.add(mockTimelinePane);
viewControlPanel.add(mComboBox);
controlPanel.add(buttonsPanel);
controlPanel.add(viewControlPanel);
mainPanel.add(controlPanel);
JBPanel viewPanel = new JBPanel();
viewPanel.setLayout(new BoxLayout(viewPanel, BoxLayout.X_AXIS));
viewPanel.add(mChart);
mScrollBar = new JScrollBar(JScrollBar.VERTICAL);
mScrollBar.addAdjustmentListener(e -> {
Range yRange = mChart.getYRange();
int yOffset = e.getValue();
yRange.setMin(yOffset);
});
viewPanel.add(mScrollBar);
mainPanel.add(viewPanel);
}
use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class ProfilerOverviewVisualTest method createToolbarPanel.
private JComponent createToolbarPanel() {
JBPanel panel = new JBPanel();
BoxLayout layout = new BoxLayout(panel, BoxLayout.X_AXIS);
panel.setLayout(layout);
panel.setBorder(BorderFactory.createLineBorder(Color.GRAY));
JComboBox<String> deviceCb = new JComboBox<>(new String[] { "Device1", "Device2" });
deviceCb.addActionListener(e -> getChoreographer().reset());
JComboBox<String> processCb = new JComboBox<>(new String[] { "Process1", "Process2" });
processCb.addActionListener(e -> getChoreographer().reset());
mResetProfilersButton = VisualTest.createButton("Back to L1", e -> mEventDispatcher.getMulticaster().profilersReset());
mResetProfilersButton.setEnabled(false);
panel.add(mResetProfilersButton);
panel.add(deviceCb);
panel.add(processCb);
return panel;
}
use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class MemoryProfilerStageView method buildMonitorUi.
@NotNull
private JPanel buildMonitorUi() {
StudioProfilers profilers = getStage().getStudioProfilers();
ProfilerTimeline timeline = profilers.getTimeline();
Range viewRange = getTimeline().getViewRange();
Range dataRange = getTimeline().getDataRange();
TabularLayout layout = new TabularLayout("*");
JPanel panel = new JBPanel(layout);
panel.setBackground(ProfilerColors.MONITOR_BACKGROUND);
// The scrollbar can modify the view range - so it should be registered to the Choreographer before all other Animatables
// that attempts to read the same range instance.
ProfilerScrollbar sb = new ProfilerScrollbar(getChoreographer(), timeline, panel);
getChoreographer().register(sb);
panel.add(sb, new TabularLayout.Constraint(3, 0));
AxisComponent timeAxis = buildTimeAxis(profilers);
getChoreographer().register(timeAxis);
panel.add(timeAxis, new TabularLayout.Constraint(2, 0));
EventMonitor events = new EventMonitor(profilers);
EventMonitorView eventsView = new EventMonitorView(events);
JComponent eventsComponent = eventsView.initialize(getChoreographer());
panel.add(eventsComponent, new TabularLayout.Constraint(0, 0));
MemoryMonitor monitor = new MemoryMonitor(profilers);
JPanel monitorPanel = new JBPanel(new TabularLayout("*", "*"));
monitorPanel.setOpaque(false);
monitorPanel.setBorder(MONITOR_BORDER);
final JLabel label = new JLabel(monitor.getName());
label.setBorder(MONITOR_LABEL_PADDING);
label.setVerticalAlignment(SwingConstants.TOP);
Range leftYRange = new Range(0, 0);
Range rightYRange = new Range(0, 0);
RangedContinuousSeries javaSeries = new RangedContinuousSeries("Java", viewRange, leftYRange, monitor.getJavaMemory());
RangedContinuousSeries nativeSeries = new RangedContinuousSeries("Native", viewRange, leftYRange, monitor.getNativeMemory());
RangedContinuousSeries graphcisSeries = new RangedContinuousSeries("Graphics", viewRange, leftYRange, monitor.getGraphicsMemory());
RangedContinuousSeries stackSeries = new RangedContinuousSeries("Stack", viewRange, leftYRange, monitor.getStackMemory());
RangedContinuousSeries codeSeries = new RangedContinuousSeries("Code", viewRange, leftYRange, monitor.getCodeMemory());
RangedContinuousSeries otherSeries = new RangedContinuousSeries("Others", viewRange, leftYRange, monitor.getOthersMemory());
RangedContinuousSeries totalSeries = new RangedContinuousSeries("Total", viewRange, leftYRange, monitor.getTotalMemory());
RangedContinuousSeries objectSeries = new RangedContinuousSeries("Allocated", viewRange, rightYRange, monitor.getObjectCount());
final JPanel lineChartPanel = new JBPanel(new BorderLayout());
lineChartPanel.setOpaque(false);
lineChartPanel.setBorder(BorderFactory.createEmptyBorder(Y_AXIS_TOP_MARGIN, 0, 0, 0));
final LineChart lineChart = new LineChart();
lineChart.addLine(javaSeries, new LineConfig(ProfilerColors.MEMORY_JAVA).setFilled(true).setStacked(true));
lineChart.addLine(nativeSeries, new LineConfig(ProfilerColors.MEMORY_NATIVE).setFilled(true).setStacked(true));
lineChart.addLine(graphcisSeries, new LineConfig(ProfilerColors.MEMORY_GRAPHCIS).setFilled(true).setStacked(true));
lineChart.addLine(stackSeries, new LineConfig(ProfilerColors.MEMORY_STACK).setFilled(true).setStacked(true));
lineChart.addLine(codeSeries, new LineConfig(ProfilerColors.MEMORY_CODE).setFilled(true).setStacked(true));
lineChart.addLine(otherSeries, new LineConfig(ProfilerColors.MEMORY_OTHERS).setFilled(true).setStacked(true));
lineChart.addLine(totalSeries, new LineConfig(ProfilerColors.MEMORY_TOTAL).setFilled(true));
lineChart.addLine(objectSeries, new LineConfig(ProfilerColors.MEMORY_OBJECTS).setStroke(LineConfig.DEFAULT_DASH_STROKE));
// TODO set proper colors / icons
DurationDataRenderer<HeapDumpDurationData> heapDumpRenderer = new DurationDataRenderer.Builder<>(new RangedSeries<>(viewRange, getStage().getHeapDumpSampleDurations()), Color.BLACK).setLabelColors(Color.DARK_GRAY, Color.GRAY, Color.lightGray, Color.WHITE).setStroke(new BasicStroke(2)).setIsBlocking(true).setLabelProvider(data -> String.format("Dump (%s)", data.getDuration() == DurationData.UNSPECIFIED_DURATION ? "in progress" : TimeAxisFormatter.DEFAULT.getFormattedString(viewRange.getLength(), data.getDuration(), true))).setClickHander(data -> getStage().setFocusedHeapDump(data.getDumpInfo())).build();
DurationDataRenderer<AllocationsDurationData> allocationRenderer = new DurationDataRenderer.Builder<>(new RangedSeries<>(viewRange, getStage().getAllocationInfosDurations()), Color.LIGHT_GRAY).setLabelColors(Color.DARK_GRAY, Color.GRAY, Color.lightGray, Color.WHITE).setStroke(new BasicStroke(2)).setLabelProvider(data -> String.format("Allocation Record (%s)", data.getDuration() == DurationData.UNSPECIFIED_DURATION ? "in progress" : TimeAxisFormatter.DEFAULT.getFormattedString(viewRange.getLength(), data.getDuration(), true))).setClickHander(data -> getStage().setAllocationsTimeRange(data.getStartTimeNs(), data.getEndTimeNs())).build();
DurationDataRenderer<GcDurationData> gcRenderer = new DurationDataRenderer.Builder<>(new RangedSeries<>(viewRange, monitor.getGcCount()), Color.BLACK).setIcon(myGcIcon).setAttachLineSeries(objectSeries).build();
lineChart.addCustomRenderer(heapDumpRenderer);
lineChart.addCustomRenderer(allocationRenderer);
lineChart.addCustomRenderer(gcRenderer);
SelectionComponent selection = new SelectionComponent(timeline.getSelectionRange(), timeline.getViewRange());
final JPanel overlayPanel = new JBPanel(new BorderLayout());
overlayPanel.setOpaque(false);
overlayPanel.setBorder(BorderFactory.createEmptyBorder(Y_AXIS_TOP_MARGIN, 0, 0, 0));
final OverlayComponent overlay = new OverlayComponent(selection);
overlay.addDurationDataRenderer(heapDumpRenderer);
overlay.addDurationDataRenderer(allocationRenderer);
overlay.addDurationDataRenderer(gcRenderer);
overlayPanel.add(overlay, BorderLayout.CENTER);
getChoreographer().register(lineChart);
getChoreographer().register(heapDumpRenderer);
getChoreographer().register(allocationRenderer);
getChoreographer().register(gcRenderer);
getChoreographer().register(overlay);
getChoreographer().register(selection);
lineChartPanel.add(lineChart, BorderLayout.CENTER);
final JPanel axisPanel = new JBPanel(new BorderLayout());
axisPanel.setOpaque(false);
AxisComponent.Builder leftBuilder = new AxisComponent.Builder(leftYRange, MEMORY_AXIS_FORMATTER, AxisComponent.AxisOrientation.RIGHT).showAxisLine(false).showMax(true).showUnitAtMax(true).clampToMajorTicks(true).setMarkerLengths(MARKER_LENGTH, MARKER_LENGTH).setMargins(0, Y_AXIS_TOP_MARGIN);
final AxisComponent leftAxis = leftBuilder.build();
getChoreographer().register(leftAxis);
axisPanel.add(leftAxis, BorderLayout.WEST);
AxisComponent.Builder rightBuilder = new AxisComponent.Builder(rightYRange, OBJECT_COUNT_AXIS_FORMATTER, AxisComponent.AxisOrientation.LEFT).showAxisLine(false).showMax(true).showUnitAtMax(true).clampToMajorTicks(true).setMarkerLengths(MARKER_LENGTH, MARKER_LENGTH).setMargins(0, Y_AXIS_TOP_MARGIN);
final AxisComponent rightAxis = rightBuilder.build();
getChoreographer().register(rightAxis);
axisPanel.add(rightAxis, BorderLayout.EAST);
final LegendComponent legend = new LegendComponent(LegendComponent.Orientation.HORIZONTAL, LEGEND_UPDATE_FREQUENCY_MS);
ArrayList<LegendRenderData> legendData = new ArrayList<>();
legendData.add(lineChart.createLegendRenderData(javaSeries, MEMORY_AXIS_FORMATTER, dataRange));
legendData.add(lineChart.createLegendRenderData(nativeSeries, MEMORY_AXIS_FORMATTER, dataRange));
legendData.add(lineChart.createLegendRenderData(graphcisSeries, MEMORY_AXIS_FORMATTER, dataRange));
legendData.add(lineChart.createLegendRenderData(stackSeries, MEMORY_AXIS_FORMATTER, dataRange));
legendData.add(lineChart.createLegendRenderData(codeSeries, MEMORY_AXIS_FORMATTER, dataRange));
legendData.add(lineChart.createLegendRenderData(otherSeries, MEMORY_AXIS_FORMATTER, dataRange));
legendData.add(lineChart.createLegendRenderData(totalSeries, MEMORY_AXIS_FORMATTER, dataRange));
legendData.add(lineChart.createLegendRenderData(objectSeries, OBJECT_COUNT_AXIS_FORMATTER, dataRange));
legend.setLegendData(legendData);
getChoreographer().register(legend);
final JPanel legendPanel = new JBPanel(new BorderLayout());
legendPanel.setOpaque(false);
legendPanel.add(label, BorderLayout.WEST);
legendPanel.add(legend, BorderLayout.EAST);
monitorPanel.add(overlayPanel, new TabularLayout.Constraint(0, 0));
monitorPanel.add(selection, new TabularLayout.Constraint(0, 0));
monitorPanel.add(legendPanel, new TabularLayout.Constraint(0, 0));
monitorPanel.add(axisPanel, new TabularLayout.Constraint(0, 0));
monitorPanel.add(lineChartPanel, new TabularLayout.Constraint(0, 0));
// Give monitor as much space as possible
layout.setRowSizing(1, "*");
panel.add(monitorPanel, new TabularLayout.Constraint(1, 0));
return panel;
}
use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class NetworkMonitorView method populateUi.
@Override
protected void populateUi(JPanel container, Choreographer choreographer) {
container.setLayout(new TabularLayout("*", "*"));
Range viewRange = getMonitor().getTimeline().getViewRange();
Range dataRange = getMonitor().getTimeline().getDataRange();
final JLabel label = new JLabel(getMonitor().getName());
label.setBorder(MONITOR_LABEL_PADDING);
label.setVerticalAlignment(JLabel.TOP);
Range leftYRange = new Range(0, 4);
final JPanel axisPanel = new JBPanel(new BorderLayout());
axisPanel.setOpaque(false);
AxisComponent.Builder builder = new AxisComponent.Builder(leftYRange, BANDWIDTH_AXIS_FORMATTER_L1, AxisComponent.AxisOrientation.RIGHT).showAxisLine(false).showMax(true).showUnitAtMax(true).setMarkerLengths(MARKER_LENGTH, MARKER_LENGTH).clampToMajorTicks(true).setMargins(0, Y_AXIS_TOP_MARGIN);
final AxisComponent leftAxis = builder.build();
axisPanel.add(leftAxis, BorderLayout.WEST);
final JPanel lineChartPanel = new JBPanel(new BorderLayout());
lineChartPanel.setOpaque(false);
lineChartPanel.setBorder(BorderFactory.createEmptyBorder(Y_AXIS_TOP_MARGIN, 0, 0, 0));
final LineChart lineChart = new LineChart();
RangedContinuousSeries rxSeries = new RangedContinuousSeries(NetworkTrafficDataSeries.Type.BYTES_RECEIVED.getLabel(), viewRange, leftYRange, getMonitor().getSpeedSeries(NetworkTrafficDataSeries.Type.BYTES_RECEIVED));
RangedContinuousSeries txSeries = new RangedContinuousSeries(NetworkTrafficDataSeries.Type.BYTES_SENT.getLabel(), viewRange, leftYRange, getMonitor().getSpeedSeries(NetworkTrafficDataSeries.Type.BYTES_SENT));
LineConfig receivedConfig = new LineConfig(ProfilerColors.NETWORK_RECEIVING_COLOR);
lineChart.addLine(rxSeries, receivedConfig);
LineConfig sentConfig = new LineConfig(ProfilerColors.NETWORK_SENDING_COLOR);
lineChart.addLine(txSeries, sentConfig);
lineChartPanel.add(lineChart, BorderLayout.CENTER);
final LegendComponent legend = new LegendComponent(LegendComponent.Orientation.HORIZONTAL, LEGEND_UPDATE_FREQUENCY_MS);
ArrayList<LegendRenderData> legendData = new ArrayList<>();
legendData.add(lineChart.createLegendRenderData(rxSeries, BANDWIDTH_AXIS_FORMATTER_L1, dataRange));
legendData.add(lineChart.createLegendRenderData(txSeries, BANDWIDTH_AXIS_FORMATTER_L1, dataRange));
legend.setLegendData(legendData);
final JPanel legendPanel = new JBPanel(new BorderLayout());
legendPanel.setOpaque(false);
legendPanel.add(label, BorderLayout.WEST);
legendPanel.add(legend, BorderLayout.EAST);
choreographer.register(lineChart);
choreographer.register(leftAxis);
choreographer.register(legend);
container.add(legendPanel, new TabularLayout.Constraint(0, 0));
container.add(leftAxis, new TabularLayout.Constraint(0, 0));
container.add(lineChartPanel, new TabularLayout.Constraint(0, 0));
container.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
getMonitor().expand();
}
});
}
Aggregations