use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class BaseSegment method initializeComponents.
public void initializeComponents() {
setLayout(new BorderLayout());
FontMetrics metrics = getFontMetrics(AdtUiUtils.DEFAULT_FONT);
mLabelPanel = createSpacerPanel(metrics.getHeight() + LABEL_BORDER_WIDTH);
mLabelPanel.setBorder(LABEL_BORDER);
mLabel = new RotatedLabel();
mLabel.setFont(AdtUiUtils.DEFAULT_FONT);
mLabel.setText(myName);
mLabel.setBorder(SEGMENT_BORDER);
mLabelPanel.add(mLabel);
this.add(mLabelPanel, BorderLayout.WEST);
JBPanel panels = new JBPanel();
panels.setBorder(SEGMENT_BORDER);
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
panels.setLayout(new GridBagLayout());
gbc.weightx = 0;
gbc.weighty = 0;
//Setup the left panel
if (hasLeftContent()) {
mLeftPanel = createSpacerPanel(getSpacerWidth());
gbc.gridx = 0;
gbc.gridy = 1;
panels.add(mLeftPanel, gbc);
setLeftContent(mLeftPanel);
}
//Setup the top center panel.
JBPanel topPanel = new JBPanel();
topPanel.setLayout(new BorderLayout());
gbc.gridx = 1;
gbc.gridy = 0;
panels.add(topPanel, gbc);
setTopCenterContent(topPanel);
//Setup the right panel
if (hasRightContent()) {
mRightPanel = createSpacerPanel(getSpacerWidth());
gbc.gridx = 2;
gbc.gridy = 1;
panels.add(mRightPanel, gbc);
setRightContent(mRightPanel);
}
//Setup the center panel, the primary component.
//This component should consume all available space.
JBPanel centerPanel = new JBPanel();
centerPanel.setLayout(new BorderLayout());
gbc.weightx = 1;
gbc.weighty = 1;
gbc.gridx = 1;
gbc.gridy = 1;
panels.add(centerPanel, gbc);
setCenterContent(centerPanel);
add(panels, BorderLayout.CENTER);
// By default, starts in L1, this gives the Segment a chance to hide the right spacer panel and determine what it should rendered.
toggleView(false);
}
use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class AccordionVisualTest method createComponentsList.
@Override
protected List<Animatable> createComponentsList() {
mStartTimeUs = TimeUnit.NANOSECONDS.toMicros(System.nanoTime());
Range timeGlobalRangeUs = new Range(0, 0);
mAnimatedTimeRange = new AnimatedTimeRange(timeGlobalRangeUs, mStartTimeUs);
mPanelX = new JBPanel();
mPanelY = new JBPanel();
mAccordionX = new AccordionLayout(mPanelX, AccordionLayout.Orientation.HORIZONTAL);
mAccordionY = new AccordionLayout(mPanelY, AccordionLayout.Orientation.VERTICAL);
mPanelX.setLayout(mAccordionX);
mPanelY.setLayout(mAccordionY);
List<Animatable> componentsList = new ArrayList<>();
// Add the scene components to the list
componentsList.add(mAccordionX);
componentsList.add(mAccordionY);
componentsList.add(mAnimatedTimeRange);
mRangedData = new ArrayList<>();
mData = new ArrayList<>();
Range yRange = new Range(0.0, 100.0);
for (int i = 0; i < 4; i++) {
if (i % 2 == 0) {
yRange = new Range(0.0, 100.0);
}
LongDataSeries series = new LongDataSeries();
RangedContinuousSeries ranged = new RangedContinuousSeries("Widgets", timeGlobalRangeUs, yRange, series);
mRangedData.add(ranged);
mData.add(series);
}
return componentsList;
}
use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class AccordionVisualTest method populateUi.
@Override
protected void populateUi(@NotNull JPanel panel) {
panel.setLayout(new GridLayout(0, 1));
Thread mUpdateDataThread = new Thread() {
@Override
public void run() {
try {
while (true) {
long nowUs = TimeUnit.NANOSECONDS.toMicros(System.nanoTime()) - mStartTimeUs;
for (LongDataSeries series : mData) {
ImmutableList<SeriesData<Long>> data = series.getAllData();
long last = data.isEmpty() ? 0 : data.get(data.size() - 1).value;
float delta = 10 * ((float) Math.random() - 0.45f);
series.add(nowUs, last + (long) delta);
}
Thread.sleep(LINECHART_DATA_DELAY);
}
} catch (InterruptedException e) {
}
}
};
mUpdateDataThread.start();
// Creates the vertical accordion at the top half.
JBPanel yPanel = new JBPanel();
panel.add(yPanel);
yPanel.setBorder(BorderFactory.createLineBorder(AdtUiUtils.DEFAULT_BORDER_COLOR));
final JPanel controlsY = VisualTest.createControlledPane(yPanel, mPanelY);
controlsY.add(VisualTest.createButton("Reset Weights", listener -> {
mAccordionY.resetComponents();
}));
controlsY.add(VisualTest.createButton("Add Chart", listener -> {
final LineChart chart = generateChart(mAccordionY, AccordionLayout.Orientation.VERTICAL, 0, PREFERRED_SIZE, Integer.MAX_VALUE);
mPanelY.add(chart);
mChartCountY++;
}));
controlsY.add(VisualTest.createButton("Add Chart With Min", listener -> {
final LineChart chart = generateChart(mAccordionY, AccordionLayout.Orientation.VERTICAL, MIN_SIZE, PREFERRED_SIZE, Integer.MAX_VALUE);
mPanelY.add(chart);
mChartCountY++;
}));
controlsY.add(VisualTest.createButton("Add Chart With Small Max", listener -> {
final LineChart chart = generateChart(mAccordionY, AccordionLayout.Orientation.VERTICAL, 0, PREFERRED_SIZE, MAX_SIZE);
mPanelY.add(chart);
mChartCountY++;
}));
controlsY.add(VisualTest.createButton("Remove Last Chart", listener -> {
mPanelY.remove(--mChartCountY);
}));
controlsY.add(new Box.Filler(new Dimension(0, 0), new Dimension(300, Integer.MAX_VALUE), new Dimension(300, Integer.MAX_VALUE)));
// Creates the horizontal accordion at the bottom half.
JBPanel xPanel = new JBPanel();
panel.add(xPanel);
xPanel.setBorder(BorderFactory.createLineBorder(AdtUiUtils.DEFAULT_BORDER_COLOR));
final JPanel controlsX = VisualTest.createControlledPane(xPanel, mPanelX);
controlsX.add(VisualTest.createButton("Reset Weights", listener -> {
mAccordionX.resetComponents();
}));
controlsX.add(VisualTest.createButton("Add Chart", listener -> {
final LineChart chart = generateChart(mAccordionX, AccordionLayout.Orientation.HORIZONTAL, 0, PREFERRED_SIZE, Integer.MAX_VALUE);
mPanelX.add(chart);
mChartCountX++;
}));
controlsX.add(VisualTest.createButton("Add Chart With Min", listener -> {
final LineChart chart = generateChart(mAccordionX, AccordionLayout.Orientation.HORIZONTAL, MIN_SIZE, PREFERRED_SIZE, Integer.MAX_VALUE);
mPanelX.add(chart);
mChartCountX++;
}));
controlsX.add(VisualTest.createButton("Add Chart With Small Max", listener -> {
final LineChart chart = generateChart(mAccordionX, AccordionLayout.Orientation.HORIZONTAL, 0, PREFERRED_SIZE, MAX_SIZE);
mPanelX.add(chart);
mChartCountX++;
}));
controlsX.add(VisualTest.createButton("Remove Last Chart", listener -> {
mPanelX.remove(--mChartCountX);
}));
controlsX.add(new Box.Filler(new Dimension(0, 0), new Dimension(300, Integer.MAX_VALUE), new Dimension(300, Integer.MAX_VALUE)));
}
use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class AxisLineChartVisualTest method populateUi.
@Override
protected void populateUi(@NotNull JPanel panel) {
panel.setLayout(new BorderLayout());
JLayeredPane mockTimelinePane = createMockTimeline();
panel.add(mockTimelinePane, BorderLayout.CENTER);
final JBPanel controls = new JBPanel();
LayoutManager manager = new BoxLayout(controls, BoxLayout.Y_AXIS);
controls.setLayout(manager);
panel.add(controls, BorderLayout.WEST);
final AtomicInteger variance = new AtomicInteger(10);
final AtomicInteger delay = new AtomicInteger(10);
Thread mUpdateDataThread = new Thread() {
@Override
public void run() {
try {
while (true) {
long nowUs = TimeUnit.NANOSECONDS.toMicros(System.nanoTime()) - mStartTimeUs;
for (LongDataSeries series : mData) {
ImmutableList<SeriesData<Long>> data = series.getAllData();
long last = data.isEmpty() ? 0 : data.get(data.size() - 1).value;
float delta = 10 * ((float) Math.random() - 0.45f);
series.add(nowUs, last + (long) delta);
}
Thread.sleep(delay.get());
}
} catch (InterruptedException e) {
}
}
};
mUpdateDataThread.start();
controls.add(VisualTest.createVariableSlider("Delay", 10, 5000, new VisualTests.Value() {
@Override
public void set(int v) {
delay.set(v);
}
@Override
public int get() {
return delay.get();
}
}));
controls.add(VisualTest.createVariableSlider("Variance", 0, 50, new VisualTests.Value() {
@Override
public void set(int v) {
variance.set(v);
}
@Override
public int get() {
return variance.get();
}
}));
controls.add(VisualTest.createCheckbox("Stable Scroll", itemEvent -> mScrollbar.setStableScrolling(itemEvent.getStateChange() == ItemEvent.SELECTED)));
controls.add(VisualTest.createCheckbox("Clamp To Major Ticks", itemEvent -> mMemoryAxis1.setClampToMajorTicks(itemEvent.getStateChange() == ItemEvent.SELECTED)));
controls.add(VisualTest.createCheckbox("Sync Vertical Axes", itemEvent -> mMemoryAxis2.setParentAxis(itemEvent.getStateChange() == ItemEvent.SELECTED ? mMemoryAxis1 : null)));
controls.add(new Box.Filler(new Dimension(0, 0), new Dimension(300, Integer.MAX_VALUE), new Dimension(300, Integer.MAX_VALUE)));
}
use of com.intellij.ui.components.JBPanel in project android by JetBrains.
the class AxisLineChartVisualTest method createMockTimeline.
private JLayeredPane createMockTimeline() {
JBLayeredPane timelinePane = new JBLayeredPane();
timelinePane.add(mMemoryAxis1);
timelinePane.add(mMemoryAxis2);
timelinePane.add(mTimeAxis);
timelinePane.add(mLineChart);
timelinePane.add(mSelection);
timelinePane.add(mGrid);
timelinePane.add(mScrollbar);
// TODO move to ProfilerOverviewVisualTest.
JBPanel labelPanel = new JBPanel();
labelPanel.setLayout(new FlowLayout());
labelPanel.add(mLegendComponent);
timelinePane.add(labelPanel);
timelinePane.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
JLayeredPane host = (JLayeredPane) e.getComponent();
if (host != null) {
Dimension dim = host.getSize();
for (Component c : host.getComponents()) {
if (c instanceof AxisComponent) {
AxisComponent axis = (AxisComponent) c;
switch(axis.getOrientation()) {
case LEFT:
axis.setBounds(0, 0, AXIS_SIZE, dim.height);
break;
case BOTTOM:
axis.setBounds(0, dim.height - AXIS_SIZE, dim.width, AXIS_SIZE);
break;
case RIGHT:
axis.setBounds(dim.width - AXIS_SIZE, 0, AXIS_SIZE, dim.height);
break;
case TOP:
axis.setBounds(0, 0, dim.width, AXIS_SIZE);
break;
}
} else if (c instanceof RangeScrollbar) {
int sbHeight = c.getPreferredSize().height;
c.setBounds(0, dim.height - sbHeight, dim.width, sbHeight);
} else {
c.setBounds(AXIS_SIZE, AXIS_SIZE, dim.width - AXIS_SIZE * 2, dim.height - AXIS_SIZE * 2);
}
}
}
}
});
return timelinePane;
}
Aggregations