java.awt.Rectangle.getSize()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(189)

本文整理了Java中java.awt.Rectangle.getSize方法的一些代码示例,展示了Rectangle.getSize的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rectangle.getSize方法的具体详情如下:
包路径:java.awt.Rectangle
类名称:Rectangle
方法名:getSize

Rectangle.getSize介绍

[英]Gets the size of this Rectangle, represented by the returned Dimension.

This method is included for completeness, to parallel the getSize method of Component.
[中]获取此Rectangle的大小,由返回的Dimension表示。
为了完整起见,包含此方法,以与ComponentgetSize方法并行。

代码示例

代码示例来源:origin: org.apache.poi/poi

public Dimension getSize() {
  return deviceBounds.getSize();
}

代码示例来源:origin: stanfordnlp/CoreNLP

private boolean addHighlight(JTextField label, MouseEvent mouseEvent1, MouseEvent mouseEvent2) {
 //Two parts: adding the highlight on the label, and scrolling the list appropriately
 //HighlightUtils handles the first part, we handle the second part here
 boolean highlightSuccessful = HighlightUtils.addHighlight(label, mouseEvent1, mouseEvent2);
 FontMetrics fm = label.getFontMetrics(label.getFont());
 int firstXpos = mouseEvent1.getX();
 int lastXpos = mouseEvent2.getX();
 int firstOffset = getCharOffset(fm, label.getText(), firstXpos);
 int lastOffset = getCharOffset(fm, label.getText(), lastXpos);
 if(lastOffset != firstOffset) {
  if(firstOffset > lastOffset) {
   int tmp = firstOffset;
   firstOffset = lastOffset;
   lastOffset = tmp;
  }
  Rectangle curVisible = list.getVisibleRect();
  if(lastXpos > curVisible.x+curVisible.width) {
   list.scrollRectToVisible(new Rectangle(new Point(lastXpos-curVisible.width, curVisible.y), curVisible.getSize()));
  } else if(lastXpos < curVisible.x) {
   list.scrollRectToVisible(new Rectangle(new Point(lastXpos, curVisible.y), curVisible.getSize()));
  }
  list.repaint();
  return highlightSuccessful;
 } else
  return false;
}

代码示例来源:origin: runelite/runelite

graphics.draw(insideStroke);
return new Dimension(rectangle.getSize());

代码示例来源:origin: igniterealtime/Openfire

