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

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

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

Rectangle.getLocation介绍

[英]Returns the location of this Rectangle.

This method is included for completeness, to parallel the getLocation method of Component.
[中]返回此Rectangle的位置。
包含此方法是为了完整性,与ComponentgetLocation方法并行。

代码示例

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

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

代码示例来源:origin: stackoverflow.com

if(bounds.contains(p)) {
  Point b = bounds.getLocation(); 
  Point s = new Point(p.x - b.x, p.y - b.y);

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

private void positionPanel() {
 if (parent == null) return;
 Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, parent);
 int height = (int)getPreferredSize().getHeight();
 if (scroll != null) {
  Rectangle bounds = scroll.getBounds();
  bounds.translate(0, scroll.getHeight() - height);
  bounds.height = height;
  Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(), oldGlass);
  bounds.setLocation(pos);
  setBounds(bounds);
  repaint();
 }
}

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

bounds.height = height;
final JRootPane rootPane = SwingUtilities.getRootPane(myParent);
final Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(), rootPane);
final Window window = SwingUtilities.getWindowAncestor(myParent);
final Point windowPos = window.getLocation();

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

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);
 }
}

代码示例来源: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: org.netbeans.api/org-openide-awt

public @Override Point getLocation() {
  return bounds.getLocation();
}

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

public Point getActualLocation() {
 return actualBounds.getLocation();
}

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

final Point location = overlay.getBounds().getLocation();
final Dimension dimension = overlay.getBounds().getSize();

代码示例来源:origin: bobbylight/RSyntaxTextArea

/**
 * Positions this popup to be in the top right-hand corner of the parent
 * editor.
 */
private void setLocation() {
  Point topLeft = textArea.getVisibleRect().getLocation();
  SwingUtilities.convertPointToScreen(topLeft, textArea);
  topLeft.y = Math.max(topLeft.y - 24, 0);
  setLocation(topLeft.x - LEFT_EMPTY_BORDER, topLeft.y);
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

/**
 * Compute the bounds in which the user can move the mouse without the
 * tip window disappearing.
 */
private void computeTipVisibleBounds() {
  // Compute area that the mouse can move in without hiding the
  // tip window. Note that Java 1.4 can only detect mouse events
  // in Java windows, not globally.
  Rectangle r = tipWindow.getBounds();
  Point p = r.getLocation();
  SwingUtilities.convertPointFromScreen(p, textArea);
  r.setLocation(p);
  tipVisibleBounds.setBounds(r.x,r.y-15, r.width,r.height+15*2);
}

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

/** Recalculates the value of variables realRowCount and
 * realColumnCount. If the view needs update calls
 * revalidate.
 */
private void updateLayoutState() {
  Dimension d = getSize();
  int x = d.width / fixedCellWidth;
  if (x < 1) {
    x = 1;
  }
  if (x != realColumnCount) {
    realColumnCount = x;
    updateLayoutStateNeeded = true;
  }
  int y = d.height / fixedCellHeight;
  if (y != realRowCount) {
    realRowCount = y;
    updateLayoutStateNeeded = true;
  }
  while ((realRowCount * realColumnCount) < getModel().getSize()) {
    realRowCount++;
  }
  locationToIndex(getVisibleRect().getLocation());
  if (updateLayoutStateNeeded) {
    updateLayoutStateNeeded = false;
    revalidate();
  }
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

return;
Point p = r.getLocation();
SwingUtilities.convertPointToScreen(p, textArea);
r.x = p.x;

代码示例来源:origin: Audiveris/audiveris

@Override
public Point getTopLeft ()
{
  checkBounds();
  return bounds.getLocation();
}

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

/**
 * @param table {@link JTable}
 * @return number of visible rows
 */
private static int getNumberOfVisibleRows(JTable table) {
  Rectangle vr = table.getVisibleRect();
  int first = table.rowAtPoint(vr.getLocation());
  vr.translate(0, vr.height);
  return table.rowAtPoint(vr.getLocation()) - first;
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-editor

public static void convertRectangleToScreen( Rectangle rectangle, Component component )
{
 Point loc = rectangle.getLocation();
 SwingUtilities.convertPointToScreen( loc, component );
 rectangle.setLocation( loc );
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-editor

public static void convertRectangleToScreen( Rectangle rectangle, Component component )
{
 Point loc = rectangle.getLocation();
 SwingUtilities.convertPointToScreen( loc, component );
 rectangle.setLocation( loc );
}

代码示例来源:origin: com.fifesoft/rsyntaxtextarea

/**
 * Positions this popup to be in the top right-hand corner of the parent
 * editor.
 */
private void setLocation() {
  Point topLeft = textArea.getVisibleRect().getLocation();
  SwingUtilities.convertPointToScreen(topLeft, textArea);
  topLeft.y = Math.max(topLeft.y - 24, 0);
  setLocation(topLeft.x - LEFT_EMPTY_BORDER, topLeft.y);
}

代码示例来源: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 ());
    }
  }
}

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

public Rectangle getBoundsToScreen(Rectangle bounds, Component ref) {
  Point location = bounds.getLocation();
  SwingUtilities.convertPointToScreen(location, ref);
  bounds.setLocation(location);
  bounds.y += getJMenuBarExtraHeight();
  return bounds;
}

相关文章