use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class NetworkProfilerStageView method buildMonitorUi.
@NotNull
private JPanel buildMonitorUi() {
StudioProfilers profilers = getStage().getStudioProfilers();
ProfilerTimeline timeline = profilers.getTimeline();
Range viewRange = getTimeline().getViewRange();
Range dataRange = getTimeline().getDataRange();
EventMonitor events = new EventMonitor(profilers);
NetworkMonitor monitor = new NetworkMonitor(getStage().getStudioProfilers());
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(4, 0));
AxisComponent timeAxis = buildTimeAxis(profilers);
getChoreographer().register(timeAxis);
panel.add(timeAxis, new TabularLayout.Constraint(3, 0));
EventMonitorView eventsView = new EventMonitorView(events);
JComponent eventsComponent = eventsView.initialize(getChoreographer());
panel.add(eventsComponent, new TabularLayout.Constraint(0, 0));
panel.add(new NetworkRadioView(this).getComponent(), new TabularLayout.Constraint(1, 0));
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, 4);
Range rightYRange = new Range(0, 5);
RangedContinuousSeries receivedSeries = new RangedContinuousSeries(NetworkTrafficDataSeries.Type.BYTES_RECEIVED.getLabel(), viewRange, leftYRange, monitor.getSpeedSeries(NetworkTrafficDataSeries.Type.BYTES_RECEIVED));
RangedContinuousSeries sentSeries = new RangedContinuousSeries(NetworkTrafficDataSeries.Type.BYTES_SENT.getLabel(), viewRange, leftYRange, monitor.getSpeedSeries(NetworkTrafficDataSeries.Type.BYTES_SENT));
RangedContinuousSeries connectionSeries = new RangedContinuousSeries("Connections", viewRange, rightYRange, monitor.getOpenConnectionsSeries());
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();
LineConfig receivedConfig = new LineConfig(ProfilerColors.NETWORK_RECEIVING_COLOR);
lineChart.addLine(receivedSeries, receivedConfig);
LineConfig sentConfig = new LineConfig(ProfilerColors.NETWORK_SENDING_COLOR);
lineChart.addLine(sentSeries, sentConfig);
LineConfig connectionConfig = new LineConfig(ProfilerColors.NETWORK_CONNECTIONS_COLOR).setStroke(LineConfig.DEFAULT_DASH_STROKE);
lineChart.addLine(connectionSeries, connectionConfig);
getChoreographer().register(lineChart);
lineChartPanel.add(lineChart, BorderLayout.CENTER);
final JPanel axisPanel = new JBPanel(new BorderLayout());
axisPanel.setOpaque(false);
AxisComponent.Builder leftAxisBuilder = new AxisComponent.Builder(leftYRange, TRAFFIC_AXIS_FORMATTER, 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 = leftAxisBuilder.build();
getChoreographer().register(leftAxis);
axisPanel.add(leftAxis, BorderLayout.WEST);
AxisComponent.Builder rightAxisBuilder = new AxisComponent.Builder(rightYRange, CONNECTIONS_AXIS_FORMATTER, AxisComponent.AxisOrientation.LEFT).showAxisLine(false).showMax(true).showUnitAtMax(true).setMarkerLengths(MARKER_LENGTH, MARKER_LENGTH).clampToMajorTicks(true).setMargins(0, Y_AXIS_TOP_MARGIN);
final AxisComponent rightAxis = rightAxisBuilder.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(receivedSeries, TRAFFIC_AXIS_FORMATTER, dataRange));
legendData.add(lineChart.createLegendRenderData(sentSeries, TRAFFIC_AXIS_FORMATTER, dataRange));
legendData.add(lineChart.createLegendRenderData(connectionSeries, CONNECTIONS_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);
SelectionComponent selection = new SelectionComponent(timeline.getSelectionRange(), timeline.getViewRange());
selection.addChangeListener(this::onSelectionChanged);
getChoreographer().register(selection);
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 as much space as possible to the main monitor panel
layout.setRowSizing(2, "*");
panel.add(monitorPanel, new TabularLayout.Constraint(2, 0));
return panel;
}
use of com.intellij.ui.components.JBPanel in project intellij-community by JetBrains.
the class ShortcutDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
JLabel icon = new JLabel(AllIcons.General.BalloonWarning);
icon.setVerticalAlignment(SwingConstants.TOP);
JLabel label = new JLabel(KeyMapBundle.message("dialog.conflicts.text"));
label.setBorder(JBUI.Borders.emptyLeft(2));
JScrollPane scroll = ScrollPaneFactory.createScrollPane(null, true);
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scroll.setViewport(new GradientViewport(myConflictsContainer, JBUI.insets(5), false));
scroll.getVerticalScrollBar().setOpaque(false);
scroll.getViewport().setOpaque(false);
scroll.setOpaque(false);
JBPanel panel = new JBPanel(new BorderLayout());
panel.add(BorderLayout.NORTH, label);
panel.add(BorderLayout.CENTER, scroll);
myConflictsPanel.add(BorderLayout.WEST, icon);
myConflictsPanel.add(BorderLayout.CENTER, panel);
myConflictsContainer.setOpaque(false);
return myConflictsPanel;
}
use of com.intellij.ui.components.JBPanel in project intellij-community by JetBrains.
the class ShortcutDialog method createNorthPanel.
@Nullable
@Override
protected JComponent createNorthPanel() {
myAction.setIpad(JBUI.insets(10, 10, 5, 10));
myShortcutPanel.addPropertyChangeListener("shortcut", new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
setShortcut(toShortcut(event.getNewValue()));
}
});
JBPanel result = new JBPanel(new BorderLayout()).withPreferredWidth(300).withMinimumWidth(200);
result.add(BorderLayout.NORTH, myAction);
result.add(BorderLayout.SOUTH, myShortcutPanel);
return result;
}
use of com.intellij.ui.components.JBPanel in project intellij-community by JetBrains.
the class EmmetPreviewHint method createHint.
@NotNull
public static EmmetPreviewHint createHint(@NotNull final EditorEx parentEditor, @NotNull String templateText, @NotNull FileType fileType) {
EditorFactory editorFactory = EditorFactory.getInstance();
Document document = editorFactory.createDocument(templateText);
final EditorEx previewEditor = (EditorEx) editorFactory.createEditor(document, parentEditor.getProject(), fileType, true);
MarkupModelEx model = previewEditor.getMarkupModel();
if (model instanceof EditorMarkupModel) {
((EditorMarkupModel) model).setErrorStripeVisible(true);
}
final EditorSettings settings = previewEditor.getSettings();
settings.setLineNumbersShown(false);
settings.setAdditionalLinesCount(1);
settings.setAdditionalColumnsCount(1);
settings.setRightMarginShown(false);
settings.setFoldingOutlineShown(false);
settings.setLineMarkerAreaShown(false);
settings.setIndentGuidesShown(false);
settings.setVirtualSpace(false);
settings.setWheelFontChangeEnabled(false);
settings.setAdditionalPageAtBottom(false);
settings.setCaretRowShown(false);
previewEditor.setCaretEnabled(false);
previewEditor.setBorder(IdeBorderFactory.createEmptyBorder());
JBPanel panel = new JBPanel(new BorderLayout()) {
@NotNull
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
Dimension parentEditorSize = parentEditor.getScrollPane().getSize();
int maxWidth = (int) parentEditorSize.getWidth() / 3;
int maxHeight = (int) parentEditorSize.getHeight() / 2;
final int width = settings.isUseSoftWraps() ? maxWidth : Math.min((int) size.getWidth(), maxWidth);
final int height = Math.min((int) size.getHeight(), maxHeight);
return new Dimension(width, height);
}
@NotNull
@Override
public Insets getInsets() {
return new Insets(1, 2, 0, 0);
}
};
panel.setBackground(previewEditor.getBackgroundColor());
panel.add(previewEditor.getComponent(), BorderLayout.CENTER);
return new EmmetPreviewHint(panel, previewEditor, parentEditor);
}
use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class HprofView method createNavigationSplitter.
@NotNull
public static JBSplitter createNavigationSplitter(@Nullable JComponent leftPanelContents, @Nullable JComponent rightPanelContents) {
JBPanel navigationPanel = new JBPanel(new BorderLayout());
navigationPanel.setBackground(JBColor.background());
if (leftPanelContents != null) {
navigationPanel.add(leftPanelContents, BorderLayout.CENTER);
}
JBPanel contextInformationPanel = new JBPanel(new BorderLayout());
contextInformationPanel.setBackground(JBColor.background());
if (rightPanelContents != null) {
contextInformationPanel.add(rightPanelContents, BorderLayout.CENTER);
}
JBSplitter navigationSplitter = new JBSplitter(false);
navigationSplitter.setFirstComponent(navigationPanel);
navigationSplitter.setSecondComponent(contextInformationPanel);
navigationSplitter.setDividerWidth(DIVIDER_WIDTH);
return navigationSplitter;
}
Aggregations