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

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

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

Rectangle.add介绍

[英]Adds a point, specified by the integer arguments newx and newy, to this Rectangle. The resulting Rectangle is the smallest Rectangle that contains both the original Rectangle and the specified point.

After adding a point, a call to contains with the added point as an argument does not necessarily return true. The contains method does not return true for points on the right or bottom edges of a Rectangle. Therefore, if the added point falls on the right or bottom edge of the enlarged Rectangle, contains returns false for that point.
[中]将由整型参数newxnewy指定的点添加到此Rectangle。结果Rectangle是包含原始Rectangle和指定点的最小Rectangle
添加一个点后,以添加的点作为参数调用contains不一定返回truecontains方法不会为Rectangle的右边缘或下边缘上的点返回true。因此,如果添加的点落在放大的Rectangle的右边缘或下边缘,contains将返回该点的false

代码示例

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

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

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

public Rectangle getFollowerBounds() {
  // find the total bounds of all the components
  Rectangle bounds = new Rectangle(getBounds());
  for (Visual sklComp : getFollowers()) {
   bounds.add(sklComp.getBounds());
  }
  return bounds;
 }
//</editor-fold>

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

public void addRegion(Element region){
 if (regions.isEmpty()){
   setActualBounds(region.getRectangle());
 }else{
   Rectangle bounds = getBounds();
   bounds.add(region.getRectangle());
   setActualBounds(bounds);
 }
 regions.add(region);
}

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

@Override
 public void actionPerformed(ActionEvent e) {

  float r = funcr.getValue(count);

  int x = (int) (origin.x + (int) radius * Math.sin(r));
  int y=  (int) (origin.y + (int) radius * Math.cos(r));

  Point p = new Point(x,y);

  Rectangle r1 = comp.getBounds();

  comp.setLocation(p);

  // r1 stores the union of the bounds before/after the animated step
  Rectangle r2 = comp.getBounds();
  r1.add(r2);

  comp.getParent().getParent().repaint(r1.x,r1.y,r1.width,r1.height);
  //repaint(r1);
  //      comp.getParent().invalidate();
  //      comp.repaint();

  if (count == repeatCount)
   count = 0;
  else
   count++;

 }
}

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

@Override
public void actionPerformed(ActionEvent e){
 if ( count <= repeatCount){
   int x = (int) tfuncx.getValue(count);
   int y = (int) tfuncy.getValue(count);
   count++;
   Rectangle r1 = comp.getBounds();
   comp.setActualLocation(x,y);
   Rectangle r2 = comp.getBounds();
   r1.add(r2);
   Container c = comp.getParent();
   if (c != null){
     c.getParent().getParent().repaint(r1.x,r1.y,r1.width,r1.height);
   }
 }else{
   timer.stop();
 }
}

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

r0.add(r1);

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

r0.add(r1);

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

@Override
public void componentMoved(ComponentEvent e) {
 Rectangle r = getBounds();
 updateBounds();
 r.add(getBounds());
 if (getTopLevelAncestor() != null)
   getTopLevelAncestor().repaint(r.x,r.y,r.width,r.height);
}

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

@Override
public void updateComponent() {
 setForeground(colorFront);
 Rectangle dirtyBounds = getBounds();
 if (from != null && to != null) {
  source = from.getCenter();
  destination = to.getCenter();
 }
 Rectangle r = new Rectangle(getSource());
 r.add(getDestination());
 r.grow(10, 10);
 setActualBounds(r);
 dirtyBounds.add(getBounds());
 if (getTopLevelAncestor() != null) {
  getTopLevelAncestor().repaint(dirtyBounds.x, dirtyBounds.y, dirtyBounds.width, dirtyBounds.height);
 }
 if (hasComponents) {
  updateVisibility();
 }
}

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

@Override
 public void actionPerformed(ActionEvent e) {
  if (isRunning()) {

   Rectangle r = sklComponent.getBounds();

   //setActualLocation((int) x, (int) y);

   animate();

   r.add(sklComponent.getBounds());

   if (sklComponent.getTopLevelAncestor() != null) {
    sklComponent.getTopLevelAncestor().repaint(r.x, r.y, r.width, r.height);
   }

  } else {
   timer.stop();
   if (looping) {
    start();
   } else {
    animationRunning = false;
    if (listener != null) {
     listener.animationCompleted();
    }
   }
  }
 }
}

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

bufferedTargetArea.add( // exand top/right
    screenSize.x + screenSize.width + REPROJECTION_RASTER_GUTTER,
    screenSize.y + screenSize.height + REPROJECTION_RASTER_GUTTER);
bufferedTargetArea.add( // exand bottom/left
    screenSize.x - REPROJECTION_RASTER_GUTTER,
    screenSize.y - REPROJECTION_RASTER_GUTTER);

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

