当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle.getSize方法代码示例

本文整理汇总了Java中java.awt.Rectangle.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getSize方法的具体用法?Java Rectangle.getSize怎么用?Java Rectangle.getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Rectangle的用法示例。


在下文中一共展示了Rectangle.getSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPopupLocation

import java.awt.Rectangle; //导入方法依赖的package包/类
private Point getPopupLocation() {
	Dimension popupSize = new Dimension((int) this.comboBox.getSize().getWidth(), (int) this.comboBox.getSize()
			.getHeight());
	Insets insets = getInsets();
	popupSize.setSize(popupSize.width - (insets.right + insets.left),
			getPopupHeightForRowCount(this.comboBox.getMaximumRowCount()));
	Rectangle popupBounds = computePopupBounds(0, this.comboBox.getBounds().height, popupSize.width,
			popupSize.height);
	Dimension scrollSize = popupBounds.getSize();
	Point popupLocation = popupBounds.getLocation();

	this.scroller.setMaximumSize(scrollSize);
	this.scroller.setPreferredSize(scrollSize);
	this.scroller.setMinimumSize(scrollSize);

	this.list.revalidate();
	return popupLocation;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:19,代码来源:ComboBoxUI.java

示例2: translateCoordinates

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Translates the given rectangle from one window to another.
 * Returns null if the translation is failed
 */
static Rectangle translateCoordinates(long src, long dst, Rectangle r,
                                      int scale)
{
    Point translatedLoc = translateCoordinates(src, dst, r.getLocation(),
                                               scale);

    if (translatedLoc == null)
    {
        return null;
    }
    else
    {
        return new Rectangle(translatedLoc, r.getSize());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:XlibUtil.java

示例3: adjustPopupAndGetBounds

import java.awt.Rectangle; //导入方法依赖的package包/类
protected Rectangle adjustPopupAndGetBounds() {
    if (isPopDown != isPopdown()) {
        updateContents(true);
    }

    final Dimension popupSize = getBestPopupSizeForRowCount(comboBox.getMaximumRowCount());
    final Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width, popupSize.height);
    if (popupBounds == null) return null; // returning null means don't show anything

    final Dimension realPopupSize = popupBounds.getSize();
    scroller.setMaximumSize(realPopupSize);
    scroller.setPreferredSize(realPopupSize);
    scroller.setMinimumSize(realPopupSize);
    list.invalidate();

    final int selectedIndex = comboBox.getSelectedIndex();
    if (selectedIndex == -1) {
        list.clearSelection();
    } else {
        list.setSelectedIndex(selectedIndex);
    }
    list.ensureIndexIsVisible(list.getSelectedIndex());

    return popupBounds;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:AquaComboBoxPopup.java

示例4: performLayout

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
protected void performLayout() {
    Rectangle rectangle = null;
    List<? extends Widget> toFit = widgets != null ? widgets : depScene.getChildren();
    if (toFit == null) {
        return;
    }

    for (Widget widget : toFit) {
        Rectangle bounds = widget.getBounds();
        if (bounds == null) {
            continue;
        }
        if (rectangle == null) {
            rectangle = widget.convertLocalToScene(bounds);
        } else {
            rectangle = rectangle.union(widget.convertLocalToScene(bounds));
        }
    }
    // margin around
    if (widgets == null) {
        rectangle.grow(5, 5);
    } else {
        rectangle.grow(25, 25);
    }
    Dimension dim = rectangle.getSize();
    Dimension viewDim = parentScrollPane.getViewportBorderBounds().getSize ();
    double zf = Math.min ((double) viewDim.width / dim.width, (double) viewDim.height / dim.height);
    if (depScene.isAnimated()) {
        if (widgets == null) {
            depScene.getSceneAnimator().animateZoomFactor(zf);
        } else {
            CenteredZoomAnimator cza = new CenteredZoomAnimator(depScene.getSceneAnimator());
            cza.setZoomFactor(zf,
                    new Point((int)rectangle.getCenterX(), (int)rectangle.getCenterY()));
        }
    } else {
        depScene.setMyZoomFactor (zf);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:DependencyGraphScene.java

示例5: getSourceBounds

import java.awt.Rectangle; //导入方法依赖的package包/类
private Rectangle getSourceBounds()
{
    Widget source = connection.getSourceAnchor().getRelatedWidget();
         
    if(source != null)
    {
        Point sourceLocation = source.getLocation();
        Rectangle clientArea = source.getClientArea();
        return new Rectangle(sourceLocation, clientArea.getSize());
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:DefaultAnchorShapeResolver.java

示例6: getTargetBounds

import java.awt.Rectangle; //导入方法依赖的package包/类
private Rectangle getTargetBounds()
{
    Widget target = connection.getTargetAnchor().getRelatedWidget();
            
    if(target != null)
    {
        Point targetLocation = target.getLocation();
        Rectangle targetArea = target.getClientArea();
        return new Rectangle(targetLocation, targetArea.getSize());
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:DefaultAnchorShapeResolver.java

示例7: show

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Create and display the popup at the given bounds.
 *
 * @param popupBounds location and size of the popup.
 * @param displayAboveCaret whether the popup is displayed above the anchor
 *  bounds or below them (it does not be right above them).
 */
private void show(Rectangle popupBounds, boolean displayAboveCaret) {
    // Hide the original popup if exists
    if (popup != null) {
        popup.hide();
        popup = null;
    }
    
    // Explicitly set the preferred size
    Dimension origPrefSize = getPreferredSize();
    Dimension newPrefSize = popupBounds.getSize();
    JComponent contComp = getContentComponent();
    if (contComp == null){
        return;
    }
    contComp.setPreferredSize(newPrefSize);
    showRetainedPreferredSize = newPrefSize.equals(origPrefSize);
    
    PopupFactory factory = PopupFactory.getSharedInstance();
    // Lightweight completion popups don't work well on the Mac - trying
    // to click on its scrollbars etc. will cause the window to be hidden,
    // so force a heavyweight parent by passing in owner==null. (#96717)
    
    JTextComponent owner = layout.getEditorComponent();
    if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) {
        owner = null;
    }
    
    // #76648: Autocomplete box is too close to text
    if(displayAboveCaret && Utilities.isMac()) {
        popupBounds.y -= 10;
    }
    
    popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y);
    popup.show();

    this.popupBounds = popupBounds;
    this.displayAboveCaret = displayAboveCaret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:CompletionLayoutPopup.java

示例8: computeLastButtonBounds

import java.awt.Rectangle; //导入方法依赖的package包/类
/** Returns bounds of last button in sliding view to which given
 * operation belongs. Bounds are relative to desktop layered pane.
 */
private Rectangle computeLastButtonBounds(SlideOperation operation) {
    String side = operation.getSide();
    SlidingView view = findView(side);
    Rectangle screenRect = view.getTabBounds(view.getTopComponents().size() - 1);
    Point leftTop = screenRect.getLocation();
    
    if (Constants.BOTTOM.equals(side)) {
        leftTop.y += desktop.getHeight() - view.getComponent().getPreferredSize().height;
    } else if (Constants.RIGHT.equals(side)) {
        leftTop.x += desktop.getWidth() - view.getComponent().getPreferredSize().width;
    }
    
    return new Rectangle(leftTop, screenRect.getSize());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DesktopImpl.java

示例9: showEffect

import java.awt.Rectangle; //导入方法依赖的package包/类
public void showEffect(JLayeredPane pane, Integer layer, SlideOperation operation) {
    this.pane = pane;
    this.operation = operation;
    Component comp = operation.getComponent();
    Graphics2D gr2d = (Graphics2D)pane.getGraphics();
    Rectangle start = operation.getStartBounds();
    Rectangle finish = operation.getFinishBounds();
    Dimension finishSize = finish.getSize();
    Dimension startSize = start.getSize();
    Rectangle current = start;
    Image compImage = preparedImage;

   /* if (compImage == null) {
        if (finishSize.width * finishSize.height > startSize.width * startSize.height) {
            compImage = renderCompIntoImage(comp, finishSize, pane);
        } else {
            compImage = renderCompIntoImage(comp, startSize, pane);
        }
    }*/
    pane.add(stretchedImage, layer);
    
    path = computePath(start, finish);
    
    curIter = 1;
    if (compImage != null) {
        stretchedImage.setOrigImage(compImage);
    } else {
        if (finishSize.width * finishSize.height > startSize.width * startSize.height) {
            stretchedImage.setComp(comp, finishSize);
        } else {
            stretchedImage.setComp(comp, startSize);
        }
    }
    stretchedImage.setBoundsAndAlpha(start, initialAlpha);
    
    getTimer().start();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:ScaleFx.java

示例10: show

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Create and display the popup at the given bounds.
 *
 * @param popupBounds location and size of the popup.
 * @param displayAboveCaret whether the popup is displayed above the anchor
 *  bounds or below them (it does not be right above them).
 */
private void show(Rectangle popupBounds, boolean displayAboveCaret) {
    // Hide the original popup if exists
    if (popup != null) {
        popup.hide();
        popup = null;
    }

    // Explicitly set the preferred size
    Dimension origPrefSize = getPreferredSize();
    Dimension newPrefSize = popupBounds.getSize();
    JComponent contComp = getContentComponent();
    if (contComp == null){
        return;
    }
    contComp.setPreferredSize(newPrefSize);
    showRetainedPreferredSize = newPrefSize.equals(origPrefSize);

    PopupFactory factory = PopupFactory.getSharedInstance();
    // Lightweight completion popups don't work well on the Mac - trying
    // to click on its scrollbars etc. will cause the window to be hidden,
    // so force a heavyweight parent by passing in owner==null. (#96717)

    JTextComponent owner = getEditorComponent();
    if(owner != null && owner.getClientProperty("ForceHeavyweightCompletionPopup") != null) { //NOI18N
        owner = null;
    }

    // #76648: Autocomplete box is too close to text
    if(displayAboveCaret && Utilities.isMac()) {
        popupBounds.y -= 10;
    }

    popup = factory.getPopup(owner, contComp, popupBounds.x, popupBounds.y);
    popup.show();

    this.popupBounds = popupBounds;
    this.displayAboveCaret = displayAboveCaret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:CompletionLayoutPopup.java

示例11: mapSize

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
   * @return the size of the map in pixels at 100% zoom,
   * including the edge buffer
   */
// FIXME: why synchronized?
  public synchronized Dimension mapSize() {
    final Rectangle r = new Rectangle(0,0);
    for (Board b : boards) r.add(b.bounds());
    r.width += edgeBuffer.width;
    r.height += edgeBuffer.height;
    return r.getSize();
  }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:13,代码来源:Map.java

示例12: mapSize

import java.awt.Rectangle; //导入方法依赖的package包/类
public Dimension mapSize() {
  final Rectangle r = new Rectangle(0,0,200,200);
  r.add(new Rectangle(super.mapSize()));

  for (GamePiece p : pieces.getPieces()) {
    final Rectangle bb = boundingBoxOf(p);
    if (bb != null) {
      r.add(bb);
    }
  }

  return r.getSize();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:14,代码来源:PlayerHand.java

示例13: getPreferredButtonSize

import java.awt.Rectangle; //导入方法依赖的package包/类
public static Dimension getPreferredButtonSize(AbstractButton b, int textIconGap)
{
    if(b.getComponentCount() > 0) {
        return null;
    }

    Icon icon = b.getIcon();
    String text = b.getText();

    Font font = b.getFont();
    FontMetrics fm = b.getFontMetrics(font);

    Rectangle iconR = new Rectangle();
    Rectangle textR = new Rectangle();
    Rectangle viewR = new Rectangle(Short.MAX_VALUE, Short.MAX_VALUE);

    SwingUtilities.layoutCompoundLabel(
        b, fm, text, icon,
        b.getVerticalAlignment(), b.getHorizontalAlignment(),
        b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
        viewR, iconR, textR, (text == null ? 0 : textIconGap)
    );

    /* The preferred size of the button is the size of
     * the text and icon rectangles plus the buttons insets.
     */

    Rectangle r = iconR.union(textR);

    Insets insets = b.getInsets();
    r.width += insets.left + insets.right;
    r.height += insets.top + insets.bottom;

    return r.getSize();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:BasicGraphicsUtils.java

示例14: translateCoordinates

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Translates the given rectangle from one window to another.
 * Returns null if the translation is failed
 */
static Rectangle translateCoordinates(long src, long dst, Rectangle r)
{
    Point translatedLoc = translateCoordinates(src, dst, r.getLocation());
    if (translatedLoc == null)
    {
        return null;
    }
    else
    {
        return new Rectangle(translatedLoc, r.getSize());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:XlibUtil.java

示例15: getSize

import java.awt.Rectangle; //导入方法依赖的package包/类
public Dimension getSize() {
    Rectangle bounds = getBounds();
    if (bounds != null) {
        return bounds.getSize();
    } else {
        return MIN_SIZE;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:BlockWidget.java


注:本文中的java.awt.Rectangle.getSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。