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

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

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

Rectangle.getY介绍

暂无

代码示例

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

@Override
public void setBounds(int x, int y, int width, int height)
{
  if (containedInScreen)
  {
    Rectangle bounds = this.getGraphicsConfiguration().getBounds();
    width = Math.min(width, width - (int)bounds.getX() + x);
    x = Math.max(x, (int)bounds.getX());
    height = Math.min(height, height - (int)bounds.getY() + y);
    y = Math.max(y, (int)bounds.getY());
    width = Math.min(width, (int)(bounds.getX() + bounds.getWidth()) - x);
    height = Math.min(height, (int)(bounds.getY() + bounds.getHeight()) - y);
  }
  super.setBounds(x, y, width, height);
}

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

/**
 * Gets the upper-left coordinate of where the widget is being drawn
 * on the canvas.
 *
 * @return the upper-left coordinate of where this widget is drawn
 */
public Point getCanvasLocation()
{
  return new Point((int) canvasBounds.getX(), (int) canvasBounds.getY());
}

代码示例来源:origin: igvteam/igv

protected Rectangle calculateDrawingRect(Rectangle arect) {
  double buffer = Math.min(arect.getHeight() * marginFraction, 10);
  Rectangle adjustedRect = new Rectangle(arect);
  adjustedRect.y = (int) (arect.getY() + buffer);
  adjustedRect.height = (int) (arect.height - (adjustedRect.y - arect.getY()));
  return adjustedRect;
}

代码示例来源:origin: org.scijava/scijava-ui-swing

public static void locateUpperRight(final Container component) {
  final int w = component.getWidth();
  final Rectangle bounds = getWorkSpaceBounds();
  final int x = (int) (bounds.getX() + bounds.getWidth() - w);
  final int y = (int) (bounds.getY());
  component.setLocation(x, y);
}

代码示例来源:origin: org.scijava/scijava-ui-swing

public static void locateLowerLeft(final Container component) {
  final int h = component.getHeight();
  final Rectangle bounds = getWorkSpaceBounds();
  final int x = (int) (bounds.getX());
  final int y = (int) (bounds.getY() + bounds.getHeight() - h);
  component.setLocation(x, y);
}

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

private void renderWidgetText(Graphics2D graphics, Rectangle bounds, int itemId, Color color)
{
  if (itemId == -1)
  {
    return;
  }
  String text = itemId + "";
  FontMetrics fm = graphics.getFontMetrics();
  Rectangle2D textBounds = fm.getStringBounds(text, graphics);
  int textX = (int) (bounds.getX() + (bounds.getWidth() / 2) - (textBounds.getWidth() / 2));
  int textY = (int) (bounds.getY() + (bounds.getHeight() / 2) + (textBounds.getHeight() / 2));
  graphics.setColor(Color.BLACK);
  graphics.drawString(text, textX + 1, textY + 1);
  graphics.setColor(color);
  graphics.drawString(text, textX, textY);
}

代码示例来源:origin: igvteam/igv

Rectangle calculateDrawingRect(Rectangle arect) {
  double buffer = Math.min(arect.getHeight() * 0.2, 10);
  Rectangle adjustedRect = new Rectangle(arect);
  adjustedRect.y = (int) (arect.getY() + buffer);
  adjustedRect.height = (int) (arect.height - (adjustedRect.y - arect.getY()));
  return adjustedRect;
}

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

private boolean isWithinCloseButton(final Point point)
  {
    Point overlayPoint = new Point(point.x - (int) overlay.getBounds().getX(),
      point.y - (int) overlay.getBounds().getY());

    return overlay.getCloseButtonBounds() != null
      && overlay.getCloseButtonBounds().contains(overlayPoint);
  }
}

代码示例来源:origin: net.imagej/ij-ui-swing

public static void locateUpperRight(java.awt.Container component) {
 int w = component.getWidth();
 Rectangle bounds = getWorkSpaceBounds();
 int x = (int) (bounds.getX() + bounds.getWidth() - w);
 int y = (int) (bounds.getY());
 component.setLocation(x, y);
}

代码示例来源:origin: net.imagej/ij-ui-swing

public static void locateLowerLeft(java.awt.Container component) {
 int h = component.getHeight();
 Rectangle bounds = getWorkSpaceBounds();
 int x = (int) (bounds.getX());
 int y = (int) (bounds.getY() + bounds.getHeight() - h);
 component.setLocation(x, y);
}

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

