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


Java Polygon类代码示例

本文整理汇总了Java中java.awt.Polygon的典型用法代码示例。如果您正苦于以下问题:Java Polygon类的具体用法?Java Polygon怎么用?Java Polygon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testResizedToOriginal_Polygon_01

import java.awt.Polygon; //导入依赖的package包/类
/**
 * Test of resizedToOriginal for polygon method, of class Resize.
 *
 * No further tests are done because the resize of the polygon points is
 * done based on resizedToOriginal for values methods.
 */
@Test
public void testResizedToOriginal_Polygon_01() {
    final String testDescription = "----------resizedToOriginalPolygon_01----------\n"
            + " Summary: Test of resizedToOriginal(Polygon) method, of class Resize\n"
            + " Description: Check there is no exception when processing null input. Input value null, the resize is set to (1.0, 1.0).\n"
            + " Pre-conditions: none\n"
            + " Conditions: none\n"
            + " Expected result: It shall output null; no errors or exceptions shall occur.\n";
    System.out.println(testDescription);

    Polygon polyResized = null;
    Resize instance = new Resize(1.0, 1.0);
    Polygon expResult = null;
    Polygon result = instance.resizedToOriginal(polyResized);
    assertEquals(expResult, result);
}
 
开发者ID:buni-rock,项目名称:Pixie,代码行数:23,代码来源:ResizeTest.java

示例2: getInteriorPolygon