Rectangle screenBounds = screensBounds[i];
if (screenBounds.x <= x && x <= (screenBounds.x + screenBounds.width)) {
  Dimension sizeScreen = screenBounds.getSize();
  sizeScreen.height -= 32;  // Hack to help prevent menu being clipped by Windows/Linux Taskbar.

代码示例来源:origin: runelite/runelite

void resizeMarker(Point point)
{
  Rectangle bounds = new Rectangle(startLocation);
  bounds.add(point);
  overlay.setPreferredLocation(bounds.getLocation());
  overlay.setPreferredSize(bounds.getSize());
}

代码示例来源:origin: runelite/runelite

@Override
public Dimension render(Graphics2D graphics)
{
  ScreenMarker marker = plugin.getCurrentMarker();
  if (marker == null)
  {
    return null;
  }
  int thickness = marker.getBorderThickness();
  int offset = thickness / 2;
  int width = getBounds().width - thickness;
  int height = getBounds().height - thickness;
  graphics.setStroke(createStripedStroke(thickness));
  graphics.setColor(marker.getColor());
  graphics.drawRect(offset, offset, width, height);
  return getBounds().getSize();
}

代码示例来源:origin: runelite/runelite

return bounds.getSize();

代码示例来源:origin: runelite/runelite

return newBounds.getSize();

代码示例来源:origin: runelite/runelite

public void finishCreation(boolean aborted)
{
  if (!aborted)
  {
    final ScreenMarkerOverlay screenMarkerOverlay = new ScreenMarkerOverlay(currentMarker);
    screenMarkerOverlay.setPreferredLocation(overlay.getBounds().getLocation());
    screenMarkerOverlay.setPreferredSize(overlay.getBounds().getSize());
    screenMarkers.add(screenMarkerOverlay);
    overlayManager.saveOverlay(screenMarkerOverlay);
    overlayManager.add(screenMarkerOverlay);
    pluginPanel.rebuild();
    updateConfig();
  }
  creatingScreenMarker = false;
  startLocation = null;
  currentMarker = null;
  setMouseListenerEnabled(false);
  pluginPanel.setCreation(false);
}

代码示例来源:origin: runelite/runelite

final Point transformed = OverlayUtil.transformPosition(getPosition(), intersectionRectangle.getSize());
intersectionRectangle.translate(transformed.x, transformed.y);

代码示例来源:origin: runelite/runelite

final Dimension dimension = overlay.getBounds().getSize();

代码示例来源:origin: RaiMan/SikuliX2

private void init(Element region) {
 try {
  robot = new Robot();
 } catch (AWTException e1) {
  e1.printStackTrace();
 }
 content = getJPanel();
 _region = region;
 Rectangle rect = _region.getRectangle();
 content.setPreferredSize(rect.getSize());
 add(content);
 setBounds(rect);
 getRootPane().putClientProperty("Window.shadow", Boolean.FALSE);
 ((JPanel) getContentPane()).setDoubleBuffered(true);
 setVisible(false);
 setFocusableWindowState(false);
}

代码示例来源:origin: protegeproject/protege

/**
 * Gets the width and height of this page object encapsulated in a {@link Dimension} object.
 * @return The dimension object that encapsulates the width and height of this page object.  Changing the width
 * and height of the returned dimension object will not change the width and height of this page object.
 */
public Dimension getSize() {
  return new Dimension(bounds.getSize());
}

代码示例来源:origin: geotools/geotools

final Dimension tileSize = ImageUtilities.toTileSize(gridBounds.getSize());
final GridSampleDimension band =
    GridSampleDimension.wrap(getSampleDimension(VISIBLE_BAND));

代码示例来源:origin: RaiMan/SikuliX2

setActualSize(rect.getSize());
} else if (mode == VERTICAL){
 setActualLocation(rect.x,0);

代码示例来源:origin: freeplane/freeplane

public static Rectangle getScreenBounds(final GraphicsConfiguration graphicsConfiguration) {
  final Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
  final Insets screenInsets = defaultToolkit.getScreenInsets(graphicsConfiguration);
  final Rectangle screenBounds = graphicsConfiguration.getBounds();
  final Point screenLocation = screenBounds.getLocation();
  final Dimension screenSize = screenBounds.getSize();
  final int screenWidth = screenSize.width - screenInsets.left - screenInsets.right;
  final int screenHeight = screenSize.height - screenInsets.top - screenInsets.bottom;
  return new Rectangle(screenLocation.x + screenInsets.left,  screenLocation.y + screenInsets.top, screenWidth, screenHeight);
}

代码示例来源:origin: org.antlr/antlr4

private Dimension getScaledTreeSize() {
  Dimension scaledTreeSize =
    treeLayout.getBounds().getBounds().getSize();
  scaledTreeSize = new Dimension((int)(scaledTreeSize.width*scale),
                  (int)(scaledTreeSize.height*scale));
  return scaledTreeSize;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

private Rectangle getTargetBounds(ConnectionWidget connectionWidget) {
  Widget target = connectionWidget.getTargetAnchor().getRelatedWidget();
  if (target == null)
    return null;
  Point targetLocation = target.getLocation();
  Rectangle targetArea = target.getClientArea();
  return new Rectangle(targetLocation, targetArea.getSize());
}

代码示例来源:origin: infinitest/infinitest

@Override
public void addNotify() {
  super.addNotify();
  Dimension textSize = getGraphics().getFontMetrics().getStringBounds("100%", getGraphics()).getBounds().getSize();
  Dimension minSize = new Dimension(textSize.width, textSize.height + getInsetHeight());
  setPreferredSize(minSize);
  validate();
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

public void justify (Widget widget) {
  Rectangle clientArea = widget.getClientArea ();
  for (Widget child : widget.getChildren ()) {
    if (child.isVisible ()) {
      Point location = child.getPreferredBounds ().getLocation ();
      child.resolveBounds (new Point (clientArea.x - location.x, clientArea.y - location.y), new Rectangle (location, clientArea.getSize ()));
    } else {
      child.resolveBounds (clientArea.getLocation (), new Rectangle ());
    }
  }
}

相关文章