@NotNull private Dimension calcSize(@NotNull Dimension dimension) { final Container container = getParent(); if (container != null) { final Dimension size = container.getSize(); return new Dimension(size.width, dimension.height); } return dimension; }
@Override public boolean getScrollableTracksViewportWidth() { return (getSize().width < getParent().getSize().width); }
private void positionPanel() { final JComponent contentComponent = myEditor.getContentComponent(); Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, contentComponent); setSize(scroll.getSize()); myLineHeight = myText.getFontMetrics(myText.getFont()).getHeight(); int count = countLines(myText.getText()); int visLines = getSize().height / myLineHeight - 1; int lines = Math.min(count, visLines); setSize(getSize().width, lines * myLineHeight + myLabel.getPreferredSize().height + getBorder().getBorderInsets(this).top * 2); int height = getSize().height; Rectangle bounds = scroll.getBounds(); bounds.translate(0, scroll.getHeight() - height); bounds.height = height; Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(), SwingUtilities.getRootPane(contentComponent).getGlassPane()); bounds.setLocation(pos); setBounds(bounds); myScrollPane.getVerticalScrollBar().setValue(0); if (!Options.getInstance().isSet("more")) { // FIX scrollOffset(100000); } else { scrollOffset(0); } }
@Override public Dimension preferredLayoutSize(Container container) { return container.getSize(); }
@Override public Dimension minimumLayoutSize(Container container) { return container.getSize(); }
void resizeMe(int zoomBoxX, int zoomBoxY, int zoomBoxWidth, int zoomBoxHeight) { Dimension viewSize = getParent().getSize(); double windowWidth = viewSize.getWidth(); double windowHeight = viewSize.getHeight(); double scaleX = getWidth() / ((double) zoomBoxWidth); double scaleY = getHeight() / ((double) zoomBoxHeight); int oldWidth = getWidth(); int oldHeight = getHeight(); int width = (int) (scaleX * windowWidth); int height = (int) (scaleY * windowHeight); // this.setPreferredSize(new Dimension(width, height)); child.resizeMe(width, height); // TODO not sure this one is needed this.revalidate(); // scroll to the new rectangle // int scrollX = (int) (zoomBoxX * scaleX); // int scrollY = (int) (zoomBoxY * scaleY); // int scrollWidth= (int) (zoomBoxWidth * scaleX); // int scrollHeight = (int) (zoomBoxHeight * scaleY); int scrollX = (int) (zoomBoxX * (width / (double) oldWidth)); int scrollY = (int) (zoomBoxY * (height / (double) oldHeight)); int scrollWidth = (int) (zoomBoxWidth * (width / (double) oldWidth)); int scrollHeight = (int) (zoomBoxHeight * (height / (double) oldHeight)); Rectangle r = new Rectangle(scrollX, scrollY, scrollWidth, scrollHeight); ((JViewport) getParent()).scrollRectToVisible(r); repaint(); }
private void fill(Component child, Container parent) { child.setLocation(0, 0); child.setSize(parent.getSize()); }
/** * The preferredSize of a list is total height of the rows * and the maximum width of the cells. If JList.fixedCellHeight * is specified then the total height of the rows is just * (cellVerticalMargins + fixedCellHeight) * model.getSize() where * rowVerticalMargins is the space we allocate for drawing * the yellow focus outline. Similarly if JListfixedCellWidth is * specified then we just use that plus the horizontal margins. * * @return The total size of the */ public Dimension getPreferredSize() { Insets insets = getInsets(); /* int dx = insets.left + insets.right; int dy = insets.top + insets.bottom; */ int max = getModel().getSize() - 1; if (max <= 0) { return new Dimension(fixedCellWidth, fixedCellHeight); } int y = (max / realColumnCount) + 1; int x = ((max < realColumnCount) ? (max + 1) : realColumnCount); int xParent = getParent().getSize().width; int yParent = getParent().getSize().height; int xRes = Math.max(xParent, x * fixedCellWidth); int yRes = Math.max(yParent, y * fixedCellHeight); Dimension d = new Dimension(xRes, yRes); return d; }
public void layoutContainer(Container parent) { Dimension d = parent.getSize(); int sPosition = splitPosition;
@Override public boolean getScrollableTracksViewportWidth() { return this.getUI().getPreferredSize(this).width <= this.getParent().getSize().width; }
int maxwidth = target.getSize().width - (insets.left + insets.right + (getHgap() * 2)); int nmembers = target.getComponentCount(); int x = 0;
private Dimension getBoundingSize(Component source) { if (source instanceof Window) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle bounds = env.getMaximumWindowBounds(); return new Dimension(bounds.width, bounds.height); } else { return source.getParent().getSize(); } }
private Dimension getBoundingSize(Component source) { if (source instanceof Window) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle bounds = env.getMaximumWindowBounds(); return new Dimension(bounds.width, bounds.height); } else { return source.getParent().getSize(); } } }
private Dimension getBoundingSize(Component source) { if (source instanceof Window) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle bounds = env.getMaximumWindowBounds(); return new Dimension(bounds.width, bounds.height); } else { return source.getParent().getSize(); } }
protected void layoutContainer(Container parent, float componentAlignmentX) { Component component = getComponent(parent); if (component != null) { layoutComponent( component, new Rectangle(parent.getSize()), componentAlignmentX, Component.CENTER_ALIGNMENT); } }
public Dimension preferredLayoutSize(final Container c) { if (!c.isValid()) { c.validate(); } return c.getSize(); }
public Dimension getPreferredScrollableViewportSize() { Dimension pref = super.getPreferredScrollableViewportSize(); if ((this.getAutoResizeMode() != JTable.AUTO_RESIZE_OFF) && (getParent() != null)) { Insets insets = getParent().getInsets(); Dimension size = getParent().getSize(); pref.height = size.height - insets.top - insets.bottom; } return pref; }