本文整理汇总了Java中java.awt.geom.Area类的典型用法代码示例。如果您正苦于以下问题:Java Area类的具体用法?Java Area怎么用?Java Area使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Area类属于java.awt.geom包,在下文中一共展示了Area类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EngineConvex2D
import java.awt.geom.Area; //导入依赖的package包/类
/**
* Costructor of the life
* @param allPoints All the point of the graph
* @param sd3 The sector of saturation
*/
public EngineConvex2D(Vector<Point2D> allPoints, Vector<Object> sd3) {
this.allPoints = (Vector<Point2D>) allPoints.clone();
allConvex = new Vector<Point2D>();
allImperant = (Vector<Point2D>) allPoints.clone();
allDominates = new Vector<Point2D>();
filtDominants = new Vector<Point2D>();
filtDominates = new Vector<Point2D>();
filtPoints = new Vector<DPoint>();
filtConvex = new Vector<Point2D>();
filtArea = new Area();
separator();
//calcConvex();
calcConvex(sd3);
dominates = (Vector<Point2D>) allDominates.clone();
imperant = (Vector<Point2D>) allImperant.clone();
convex = (Vector<Point2D>) allConvex.clone();
points = (Vector<Point2D>) this.allPoints.clone();
}
示例2: getShape
import java.awt.geom.Area; //导入依赖的package包/类
public Area getShape() {
Area maskArea = new Area();
Rectangle rect = new Rectangle(0, 0, reader.getWidth(), reader.getHeight());
GeometryFactory gf = new GeometryFactory();
Coordinate[] coords = new Coordinate[]{
new Coordinate((int) rect.getMinX(), (int) rect.getMinY()),
new Coordinate((int) rect.getMaxX(), (int) rect.getMinY()),
new Coordinate((int) rect.getMaxX(), (int) rect.getMaxY()),
new Coordinate((int) rect.getMinX(), (int) rect.getMaxY()),
new Coordinate((int) rect.getMinX(), (int) rect.getMinY()),
};
Polygon geom = gf.createPolygon(gf.createLinearRing(coords), null);
for (Geometry p : glayer.getGeometries()) {
if (p.intersects(geom)) {
int[] xPoints = new int[p.getNumPoints()];
int[] yPoints = new int[p.getNumPoints()];
int i = 0;
for (Coordinate c : p.getCoordinates()) {
xPoints[i] = (int) (c.x);
yPoints[i++] = (int) (c.y);
}
maskArea.add(new Area(new java.awt.Polygon(xPoints, yPoints, p.getNumPoints())));
}
}
return maskArea;
}
示例3: drawNeedle
import java.awt.geom.Area; //导入依赖的package包/类
/**
* Draws the needle.
*
* @param g2 the graphics device.
* @param plotArea the plot area.
* @param rotate the rotation point.
* @param angle the angle.
*/
protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea,
Point2D rotate, double angle) {
Arc2D shape = new Arc2D.Double(Arc2D.PIE);
double radius = plotArea.getHeight();
double halfX = plotArea.getWidth() / 2;
double diameter = 2 * radius;
shape.setFrame(plotArea.getMinX() + halfX - radius ,
plotArea.getMinY() - radius,
diameter, diameter);
radius = Math.toDegrees(Math.asin(halfX / radius));
shape.setAngleStart(270 - radius);
shape.setAngleExtent(2 * radius);
Area s = new Area(shape);
if ((rotate != null) && (angle != 0)) {
/// we have rotation houston, please spin me
getTransform().setToRotation(angle, rotate.getX(), rotate.getY());
s.transform(getTransform());
}
defaultDisplay(g2, s);
}
示例4: updateVisionShape
import java.awt.geom.Area; //导入依赖的package包/类
@Override
public void updateVisionShape() {
final Path2D path = new Path2D.Float();
final Path2D renderPath = new Path2D.Float();
path.append(this.getMapVisionCircle(this.combatEntity), false);
renderPath.append(this.getRenderVisionArc(this.combatEntity), false);
for (final ICombatEntity entity : this.environment.getCombatEntities()) {
if (entity.isFriendly(this.combatEntity) && !entity.equals(this.combatEntity)) {
path.append(this.getMapVisionCircle(entity), false);
renderPath.append(this.getRenderVisionArc(entity), false);
}
}
this.renderVisionShape = renderPath;
final float width = (float) this.environment.getMap().getSizeInPixels().getWidth();
final float height = (float) this.environment.getMap().getSizeInPixels().getHeight();
final Rectangle2D rect = new Rectangle2D.Float(0, 0, width, height);
final Area rectangleArea = new Area(rect);
rectangleArea.subtract(new Area(path));
this.fogOfWar = rectangleArea;
}
示例5: paintTopLine
import java.awt.geom.Area; //导入依赖的package包/类
private static final void paintTopLine(Graphics g,
WinXPEditorTabCellRenderer ren,
TabPainter p) {
Polygon poly = p.getInteriorPolygon(ren);
((Graphics2D) g).setPaint(getHighlightColor());
g.setColor(getHighlightColor());
Shape clip = g.getClip();
Insets ins = p.getBorderInsets(ren);
try {
if (clip != null) {
Area a = new Area(clip);
a.intersect(new Area(poly));
g.setClip(a);
} else {
g.setClip(poly);
}
g.fillRect(0, ins.top, ren.getWidth(), 3);
} finally {
g.setClip(clip);
}
}
示例6: getDropIndication
import java.awt.geom.Area; //导入依赖的package包/类
/**
* Get a shape appropriate for drawing on the window's glass pane to
* indicate where a component should appear in the tab order if it is
* dropped here.
*
* @param dragged An object being dragged, or null. The object may be an
* instance of
* <code>TabData</code> or
* <code>Component</code>, in which case a check will be done of whether the
* dragged object is already in the data model, so that attempts to drop the
* object over the place it already is in the model will always return the
* exact indication of that tab's position.
*
* @param location A point
* @return Drop indication drawing
*/
public Shape getDropIndication( Object dragged, Point location ) {
int over = dropIndexOfPoint( location );
Rectangle component = getSelectedComponent().getBounds();
Area selectedComponent = new Area( component );
Rectangle firstTab = null, secondTab = null;
if( over > 0 && over < getTabCount() )
firstTab = getBoundsAt( over-1 );
if( over < getTabCount() )
secondTab = getBoundsAt( over );
if( over >= getTabCount() ) {
firstTab = getBoundsAt( getTabCount()-1 );
secondTab = null;
}
Rectangle joined = joinTabAreas( firstTab, secondTab );
Area t = new Area( joined );
selectedComponent.add( t );
return selectedComponent;
}
示例7: drawUtilizationMulti
import java.awt.geom.Area; //导入依赖的package包/类
private void drawUtilizationMulti(double U, Color startC, Color border, boolean gradientFill, Graphics2D g2d, int cpu) {
double x = getProcessorXY().x, y = getProcessorXY().y;
try {
occupiedRect = new Rectangle2D.Double(x + PROC_RAD / 2 + ELEMS_GAP / 2, y + cpu * (PROC_RAD - ELEMS_GAP) + ELEMS_GAP * cpu * 3
- ELEMS_GAP / 2, PROC_RAD - ELEMS_GAP, (PROC_RAD - ELEMS_GAP) * (1 - U / nCpu));
} catch (Exception e) {
occupiedRect = new Rectangle2D.Double(x + PROC_RAD / 2 + ELEMS_GAP / 2, y + cpu * (PROC_RAD - ELEMS_GAP) + ELEMS_GAP * cpu * 3
- ELEMS_GAP / 2, PROC_RAD - ELEMS_GAP, 0);
}
occupiedEll = new Ellipse2D.Double(x + PROC_RAD / 2 + ELEMS_GAP / 2, y + cpu * (PROC_RAD - ELEMS_GAP) + ELEMS_GAP * cpu * 3 - ELEMS_GAP / 2,
PROC_RAD - ELEMS_GAP, PROC_RAD - ELEMS_GAP);
if (gradientFill) {
GradientPaint gp = new GradientPaint((float) x, (float) y, startC.brighter(), (float) x, (float) (y + 2 * PROC_RAD), startC.darker(),
false);
g2d.setPaint(gp);
} else {
g2d.setPaint(startC);
}
occupiedArea = new Area(occupiedEll);
occupiedArea.subtract(new Area(occupiedRect));
g2d.fill(occupiedArea);
g2d.setPaint(Color.BLACK);
g2d.draw(occupiedArea);
}
示例8: drawFiltArea
import java.awt.geom.Area; //导入依赖的package包/类
/**
* Draw a semi-trasparent area that is the filtered area
* @param g The graphic object
* @param filteredArea The filtered area
*/
public void drawFiltArea(Graphics2D g, Area filtArea) {
AffineTransform t = new AffineTransform();
t.scale(scale / 100, scale / 100);
AffineTransform t2 = new AffineTransform();
t2.translate(tran_x, tran_y);
filtArea.transform(t);
filtArea.transform(t2);
Stroke oldStro = g.getStroke();
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
g.setStroke(stroke);
g.setColor(Color.GRAY);
Composite oldComp = g.getComposite();
Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
g.setComposite(alphaComp);
g.fill(filtArea);
g.setComposite(oldComp);
g.setStroke(oldStro);
}
示例9: getArea
import java.awt.geom.Area; //导入依赖的package包/类
public Area getArea(MapShader shader) {
Area a = null;
final MapShader.ShadedPiece shaded = (MapShader.ShadedPiece) Decorator.getDecorator(piece,MapShader.ShadedPiece.class);
if (shaded != null) {
a = shaded.getArea(shader);
}
if (alwaysActive || active) {
if (shader.getConfigureName().equals(mapShaderName)) {
Area myArea = getArea();
if (a == null) {
a = myArea;
}
else {
a.add(myArea);
}
}
}
return a;
}
示例10: checkPiece
import java.awt.geom.Area; //导入依赖的package包/类
protected void checkPiece(Area area, GamePiece piece) {
if (piece instanceof Stack) {
Stack s = (Stack) piece;
for (int i = 0; i < s.getPieceCount(); i++) {
checkPiece(area, s.getPieceAt(i));
}
}
else {
ShadedPiece shaded = (ShadedPiece) Decorator.getDecorator(piece,ShadedPiece.class);
if (shaded != null) {
Area shape = shaded.getArea(this);
if (shape != null) {
if (type.equals(FG_TYPE)) {
area.add(shape);
}
else {
area.subtract(shape);
}
}
}
}
}
示例11: draw
import java.awt.geom.Area; //导入依赖的package包/类
public void draw(Graphics g, Rectangle bounds, Rectangle visibleRect, double scale, boolean reversed) {
if ((getGrid() != null && getGrid().isVisible()) || highlighter != null) {
final Graphics2D g2d = (Graphics2D) g;
final Shape oldClip = g2d.getClip();
final Area newClip = new Area(visibleRect);
final Shape s = getCachedShape(myPolygon, bounds.x, bounds.y, scale);
newClip.intersect(new Area(s));
g2d.setClip(newClip);
if (getGrid() != null && getGrid().isVisible()) {
getGrid().draw(g, bounds, visibleRect, scale, reversed);
}
if (highlighter != null) {
highlighter.draw(g2d, s, scale);
}
g2d.setClip(oldClip);
}
}
示例12: drawFiltArea
import java.awt.geom.Area; //导入依赖的package包/类
/**
* Draw a semi-trasparent area that is the filtered area
* @param g The graphic object
* @param filteredArea The filtered area
*/
public void drawFiltArea(Graphics2D g, Area filtArea) {
AffineTransform t = new AffineTransform();
t.scale(scale / 100, scale / 100);
AffineTransform t2 = new AffineTransform();
t2.translate(tran_x, tran_y);
filtArea.transform(t);
filtArea.transform(t2);
Stroke oldStro = g.getStroke();
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
g.setStroke(stroke);
g.setColor(Color.gray);
Composite oldComp = g.getComposite();
Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
g.setComposite(alphaComp);
g.fill(filtArea);
g.setComposite(oldComp);
g.setStroke(oldStro);
}
示例13: registerMultipleServices
import java.awt.geom.Area; //导入依赖的package包/类
private void registerMultipleServices() {
area = new Area();
rectangle = new Rectangle();
polygon = new Polygon();
Dictionary polygonProp = new Properties();
polygonProp.put(Constants.SERVICE_RANKING, new Integer(1));
// first register polygon
polygonReg = bundleContext.registerService(Shape.class.getName(), polygon, polygonProp);
// then rectangle
Dictionary rectangleProp = new Properties();
rectangleProp.put(Constants.SERVICE_RANKING, new Integer(10));
rectangleReg = bundleContext.registerService(Shape.class.getName(), rectangle, rectangleProp);
// then area
Dictionary areaProp = new Properties();
areaProp.put(Constants.SERVICE_RANKING, new Integer(100));
areaReg = bundleContext.registerService(Shape.class.getName(), area, areaProp);
}
示例14: testBehaviour
import java.awt.geom.Area; //导入依赖的package包/类
public void testBehaviour() throws Exception {
String bundleId = "org.eclipse.gemini.blueprint.iandt, async-nowait-bundle,"
+ getSpringDMVersion();
// start it
Bundle bundle = installBundle(bundleId);
bundle.start();
// wait for the bundle to start and fail
Thread.sleep(3000);
// put service up
registration = bundleContext.registerService(Shape.class.getName(), new Area(), null);
assertTrue("bundle " + bundle + "hasn't been fully started", OsgiBundleUtils.isBundleActive(bundle));
// check that the appCtx is *not* published
// TODO: this fails sometimes on the build server - find out why
// assertContextServiceIs(bundle, false, 1000);
}
示例15: testBehaviour
import java.awt.geom.Area; //导入依赖的package包/类
public void testBehaviour() throws Exception {
String bundleId = "org.eclipse.gemini.blueprint.iandt, async-wait-bundle,"
+ getSpringDMVersion();
// start it
Bundle bundle = installBundle(bundleId);
bundle.start();
assertTrue("bundle " + bundle + "hasn't been fully started", OsgiBundleUtils.isBundleActive(bundle));
// make sure the appCtx is not up
// check that the appCtx is *not* published (it waits for the service to
// appear)
assertContextServiceIs(bundle, false, 500);
// put service up
registration = bundleContext.registerService(Shape.class.getName(), new Area(), null);
// do wait a bit to let the appCtx to fully start
// check the appCtx again (should be published)
assertContextServiceIs(bundle, true, 4000);
}