Search in sources :

Example 1 with DefaultBoundedRangeModel

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();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GCResourceGroup(com.tagtraum.perf.gcviewer.view.model.GCResourceGroup) JViewport(javax.swing.JViewport) JTabbedPane(javax.swing.JTabbedPane) Dimension(java.awt.Dimension) Point(java.awt.Point) DefaultBoundedRangeModel(javax.swing.DefaultBoundedRangeModel) JScrollBar(javax.swing.JScrollBar) PropertyChangeListener(java.beans.PropertyChangeListener) ChangeListener(javax.swing.event.ChangeListener)

Example 2 with DefaultBoundedRangeModel

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;
}
Also used : BoundedRangeModel(javax.swing.BoundedRangeModel) DefaultBoundedRangeModel(javax.swing.DefaultBoundedRangeModel) DefaultBoundedRangeModel(javax.swing.DefaultBoundedRangeModel)

Aggregations

DefaultBoundedRangeModel (javax.swing.DefaultBoundedRangeModel)2 GCResourceGroup (com.tagtraum.perf.gcviewer.view.model.GCResourceGroup)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 Point (java.awt.Point)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 BoundedRangeModel (javax.swing.BoundedRangeModel)1 JPanel (javax.swing.JPanel)1 JScrollBar (javax.swing.JScrollBar)1 JTabbedPane (javax.swing.JTabbedPane)1 JViewport (javax.swing.JViewport)1 ChangeListener (javax.swing.event.ChangeListener)1