private void makeComponent() {
 if (layout == Layout.TOP) {
  triangle.rotate(0);
  dx = 0; dy = 0;
  triangle.setLocationRelativeToComponent(rbox, Layout.BOTTOM);
 } else if (layout == Layout.BOTTOM) {
  dx = 0; dy = TRIANGLE_SIZE;
  triangle.rotate(Math.PI);
  triangle.setLocationRelativeToComponent(rbox, Layout.TOP);
 } else if (layout == Layout.LEFT) {
  dx = 0; dy = 0;
  triangle.rotate(-Math.PI / 2);
  triangle.setLocationRelativeToComponent(rbox, Layout.RIGHT);
 } else if (layout == Layout.RIGHT) {
  dx = TRIANGLE_SIZE; dy = 0;
  triangle.rotate(Math.PI / 2);
  triangle.setLocationRelativeToComponent(rbox, Layout.LEFT);
 }
 Rectangle bounds = rbox.getBounds();
 bounds.add(triangle.getBounds());
 setActualBounds(bounds);
}

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

rect.add(comp.getBounds());
}else if (relationship == INTERSECTION){
  rect = rect.intersection(comp.getBounds());

代码示例来源:origin: sc.fiji/TrakEM2_

/** Enlarge the 2D universe so that all Displayable in the collection fit in it;
 * that is, that no Displayable has a negative x,y position or lays beyond bounds.*/
synchronized public void enlargeToFit(final Collection<? extends Displayable> ds) {
  Rectangle r = null;
  for (Displayable d : ds) {
    if (null == r) r = d.getBoundingBox();
    else r.add(d.getBoundingBox());
  }
  if (null == r) return; //empty collection
  r.add(get2DBounds());
  setDimensions(r.x, r.y, r.width, r.height);
}

代码示例来源:origin: sc.fiji/TrakEM2_

@Override
public Rectangle getRepaintBounds() {
  final Rectangle b = display.getSelection().getLinkedBox();
  b.add(floater.getBoundingBox(new Rectangle()));
  return b;
}

代码示例来源:origin: danfickle/openhtmltopdf

private void paintRootElementBackground(RenderingContext c, PaintingInfo pI) {
  Dimension marginCorner = pI.getOuterMarginCorner();
  Rectangle canvasBounds = new Rectangle(0, 0, marginCorner.width, marginCorner.height);
  canvasBounds.add(c.getViewportRectangle());
  c.getOutputDevice().paintBackground(c, getStyle(), canvasBounds, canvasBounds, BorderPropertySet.EMPTY_BORDER);
}

代码示例来源:origin: danfickle/openhtmltopdf

public static Rectangle findLayerRect(CssContext c, Layer layer) {
  Box container = layer.getMaster();
  Rectangle bounds = getBoxRect(c, container);
  // Floaters may be outside master box.
  // TODO: If this layer was triggered by a transform (not a positioned element)
  // then child positioned boxes may also fall otuside master box.
  for (BlockBox floater : layer.getFloats()) {
    Rectangle fBounds = getBoxRect(c, floater);
    bounds.add(fBounds);
  }
  
  return bounds;
}

代码示例来源:origin: danfickle/openhtmltopdf

protected void calcChildPaintingInfo(
    CssContext c, PaintingInfo result, boolean useCache) {
  for (int i = 0; i < getChildCount(); i++) {
    Box child = getChild(i);
    PaintingInfo info = child.calcPaintingInfo(c, useCache);
    moveIfGreater(result.getOuterMarginCorner(), info.getOuterMarginCorner());
    result.getAggregateBounds().add(info.getAggregateBounds());
  }
}

代码示例来源:origin: org.xhtmlrenderer/core-renderer

protected void calcChildPaintingInfo(
    CssContext c, PaintingInfo result, boolean useCache) {
  for (int i = 0; i < getInlineChildCount(); i++) {
    Object obj = getInlineChild(i);
    if (obj instanceof Box) {
      PaintingInfo info = ((Box)obj).calcPaintingInfo(c, useCache);
      moveIfGreater(result.getOuterMarginCorner(), info.getOuterMarginCorner());
      result.getAggregateBounds().add(info.getAggregateBounds());
    } 
  }
}

代码示例来源:origin: danfickle/openhtmltopdf

protected void calcChildPaintingInfo(
    CssContext c, PaintingInfo result, boolean useCache) {
  for (int i = 0; i < getInlineChildCount(); i++) {
    Object obj = getInlineChild(i);
    if (obj instanceof Box) {
      PaintingInfo info = ((Box)obj).calcPaintingInfo(c, useCache);
      moveIfGreater(result.getOuterMarginCorner(), info.getOuterMarginCorner());
      result.getAggregateBounds().add(info.getAggregateBounds());
    } 
  }
}

相关文章