📄 erectangle.java
字号:
public double getLambdaMinX() { return lambdaMinX; } /** * Returns the smallest Y coordinate of this <code>ERectangle</code> * in lambda units in <code>double</code> precision. * @return the smallest y coordinate of this <code>ERectangle</code>. */ public double getLambdaMinY() { return lambdaMinY; } /** * Returns the largest X coordinate of this <code>ERectangle</code> * in lambda units in <code>double</code> precision. * @return the largest x coordinate of this <code>ERectangle</code>. */ public double getLambdaMaxX() { return lambdaMaxX; } /** * Returns the largest Y coordinate of this <code>ERectangle</code> * in lambda units in <code>double</code> precision. * @return the largest y coordinate of this <code>ERectangle</code>. */ public double getLambdaMaxY() { return lambdaMaxY; } /** * Returns the X coordinate of the center of this <code>ERectangle</code> * in lambda units in <code>double</code> precision. * @return the x coordinate of this <code>ERectangle</code> object's center. */ public double getLambdaCenterX() { return getCenterX(); } /** * Returns the Y coordinate of the center of this <code>ERectangle</code> * in lambda units in <code>double</code> precision. * @return the y coordinate of this <code>ERectangle</code> object's center. */ public double getLambdaCenterY() { return getCenterY(); } /** * Returns the X coordinate of this <code>ERectangle</code> * in grid units in long precision. * @return the X coordinate of this <code>ERectangle</code>. */ public long getGridX() { return gridMinX; } /** * Returns the Y coordinate of this <code>ERectangle</code> * in grid units in long precision. * @return the X coordinate of this <code>ERectangle</code>. */ public long getGridY() { return gridMinY; } /** * Returns the width of this <code>ERectangle</code> * in grid units in long precision. * @return the width of this <code>ERectangle</code>. */ public long getGridWidth() { return gridMaxX - gridMinX; } /** * Returns the heigth of this <code>ERectangle</code> * in grid units in long precision. * @return the heigth of this <code>ERectangle</code>. */ public long getGridHeight() { return gridMaxY - gridMinY; } /** * Returns the smallest X coordinate of this <code>ERectangle</code> * in grid units in <code>long</code> precision. * @return the smallest x coordinate of this <code>ERectangle</code>. */ public long getGridMinX() { return gridMinX; } /** * Returns the smallest Y coordinate of this <code>ERectangle</code> * in grid units in <code>long</code> precision. * @return the smallest y coordinate of this <code>ERectangle</code>. */ public long getGridMinY() { return gridMinY; } /** * Returns the largest X coordinate of this <code>ERectangle</code> * in grid units in <code>long</code> precision. * @return the largest x coordinate of this <code>ERectangle</code>. */ public long getGridMaxX() { return gridMaxX; } /** * Returns the largest Y coordinate of this <code>ERectangle</code> * in grid units in <code>long</code> precision. * @return the largest y coordinate of this <code>ERectangle</code>. */ public long getGridMaxY() { return gridMaxY; } /** * Returns the X coordinate of the center of this <code>ERectangle</code> * in grid units in <code>long</code> precision. * @return the x coordinate of this <code>ERectangle</code> object's center. */ public double getGridCenterX() { return (gridMinX + gridMaxX) >> 1; } /** * Returns the Y coordinate of the center of this <code>ERectangle</code> * in grid units in <code>long</code> precision. * @return the y coordinate of this <code>ERectangle</code> object's center. */ public double getGridCenterY() { return (gridMinY + gridMaxY) >> 1; } @Override public boolean isEmpty() { return gridMinX >= gridMaxX || gridMinY >= gridMaxY; } /** * Returns true if all coordinates of this EPoint are "small ints". * @return true if all coordinates of this EPoint are "small ints". * @see com.sun.electric.database.geometry.GenMath#MIN_SMALL_COORD * @see com.sun.electric.database.geometry.GenMath#MAX_SMALL_COORD */ public boolean isSmall() { return isSmall; } @Override public void setRect(double x, double y, double w, double h) { throw new UnsupportedOperationException(); } @Override public int outcode(double x, double y) { int out = 0; if (gridMinX >= gridMaxX) { out |= OUT_LEFT | OUT_RIGHT; } else if (x*DBMath.GRID < gridMinX) { out |= OUT_LEFT; } else if (x*DBMath.GRID > gridMaxX) { out |= OUT_RIGHT; } if (gridMinY >= gridMaxY) { out |= OUT_TOP | OUT_BOTTOM; } else if (y*DBMath.GRID < gridMinY) { out |= OUT_TOP; } else if (y*DBMath.GRID > gridMaxY) { out |= OUT_BOTTOM; } return out; } @Override public Rectangle2D getBounds2D() { return this; } /** * Returns the bounding box of the <code>ERectangle</code>. * @return a {@link Rectangle} object that bounds the * <code>ERectangle</code>. */ public Rectangle getBounds() { long width = getGridWidth(); long height = getGridHeight(); if (width < 0 || height < 0) { return new Rectangle(); } return new Rectangle((int)getGridX(), (int)getGridY(), (int)width, (int)height); } @Override public Rectangle2D createIntersection(Rectangle2D r) { if (r instanceof ERectangle) { ERectangle src = (ERectangle)r; long x1 = Math.max(gridMinX, src.gridMinX); long y1 = Math.max(gridMinY, src.gridMinY); long x2 = Math.min(gridMaxX, src.gridMaxX); long y2 = Math.min(gridMaxY, src.gridMaxY); if (x1 == gridMinX && y1 == gridMinY && x2 == gridMaxX && y2 == gridMaxY) return this; if (x1 == src.gridMinX && y1 == src.gridMinY && x2 == src.gridMaxX && y2 == src.gridMaxY) return src; return new ERectangle(x1, y1, x2 - x1, y2 - 1); } Rectangle2D dest = new Rectangle2D.Double(); Rectangle2D.intersect(this, r, dest); return dest; } @Override public Rectangle2D createUnion(Rectangle2D r) { if (r instanceof ERectangle) { ERectangle src = (ERectangle)r; long x1 = Math.min(gridMinX, src.gridMinX); long y1 = Math.min(gridMinY, src.gridMinY); long x2 = Math.max(gridMaxX, src.gridMaxX); long y2 = Math.max(gridMaxY, src.gridMaxY); if (x1 == gridMinX && y1 == gridMinY && x2 == gridMaxX && y2 == gridMaxY) return this; if (x1 == src.gridMinX && y1 == src.gridMinY && x2 == src.gridMaxX && y2 == src.gridMaxY) return src; return new ERectangle(x1, y1, x2 - x1, y2 - 1); } Rectangle2D dest = new Rectangle2D.Double(); Rectangle2D.union(this, r, dest); return dest; } @Override public String toString() { return getClass().getName() + "[x=" + getX() + ",y=" + getY() + ",w=" + getWidth() + ",h=" + getHeight() + "]"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -