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();
}
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);
}
}
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()));
}
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()));
}
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");
}
}
Aggregations