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


Java Area类代码示例

本文整理汇总了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();
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:28,代码来源:EngineConvex2D.java

示例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;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:27,代码来源:InterpolatedVectorLayer.java

示例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);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:34,代码来源:PlumNeedle.java

示例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;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:25,代码来源:CombatEntityVision.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:WinXPEditorTabCellRenderer.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:JTabbedPaneAdapter.java

示例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);

	}
 
开发者ID:max6cn,项目名称:jmt,代码行数:27,代码来源:QueueDrawer.java

示例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);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:28,代码来源:PainterConvex2D.java

示例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;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:20,代码来源:AreaOfEffect.java

示例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);
        }
      }
    }
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:23,代码来源:MapShader.java

示例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);
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:18,代码来源:Zone.java

示例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);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:28,代码来源:PainterConvex2D.java

示例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);

}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:22,代码来源:ServiceListenerSyntheticEvents.java

示例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);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:21,代码来源:AsyncNoWaitTest.java

示例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);

	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:25,代码来源:AsyncWaitTest.java


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