/** Programmatically set the column widths of the prompt set table */ private void setColumnWidths() { // only try to do this when we are visible if (!this.isVisible()) return; // Get columns from column model TableColumn recStatusColumn = jTable_PromptSet.getColumnModel().getColumn(0); TableColumn baseNameColumn = jTable_PromptSet.getColumnModel().getColumn(1); TableColumn promptColumn = jTable_PromptSet.getColumnModel().getColumn(2); // Get length of longest string in the column int widestBasename = LookAndFeel.getMaxColumnWidth(this.jTable_PromptSet, this.BASENAME_COLUMN); // These widths seem to be appropriate for the firs two columns - set them int recStatusColumnWidth = 50; // Leave hardcoded since only three possible values int baseNameColumnWidth = widestBasename + 10; // was 110 when hardcorded Test.output("Basename column width: " + widestBasename); recStatusColumn.setPreferredWidth(recStatusColumnWidth); baseNameColumn.setPreferredWidth(baseNameColumnWidth); // Now set prompt column to fill remaining width of the table int scrollbarBuffer = 3; // Buffer to avoid displaying a horizontal scrollbar int tableWidth = jScrollPane_PromptSet.getWidth(); promptColumn.setPreferredWidth(tableWidth - (recStatusColumnWidth + baseNameColumnWidth + scrollbarBuffer)); }
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 = WIDTH_JSDOC) @Override public int getWidth() { return super.getWidth(); }
/** * 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(); } } }
public void componentResized(ComponentEvent e) { editor.setSize(new Dimension( scroller.getWidth()-20, scroller.getHeight()-20));
public static boolean isValidCellBoundary(Component aTarget) { JScrollPane scroll = getFirstScrollPane(aTarget); if (scroll != null && (scroll.getHorizontalScrollBar() == null || !scroll.getHorizontalScrollBar().isVisible())) { Point rightOnScroll = SwingUtilities.convertPoint(aTarget, new Point(aTarget.getWidth(), 1), scroll); int scrollRightBoundary = (scroll.getWidth() - (scroll.getInsets() != null ? scroll.getInsets().right : 0)); return (scrollRightBoundary - rightOnScroll.x) > MultiLevelHeader.PICK_MARGIN_SIZE; } return true; } }
int maxSize = Math.max(MAX_SIZE, Math.max(_scrollPane.getWidth(), _scrollPane.getHeight()) / 2);
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); }
commentPane.setSize(w, h); createCommentImage(!comment.equals(this.cachedComment), w, h); commentRect = new Rectangle(x, y, scrollPane.getWidth(), scrollPane.getHeight()); g.drawImage( cachedCommentImage,
public void actionPerformed(ActionEvent e) { JOptionPane helpPane = new JOptionPane(helpScroller, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog = helpPane.createDialog(HelpButton.this, "Help"); dialog.setResizable(true); dialog.setModal(false); dialog.setSize(dialog.getHeight(), helpScroller.getWidth() + 10); dialog.setVisible(true); }
public void actionPerformed(ActionEvent e) { JOptionPane helpPane = new JOptionPane(helpScroller, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog = helpPane.createDialog(HelpButton.this, "Help"); dialog.setResizable(true); dialog.setModal(false); dialog.setSize(dialog.getHeight(), helpScroller.getWidth() + 10); dialog.setVisible(true); }
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(); }
private void setup( Component parent ) { EntityDef root = lodDef.getRoot(); lodDefLayout = env.getOdLayout( lodDef ); EntitySquare e = new EntitySquare( this, env, null ); // Create a dummy just to get the size. Dimension size = new Dimension( lodDefLayout.getWidth() * e.getPaddedSize().width, lodDefLayout.getHeight() * e.getPaddedSize().height ); drawingPane.setPreferredSize( size ); drawingPane.setVisible( true ); e = addEntity( root, 0, size.width ); setSelectedEntity( e ); if ( scroller.getWidth() < size.width ) { int mid = size.width / 2 - parent.getWidth() / 2 + 10; // 10 is for width of scroll bar. Point p = new Point( mid, 0 ); scroller.getViewport().setViewPosition( p ); } }
@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); }
/** * Enable or disable the userlist. As with setting the initial size, this * requires some hacky stuff to get the size back correctly. * * @param enable */ public final void setUserlistEnabled(boolean enable) { if (enable == userlistEnabled) { return; } if (enable) { userlist.setVisible(true); mainPane.setDividerSize(DIVIDER_SIZE); setUserlistWidth(previousUserlistWidth, userlistMinWidth); setTextPreferredSizeTemporarily(); mainPane.setDividerLocation(-1); } else { previousUserlistWidth = userlist.getWidth(); userlist.setVisible(false); mainPane.setDividerSize(0); } userlistEnabled = enable; revalidate(); }
/** * 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()); }
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; rowHeadR.y = availR.y - vpbInsets.top;
JScrollPane pane = (JScrollPane)parent; Rectangle bounds = new Rectangle(pane.getWidth(), pane.getHeight()); JBInsets.removeFrom(bounds, pane.getInsets());