Java 8 Rectangle - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Rectangle class.

This code example shows how to use the following methods:grow, setLocation, setSize
      this.text = text;
       
      setForeground(Color.black);
      setBackground(Color.green);
 
      textBox = new Rectangle();
      triangle = new Rectangle();
 
      font = new Font("sansserif", Font.BOLD, 14);
      fm = getFontMetrics(font);
      textBox.setSize(fm.stringWidth(text),fm.getHeight());
      textBox.grow(PADDING_X, PADDING_Y);
       
      setDirection(DIRECTION_EAST);
   } 
 
   public void setLocationRelativeToRegion(Region region, Layout side) {
      if (side == Layout.TOP){
         setDirection(DIRECTION_SOUTH);
      } else if (side == Layout.BOTTOM){

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add, grow
         source = from.getCenter();
         destination = to.getCenter();
      } 
 
      Debug.info("" + getSource() + " to " + getDestination());
      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);
 
   } 
 
   void updateVisibility(){ 
      setVisible(from.isVisible() && to.isVisible());      
   } 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMaxX, getMaxY, getMinX, getMinY
 
      int[]xs;
      int[]ys;
 
      int d = 5;
      if (p.x > rect.getMinX()-5 && p.x < rect.getMaxX()+5 ||
            p.y > rect.getMinY()-5 && p.y < rect.getMaxY()+5){
 
         xs = new int[3];
         ys = new int[3];
 
 
         xs[0] = (int) p.x;
         xs[1] = (int) corners.get(0).x;
         xs[2] = (int) corners.get(1).x;
 
         ys[0] = (int) p.y;
         ys[1] = (int) corners.get(0).y;
         ys[2] = (int) corners.get(1).y;
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getHeight, getWidth, getX, getY
This code example shows how to use the following methods:getHeight, getWidth, getMinX, getMinY
This code example shows how to use the following methods:getMaxX, getMaxY, getMinX, getMinY
         
        // world and screen bounds with different aspect ratios 
        final ReferencedEnvelope world = WORLD_1_1;
        final Rectangle screen = SCREEN_2_1;
        vp.setBounds(world);
        vp.setScreenArea(screen);
 
        double[] screenXY = {
            screen.getMinX(), screen.getMinY(), screen.getMaxX(), screen.getMaxY()
        }; 
         
        double[] worldXY = new double[screenXY.length];
        vp.getScreenToWorld().transform(screenXY, 0, worldXY, 0, screenXY.length / 2);
         
        assertEquals(world.getMinX(), worldXY[0], TOL);
        assertEquals(world.getMaxY(), worldXY[1], TOL);
        assertEquals(world.getMaxX(), worldXY[2], TOL);
        assertEquals(world.getMinY(), worldXY[3], TOL);
    } 
     
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMaxX, getMaxY, getMinX, getMinY
    } 
     
    public void intersectLine(Line2D line) {
        this.line = line;
        points.clear();
        float rx0 = (float) rectangle.getMinX();
        float ry0 = (float) rectangle.getMinY();
        float rx1 = (float) rectangle.getMaxX();
        float ry1 = (float) rectangle.getMaxY();
         
        float x1 = (float) line.getX1();
        float y1 = (float) line.getY1();
        float x2 = (float) line.getX2();
        float y2 = (float) line.getY2();
         
        float dy = y2 - y1;
        float dx = x2 - x1;
         
        if(dx != 0) {
            float m = dy/dx;

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getHeight, getWidth, getX, getY
   */ 
  public MfRecord getRecord() 
  { 
    final Rectangle rc = getBounds();
    final MfRecord record = new MfRecord(RECORD_SIZE);
    record.setParam(POS_BOTTOM, (int) (rc.getY() + rc.getHeight()));
    record.setParam(POS_RIGHT, (int) (rc.getX() + rc.getWidth()));
    record.setParam(POS_TOP, (int) (rc.getY()));
    record.setParam(POS_LEFT, (int) (rc.getX()));
    return record;
  } 
 
  public String toString()
  { 
    final StringBuffer b = new StringBuffer();
    b.append("[EXCLUDE_CLIP_RECT] bounds=");
    b.append(getBounds());
    return b.toString();
  } 
 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getHeight, getWidth, getX, getY
    return MfType.PIE; 
  } 
 
  public Rectangle getBounds()
  { 
    return new Rectangle(x, y, width, height);
  } 
 
  public Rectangle getScaledBounds()
  { 
    return new Rectangle(scaled_x, scaled_y, scaled_width, scaled_height);
  } 
 
  public String toString()
  { 
    final StringBuffer b = new StringBuffer();
    b.append("[PIE] bounds=");
    b.append(getBounds());
    b.append(" startIntersection=");
    b.append(getStartingIntersection());

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getHeight, getWidth, getX, getY
@PropertyEditorFor(Rectangle.class)
public class RectanglePropertyEditor extends AbstractPropertyEditor { 
    public String getAsText() {
        if (null == getValue()) return null; 
        Rectangle r = (Rectangle) getValue();
        return r.getX() + ", " + r.getY() + ", " + r.getWidth() + ", " + r.getHeight();
    } 
 
    protected void setValueInternal(Object value) { 
        if (null == value) { 
            super.setValueInternal(null); 
        } else if (value instanceof CharSequence) {
            handleAsString(String.valueOf(value));
        } else if (value instanceof List) {
            handleAsList((List) value);
        } else if (value instanceof Map) {
            handleAsMap((Map) value);
        } else if (value instanceof Rectangle) {
            super.setValueInternal(value); 
        } else { 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 Rectangle Methods: