本文整理匯總了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}