本文整理汇总了Java中java.awt.Polygon.addPoint方法的典型用法代码示例。如果您正苦于以下问题:Java Polygon.addPoint方法的具体用法?Java Polygon.addPoint怎么用?Java Polygon.addPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Polygon
的用法示例。
在下文中一共展示了Polygon.addPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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;
}
示例3: mousePressed
import java.awt.Polygon; //导入方法依赖的package包/类
public void mousePressed(MouseEvent e) {
if (e.isControlDown()) return;
if (e.isConsumed()||!map.isSelectable()) return;
if (((MapApp) map.getApp()).getMapTools().panB.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);
}
}
示例4: 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);
}
示例5: getRegiao
import java.awt.Polygon; //导入方法依赖的package包/类
@Override
public Shape getRegiao() {
if (Regiao == null) {
Point[] tri = getPontosDoTriangulo();
Point p1 = tri[0], p2 = tri[1], p3 = tri[2];
Polygon triang = new Polygon();
triang.addPoint(p1.x, p1.y);
triang.addPoint(p2.x, p2.y);
triang.addPoint(p3.x, p3.y);
Regiao = triang;
}
return Regiao;
}
示例6: mousePressed
import java.awt.Polygon; //导入方法依赖的package包/类
public void mousePressed(MouseEvent e) {
if (!initDrag(e.getPoint(), (XYGraph)e.getSource()) && lassoButton != null && lassoButton.isSelected()) { // If we aren't dragging a side
// Make a lasso
// XYGraph g = (XYGraph) e.getSource();
poly = new Polygon();
poly.addPoint(e.getPoint().x, e.getPoint().y);
}
}
示例7: mousePressed
import java.awt.Polygon; //导入方法依赖的package包/类
public void mousePressed(MouseEvent e) {
if (!initDrag(e.getPoint(), (XYGraph)e.getSource()) && lassoButton.isSelected()) { // If we aren't dragging a side
// Make a lasso
XYGraph g = (XYGraph) e.getSource();
poly = new Polygon();
poly.addPoint(e.getPoint().x, e.getPoint().y);
}
}
示例8: drawMaskedOffRectangle
import java.awt.Polygon; //导入方法依赖的package包/类
public void drawMaskedOffRectangle(Graphics2D g, Point2D point, Color color) {
Polygon poly = new Polygon();
poly.addPoint(plane.getTrueX(0), plane.getTrueY(0));
poly.addPoint(plane.getTrueX(0), plane.getTrueY(point.getY()));
poly.addPoint(plane.getTrueX(point.getX()),
plane.getTrueY(point.getY()));
poly.addPoint(plane.getTrueX(point.getX()), plane.getTrueY(0));
g.setStroke(LINES);
g.setColor(color);
g.fillPolygon(poly);
}
示例9: twoPointRectangle
import java.awt.Polygon; //导入方法依赖的package包/类
/**
* Create a Polygon that is a rectangle draw between two point
* @param xP1 The x of the first point
* @param yP1 The y of the first point
* @param xP2 The x of the second point
* @param yP2 The y of the second point
* @return The rectangle in a polygon object
*/
public Polygon twoPointRectangle(int xP1, int yP1, int xP2, int yP2) {
Polygon p = new Polygon();
p.addPoint(xP1, yP1);
p.addPoint(xP1, yP2);
p.addPoint(xP2, yP2);
p.addPoint(xP2, yP1);
return p;
}
示例10: getRegiao
import java.awt.Polygon; //导入方法依赖的package包/类
@Override
public Shape getRegiao() {
if (Regiao == null) {
Rectangle r = new Rectangle(getLeft(), getTop(), getWidth(), getHeight()); //getBounds();
Polygon los = new Polygon();
los.addPoint(r.x, r.y + r.height / 2);
los.addPoint(r.x + r.width / 2, r.y);
los.addPoint(r.x + r.width, r.y + r.height / 2);
los.addPoint(r.x + r.width / 2, r.y + r.height);
Regiao = los;
}
return Regiao;
}
示例11: selectLine
import java.awt.Polygon; //导入方法依赖的package包/类
/**
* Return true if the point is on a line between the first and the second point
* @param p1 The first point of the line
* @param p2 The second point of the line
* @param point The point that could be on the line
* @return True if the point is on a line between the first and the second point
*/
public boolean selectLine(DPoint p1, DPoint p2, Point point) {
Polygon p = new Polygon();
p.addPoint((int) ((p1.getX() * scale) + tran_x - ((pointSize + 1))), (int) ((tran_y - (p1.getY() * scale) + ((pointSize + 1)))));
p.addPoint((int) ((p1.getX() * scale) + tran_x + ((pointSize + 1))), (int) ((tran_y - (p1.getY() * scale) - ((pointSize + 1)))));
p.addPoint((int) ((p2.getX() * scale) + tran_x + ((pointSize + 1))), (int) ((tran_y - (p2.getY() * scale) - ((pointSize + 1)))));
p.addPoint((int) ((p2.getX() * scale) + tran_x - ((pointSize + 1))), (int) ((tran_y - (p2.getY() * scale) + ((pointSize + 1)))));
if (p.contains(point)) {
return true;
}
return false;
}
示例12: paintWidget
import java.awt.Polygon; //导入方法依赖的package包/类
@Override
public void paintWidget() {
ObjectState os = this.getState();
if(!os.isHovered() && !os.isSelected()) return; //all previewEdges visible and not hovering,
//no need to paint the switch
float hw = width/2;
Polygon pol = new Polygon();
pol.addPoint(0,(int) -height/2);
pol.addPoint((int)hw,(int) height/2);
pol.addPoint((int)-hw,(int) height/2);
Graphics2D gr = getGraphics();
gr.setColor(this.getForeground());
BasicStroke bs = new BasicStroke(2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
gr.setStroke(bs);
AffineTransform previousTransform;
previousTransform = gr.getTransform ();
if(output) {
if(os.isSelected() ){//hidden
gr.scale(1.0, -1.0);
}
} else { //input switch
if(os.isHovered() && !os.isSelected()){
gr.scale(1.0, -1.0);
}
}
gr.fillPolygon(pol);
gr.setTransform(previousTransform);
}
示例13: getPolygonFromPoints
import java.awt.Polygon; //导入方法依赖的package包/类
public Polygon getPolygonFromPoints(List<Point> pointsList)
{
Polygon shapePoly = new Polygon();
for(Point point : pointsList)
{
shapePoly.addPoint(point.x, point.y);
}
return shapePoly;
}
示例14: mousePressed
import java.awt.Polygon; //导入方法依赖的package包/类
public void mousePressed(MouseEvent e) {
polygon = new Polygon();
polygon.addPoint(e.getX(), e.getY());
polygon.addPoint(e.getX(), e.getY());
polygon.addPoint(e.getX(), e.getY());
polygon.addPoint(e.getX(), e.getY());
addMouseMotionListener(this);
}
示例15: initContext
import java.awt.Polygon; //导入方法依赖的package包/类
public void initContext(TestEnvironment env, Context ctx) {
ctx.graphics = env.getGraphics();
int w = env.getWidth();
int h = env.getHeight();
ctx.size = env.getIntValue(sizeList);
ctx.outdim = getOutputSize(ctx.size, ctx.size);
ctx.pixscale = 1.0;
if (hasGraphics2D) {
Graphics2D g2d = (Graphics2D) ctx.graphics;
AlphaComposite ac = (AlphaComposite) env.getModifier(compRules);
if (env.isEnabled(doExtraAlpha)) {
ac = AlphaComposite.getInstance(ac.getRule(), 0.125f);
}
g2d.setComposite(ac);
if (env.isEnabled(doXor)) {
g2d.setXORMode(Color.white);
}
if (env.isEnabled(doClipping)) {
Polygon p = new Polygon();
p.addPoint(0, 0);
p.addPoint(w, 0);
p.addPoint(0, h);
p.addPoint(w, h);
p.addPoint(0, 0);
g2d.clip(p);
}
Transform tx = (Transform) env.getModifier(transforms);
Dimension envdim = new Dimension(w, h);
tx.init(g2d, ctx, envdim);
w = envdim.width;
h = envdim.height;
g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
env.getModifier(renderHint));
}
switch (env.getIntValue(animList)) {
case 0:
ctx.animate = false;
ctx.maxX = 3;
ctx.maxY = 1;
ctx.orgX = (w - ctx.outdim.width) / 2;
ctx.orgY = (h - ctx.outdim.height) / 2;
break;
case 1:
ctx.animate = true;
ctx.maxX = Math.max(Math.min(32, w - ctx.outdim.width), 3);
ctx.maxY = 1;
ctx.orgX = (w - ctx.outdim.width - ctx.maxX) / 2;
ctx.orgY = (h - ctx.outdim.height) / 2;
break;
case 2:
ctx.animate = true;
ctx.maxX = (w - ctx.outdim.width) + 1;
ctx.maxY = (h - ctx.outdim.height) + 1;
ctx.maxX = adjustWidth(ctx.maxX, ctx.maxY);
ctx.maxX = Math.max(ctx.maxX, 3);
ctx.maxY = Math.max(ctx.maxY, 1);
// ctx.orgX = ctx.orgY = 0;
break;
}
ctx.initX = ctx.maxX / 2;
ctx.initY = ctx.maxY / 2;
}