use of javax.swing.DefaultBoundedRangeModel in project GCViewer by chewiebug.
the class GCDocument method relayout.
/**
* Relayouts all chartPanelViews contained in this document. Should always be called, when
* a change with the chartPanelViews happened (add / remove / minimize / maximize
* chartPanelView).
*/
public void relayout() {
getContentPane().removeAll();
String newTitle = "";
if (chartPanelViews.size() > 0) {
GCResourceGroup group = new GCResourceGroup(getGCResources());
newTitle = group.getGroupStringShort();
}
setTitle(newTitle);
int row = 0;
boolean noMaximizedChartPanelView = true;
ChartPanelView lastMaximizedChartPanelView = getLastMaximizedChartPanelView();
MasterViewPortChangeListener masterViewPortChangeListener = new MasterViewPortChangeListener();
for (int i = 0; i < chartPanelViews.size(); i++) {
final ChartPanelView chartPanelView = chartPanelViews.get(i);
final ModelChartImpl modelChart = (ModelChartImpl) chartPanelView.getModelChart();
final ModelMetricsPanel modelMetricsPanel = chartPanelView.getModelMetricsPanel();
final JTabbedPane modelChartAndDetails = chartPanelView.getModelChartAndDetails();
modelChart.resetPolygonCache();
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.anchor = GridBagConstraints.NORTH;
constraints.gridy = row;
if (chartPanelViews.size() > 1 || (chartPanelView.isMinimized() && chartPanelViews.size() == 1)) {
constraints.gridwidth = 2;
constraints.weightx = 2;
//constraints.weighty = 1;
getContentPane().add(chartPanelView.getViewBar(), constraints);
row++;
}
constraints.fill = GridBagConstraints.BOTH;
constraints.gridy = row;
constraints.gridwidth = 1;
//2
constraints.gridheight = 1;
constraints.gridx = 0;
constraints.weightx = 2;
constraints.weighty = 2;
modelChart.setPreferredSize(new Dimension(800, 600));
modelChartAndDetails.setVisible(!chartPanelView.isMinimized());
getContentPane().add(modelChartAndDetails, constraints);
constraints.gridy = row;
constraints.gridheight = 1;
constraints.gridx = 1;
constraints.weightx = 0;
constraints.weighty = 0;
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.anchor = GridBagConstraints.SOUTH;
getContentPane().add(modelMetricsPanel, constraints);
modelMetricsPanel.setVisible(showModelMetricsPanel && (!chartPanelView.isMinimized()));
if (!chartPanelView.isMinimized()) {
noMaximizedChartPanelView = false;
final boolean isLastMaximizedChartPanelView = lastMaximizedChartPanelView == chartPanelView;
// lock viewports with each other...
// remove old master listeners
final JViewport viewport = modelChart.getViewport();
lockChartsToOneScrollbar(viewport, isLastMaximizedChartPanelView, modelChart, masterViewPortChangeListener);
final JScrollBar horizontalScrollBar = modelChart.getHorizontalScrollBar();
// clean old change listeners
ChangeListener[] changeListeners = ((DefaultBoundedRangeModel) horizontalScrollBar.getModel()).getChangeListeners();
for (int j = 0; j < changeListeners.length; j++) {
if (changeListeners[j] instanceof ScrollBarMaximumChangeListener) {
horizontalScrollBar.getModel().removeChangeListener(changeListeners[j]);
}
}
if (isLastMaximizedChartPanelView && isWatched()) {
horizontalScrollBar.getModel().addChangeListener(new ScrollBarMaximumChangeListener());
}
if (isLastMaximizedChartPanelView) {
horizontalScrollBar.setEnabled(!isWatched());
}
}
row++;
}
if (noMaximizedChartPanelView) {
// add dummy panel
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.BOTH;
constraints.gridy = row;
constraints.weightx = 3;
constraints.weighty = 3;
getContentPane().add(new JPanel(), constraints);
}
scaleModelChart();
invalidate();
}
use of javax.swing.DefaultBoundedRangeModel in project jvm-tools by aragozin.
the class HeapProgress method getProgress.
public static BoundedRangeModel getProgress() {
BoundedRangeModel model = (BoundedRangeModel) progressThreadLocal.get();
if (model == null) {
model = new DefaultBoundedRangeModel(0, 0, 0, PROGRESS_MAX);
progressThreadLocal.set(model);
}
return model;
}
Aggregations