當前位置: 首頁>>代碼示例>>Java>>正文


Java Shape.intersects方法代碼示例

本文整理匯總了Java中java.awt.Shape.intersects方法的典型用法代碼示例。如果您正苦於以下問題:Java Shape.intersects方法的具體用法?Java Shape.intersects怎麽用?Java Shape.intersects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.Shape的用法示例。


在下文中一共展示了Shape.intersects方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: containsPoint

import java.awt.Shape; //導入方法依賴的package包/類
public static boolean containsPoint(Edge edge, Point2D p, double scaleFactor) {
	Shape edgeShape = null;

	if (edge.getShape().equalsIgnoreCase(Constants.LINE_STRAIGHT)) {
		edgeShape = new Line2D.Double(edge.getSource().getPosition(), edge
				.getTarget().getPosition());

	} else if (edge.getShape().equalsIgnoreCase(Constants.LINE_CURVED)) {
		Point2D from = edge.getSource().getPosition();
		Point2D to = edge.getTarget().getPosition();
		double fx = from.getX();
		double fy = from.getY();
		double tx = to.getX();
		double ty = to.getY();
		double a = Utilities.calculateAngle(from, to);
		double h = EdgeRenderer.QUADCURVE_CTRL_POINT.getY() / scaleFactor;

		// Calculate Control Point
		double cx = (fx + tx) / 2 - h * Math.sin(a);
		double cy = (fy + ty) / 2 + h * Math.cos(a);

		edgeShape = new QuadCurve2D.Double(fx, fy, cx, cy, tx, ty);

	} else if (edge.getShape().equalsIgnoreCase(Constants.LINE_LOOP)) {
		// TODO: Calculate shape for loop to enable picking of loop edges
	}

	// Create a small rectangular area around point, and use it
	// to check for intersection with the line of the edge
	double pickRadius = 1;
	double px = p.getX();
	double py = p.getY();
	Rectangle2D pickArea = new Rectangle2D.Double(px - pickRadius, py
			- pickRadius, 2 * pickRadius, 2 * pickRadius);

	return edgeShape.intersects(pickArea);
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:38,代碼來源:IntersectingShapePickSupport.java

示例2: drawItem

import java.awt.Shape; //導入方法依賴的package包/類
/**
 * Draws the block representing the specified item.
 * 
 * @param g2
 *            the graphics device.
 * @param state
 *            the state.
 * @param dataArea
 *            the data area.
 * @param info
 *            the plot rendering info.
 * @param plot
 *            the plot.
 * @param domainAxis
 *            the x-axis.
 * @param rangeAxis
 *            the y-axis.
 * @param dataset
 *            the dataset.
 * @param series
 *            the series index.
 * @param item
 *            the item index.
 * @param crosshairState
 *            the crosshair state.
 * @param pass
 *            the pass index.
 */
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info,
		XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item,
		CrosshairState crosshairState, int pass) {

	Shape hotspot = null;
	EntityCollection entities = null;
	if (info != null) {
		entities = info.getOwner().getEntityCollection();
	}

	double x = dataset.getXValue(series, item);
	double y = dataset.getYValue(series, item);
	double colorValue = ((XYZDataset) dataset).getZValue(series, item);
	double normalized = (colorValue - minColor) / (maxColor - minColor);

	if (Double.isNaN(x) || Double.isNaN(y)) {
		// can't draw anything
		return;
	}

	double transX = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge());
	double transY = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge());

	PlotOrientation orientation = plot.getOrientation();

	Shape shape = getItemShape(series, item);
	if (orientation == PlotOrientation.HORIZONTAL) {
		shape = ShapeUtilities.createTranslatedShape(shape, transY, transX);
	} else if (orientation == PlotOrientation.VERTICAL) {
		shape = ShapeUtilities.createTranslatedShape(shape, transX, transY);
	}
	hotspot = shape;
	if (shape.intersects(dataArea)) {
		g2.setPaint(colorProvider.getPointColor(normalized));
		g2.fill(shape);
		if (getDrawOutlines()) {
			if (getUseOutlinePaint()) {
				g2.setPaint(getItemOutlinePaint(series, item));
			} else {
				g2.setPaint(getItemPaint(series, item));
			}
			g2.setStroke(getItemOutlineStroke(series, item));
			g2.draw(shape);
		}
	}

	// add an entity for the item...
	if (entities != null) {
		addEntity(entities, hotspot, dataset, series, item, transX, transY);
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:81,代碼來源:ColorizedShapeItemRenderer.java

示例3: printView

import java.awt.Shape; //導入方法依賴的package包/類
private boolean printView(final Graphics2D graphics2D,
                          final Shape allocation, final View view) {
    boolean pageExists = false;
    final Rectangle clipRectangle = new Rectangle(0, 0, (int) (pageFormat
            .getImageableWidth() / SCALE), (int) clientHeight);
    Shape childAllocation;
    View childView;

    if (view.getViewCount() > 0) {
        for (int i = 0; i < view.getViewCount(); i++) {
            childAllocation = view.getChildAllocation(i, allocation);
            if (childAllocation != null) {
                childView = view.getView(i);
                if (printView(graphics2D, childAllocation, childView)) {
                    pageExists = true;
                }
            }
        }
    } else {
        if (allocation.getBounds().getMaxY() >= clipRectangle.getY()) {

            if (allocation.getBounds().getHeight() > clipRectangle
                    .getHeight()
                    && allocation.intersects(clipRectangle)) {
                paintView(graphics2D, view, allocation);
                pageExists = true;
            } else {
                if (allocation.getBounds().getY() >= clipRectangle.getY()) {
                    if (allocation.getBounds().getMaxY() <= clipRectangle
                            .getMaxY()) {
                        paintView(graphics2D, view, allocation);
                        pageExists = true;

                    } else {
                        if (allocation.getBounds().getY() < pageEndY) {
                            pageEndY = allocation.getBounds().getY();
                        }
                    }
                }
            }
        }
    }
    return pageExists;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:45,代碼來源:HTMLPrintable.java

示例4: select

import java.awt.Shape; //導入方法依賴的package包/類
public boolean select( Shape shape, Rectangle2D shapeBounds ) {
	if( shapeBounds.intersects(getBounds()) )return shape.intersects(getBounds());
	return false;
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:5,代碼來源:ImageLayer.java


注:本文中的java.awt.Shape.intersects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。