use of com.tagtraum.perf.gcviewer.view.model.GCResourceGroup 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 com.tagtraum.perf.gcviewer.view.model.GCResourceGroup in project GCViewer by chewiebug.
the class GCViewerGuiController method copyPreferencesFromGui.
/**
* Copies values that are stored in menu items into <code>GCPreferences</code> instance.
*
* @param gui source to copy values from
* @return <code>GCPreferences</code> with current values
*/
private GCPreferences copyPreferencesFromGui(GCViewerGui gui) {
GCPreferences preferences = gui.getPreferences();
for (Entry<String, JCheckBoxMenuItem> menuEntry : ((GCViewerGuiMenuBar) gui.getJMenuBar()).getViewMenuItems().entrySet()) {
JCheckBoxMenuItem item = menuEntry.getValue();
preferences.setGcLineProperty(item.getActionCommand(), item.getState());
}
preferences.setWindowWidth(gui.getWidth());
preferences.setWindowHeight(gui.getHeight());
preferences.setWindowX(gui.getX());
preferences.setWindowY(gui.getY());
OpenFile openFileAction = (OpenFile) gui.getActionMap().get(ActionCommands.OPEN_FILE.toString());
if (openFileAction.getLastSelectedFiles().length != 0) {
preferences.setLastFile(openFileAction.getLastSelectedFiles()[0].getAbsolutePath());
}
// recent files
List<String> recentFileList = new LinkedList<String>();
for (GCResourceGroup urlSet : ((GCViewerGuiMenuBar) gui.getJMenuBar()).getRecentGCResourcesModel().getResourceNameGroups()) {
recentFileList.add(urlSet.getUrlGroupString());
}
preferences.setRecentFiles(recentFileList);
return preferences;
}
Aggregations