use of java.awt.Polygon in project hackpad by dropbox.
the class RunProxy method paint.
/**
* Paints the component.
*/
@Override
public void paint(Graphics g) {
super.paint(g);
FileTextArea textArea = fileWindow.textArea;
Font font = textArea.getFont();
g.setFont(font);
FontMetrics metrics = getFontMetrics(font);
Rectangle clip = g.getClipBounds();
g.setColor(getBackground());
g.fillRect(clip.x, clip.y, clip.width, clip.height);
int ascent = metrics.getMaxAscent();
int h = metrics.getHeight();
int lineCount = textArea.getLineCount() + 1;
String dummy = Integer.toString(lineCount);
if (dummy.length() < 2) {
dummy = "99";
}
int startLine = clip.y / h;
int endLine = (clip.y + clip.height) / h + 1;
int width = getWidth();
if (endLine > lineCount)
endLine = lineCount;
for (int i = startLine; i < endLine; i++) {
String text;
int pos = -2;
try {
pos = textArea.getLineStartOffset(i);
} catch (BadLocationException ignored) {
}
boolean isBreakPoint = fileWindow.isBreakPoint(i + 1);
text = Integer.toString(i + 1) + " ";
int y = i * h;
g.setColor(Color.blue);
g.drawString(text, 0, y + ascent);
int x = width - ascent;
if (isBreakPoint) {
g.setColor(new Color(0x80, 0x00, 0x00));
int dy = y + ascent - 9;
g.fillOval(x, dy, 9, 9);
g.drawOval(x, dy, 8, 8);
g.drawOval(x, dy, 9, 9);
}
if (pos == fileWindow.currentPos) {
Polygon arrow = new Polygon();
int dx = x;
y += ascent - 10;
int dy = y;
arrow.addPoint(dx, dy + 3);
arrow.addPoint(dx + 5, dy + 3);
for (x = dx + 5; x <= dx + 10; x++, y++) {
arrow.addPoint(x, y);
}
for (x = dx + 9; x >= dx + 5; x--, y++) {
arrow.addPoint(x, y);
}
arrow.addPoint(dx + 5, dy + 7);
arrow.addPoint(dx, dy + 7);
g.setColor(Color.yellow);
g.fillPolygon(arrow);
g.setColor(Color.black);
g.drawPolygon(arrow);
}
}
}
use of java.awt.Polygon in project android by JetBrains.
the class ConnectionDraw method getTopArrow.
/**
* Static accessor to the top arrow
*
* @return return a Polygon representing a top arrow
*/
public static Polygon getTopArrow() {
if (sTopArrow == null) {
sTopArrow = new Polygon();
sTopArrow.addPoint(0, 0);
sTopArrow.addPoint(-CONNECTION_ARROW_SIZE, ARROW_SIDE);
sTopArrow.addPoint(+CONNECTION_ARROW_SIZE, ARROW_SIDE);
}
return sTopArrow;
}
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);
}
use of java.awt.Polygon in project Activiti by Activiti.
the class DefaultProcessDiagramCanvas method drawArrowHead.
public void drawArrowHead(Line2D.Double line, double scaleFactor) {
int doubleArrowWidth = (int) (2 * ARROW_WIDTH / scaleFactor);
if (doubleArrowWidth == 0) {
doubleArrowWidth = 2;
}
Polygon arrowHead = new Polygon();
arrowHead.addPoint(0, 0);
int arrowHeadPoint = (int) (-ARROW_WIDTH / scaleFactor);
if (arrowHeadPoint == 0) {
arrowHeadPoint = -1;
}
arrowHead.addPoint(arrowHeadPoint, -doubleArrowWidth);
arrowHeadPoint = (int) (ARROW_WIDTH / scaleFactor);
if (arrowHeadPoint == 0) {
arrowHeadPoint = 1;
}
arrowHead.addPoint(arrowHeadPoint, -doubleArrowWidth);
AffineTransform transformation = new AffineTransform();
transformation.setToIdentity();
double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
transformation.translate(line.x2, line.y2);
transformation.rotate((angle - Math.PI / 2d));
AffineTransform originalTransformation = g.getTransform();
g.setTransform(transformation);
g.fill(arrowHead);
g.setTransform(originalTransformation);
}
use of java.awt.Polygon in project GDSC-SMLM by aherbert.
the class PSFCreator method getSpots.
/**
* @return Extract all the ROI points that are not within twice the box radius of any other spot
*/
private BasePoint[] getSpots() {
Roi roi = imp.getRoi();
if (roi != null && roi.getType() == Roi.POINT) {
Polygon p = ((PolygonRoi) roi).getNonSplineCoordinates();
int n = p.npoints;
Rectangle bounds = roi.getBounds();
BasePoint[] roiPoints = new BasePoint[n];
for (int i = 0; i < n; i++) {
roiPoints[i] = new BasePoint(bounds.x + p.xpoints[i], bounds.y + p.ypoints[i], 0);
}
// All vs all distance matrix
double[][] d = new double[n][n];
for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) d[i][j] = d[j][i] = roiPoints[i].distanceXY2(roiPoints[j]);
// Spots must be twice as far apart to have no overlap of the extracted box region
double d2 = boxRadius * boxRadius * 4;
int ok = 0;
for (int i = 0; i < n; i++) {
if (noNeighbours(d, n, i, d2))
roiPoints[ok++] = roiPoints[i];
}
return Arrays.copyOf(roiPoints, ok);
}
return new BasePoint[0];
}
Aggregations