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

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

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

Rectangle.getBounds介绍

[英]Gets the bounding Rectangle of this Rectangle.

This method is included for completeness, to parallel the getBounds method of Component.
[中]获取此Rectangle的边界Rectangle
为了完整起见,包含此方法,以与组件的getBounds方法并行。

代码示例

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

private static Element getDefaultScreenAsElement() {
 if (SX.isNull(defaultScreenAsElement)) {
  defaultScreenAsElement = new Element(SX.getSXLOCALDEVICE().getMonitor().getBounds());
  defaultScreenAsElement.setName("SCREEN0");
 }
 return defaultScreenAsElement;
}

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

public ColorRegionMatch(Rectangle r){
  super(r.getBounds());
}

代码示例来源:origin: MegaMek/megamek

public Rectangle getBounds() {
  return areaShape.getBounds();
}

代码示例来源:origin: sikuli/sikuli-api

public ColorRegionMatch(Rectangle r){
  super(r.getBounds());
}

代码示例来源:origin: org.geotools/gt-widgets-swing-pending

/**
 * clear drawings
 * @param tree 
 */
private final void clearImage(JXTreeTable tree) {
  tree.paintImmediately(rect2D.getBounds());
}

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

public Rectangle getBounds() {
  if (npoints==0)
    return new Rectangle();
  if (bounds==null)
    calculateBounds(xpoints, ypoints, npoints);
  return bounds.getBounds();
}

代码示例来源:origin: imagej/ImageJA

public Rectangle getBounds() {
  if (npoints==0)
    return new Rectangle();
  if (bounds==null)
    calculateBounds(xpoints, ypoints, npoints);
  return bounds.getBounds();
}

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

private final void clearImage() {
    tree.paintImmediately(rect2D.getBounds());
}

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

private final void paintImage(Point pt) {
if (null == rect2D || null == image) {
  return;
}
    tree.paintImmediately(rect2D.getBounds());
    rect2D.setRect((int) pt.getX(),(int) pt.getY(),image.getWidth(),image.getHeight());
    tree.getGraphics().drawImage(image,(int) pt.getX(),(int) pt.getY(),tree);
}

代码示例来源:origin: org.geotools/gt-widgets-swing-pending

/**
 * paint the dragged node
 * @param tree 
 * @param pt 
 */
private final void paintImage(JXTreeTable tree, Point pt) {
  BufferedImage image = handler.getDragImage(tree);
  if (image != null) {
    tree.paintImmediately(rect2D.getBounds());
    rect2D.setRect((int) pt.getX() - 15, (int) pt.getY() - 15, image.getWidth(), image.getHeight());
    tree.getGraphics().drawImage(image, (int) pt.getX() - 15, (int) pt.getY() - 15, tree);
  }
}

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

