use of java.awt.geom.Path2D in project flutter-intellij by flutter.
the class HeapState method paintComponent.
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (heapState == null) {
return;
}
final int height = getHeight() - 1;
final int width = getWidth();
final long now = System.currentTimeMillis();
final int maxDataSize = Math.round(heapState.getMaxHeapInBytes() / TEN_MB) * TEN_MB + TEN_MB;
final Graphics2D graphics2D = (Graphics2D) g;
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics2D.setColor(getForegroundColor());
graphics2D.setStroke(GRAPH_STROKE);
Path2D path = null;
for (HeapSample sample : heapState.getSamples()) {
final double x = width - (((double) (now - sample.getSampleTime())) / ((double) heapState.getMaxSampleSizeMs()) * width);
// TODO(pq): consider a Y offset or scaling.
final double y = (double) height * sample.getBytes() / maxDataSize;
if (path == null) {
path = new Path2D.Double();
path.moveTo(x, height - y + 1);
} else {
path.lineTo(x, height - y + 1);
}
}
graphics2D.draw(path);
}
use of java.awt.geom.Path2D in project cytoscape-impl by cytoscape.
the class GraphicsUtilities method starShape.
private static Shape starShape(int sides, double x, double y, double width, double height) {
Path2D poly = new Path2D.Double(Path2D.WIND_EVEN_ODD, sides);
width = width / 2;
height = height / 2;
x = x + width;
y = y + height;
int nPoints = sides * 2;
Point2D.Double[] points = new Point2D.Double[nPoints];
for (int i = 0; i < sides; i++) {
double x1 = circleX(sides, i, false) * width + x;
double y1 = circleY(sides, i, false) * height + y;
double x2 = circleX(sides, (i + 2) % sides, false) * width + x;
double y2 = circleY(sides, (i + 2) % sides, false) * height + y;
points[i * 2] = new Point2D.Double(x1, y1);
points[(i * 2 + 4) % nPoints] = new Point2D.Double(x2, y2);
}
// Fill in the intersection points
for (int i = 0; i < nPoints; i = i + 2) {
int p1 = i;
int p2 = (i + 4) % nPoints;
int p3 = (i + 2) % nPoints;
int p4 = (p3 + nPoints - 4) % nPoints;
points[(i + 1) % nPoints] = findIntersection(points[p1], points[p2], points[p3], points[p4]);
}
// Now, add the points
poly.moveTo(points[0].getX(), points[0].getY());
for (int i = 1; i < nPoints; i++) {
poly.lineTo(points[i].getX(), points[i].getY());
}
poly.closePath();
return poly;
}
use of java.awt.geom.Path2D in project cytoscape-impl by cytoscape.
the class GraphicsUtilities method openArrow.
// Create a shape with a 30 degree arrow
static Shape openArrow(double size) {
Path2D path = new Path2D.Double();
path.moveTo(-size * 1.7, -size / 2.0);
path.lineTo(0.0, 0.0);
path.lineTo(-size * 1.7, size / 2.0);
return path;
}
use of java.awt.geom.Path2D in project cytoscape-impl by cytoscape.
the class GraphicsUtilities method concaveArrow.
// Create a shape with a 30 degree arrow
static Shape concaveArrow(double size) {
Path2D path = new Path2D.Double();
path.moveTo(-size, 0.0);
path.lineTo(-size * 1.7, -size / 2.0);
path.lineTo(0.0, 0.0);
path.lineTo(-size * 1.7, size / 2.0);
path.closePath();
return path;
}
use of java.awt.geom.Path2D in project cytoscape-impl by cytoscape.
the class GraphicsUtilities method parallelogramShape.
private static Shape parallelogramShape(double x, double y, double width, double height) {
Path2D poly = new Path2D.Double(Path2D.WIND_EVEN_ODD, 4);
double xMax = x + width;
double yMax = y + height;
poly.moveTo(x, y);
poly.lineTo(((2.0f * xMax) + x) / 3.0f, y);
poly.lineTo(xMax, yMax);
poly.lineTo(((2.0f * x) + xMax) / 3.0f, yMax);
poly.closePath();
return poly;
}
Aggregations