Search in sources :

Example 1 with JViewport

use of javax.swing.JViewport 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 JViewport

use of javax.swing.JViewport in project jadx by skylot.

the class CodeArea method centerCurrentLine.

public void centerCurrentLine() {
    JViewport viewport = (JViewport) SwingUtilities.getAncestorOfClass(JViewport.class, this);
    if (viewport == null) {
        return;
    }
    try {
        Rectangle r = modelToView(getCaretPosition());
        if (r == null) {
            return;
        }
        int extentHeight = viewport.getExtentSize().height;
        Dimension viewSize = viewport.getViewSize();
        if (viewSize == null) {
            return;
        }
        int viewHeight = viewSize.height;
        int y = Math.max(0, r.y - extentHeight / 2);
        y = Math.min(y, viewHeight - extentHeight);
        viewport.setViewPosition(new Point(0, y));
    } catch (BadLocationException e) {
        LOG.debug("Can't center current line", e);
    }
}
Also used : JViewport(javax.swing.JViewport) Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension) Point(java.awt.Point) Point(java.awt.Point) BadLocationException(javax.swing.text.BadLocationException)

Example 3 with JViewport

use of javax.swing.JViewport in project zaproxy by zaproxy.

the class HttpPanelSyntaxHighlightTextArea method saveConfiguration.

public void saveConfiguration(String key, FileConfiguration fileConfiguration) {
    fileConfiguration.setProperty(key + ANTI_ALIASING, Boolean.valueOf(this.getAntiAliasingEnabled()));
    Component c = getParent();
    if (c instanceof JViewport) {
        c = c.getParent();
        if (c instanceof RTextScrollPane) {
            final RTextScrollPane scrollPane = (RTextScrollPane) c;
            fileConfiguration.setProperty(key + SHOW_LINE_NUMBERS, Boolean.valueOf(scrollPane.getLineNumbersEnabled()));
        }
    }
    fileConfiguration.setProperty(key + WORD_WRAP, Boolean.valueOf(this.getLineWrap()));
    fileConfiguration.setProperty(key + HIGHLIGHT_CURRENT_LINE, Boolean.valueOf(this.getHighlightCurrentLine()));
    fileConfiguration.setProperty(key + FADE_CURRENT_HIGHLIGHT_LINE, Boolean.valueOf(this.getFadeCurrentLineHighlight()));
    fileConfiguration.setProperty(key + SHOW_WHITESPACE_CHARACTERS, Boolean.valueOf(this.isWhitespaceVisible()));
    fileConfiguration.setProperty(key + SHOW_NEWLINE_CHARACTERS, Boolean.valueOf(this.getEOLMarkersVisible()));
    fileConfiguration.setProperty(key + MARK_OCCURRENCES, Boolean.valueOf(this.getMarkOccurrences()));
    fileConfiguration.setProperty(key + ROUNDED_SELECTION_EDGES, Boolean.valueOf(this.getRoundedSelectionEdges()));
    fileConfiguration.setProperty(key + BRACKET_MATCHING, Boolean.valueOf(this.isBracketMatchingEnabled()));
    fileConfiguration.setProperty(key + ANIMATED_BRACKET_MATCHING, Boolean.valueOf(this.getAnimateBracketMatching()));
}
Also used : JViewport(javax.swing.JViewport) Component(java.awt.Component) RTextScrollPane(org.fife.ui.rtextarea.RTextScrollPane)

Example 4 with JViewport

use of javax.swing.JViewport in project zaproxy by zaproxy.

the class HttpPanelSyntaxHighlightTextArea method loadConfiguration.

public void loadConfiguration(String key, FileConfiguration fileConfiguration) {
    setAntiAliasingEnabled(fileConfiguration.getBoolean(key + ANTI_ALIASING, this.getAntiAliasingEnabled()));
    Component c = getParent();
    if (c instanceof JViewport) {
        c = c.getParent();
        if (c instanceof RTextScrollPane) {
            final RTextScrollPane scrollPane = (RTextScrollPane) c;
            scrollPane.setLineNumbersEnabled(fileConfiguration.getBoolean(key + SHOW_LINE_NUMBERS, scrollPane.getLineNumbersEnabled()));
        }
    }
    setLineWrap(fileConfiguration.getBoolean(key + WORD_WRAP, this.getLineWrap()));
    setHighlightCurrentLine(fileConfiguration.getBoolean(key + HIGHLIGHT_CURRENT_LINE, this.getHighlightCurrentLine()));
    setFadeCurrentLineHighlight(fileConfiguration.getBoolean(key + FADE_CURRENT_HIGHLIGHT_LINE, this.getFadeCurrentLineHighlight()));
    setWhitespaceVisible(fileConfiguration.getBoolean(key + SHOW_WHITESPACE_CHARACTERS, this.isWhitespaceVisible()));
    setEOLMarkersVisible(fileConfiguration.getBoolean(key + SHOW_NEWLINE_CHARACTERS, this.getEOLMarkersVisible()));
    setMarkOccurrences(fileConfiguration.getBoolean(key + MARK_OCCURRENCES, this.getMarkOccurrences()));
    setRoundedSelectionEdges(fileConfiguration.getBoolean(key + ROUNDED_SELECTION_EDGES, this.getRoundedSelectionEdges()));
    setBracketMatchingEnabled(fileConfiguration.getBoolean(key + BRACKET_MATCHING, this.isBracketMatchingEnabled()));
    setAnimateBracketMatching(fileConfiguration.getBoolean(key + ANIMATED_BRACKET_MATCHING, this.getAnimateBracketMatching()));
}
Also used : JViewport(javax.swing.JViewport) Component(java.awt.Component) RTextScrollPane(org.fife.ui.rtextarea.RTextScrollPane)

Example 5 with JViewport

use of javax.swing.JViewport in project jdk8u_jdk by JetBrains.

the class DimensionEncapsulation method run.

@Override
public void run() {
    runTest(new Panel());
    runTest(new Button());
    runTest(new Checkbox());
    runTest(new Canvas());
    runTest(new Choice());
    runTest(new Label());
    runTest(new Scrollbar());
    runTest(new TextArea());
    runTest(new TextField());
    runTest(new Dialog(new JFrame()));
    runTest(new Frame());
    runTest(new Window(new JFrame()));
    runTest(new FileDialog(new JFrame()));
    runTest(new List());
    runTest(new ScrollPane());
    runTest(new JFrame());
    runTest(new JDialog(new JFrame()));
    runTest(new JWindow(new JFrame()));
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    //runTest(new JScrollBar()); --> don't test defines max and min in
    // terms of preferred
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Aggregations

JViewport (javax.swing.JViewport)33 JScrollPane (javax.swing.JScrollPane)12 Component (java.awt.Component)9 Container (java.awt.Container)8 Dimension (java.awt.Dimension)7 Point (java.awt.Point)5 Rectangle (java.awt.Rectangle)5 RTextScrollPane (org.fife.ui.rtextarea.RTextScrollPane)3 Graphics (java.awt.Graphics)2 BufferedImage (java.awt.image.BufferedImage)2 JButton (javax.swing.JButton)2 JCheckBox (javax.swing.JCheckBox)2 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)2 JColorChooser (javax.swing.JColorChooser)2 JComponent (javax.swing.JComponent)2 JDesktopPane (javax.swing.JDesktopPane)2 JScrollBar (javax.swing.JScrollBar)2 JTabbedPane (javax.swing.JTabbedPane)2 JTable (javax.swing.JTable)2 ChangeListener (javax.swing.event.ChangeListener)2