use of java.awt.geom.GeneralPath in project gephi by gephi.
the class GradientSliderUI method paintThumbs.
@Override
protected void paintThumbs(Graphics2D g) {
if (slider.isEnabled() == false) {
return;
}
if (hTriangle == null) {
hTriangle = new GeneralPath();
hTriangle.moveTo(0, 0);
hTriangle.lineTo(TRIANGLE_SIZE, TRIANGLE_SIZE);
hTriangle.lineTo(-TRIANGLE_SIZE, TRIANGLE_SIZE);
hTriangle.lineTo(0, 0);
hTriangle.closePath();
vTriangle = new GeneralPath();
vTriangle.moveTo(0, 0);
vTriangle.lineTo(TRIANGLE_SIZE, TRIANGLE_SIZE);
vTriangle.lineTo(TRIANGLE_SIZE, -TRIANGLE_SIZE);
vTriangle.lineTo(0, 0);
vTriangle.closePath();
}
AffineTransform t = new AffineTransform();
int dx = trackRect.x + trackRect.width;
int dy = trackRect.y + trackRect.height;
dy -= trackRect.height / 6;
dx -= trackRect.width / 6;
int selected = slider.getSelectedThumb(false);
float[] f = slider.getThumbPositions();
int orientation = slider.getOrientation();
Shape shape;
Composite oldComposite = g.getComposite();
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, indication));
for (int a = 0; a < thumbPositions.length; a++) {
if (f[a] >= 0 && f[a] <= 1 && a != selected) {
if (orientation == GradientSlider.HORIZONTAL) {
dx = thumbPositions[a];
shape = hTriangle;
} else {
dy = thumbPositions[a];
shape = vTriangle;
}
t.setToTranslation(dx, dy);
g.transform(t);
float brightness = Math.max(0, thumbIndications[a] * .6f);
g.setColor(new Color((int) (255 * brightness), (int) (255 * brightness), (int) (255 * brightness)));
g.fill(shape);
g.translate(-.5f, -.5f);
g.setColor(new Color(255, 255, 255));
g.draw(shape);
g.translate(.5f, .5f);
t.setToTranslation(-dx, -dy);
g.transform(t);
}
}
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, indication));
if (selected != -1 && f[selected] >= 0 && f[selected] <= 1) {
if (orientation == GradientSlider.HORIZONTAL) {
dx = thumbPositions[selected];
shape = hTriangle;
} else {
dy = thumbPositions[selected];
shape = vTriangle;
}
t.setToTranslation(dx, dy);
g.transform(t);
g.setColor(new Color(255, 255, 255));
g.fill(shape);
g.translate(-.5f, -.5f);
g.setColor(new Color(0, 0, 0));
g.draw(shape);
g.translate(.5f, .5f);
t.setToTranslation(-dx, -dy);
g.transform(t);
}
g.setComposite(oldComposite);
}
use of java.awt.geom.GeneralPath in project gephi by gephi.
the class EquationDisplay method drawEquation.
private void drawEquation(Graphics2D g2, AbstractEquation equation) {
float x = 0.0f;
float y = (float) yPositionToPixel(equation.compute(xPixelToPosition(0.0)));
GeneralPath path = new GeneralPath();
path.moveTo(x, y);
for (x = 0.0f; x < getWidth(); x += 1.0f) {
double position = xPixelToPosition(x);
y = (float) yPositionToPixel(equation.compute(position));
path.lineTo(x, y);
}
g2.draw(path);
}
use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.
the class Path2DGrow method testEmptyGeneralPath.
static void testEmptyGeneralPath() {
echo("\n - Test(GeneralPath[0]) ---");
test(() -> new GeneralPath(Path2D.WIND_NON_ZERO, 0));
}
use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.
the class Path2DCopyConstructor method test.
static void test(Path2D p2d, boolean isEmpty) {
testEqual(new Path2D.Float(p2d), p2d);
testEqual(new Path2D.Double(p2d), p2d);
testEqual(new GeneralPath(p2d), p2d);
testIterator(new Path2D.Float(p2d), p2d);
testIterator(new Path2D.Double(p2d), p2d);
testIterator((Path2D) p2d.clone(), p2d);
testFlattening(new Path2D.Float(p2d), p2d);
testFlattening(new Path2D.Double(p2d), p2d);
testFlattening((Path2D) p2d.clone(), p2d);
testAddMove(new Path2D.Float(p2d));
testAddMove(new Path2D.Double(p2d));
testAddMove((Path2D) p2d.clone());
// These should expect exception if empty
testAddLine(new Path2D.Float(p2d), isEmpty);
testAddLine(new Path2D.Double(p2d), isEmpty);
testAddLine((Path2D) p2d.clone(), isEmpty);
testAddQuad(new Path2D.Float(p2d), isEmpty);
testAddQuad(new Path2D.Double(p2d), isEmpty);
testAddQuad((Path2D) p2d.clone(), isEmpty);
testAddCubic(new Path2D.Float(p2d), isEmpty);
testAddCubic(new Path2D.Double(p2d), isEmpty);
testAddCubic((Path2D) p2d.clone(), isEmpty);
testAddClose(new Path2D.Float(p2d), isEmpty);
testAddClose(new Path2D.Double(p2d), isEmpty);
testAddClose((Path2D) p2d.clone(), isEmpty);
testGetBounds(new Path2D.Float(p2d), p2d);
testGetBounds(new Path2D.Double(p2d), p2d);
testGetBounds((Path2D) p2d.clone(), p2d);
testTransform(new Path2D.Float(p2d));
testTransform(new Path2D.Double(p2d));
testTransform((Path2D) p2d.clone());
testIntersect(new Path2D.Float(p2d), p2d);
testIntersect(new Path2D.Double(p2d), p2d);
testIntersect((Path2D) p2d.clone(), p2d);
testContains(new Path2D.Float(p2d), p2d);
testContains(new Path2D.Double(p2d), p2d);
testContains((Path2D) p2d.clone(), p2d);
testGetCurrentPoint(new Path2D.Float(p2d), p2d);
testGetCurrentPoint(new Path2D.Double(p2d), p2d);
testGetCurrentPoint((Path2D) p2d.clone(), p2d);
}
use of java.awt.geom.GeneralPath in project jdk8u_jdk by JetBrains.
the class Path2DCopyConstructor method testEmptyGeneralPath.
static void testEmptyGeneralPath() {
log("\n - Test(GeneralPath[0]) ---");
test(() -> new GeneralPath(Path2D.WIND_NON_ZERO, 0));
}
Aggregations