private void showMatchedPart(int idx) { Point2D.Double coord = matchedPartCoordinates.get(idx); Dimension treeSize = tjp.getPreferredSize(); JScrollBar horizontal = scroller.getHorizontalScrollBar(); JScrollBar vertical = scroller.getVerticalScrollBar(); int horizontalLength = horizontal.getMaximum() - horizontal.getMinimum(); double x = Math.max(0, (coord.getX() / treeSize.getWidth() * horizontalLength - (scroller.getWidth() / 2.0))); int verticalLength = vertical.getMaximum() - vertical.getMinimum(); double y = Math.max(0, (coord.getY() / treeSize.getHeight() * verticalLength - (scroller.getHeight() / 2.0))); horizontal.setValue((int) x); vertical.setValue((int) y); }
@ScriptFunction(jsDoc = HEIGHT_JSDOC) @Override public int getHeight() { return super.getHeight(); }
int scrollPaneHeight = scrollPane.getHeight(); JTableHeader header = table.getTableHeader(); int heightOfheaderOfTabel = header.getHeight();
editor.setSize(new Dimension( scroller.getWidth()-20, scroller.getHeight()-20));
/** * Create comment cached image * * @param forceRefresh * @param w * @param h */ public void createCommentImage(boolean forceRefresh, int w, int h) { if (forceRefresh || scrollPane.getWidth() != w || scrollPane.getHeight() != h) { if (w > 0 && h > 0) { scrollPane.setSize(w, h); cachedCommentImage = new BufferedImage(scrollPane.getWidth(), scrollPane.getHeight(), TYPE_INT_ARGB); Graphics2D g2 = cachedCommentImage.createGraphics(); scrollPane.doLayout(); scrollPane.validate(); scrollPane.printAll(g2); g2.dispose(); } } }
@Override public void valueChanged(final TreeSelectionEvent tse) { final ValueInspectorTreeNode node = (ValueInspectorTreeNode) tse.getPath().getLastPathComponent(); if (node != null && tse.isAddedPath()) { if (node.getEvalString() == null && textScrollPane.getHeight() != 0) { _textArea.setText(null); node.evalString(new Runnable() { @Override public void run() { _textArea.setText(node.getEvalString()); } }); ; } else { _textArea.setText(node.getEvalString()); } } } });
private void showMatchedPart(int idx) { Point2D.Double coord = matchedPartCoordinates.get(idx); Dimension treeSize = tjp.getPreferredSize(); JScrollBar horizontal = scroller.getHorizontalScrollBar(); JScrollBar vertical = scroller.getVerticalScrollBar(); int horizontalLength = horizontal.getMaximum() - horizontal.getMinimum(); double x = Math.max(0, (coord.getX() / treeSize.getWidth() * horizontalLength - (scroller.getWidth() / 2.0))); int verticalLength = vertical.getMaximum() - vertical.getMinimum(); double y = Math.max(0, (coord.getY() / treeSize.getHeight() * verticalLength - (scroller.getHeight() / 2.0))); horizontal.setValue((int) x); vertical.setValue((int) y); }
int maxSize = Math.max(MAX_SIZE, Math.max(_scrollPane.getWidth(), _scrollPane.getHeight()) / 2);
@Override public void show( final Component c, final int iX, final int iY ) { super.show( c, iX, iY ); EventQueue.invokeLater( () -> { if( !_bResizedWidth && _viewer.getWidth() > MAX_WIDTH ) { //noinspection SuspiciousNameCombination _scroller.setPreferredSize( new Dimension( MAX_WIDTH, MAX_WIDTH ) ); _bResizedWidth = true; pack(); setVisible( false ); show( c, iX, iY ); return; } if( !_bResizedHeight && isViewerLessThanHalfFull() ) { _scroller.setPreferredSize( new Dimension( MAX_WIDTH, _scroller.getHeight() / 2 ) ); _bResizedHeight = true; pack(); setVisible( false ); show( c, iX, iY ); } } ); }
@Override public void show( final Component c, final int iX, final int iY ) { super.show( c, iX, iY ); EventQueue.invokeLater( () -> { if( !_bResizedWidth && _viewer.getWidth() > MAX_WIDTH ) { //noinspection SuspiciousNameCombination _scroller.setPreferredSize( new Dimension( MAX_WIDTH, MAX_WIDTH ) ); _bResizedWidth = true; pack(); setVisible( false ); show( c, iX, iY ); return; } if( !_bResizedHeight && isViewerLessThanHalfFull() ) { _scroller.setPreferredSize( new Dimension( MAX_WIDTH, _scroller.getHeight() / 2 ) ); _bResizedHeight = true; pack(); setVisible( false ); show( c, iX, iY ); } } ); }
commentPane.setSize(w, h); createCommentImage(!comment.equals(this.cachedComment), w, h); commentRect = new Rectangle(x, y, scrollPane.getWidth(), scrollPane.getHeight()); g.drawImage( cachedCommentImage,
private void mouseMovedInScrollPane(Point point) { Rectangle bounds = scrollPane.getViewport().getBounds(); int tw = getScrollBarWidth(); int th = getScrollBarHeight(); Point p = new Point(point.x - bounds.x, point.y - bounds.y); boolean dansHaut = p.y >= 0 && p.y < th; boolean dansBas = p.y >= scrollPane.getHeight() - th && p.y < scrollPane.getHeight(); boolean dansGauche = p.x >= 0 && p.x < tw; boolean dansDroite = p.x >= scrollPane.getWidth() - tw && p.x < scrollPane.getWidth(); if (feedback.showHaut) { feedback.setMouseInHaut(dansHaut); feedback.distanceHaut = p.y; } if (feedback.showBas) { feedback.setMouseInBas(dansBas); feedback.distanceBas = scrollPane.getHeight() - p.y; } if (feedback.showGauche) { feedback.setMouseInGauche(dansGauche); feedback.distanceGauche = p.x; } if (feedback.showDroite) { feedback.setMouseInDroite(dansDroite); feedback.distanceDroite = scrollPane.getWidth() - p.x; } verifyTimer(); }
/** * * @return */ private boolean isViewerLessThanHalfFull() { Position endPos = _viewer.getDocument().getEndPosition(); if( endPos == null ) { return false; } int iEndPos = endPos.getOffset() - 1; try { Rectangle rcEndPos = _viewer.modelToView( iEndPos ); if( rcEndPos != null ) { return rcEndPos.y + rcEndPos.height < _scroller.getHeight() / 2; } } catch( Exception e ) { // Do nothing } return false; }
/** * * @return */ private boolean isViewerLessThanHalfFull() { Position endPos = _viewer.getDocument().getEndPosition(); if( endPos == null ) { return false; } int iEndPos = endPos.getOffset() - 1; try { Rectangle rcEndPos = _viewer.modelToView( iEndPos ); if( rcEndPos != null ) { return rcEndPos.y + rcEndPos.height < _scroller.getHeight() / 2; } } catch( Exception e ) { // Do nothing } return false; }
@Override public void paintComponent(Graphics g) { if (img != null) { Graphics2D g2 = (Graphics2D)g; g2.addRenderingHints(new RenderingHints( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); g2.addRenderingHints(new RenderingHints( RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY)); g2.addRenderingHints(new RenderingHints( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC)); int w = imgScrollPanel.getWidth()*zoom - 10; int h = imgScrollPanel.getHeight()*zoom - 10; setIcon(new ImageIcon(new FixedSizeThumbnailMaker() .size(w, h) .keepAspectRatio(true) .fitWithinDimensions(true) .make(img))); } super.paintComponent(g); }
/** * redraws and revalidates the size and preferred size of the viewport * and scroll pane to reflect the current collection of explorers. */ public void reformView() { int accumWidth = 0; int height = scroll.getHeight(); int width = scroll.getWidth(); for (Explorer explorer : explorers) { explorer.getJComponent().setBounds(accumWidth, 0, width, height); explorer.reformView(); accumWidth += width; } view.setPreferredSize(new Dimension(accumWidth, height)); view.setBounds(0, 0, accumWidth, height); scroll.revalidate(); scroll.repaint(); scroll.getHorizontalScrollBar().setValue(explorers.get(position).getJComponent().getX()); }
vsbR.height = isVsbCoversWholeHeight(scrollPane) ? scrollPane.getHeight() - insets.bottom - insets.top : availR.height + vpbInsets.top + vpbInsets.bottom; hsbR.width = isHsbCoversWholeWidth(scrollPane) ? scrollPane.getWidth() - vsbR.width - insets.left - insets.right : availR.width + vpbInsets.left + vpbInsets.right; rowHeadR.height = availR.height + vpbInsets.top + vpbInsets.bottom;
JScrollPane pane = (JScrollPane)parent; Rectangle bounds = new Rectangle(pane.getWidth(), pane.getHeight()); JBInsets.removeFrom(bounds, pane.getInsets());