当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle.intersects方法代码示例

本文整理汇总了Java中java.awt.Rectangle.intersects方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.intersects方法的具体用法?Java Rectangle.intersects怎么用?Java Rectangle.intersects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Rectangle的用法示例。


在下文中一共展示了Rectangle.intersects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: intersectsRect

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Returns whether or not the rectangle passed in hits any part of this
 * curve.
 * @param rect the rectangle to detect for a hit
 * @return whether or not the rectangle hits this curve
 */
public boolean intersectsRect(Rectangle rect)
{
	// To save CPU, we can test if the rectangle intersects the entire
	// bounds of this label
	if ( (labelBounds != null
			&& (!labelBounds.getRectangle().intersects(rect)) )
			|| labelGlyphs == null )
	{
		return false;
	}

	for (int i = 0; i < labelGlyphs.length; i++)
	{
		if (labelGlyphs[i].visible
				&& rect.intersects(labelGlyphs[i].drawingBounds
						.getRectangle()))
		{
			return true;
		}
	}

	return false;
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:30,代码来源:mxCurveLabelShape.java

示例2: focusGained

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public void focusGained(FocusEvent e) {
    if (e.isTemporary()) {
        return;
    }
    Component cmp = e.getComponent();
    if(cmp instanceof JComponent) {
        JViewport vp = getViewport(container);
        if(vp == null) {
            return;
        }
        Rectangle vr = vp.getViewRect();
        Point p = SwingUtilities.convertPoint(cmp.getParent(), cmp.getLocation(), container);
        final Rectangle r = new Rectangle(p, cmp.getSize());
        if(vr.intersects(r)) {
            return; 
        }
        container.scrollRectToVisible(r);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:UIUtils.java

示例3: checkPolygonBounds

import java.awt.Rectangle; //导入方法依赖的package包/类
private boolean checkPolygonBounds(UnknownData d, Rectangle2D viewBounds, double wrap) {
	if (d.polyline == null) return false;
	Rectangle polyBounds = d.polyline.getBounds();
	polyBounds.x += d.x;
	polyBounds.y += d.y;

	while (true) {
		if (polyBounds.intersects(viewBounds))
			return true;

		if (wrap <= 0) break;
		if (polyBounds.x >= wrap) break;
		polyBounds.x += wrap;
	}
	return false;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:17,代码来源:DBTableModel.java

示例4: paint

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public void paint(Graphics g, JComponent c) {
	recalculateIfInsetsChanged();
	recalculateIfOrientationChanged();
	Rectangle clip = g.getClipBounds();

	if (!clip.intersects(trackRect) && slider.getPaintTrack()) {
		calculateGeometry();
	}

	if (slider.getPaintTrack() && clip.intersects(trackRect)) {
		paintTrack(g);
	}
	if (slider.hasFocus() && clip.intersects(focusRect)) {
		paintFocus(g);
	}

	// the ticks are now inside the track so they have to be painted each thumb movement
	paintTicks(g);
	// thumb is always painted due to value below thumb
	paintThumb(g);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:SliderUI.java

示例5: displayStats

import java.awt.Rectangle; //导入方法依赖的package包/类
public void displayStats(GLAutoDrawable drawable) {
    if ((drawable == null) || (chip.getCanvas() == null)) {
        return;
    }
    canvas = chip.getCanvas();
    glCanvas = (GLCanvas) canvas.getCanvas();
    int sx = chip.getSizeX(), sy = chip.getSizeY();
    Rectangle chipRect = new Rectangle(sx, sy);
    GL2 gl = drawable.getGL().getGL2();
    if (selection != null && chipRect.intersects(selection)) {
        drawSelection(gl, selection, SELECT_COLOR);
    }
    stats.drawStats(drawable);
    stats.play();

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:17,代码来源:CellStatsProber.java

示例6: displayStats

import java.awt.Rectangle; //导入方法依赖的package包/类
public void displayStats(GLAutoDrawable drawable) {
    if ((drawable == null) || (selection == null) || (chip.getCanvas() == null)) {
        return;
    }
    canvas = chip.getCanvas();
    glCanvas = (GLCanvas) canvas.getCanvas();
    int sx = chip.getSizeX(), sy = chip.getSizeY();
    Rectangle chipRect = new Rectangle(sx, sy);
    GL2 gl = drawable.getGL().getGL2();
    if (!chipRect.intersects(selection)) {
        return;
    }
    drawSelection(gl, selection, SELECT_COLOR);
    stats.drawStats(drawable);
    stats.play();

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:18,代码来源:CellStatsProber_cochlea.java

示例7: findAt

import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public ComponentInfo findAt(int x, int y) {
    Rectangle bounds = getWindowBounds();
    if (!bounds.contains(x, y)) {
        return null;
    }

    ComponentInfo[] subComponents = getSubComponents();
    if (subComponents != null) {
        Rectangle tempRect = null;
        ComponentInfo tempRslt = null;
        for (int i = 0; i < subComponents.length; i++) {
            Rectangle sb = subComponents[i].getWindowBounds();
            if (sb.contains(x, y)) {
                tempRect = sb;
                tempRslt = subComponents[i];
                ComponentInfo tci = subComponents[i].findAt(x, y);
                if (tci != null) {
                    Rectangle tbounds = tci.getWindowBounds();
                    if (tempRect.intersects(tbounds)) {
                        tempRect = tbounds;
                        tempRslt = tci;
                    }
                }
            }
        }
        return tempRslt;
    }
    return this;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:RemoteFXScreenshot.java

示例8: drawOccupant

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * Draw one occupant object. First verify that the object is actually
 * visible before any drawing, set up the clip appropriately and use the
 * DisplayMap to determine which object to call upon to render this
 * particular Locatable. Note that we save and restore the graphics
 * transform to restore back to normalcy no matter what the renderer did to
 * to the coordinate system.
 *
 * @param g2    the Graphics2D object to use to render
 * @param xleft the leftmost pixel of the rectangle
 * @param ytop  the topmost pixel of the rectangle
 * @param obj   the Locatable object to draw
 */
private void drawOccupant(Graphics2D g2, int xleft, int ytop, Object obj) {
    Rectangle cellToDraw = new Rectangle(xleft, ytop, cellSize, cellSize);

    // Only draw if the object is visible within the current clipping
    // region.
    if (cellToDraw.intersects(g2.getClip().getBounds())) {
        Graphics2D g2copy = (Graphics2D) g2.create();
        g2copy.clip(cellToDraw);
        // Get the drawing object to display this occupant.
        Display displayObj = displayMap.findDisplayFor(obj.getClass());
        displayObj.draw(obj, this, g2copy, cellToDraw);
        g2copy.dispose();
    }
}
 
开发者ID:CBSkarmory,项目名称:AWGW,代码行数:28,代码来源:GridPanel.java

示例9: paintCol

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * narysowanie kolumny
 *
 * @param col - indeks kolumny
 * @param g - kontekst graficzny
 */
private void paintCol(int col, Graphics g) {
    Rectangle rect = g.getClipBounds();
    SpanTable spanTable = (SpanTable) table;
    for (int row = 0; row < table.getRowCount(); row++) {
        Rectangle cellRect = table.getCellRect(row, col, true);
        if (cellRect.intersects(rect)) // czy jest widoczny
        {
            int rowIndex = spanTable.visibleRow(row, col);
            paintCell(rowIndex, col, g, cellRect);
            row += spanTable.rowSpan(rowIndex, col) - 1;
        }
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:20,代码来源:SpanTableUI.java

示例10: PixelPointCollision

import java.awt.Rectangle; //导入方法依赖的package包/类
public static final Rectangle PixelPointCollision(int PointX, int PointY,
		BufferedImage Img1, int X, int Y, int width, int height, int SrcX,
		int SrcY)
{
	Rectangle rct = new Rectangle();

	rct.x = PointX;
	rct.y = PointY;
	rct.width = 1;
	rct.height = 1;

	Rectangle rct2 = new Rectangle();

	rct2.x = X;
	rct2.y = Y;
	rct2.width = width;
	rct2.height = height;

	if (rct.intersects(rct2) == true)
	{
		Rectangle intersection = rct.intersection(rct2);

		int Image1StartX = SrcX + (intersection.x - X);
		int Image1StartY = SrcY + (intersection.y - Y);
		int pixel1 = Img1.getRGB(Image1StartX, Image1StartY);
		int alpha1 = (pixel1 >> 24) & 0xff;

		if (alpha1 > 0)
		{
			return intersection;
		}
	}

	return null;
}
 
开发者ID:TheRemote,项目名称:Spark,代码行数:36,代码来源:Collision.java

示例11: PixelPointWeaponCollision

import java.awt.Rectangle; //导入方法依赖的package包/类
public static final Rectangle PixelPointWeaponCollision(int PointX, int PointY,
		BufferedImage Img1, int X, int Y, int width, int height, int SrcX,
		int SrcY, int Tolerance)
{
	Rectangle rct = new Rectangle();

	rct.x = PointX;
	rct.y = PointY;
	rct.width = 1;
	rct.height = 1;

	Rectangle rct2 = new Rectangle();

	rct2.x = X + Tolerance;
	rct2.y = Y + Tolerance;
	rct2.width = width - Tolerance;
	rct2.height = height - Tolerance;

	if (rct.intersects(rct2) == true)
	{
		Rectangle intersection = rct.intersection(rct2);

		int Image1StartX = SrcX + (intersection.x - rct2.x);
		int Image1StartY = SrcY + (intersection.y - rct2.y);
		int pixel1 = Img1.getRGB(Image1StartX, Image1StartY);
		int alpha = (pixel1 >> 24) & 0xff;
		int red = (pixel1 >> 16) & 0xff;
		int green = (pixel1 >> 8) & 0xff;
		int blue = (pixel1) & 0xff;

		if (alpha > 0 && !(red == 255 && green == 0 && blue == 0))
		{
			return intersection;
		}
	}

	return null;
}
 
开发者ID:TheRemote,项目名称:Spark,代码行数:39,代码来源:Collision.java

示例12: avoid

import java.awt.Rectangle; //导入方法依赖的package包/类
/**
 * 
 */
protected void avoid(mxCellState edge, mxCellState vertex) {
  mxIGraphModel model = graph.getModel();
  Rectangle labRect = edge.getLabelBounds().getRectangle();
  Rectangle vRect = vertex.getRectangle();

  if (labRect.intersects(vRect)) {
    int dy1 = -labRect.y - labRect.height + vRect.y;
    int dy2 = -labRect.y + vRect.y + vRect.height;

    int dy = (Math.abs(dy1) < Math.abs(dy2)) ? dy1 : dy2;

    int dx1 = -labRect.x - labRect.width + vRect.x;
    int dx2 = -labRect.x + vRect.x + vRect.width;

    int dx = (Math.abs(dx1) < Math.abs(dx2)) ? dx1 : dx2;

    if (Math.abs(dx) < Math.abs(dy)) {
      dy = 0;
    } else {
      dx = 0;
    }

    mxGeometry g = model.getGeometry(edge.getCell());

    if (g != null) {
      g = (mxGeometry) g.clone();

      if (g.getOffset() != null) {
        g.getOffset().setX(g.getOffset().getX() + dx);
        g.getOffset().setY(g.getOffset().getY() + dy);
      } else {
        g.setOffset(new mxPoint(dx, dy));
      }

      model.setGeometry(edge.getCell(), g);
    }
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:42,代码来源:mxEdgeLabelLayout.java

示例13: IntersectPath

import java.awt.Rectangle; //导入方法依赖的package包/类
public boolean IntersectPath(Rectangle recsel) {
    return recsel.intersects(getBounds());
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:4,代码来源:FormaElementar.java

示例14: paint

import java.awt.Rectangle; //导入方法依赖的package包/类
/** Paint a representation of the <code>table</code> instance
    * that was set in installUI().
    * 
    * (copy & paste from BasicTableUI)
    */
   public void paint(Graphics g, JComponent c) {
       Rectangle clip = g.getClipBounds();

       Rectangle bounds = table.getBounds();
       // account for the fact that the graphics has already been translated
       // into the table's bounds
       bounds.x = bounds.y = 0;

if (table.getRowCount() <= 0 || table.getColumnCount() <= 0 ||
               // this check prevents us from painting the entire table
               // when the clip doesn't intersect our bounds at all
               !bounds.intersects(clip)) {

    return;
}

Point upperLeft = clip.getLocation();
Point lowerRight = new Point(clip.x + clip.width - 1, clip.y + clip.height - 1);
       int rMin = table.rowAtPoint(upperLeft);
       int rMax = table.rowAtPoint(lowerRight);
       // This should never happen (as long as our bounds intersect the clip,
       // which is why we bail above if that is the case).
       if (rMin == -1) {
    rMin = 0;
       }
       // If the table does not have enough rows to fill the view we'll get -1.
       // (We could also get -1 if our bounds don't intersect the clip,
       // which is why we bail above if that is the case).
       // Replace this with the index of the last row.
       if (rMax == -1) {
    rMax = table.getRowCount()-1;
       }

       boolean ltr = table.getComponentOrientation().isLeftToRight();
       int cMin = table.columnAtPoint(ltr ? upperLeft : lowerRight); 
       int cMax = table.columnAtPoint(ltr ? lowerRight : upperLeft);        
       // This should never happen.
       if (cMin == -1) {
    cMin = 0;
       }
// If the table does not have enough columns to fill the view we'll get -1.
       // Replace this with the index of the last column.
       if (cMax == -1) {
    cMax = table.getColumnCount()-1;
       }

       // Paint the grid.
       paintGrid(g, rMin, rMax, cMin, cMax);

       // Paint the cells.
paintCells(g, rMin, rMax, cMin, cMax);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:58,代码来源:TaskListTableUI.java

示例15: paint

import java.awt.Rectangle; //导入方法依赖的package包/类
public void paint(Graphics g, JComponent c) {

        Rectangle clip = g.getClipBounds();
        thumbRect = zeroRect;

        super.paint(g, c);

        int thumbNum = additonalUi.getThumbNum();
        Rectangle[] thumbRects = additonalUi.getThumbRects();

        for (int i = thumbNum - 1; 0 <= i; i--) {
            if (clip.intersects(thumbRects[i])) {
                thumbRect = thumbRects[i];

                paintThumb(g);

            }
        }
    }
 
开发者ID:ec-europa,项目名称:sumo,代码行数:20,代码来源:MultiThumbSlider.java


注:本文中的java.awt.Rectangle.intersects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。