protected static boolean isValidWindowPosition( Point location, Dimension dimension )
{
  Rectangle windowTitleBounds = new Rectangle( location.x, location.y, dimension.width, 20 );
  double windowTitleArea = windowTitleBounds.getWidth() * windowTitleBounds.getHeight();
  Rectangle[] screenBounds = GraphicUtils.getScreenBounds();
  for ( Rectangle screenBound : screenBounds )
  {
    Rectangle screen = screenBound.getBounds();
    Rectangle intersection = screen.intersection( windowTitleBounds );
    double visibleArea = intersection.getWidth() * intersection.getHeight();
    // if 25% of it is visible in the device, then it is good
    if ( ( visibleArea / windowTitleArea ) > 0.25 )
    {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial

@Override
  public void computeBounds (JTextPane textPane) {
    Rectangle tpBounds = textPane.getBounds();
    TextUI tui = textPane.getUI();
    this.bounds = new Rectangle();
    try {
      Rectangle startr = tui.modelToView(textPane, docstart, Position.Bias.Forward).getBounds();
      Rectangle endr = tui.modelToView(textPane, docend, Position.Bias.Backward).getBounds();
      this.bounds = new Rectangle(tpBounds.x + startr.x, startr.y, endr.x - startr.x, startr.height);
    } catch (BadLocationException ex) {
      Exceptions.printStackTrace(ex);
    }
  }
}

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

public void render(RenderContext context, Rectangle rect) {
  Graphics2D g2d = context.getGraphics();
  Rectangle clip = new Rectangle(g2d.getClip().getBounds());
  g2d.setClip(rect.intersection(clip.getBounds()));
  context.clearGraphicsCache();
  try {
    basePairRenderer.draw(basePairData, context, rect, renderOptions);
    context.clearGraphicsCache();
  } finally {
    g2d.setClip(clip);
  }
}

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

&& bounds.getBounds().equals(sourceGridRange)
    && isSimpleTransform
    && nodata == null
final Rectangle boundsInt = bounds.getBounds();
layout.setMinX(boundsInt.x);
layout.setWidth(boundsInt.width);

代码示例来源:origin: undera/jmeter-plugins

@Override
  public void mouseClicked(MouseEvent e) {
    log.debug("mouse click [" + e.getX() + "," + e.getY() + "] ClickCount[" + e.getClickCount() + "]");
    if (e.getClickCount() == 2) {
      for (Entry<String, AbstractGraphRow> row : model.entrySet()) {
        AbstractGraphRow agr = row.getValue();
        if (agr != null) {
          Rectangle r = agr.getLegendColorBox();
          if (r != null) {
            Rectangle slightlyLargerTarget = r.getBounds();
            slightlyLargerTarget.height += 4;
            slightlyLargerTarget.width += 2;
            boolean hit = slightlyLargerTarget.contains(e.getPoint());
            log.debug("hit [" + hit + "] rectangle [" + slightlyLargerTarget.toString() + "] point [" + e.getPoint() + "]");
            if (hit) {
              row.getValue().setColor(colors.getNextColor());
            }
          }
        }
      }
      updateGui(null);
    }
    //repaint();
  }
}

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

public List<Sequence> insertGapLeftOfSelectedBase(boolean undoable) {
  List<Sequence> editedSequences = new ArrayList<Sequence>();
  List<Sequence> selectedSeqs = selectionModel.getSelectedSequences(); 
  Rectangle selectionBounds = selectionModel.getSelectionBounds();
  for(Sequence seq: selectedSeqs){
    if(undoable){
      Sequence copy =  seq.getCopy();                
      editedSequences.add(copy);
    }
    seq.insertGapLeftOfSelectedBase();
  }
  if(selectedSeqs.size() > 0 && selectedSeqs.size() == delegateSequences.size()){
    int posToAdd = (int) (selectionBounds.getBounds().getMaxX() - 1);
    getAlignmentMeta().insertPosition(posToAdd);
  }
  if(selectedSeqs.size() > 0){
    fireSequencesChanged(selectedSeqs);
  }
  return editedSequences;
}

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

@Override
public void render(RenderContext context, Rectangle rect) {
  Graphics2D g2d = context.getGraphics();
  Rectangle clip = new Rectangle(g2d.getClip().getBounds());
  g2d.setClip(rect.intersection(clip.getBounds()));
  context.clearGraphicsCache();
  try {
    String chr = context.getReferenceFrame().getChrName();
    List<BedPEFeature> features = featureMap.get(chr);
    if (features != null) {
      renderer.render(features, context, rect, this);
    }
    context.clearGraphicsCache();
  } finally {
    g2d.setClip(clip);
  }
}

代码示例来源:origin: nroduit/Weasis

public AcquireImageValues(AcquireImageValues object) {
  setCropZone(Optional.ofNullable(object.cropZone).map(r -> r.getBounds()).orElse(null));
  setLayerOffset(Optional.ofNullable(object.layerOffset).map(p -> p.getLocation()).orElse(null));
  setOrientation(object.orientation);
  setRotation(object.rotation);
  setBrightness(object.brightness);
  setContrast(object.contrast);
  setAutoLevel(object.autoLevel);
  setFlip(object.flip);
  setCalibrationUnit(object.calibrationUnit);
  setCalibrationRatio(object.calibrationRatio);
  setRatio(object.ratio);
}

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

public List<Sequence> insertGapRightOfSelectedBase(boolean undoable) {
  List<Sequence> editedSequences = new ArrayList<Sequence>();
  List<Sequence> selectedSeqs = selectionModel.getSelectedSequences(); 
  Rectangle selectionBounds = selectionModel.getSelectionBounds();
  for(Sequence seq: selectedSeqs){
    if(undoable){
      editedSequences.add(seq.getCopy());
    }
    seq.insertGapRightOfSelectedBase();
  }
  if(selectedSeqs.size() == delegateSequences.size()){
    int posToAdd = (int) (selectionBounds.getBounds().getMaxX() + 1);
    getAlignmentMeta().insertPosition(posToAdd);
  }
  if(selectedSeqs.size() > 0){
    fireSequencesChanged(selectedSeqs);
  }
  return editedSequences;	
}

代码示例来源:origin: vasl-developers/vasl

/**
 * If the hex contains inherent terrain set center location to that terrain type
 */
private void setInherentTerrain(double gridadj){
  final Rectangle rectangle = getHexBorder().getBounds();
  Terrain terrain = null;
  for(int x = rectangle.x; x < rectangle.x + rectangle.width && terrain == null && x < map.getGridWidth(); x++) {
    for(int y = rectangle.y; y < rectangle.y + rectangle.height  && terrain == null; y++) {
      if(rectangle.getBounds().contains(x,y) &&
          map.onMap(x,y)  &&
          (x +gridadj< map.getGridWidth()) &&  //these two lines are to ensure point is within the terrain grid
          (x + gridadj >= 0) &&
          map.getGridTerrain((int)(x + gridadj),y).isInherentTerrain() &&
        getNearestLocation(x, y).equals(centerLocation)) {
        terrain = map.getGridTerrain((int)(x + gridadj),y);
      }
    }
  }
  if(terrain != null) {
    centerLocation.setTerrain(terrain);
  }
}

相关文章