import java.awt.Polygon; //导入依赖的package包/类
public Polygon getInteriorPolygon(Component c) {
    NimbusEditorTabCellRenderer ren = (NimbusEditorTabCellRenderer) c;

    Insets ins = getBorderInsets(c);
    Polygon p = new Polygon();
    int x = ren.isLeftmost() ? 3 : 0;
    int y = 0;

    int width = ren.isLeftmost() ? c.getWidth() - 3 : c.getWidth();
    int height = c.getHeight() - 4;
            
    //Modified to return rectangle
    p.addPoint(x, y);
    p.addPoint(x + width, y);
    p.addPoint(x + width, y + height);
    p.addPoint(x, y + height);
    return p;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:NimbusEditorTabCellRenderer.java

示例3: test

import java.awt.Polygon; //导入依赖的package包/类
private static long test(Image bi, Image vi, AffineTransform atfm) {
    final Polygon p = new Polygon();
    p.addPoint(0, 0);
    p.addPoint(SIZE, 0);
    p.addPoint(0, SIZE);
    p.addPoint(SIZE, SIZE);
    p.addPoint(0, 0);
    Graphics2D g2d = (Graphics2D) vi.getGraphics();
    g2d.clip(p);
    g2d.transform(atfm);
    g2d.setComposite(AlphaComposite.SrcOver);
    final long start = System.nanoTime();
    g2d.drawImage(bi, 0, 0, null);
    final long time = System.nanoTime() - start;
    g2d.dispose();
    return time;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:UnmanagedDrawImagePerformance.java

示例4: getRegiaoComentario

import java.awt.Polygon; //导入依赖的package包/类
public Shape getRegiaoComentario() {
    if (Regiao == null) {

        GeneralPath pa = new GeneralPath();
        pa.setWindingRule(GeneralPath.WIND_NON_ZERO);

        Rectangle rec = getBounds();
        int tam = Math.min(rec.width / 6, rec.height / 6);
        int curv = tam / 4;
        int lw = rec.x + rec.width;
        int[] px = new int[]{rec.x, lw - tam, lw, lw, rec.x};
        int[] py = new int[]{rec.y, rec.y, rec.y + tam, rec.y + rec.height, rec.y + rec.height};
        Polygon po = new Polygon(px, py, 5);
        pa.append(po, true);
        pa.moveTo(lw - tam, rec.y);
        pa.curveTo(lw - tam, rec.y, lw - tam + curv, rec.y + curv, lw - tam, rec.y + tam - (1));
        pa.moveTo(lw - tam, rec.y + tam - (1));
        pa.lineTo(lw, rec.y + tam);
        pa.closePath();
        Regiao = pa;
    }
    return Regiao;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:24,代码来源:LivreBase.java

示例5: drawDragArea

import java.awt.Polygon; //导入依赖的package包/类
/**
 * Draw a semi-trasparet area
 * @param g The graphic object
 * @param dragPoint The first point
 * @param beginPoint The second point
 * @param c The color of the area
 */
public void drawDragArea(Graphics2D g, Point dragPoint, Point beginPoint, Color c) {
	g.setColor(c);

	Polygon poly = new Polygon();

	poly.addPoint((int) beginPoint.getX(), (int) beginPoint.getY());
	poly.addPoint((int) beginPoint.getX(), (int) dragPoint.getY());
	poly.addPoint((int) dragPoint.getX(), (int) dragPoint.getY());
	poly.addPoint((int) dragPoint.getX(), (int) beginPoint.getY());

	//Set the widths of the shape's outline
	Stroke oldStro = g.getStroke();
	Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
	g.setStroke(stroke);
	g.drawPolygon(poly);
	g.setStroke(oldStro);

	//Set the trasparency of the iside of the rectangle
	Composite oldComp = g.getComposite();
	Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
	g.setComposite(alphaComp);
	g.fillPolygon(poly);
	g.setComposite(oldComp);

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

示例6: createShape

import java.awt.Polygon; //导入依赖的package包/类
/**
 * 
 */
public Shape createShape(mxGraphics2DCanvas canvas, mxCellState state) {
  Rectangle temp = state.getRectangle();
  int x = temp.x;
  int y = temp.y;
  int w = temp.width;
  int h = temp.height;
  int halfWidth = w / 2;
  int halfHeight = h / 2;

  Polygon rhombus = new Polygon();
  rhombus.addPoint(x + halfWidth, y);
  rhombus.addPoint(x + w, y + halfHeight);
  rhombus.addPoint(x + halfWidth, y + h);
  rhombus.addPoint(x, y + halfHeight);

  return rhombus;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:21,代码来源:mxRhombusShape.java

示例7: mousePressed

import java.awt.Polygon; //导入依赖的package包/类
public void mousePressed(MouseEvent e) {
	
	if (station){
		//This will detect if the mouse clicks on a datapoint 
		//and will set the selectedRow value.  Used for dragging.
		selectedRow = -1;
		selectPoint(e);
	}		
	
	if (e.isControlDown()) return;
	if (e.isConsumed()||!map.isSelectable()) return;

	if (db.panTB.isSelected()) return;
	if (e.isShiftDown()) {
		p1=e.getPoint();
		p2=new Point(p1.x+1,p1.y+1);
		drawSelectionBox();
	}
	else {
		poly = new Polygon();
		poly.addPoint(e.getPoint().x, e.getPoint().y);
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:24,代码来源:UnknownDataSet.java

示例8: createShape

import java.awt.Polygon; //导入依赖的package包/类
/**
 * 
 */
public Shape createShape(mxGraphics2DCanvas canvas, mxCellState state)
{
	Rectangle temp = state.getRectangle();
	int x = temp.x;
	int y = temp.y;
	int w = temp.width;
	int h = temp.height;
	int halfWidth = w / 2;
	int halfHeight = h / 2;

	Polygon rhombus = new Polygon();
	rhombus.addPoint(x + halfWidth, y);
	rhombus.addPoint(x + w, y + halfHeight);
	rhombus.addPoint(x + halfWidth, y + h);
	rhombus.addPoint(x, y + halfHeight);

	return rhombus;
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:22,代码来源:mxRhombusShape.java

示例9: MapArea

import java.awt.Polygon; //导入依赖的package包/类
/**
 * Creates a polygon MapArea
 */
public MapArea(Polygon polygon)
{
  int[] coords = null;

  if ((polygon != null) && (polygon.npoints != 0))
  {
    coords = new int[polygon.npoints * 2];
    for (int i = 0; i < polygon.npoints; i++)
    {
      coords[i*2] = polygon.xpoints[i];
      coords[i*2+1] = polygon.ypoints[i];
    }
  }

  _init(POLYGON_SHAPE, coords);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:20,代码来源:MapArea.java

示例10: registerMultipleServices

import java.awt.Polygon; //导入依赖的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

示例11: testMultipleInterceptorEquality

import java.awt.Polygon; //导入依赖的package包/类
public void testMultipleInterceptorEquality() throws Exception {
	target = new Polygon();

	Advice interceptorA1 = createInterceptorWOServiceRequired();

	Advice interceptorA2 = new LocalBundleContextAdvice(bundleContext);
	Advice interceptorA3 = new ServiceTCCLInterceptor(null);

	Advice interceptorB1 = createInterceptorWOServiceRequired();
	Advice interceptorB2 = new LocalBundleContextAdvice(bundleContext);
	Advice interceptorB3 = new ServiceTCCLInterceptor(null);

	Object proxyA = createProxy(target, Shape.class, new Advice[] { interceptorA1, interceptorA2, interceptorA3 });
	Object proxyB = createProxy(target, Shape.class, new Advice[] { interceptorB1, interceptorB2, interceptorB3 });

	assertFalse(proxyA == proxyB);
	assertEquals(interceptorA1, interceptorB1);
	assertEquals(interceptorA2, interceptorB2);
	assertEquals(interceptorA3, interceptorB3);

	assertEquals(proxyA, proxyB);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:23,代码来源:OsgiServiceProxyEqualityTest.java

示例12: paintMarker

import java.awt.Polygon; //导入依赖的package包/类
public mxPoint paintMarker(mxGraphics2DCanvas canvas, mxCellState state, String type,
    mxPoint pe, double nx, double ny, double size, boolean source) {
  Polygon poly = new Polygon();
  poly.addPoint((int) Math.round(pe.getX()), (int) Math.round(pe.getY()));
  poly.addPoint((int) Math.round(pe.getX() - nx - ny / 2),
      (int) Math.round(pe.getY() - ny + nx / 2));

  if (type.equals(mxConstants.ARROW_CLASSIC)) {
    poly.addPoint((int) Math.round(pe.getX() - nx * 3 / 4),
        (int) Math.round(pe.getY() - ny * 3 / 4));
  }

  poly.addPoint((int) Math.round(pe.getX() + ny / 2 - nx),
      (int) Math.round(pe.getY() - ny - nx / 2));

  if (mxUtils.isTrue(state.getStyle(), (source) ? "startFill" : "endFill", true)) {
    canvas.fillShape(poly);
  }

  canvas.getGraphics().draw(poly);

  return new mxPoint(-nx, -ny);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:24,代码来源:mxMarkerRegistry.java

示例13: L2Territory

import java.awt.Polygon; //导入依赖的package包/类
public L2Territory(/*String string*/)
	{
		poly = new Polygon();
		_points = new Point[0];
//		_terr = string;
		_xMin = 999999;
		_xMax = -999999;
		_yMin = 999999;
		_yMax = -999999;
		_zMin = 999999;
		_zMax = -999999;
		_procMax = 0;
	}
 
开发者ID:L2jBrasil,项目名称:L2jBrasil,代码行数:14,代码来源:L2Territory.java

示例14: getExactTabIndication

import java.awt.Polygon; //导入依赖的package包/类
public Polygon getExactTabIndication(int idx) {
    Polygon result = tabDisplayer.getUI().getExactTabIndication(idx);
    scratchPoint.setLocation(0,0);
    Point p = SwingUtilities.convertPoint(tabDisplayer, scratchPoint, container);
    result.translate (-p.x, -p.y);
    return appendContentBoundsTo(result);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:DefaultTabbedContainerUI.java

示例15: getInsertTabIndication

import java.awt.Polygon; //导入依赖的package包/类
public Polygon getInsertTabIndication(int idx) {
    Polygon result = tabDisplayer.getUI().getInsertTabIndication(idx);
    scratchPoint.setLocation(0,0);
    Point p = SwingUtilities.convertPoint(tabDisplayer, scratchPoint, container);
    result.translate (-p.x, -p.y);
    return appendContentBoundsTo(result);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:DefaultTabbedContainerUI.java


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