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


Java Area.getBounds2D方法代码示例

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


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

示例1: clip

import java.awt.geom.Area; //导入方法依赖的package包/类
@Override
public void clip(Shape s) {	
	if(s==null) return;
	
	if(clipping==null) {
		setClip(s);
		return;
	}
	
	Area a1 = new Area(clipping);
	Area a2 = new Area(s);
	a2.transform(transform);
	a1.intersect(a2);
	
	if(a1.isRectangular()) {
		clipping = a1.getBounds2D();
	} else {
		clipping = a1;
	}		
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:21,代码来源:AbstractGraphics2D.java

示例2: getClip

import java.awt.geom.Area; //导入方法依赖的package包/类
@Override
public Shape getClip() {
	if(clipping==null)
		return null;
	
	try {
		Area area = new Area(clipping);
		area.transform(transform.createInverse());
		if(area.isRectangular())
			return area.getBounds2D();
		return area;
	} catch(NoninvertibleTransformException t) {
		RuntimeException e2 = new RuntimeException();
		e2.initCause(t);
		throw e2;
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:18,代码来源:AbstractGraphics2D.java

示例3: isClipped

import java.awt.geom.Area; //导入方法依赖的package包/类
/** Return true if this instruction is affected by the current clipping.
 * (Returns false if no clipping is present.)
 */
public boolean isClipped() {
	if(clipping==null) return false;
	if(isClipped==null) {
		Stroke currentStroke = stroke;
		if(currentStroke instanceof BasicStroke) {
			BasicStroke bs = (BasicStroke)currentStroke;
			currentStroke = new BasicStroke(bs.getLineWidth(),
					BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL);
		}
		Area strokeArea = new Area(currentStroke.createStrokedShape(path));
		strokeArea.transform(transform);
		Area clipArea = new Area(clipping);
		
		strokeArea.subtract(clipArea);
		
		Rectangle2D r = strokeArea.getBounds2D();
		isClipped = new Boolean( r.getWidth()>.00001 && r.getHeight()>.00001 );
	}
	return isClipped.booleanValue();
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:24,代码来源:BasicDrawInstruction.java

示例4: testLineCircleIntersections

import java.awt.geom.Area; //导入方法依赖的package包/类
@Test
public void testLineCircleIntersections() {
    // Arrange
    Path2D line = new Path2D.Double(Path2D.WIND_NON_ZERO, 3);
    line.moveTo(1, 10);
    line.lineTo(20-1, 10);
    line.lineTo(20-1 + SMALL_DELTA, 10 + SMALL_DELTA);
    line.closePath();
    Ellipse2D.Double circle = new Ellipse2D.Double(4, 8, 4, 4);

    // Act
    Area intersectionArea = new Area(line);
    intersectionArea.intersect(new Area(circle));

    // Assert
    assertFalse(intersectionArea.isEmpty());
    Rectangle2D bounds2D = intersectionArea.getBounds2D();
    assertEquals(4d,  bounds2D.getX(), PRECISION);
    assertEquals(10d,  bounds2D.getY(), PRECISION);
    assertEquals(8d, bounds2D.getX() + bounds2D.getWidth(), PRECISION);
    assertEquals(10d, bounds2D.getY() + bounds2D.getHeight(), PRECISION);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:23,代码来源:BpmnJsonConverterTest.java

示例5: testLineRectangleIntersections

import java.awt.geom.Area; //导入方法依赖的package包/类
@Test
public void testLineRectangleIntersections() {
    // Arrange
    Path2D line = new Path2D.Double(Path2D.WIND_NON_ZERO, 3);
    line.moveTo(1, 10);
    line.lineTo(20 - 1, 10);
    line.lineTo(20 - 1 + SMALL_DELTA, 10 + SMALL_DELTA);
    line.closePath();
    Rectangle2D.Double rectangle = new Rectangle2D.Double(4, 8, 4, 4);

    // Act
    Area intersectionArea = new Area(line);
    intersectionArea.intersect(new Area(rectangle));

    // Assert
    assertFalse(intersectionArea.isEmpty());
    Rectangle2D bounds2D = intersectionArea.getBounds2D();
    assertEquals(4d, bounds2D.getX(), PRECISION);
    assertEquals(10d, bounds2D.getY(), PRECISION);
    assertEquals(8d, bounds2D.getX() + bounds2D.getWidth(), PRECISION);
    assertEquals(10d, bounds2D.getY() + bounds2D.getHeight(), PRECISION);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:23,代码来源:BpmnJsonConverterTest.java

示例6: getShapeROI

import java.awt.geom.Area; //导入方法依赖的package包/类
/**
 * Get a PathShape from an Area.
 * This will try to return a PathRectangleROI or PathPolygonROI if possible,
 * or PathAreaROI if neither of the other classes can adequately represent the area.
 * 
 * @param area
 * @param c
 * @param z
 * @param t
 * @param flatness - can be used to prefer polygons, see Shape.getPathIterator(AffineTransform at, double flatness)
 * @return
 */
public static PathShape getShapeROI(Area area, int c, int z, int t, double flatness) {
	if (area.isRectangular()) {
		Rectangle2D bounds = area.getBounds2D();
		return new RectangleROI(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), c, z, t);
	}
	//		else if (area.isPolygonal() && area.isSingular())
	else if (area.isSingular() && (area.isPolygonal() || flatness > 0)) {
		Path2D path = new Path2D.Float(area);
		List<Point2> points = flatness > 0 ? AWTAreaROI.getLinearPathPoints(path, path.getPathIterator(null, flatness)) : AWTAreaROI.getLinearPathPoints(path, path.getPathIterator(null));
		return new PolygonROI(points, c, z, t);
		//			if (area.isPolygonal())
		//				return new PolygonROI(new Path2D.Float(area), c, z, t);
		//			else if (flatness > 0) {
		//				Path2D path = new Path2D.Float();
		//				path.append(area.getPathIterator(null, flatness), false);
		//				return new PolygonROI(path, c, z, t);
		//			}
	}
	return new AWTAreaROI(area, c, z, t);		
}
 
开发者ID:qupath,项目名称:qupath,代码行数:33,代码来源:PathROIToolsAwt.java

示例7: getBounds

import java.awt.geom.Area; //导入方法依赖的package包/类
/** Returns the transformed bounds of this instruction. */
public Rectangle2D getBounds() {
	if(clipping==null) {
		return ShapeBounds.getBounds(path,transform);
	}

	Area clipArea = new Area(clipping);
	Area shapeArea = new Area(path);
	shapeArea.transform(transform);
	clipArea.intersect(shapeArea);
	return clipArea.getBounds2D();
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:13,代码来源:BasicFillInstruction.java

示例8: getBounds

import java.awt.geom.Area; //导入方法依赖的package包/类
/** Returns the area affected by this instruction.
 * This takes into account the transform and clipping.
 */
public Rectangle2D getBounds() {
	if(clipping==null) {
		return ShapeBounds.getBounds(destRect,transform);
	}

	Area clipArea = new Area(clipping);
	Area imageArea = new Area(destRect);
	imageArea.transform(transform);
	clipArea.intersect(imageArea);
	return clipArea.getBounds2D();
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:15,代码来源:ImageInstruction.java

示例9: setClip

import java.awt.geom.Area; //导入方法依赖的package包/类
@Override
public void setClip(Shape newClip) {
	if(newClip==null) {
		clipping = null;
		return;
	}
	
	Area area = new Area(newClip);
	area.transform( transform );
	if(area.isRectangular()) {
		clipping = area.getBounds2D();
	} else {
		clipping = area;
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:16,代码来源:AbstractGraphics2D.java

示例10: getBounds

import java.awt.geom.Area; //导入方法依赖的package包/类
/** Returns the area affected by this instruction.  This
 * takes into account the clipping and transform.
 */
public Rectangle2D getBounds() {
	if(clipping==null) {
		return ShapeBounds.getBounds(stroke.createStrokedShape(path),transform);
	}

	Area clipArea = new Area(clipping);
	Area strokeArea = new Area(stroke.createStrokedShape(path));
	strokeArea.transform(transform);
	clipArea.intersect(strokeArea);
	return clipArea.getBounds2D();
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:15,代码来源:BasicDrawInstruction.java

示例11: getIntersections

import java.awt.geom.Area; //导入方法依赖的package包/类
protected Collection<java.awt.geom.Point2D> getIntersections(java.awt.geom.Line2D line, Area shape) {
    Area intersectionArea = new Area(getLineShape(line));
    intersectionArea.intersect(shape);
    if (!intersectionArea.isEmpty()) {
        Rectangle2D bounds2D = intersectionArea.getBounds2D();
        HashSet<java.awt.geom.Point2D> intersections = new HashSet<>(2);
        intersections.add(new java.awt.geom.Point2D.Double(bounds2D.getX(), bounds2D.getY()));
        return intersections;
    }
    return Collections.EMPTY_SET;
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:12,代码来源:CmmnJsonConverter.java

示例12: getIntersections

import java.awt.geom.Area; //导入方法依赖的package包/类
protected Collection<java.awt.geom.Point2D> getIntersections(java.awt.geom.Line2D line, Area shape) {
    Area intersectionArea = new Area(getLineShape(line));
    intersectionArea.intersect(shape);
    if (!intersectionArea.isEmpty()) {
        Rectangle2D bounds2D = intersectionArea.getBounds2D();
        HashSet<java.awt.geom.Point2D> intersections = new HashSet<>(1);
        intersections.add(new java.awt.geom.Point2D.Double(bounds2D.getX(), bounds2D.getY()));
        return intersections;
    }
    return Collections.EMPTY_SET;
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:12,代码来源:BpmnJsonConverter.java

示例13: paintAboveChildren

import java.awt.geom.Area; //导入方法依赖的package包/类
public void paintAboveChildren(Graphics2D g) {
	
	boolean selected = whylineUI.getArrowOver() == dependencyNumber;

	g.setColor(UI.getFileColor());
	g.drawGlyphVector(glyphs, left, baseline);

	if(selected) {
		
		// Move to the global coordinate system, the common coordinate system for tokens
		g = (Graphics2D)g.create();
		g.translate(-getGlobalLeft() + getLocalLeft(), -getGlobalTop() + getLocalTop());

		int padding = 1;

		// Get the boundaries of this label.
		int labelLeft = (int)getGlobalLeft() - padding;
		int labelRight = labelLeft + (int)glyphBounds.getWidth() + padding * 2;
		int labelTop = (int)getGlobalTop() - padding; 
		int labelBottom = labelTop + (int)getGlobalHeight() + padding * 2;

		g.setColor(UI.ERROR_COLOR);
		Area toArea = files.outline(g, toRange);
		Area fromArea = files.outline(g, fromRange);
		
		if(toArea != null && fromArea != null) {

			Rectangle2D toBounds = toArea.getBounds2D();
			Rectangle2D fromBounds = fromArea.getBounds2D();				
			
			Line2D line = Util.getLineBetweenRectangleEdges(
					fromBounds.getMinX(), fromBounds.getMaxX(),
					fromBounds.getMinY(), fromBounds.getMaxY(), 
					toBounds.getMinX(), toBounds.getMaxX(),
					toBounds.getMinY(), toBounds.getMaxY()
			);

			int xOff = 0;
			int yOff = 0;

			Util.drawQuadraticCurveArrow(g, (int)line.getX1(), (int)line.getY1(), (int)line.getX2(), (int)line.getY2(), xOff, yOff, true, UI.SELECTED_STROKE);
			
		}
		
	}

}
 
开发者ID:andyjko,项目名称:whyline,代码行数:48,代码来源:UnexecutedArrowView.java


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