use of java.awt.Polygon in project OpenNotebook by jaltekruse.
the class LineObjectGUI method getCollisionAndSelectionPolygon.
public Polygon getCollisionAndSelectionPolygon(LineObject line, Point pageOrigin, float zoomLevel) {
ScaledSizeAndPosition sap = getSizeAndPosition(line, pageOrigin, zoomLevel);
GridPoint[] pts = line.getAdjustedVertices();
int[] xVals = new int[pts.length];
int[] yVals = new int[pts.length];
int i = 0;
for (GridPoint pt : pts) {
xVals[i] = (int) (pt.getx() * sap.getWidth()) + sap.getxOrigin();
yVals[i] = (int) (pt.gety() * sap.getHeight()) + sap.getyOrigin();
i++;
}
return new Polygon(xVals, yVals, pts.length);
}
use of java.awt.Polygon in project scriptographer by scriptographer.
the class AbstractGraphics2D method fillPolygon.
/**
* Fills a closed polygon defined by
* arrays of <i>x</i> and <i>y</i> coordinates.
* <p>
* This method draws the polygon defined by <code>nPoint</code> line
* segments, where the first <code>nPoint - 1</code>
* line segments are line segments from
* <code>(xPoints[i - 1], yPoints[i - 1])</code>
* to <code>(xPoints[i], yPoints[i])</code>, for
* 1 ≤ <i>i</i> ≤ <code>nPoints</code>.
* The figure is automatically closed by drawing a line connecting
* the final point to the first point, if those points are different.
* <p>
* The area inside the polygon is defined using an
* even-odd fill rule, also known as the alternating rule.
* @param xPoints a an array of <code>x</code> coordinates.
* @param yPoints a an array of <code>y</code> coordinates.
* @param nPoints a the total number of points.
* @see java.awt.Graphics#drawPolygon(int[], int[], int)
*/
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
Polygon polygon = new Polygon(xPoints, yPoints, nPoints);
fill(polygon);
}
use of java.awt.Polygon in project scriptographer by scriptographer.
the class AbstractGraphics2D method drawPolygon.
/**
* Draws a closed polygon defined by
* arrays of <i>x</i> and <i>y</i> coordinates.
* Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
* <p>
* This method draws the polygon defined by <code>nPoint</code> line
* segments, where the first <code>nPoint - 1</code>
* line segments are line segments from
* <code>(xPoints[i - 1], yPoints[i - 1])</code>
* to <code>(xPoints[i], yPoints[i])</code>, for
* 1 ≤ <i>i</i> ≤ <code>nPoints</code>.
* The figure is automatically closed by drawing a line connecting
* the final point to the first point, if those points are different.
* @param xPoints a an array of <code>x</code> coordinates.
* @param yPoints a an array of <code>y</code> coordinates.
* @param nPoints a the total number of points.
* @see java.awt.Graphics#fillPolygon(int[],int[],int)
* @see java.awt.Graphics#drawPolyline
*/
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
Polygon polygon = new Polygon(xPoints, yPoints, nPoints);
draw(polygon);
}
use of java.awt.Polygon in project DistributedFractalNetwork by Budder21.
the class ArrowButton method isClicked.
/**
* Used to determine whether or not the button was clicked
* @param p a point on the screen that was clicked
* @return whether or not the arrow contains the point
*/
public boolean isClicked(Point p) {
if (down) {
int[] xPoints = { location.x, location.x - 6, location.x + 6 };
int[] yPoints = { location.y, location.y - 9, location.y - 9 };
Polygon poly = new Polygon(xPoints, yPoints, 3);
Rectangle r = new Rectangle(location.x - 6, location.y - 12 - 9, 13, 12);
return poly.contains(p) || r.contains(p);
}
int[] xPoints = { location.x, location.x - 6, location.x + 6 };
int[] yPoints = { location.y, location.y + 9, location.y + 9 };
Polygon poly = new Polygon(xPoints, yPoints, 3);
Rectangle r = new Rectangle(location.x - 6, location.y + 9, 13, 12);
return poly.contains(p) || r.contains(p);
}
use of java.awt.Polygon in project Activiti by Activiti.
the class DefaultProcessDiagramCanvas method drawConditionalSequenceFlowIndicator.
public void drawConditionalSequenceFlowIndicator(Line2D.Double line, double scaleFactor) {
if (scaleFactor > 1.0)
return;
int horizontal = (int) (CONDITIONAL_INDICATOR_WIDTH * 0.7);
int halfOfHorizontal = horizontal / 2;
int halfOfVertical = CONDITIONAL_INDICATOR_WIDTH / 2;
Polygon conditionalIndicator = new Polygon();
conditionalIndicator.addPoint(0, 0);
conditionalIndicator.addPoint(-halfOfHorizontal, halfOfVertical);
conditionalIndicator.addPoint(0, CONDITIONAL_INDICATOR_WIDTH);
conditionalIndicator.addPoint(halfOfHorizontal, halfOfVertical);
AffineTransform transformation = new AffineTransform();
transformation.setToIdentity();
double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
transformation.translate(line.x1, line.y1);
transformation.rotate((angle - Math.PI / 2d));
AffineTransform originalTransformation = g.getTransform();
g.setTransform(transformation);
g.draw(conditionalIndicator);
Paint originalPaint = g.getPaint();
g.setPaint(CONDITIONAL_INDICATOR_COLOR);
g.fill(conditionalIndicator);
g.setPaint(originalPaint);
g.setTransform(originalTransformation);
}
Aggregations