@Override
public void setLocation(int x, int y)
{
  if (containedInScreen)
  {
    Rectangle bounds = this.getGraphicsConfiguration().getBounds();
    x = Math.max(x, (int)bounds.getX());
    x = Math.min(x, (int)(bounds.getX() + bounds.getWidth() - this.getWidth()));
    y = Math.max(y, (int)bounds.getY());
    y = Math.min(y, (int)(bounds.getY() + bounds.getHeight() - this.getHeight()));
  }
  super.setLocation(x, y);
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

private Rectangle boundsWithXandWidth(Rectangle bounds, double x, double width) {
 Rectangle r = new Rectangle();
 r.setBounds((int)x, (int)(bounds.getY()), (int)width, (int)(bounds.getHeight()));
 return r;
}

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

public Raster getRaster(int xOffset, int yOffset, int w, int h) {
  ColorModel cm = getColorModel();
  if (raster == null) createRaster();
  // TODO: eventually use caching here
  WritableRaster childRaster = cm.createCompatibleWritableRaster(w, h);
  Rectangle2D childRect = new Rectangle2D.Double(xOffset, yOffset, w, h);
  if (!childRect.intersects(deviceBounds)) {
    // usually doesn't happen ...
    return childRaster;
  }
  
  Rectangle2D destRect = new Rectangle2D.Double();
  Rectangle2D.intersect(childRect, deviceBounds, destRect);
  int dx = (int)(destRect.getX()-deviceBounds.getX());
  int dy = (int)(destRect.getY()-deviceBounds.getY());
  int dw = (int)destRect.getWidth();
  int dh = (int)destRect.getHeight();
  Object data = raster.getDataElements(dx, dy, dw, dh, null);
  dx = (int)(destRect.getX()-childRect.getX());
  dy = (int)(destRect.getY()-childRect.getY());
  childRaster.setDataElements(dx, dy, dw, dh, data);
  
  return childRaster;
}

代码示例来源:origin: JetBrains/ideavim

@NotNull
private static List<EditorWindow> findWindowsInRow(@NotNull EditorWindow anchor,
                          @NotNull List<EditorWindow> windows, final boolean vertical) {
 final Rectangle anchorRect = getEditorWindowRectangle(anchor);
 if (anchorRect != null) {
  final List<EditorWindow> result = new ArrayList<>();
  final double coord = vertical ? anchorRect.getX() : anchorRect.getY();
  for (EditorWindow window : windows) {
   final Rectangle rect = getEditorWindowRectangle(window);
   if (rect != null) {
    final double min = vertical ? rect.getX() : rect.getY();
    final double max = min + (vertical ? rect.getWidth() : rect.getHeight());
    if (coord >= min && coord <= max) {
     result.add(window);
    }
   }
  }
  result.sort((window1, window2) -> {
   final Rectangle rect1 = getEditorWindowRectangle(window1);
   final Rectangle rect2 = getEditorWindowRectangle(window2);
   if (rect1 != null && rect2 != null) {
    final double diff = vertical ? (rect1.getY() - rect2.getY()) : (rect1.getX() - rect2.getX());
    return diff < 0 ? -1 : diff > 0 ? 1 : 0;
   }
   return 0;
  });
  return result;
 }
 return Collections.singletonList(anchor);
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

private Rectangle boundsWithXandWidth(Rectangle bounds, double x, double width) {
 Rectangle r = new Rectangle();
 r.setBounds((int)x, (int)(bounds.getY()), (int)width, (int)(bounds.getHeight()));
 return r;
}

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

(int) closeButtonBounds.getX(), (int) closeButtonBounds.getY(), null);

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

private Point clipToRectangle(Point drawPoint, Rectangle mapDisplayRectangle)
  {
    int clippedX = drawPoint.getX();

    if (drawPoint.getX() < mapDisplayRectangle.getX())
    {
      clippedX = (int) mapDisplayRectangle.getX();
    }

    if (drawPoint.getX() > mapDisplayRectangle.getX() + mapDisplayRectangle.getWidth())
    {
      clippedX = (int) (mapDisplayRectangle.getX() + mapDisplayRectangle.getWidth());
    }

    int clippedY = drawPoint.getY();

    if (drawPoint.getY() < mapDisplayRectangle.getY())
    {
      clippedY = (int) mapDisplayRectangle.getY();
    }

    if (drawPoint.getY() > mapDisplayRectangle.getY() + mapDisplayRectangle.getHeight())
    {
      clippedY = (int) (mapDisplayRectangle.getY() + mapDisplayRectangle.getHeight());
    }

    return new Point(clippedX, clippedY);
  }
}

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

void selectRowForEvent(MouseEvent e) {
  int closestRow = getClosestRowForLocation(e.getX(), e.getY());
  Rectangle closestRowBounds = getRowBounds(closestRow);
  if(e.getY() >= closestRowBounds.getY()
      && e.getY() < closestRowBounds.getY() + closestRowBounds.getHeight()
      && !isRowSelected(closestRow)) {
    setSelectionRow(closestRow);
  }
}

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

int height = fm.getHeight();
int width = fm.stringWidth(output);
graphics.fillRect((int)worldMapRectangle.getX(), (int)worldMapRectangle.getY() + worldMapRectangle.height - height, (int)worldMapRectangle.getX() + width, (int)worldMapRectangle.getY() + worldMapRectangle.height);
graphics.drawString(output, (int) worldMapRectangle.getX(), (int) worldMapRectangle.getY() + worldMapRectangle.height);

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

private void renderInventory(Graphics2D graphics)
{
  Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY);
  if (inventoryWidget == null || inventoryWidget.isHidden())
  {
    return;
  }
  for (WidgetItem item : inventoryWidget.getWidgetItems())
  {
    Rectangle slotBounds = item.getCanvasBounds();
    String idText = "" + item.getId();
    FontMetrics fm = graphics.getFontMetrics();
    Rectangle2D textBounds = fm.getStringBounds(idText, graphics);
    int textX = (int) (slotBounds.getX() + (slotBounds.getWidth() / 2) - (textBounds.getWidth() / 2));
    int textY = (int) (slotBounds.getY() + (slotBounds.getHeight() / 2) + (textBounds.getHeight() / 2));
    graphics.setColor(new Color(255, 255, 255, 65));
    graphics.fill(slotBounds);
    graphics.setColor(Color.BLACK);
    graphics.drawString(idText, textX + 1, textY + 1);
    graphics.setColor(YELLOW);
    graphics.drawString(idText, textX, textY);
  }
}

相关文章