use of java.awt.RadialGradientPaint in project SIMVA-SoS by SESoS.
the class PiePlot method lookupSectionPaint.
/**
* Returns the paint for the specified section. This is equivalent to
* <code>lookupSectionPaint(section)</code>.
* Checks to see if the user set the Paint to be of type RadialGradientPaint
* If so it adjusts the center and radius to match the Pie
*
* @param key the section key.
* @param state PiePlotState.
*
* @return The paint for the specified section.
*
* @since 1.0.14
*/
protected Paint lookupSectionPaint(Comparable key, PiePlotState state) {
Paint paint = lookupSectionPaint(key, getAutoPopulateSectionPaint());
// the current pie segment...
if (paint instanceof RadialGradientPaint) {
RadialGradientPaint rgp = (RadialGradientPaint) paint;
Point2D center = getArcCenter(state, key);
float radius = (float) Math.max(state.getPieHRadius(), state.getPieWRadius());
float[] fractions = rgp.getFractions();
Color[] colors = rgp.getColors();
paint = new RadialGradientPaint(center, radius, fractions, colors);
}
return paint;
}
use of java.awt.RadialGradientPaint in project SIMVA-SoS by SESoS.
the class PieChartFXDemo1 method createGradientPaint.
/**
* A utility method for creating gradient paints.
*
* @param c1 color 1.
* @param c2 color 2.
*
* @return A radial gradient paint.
*/
private static RadialGradientPaint createGradientPaint(Color c1, Color c2) {
Point2D center = new Point2D.Float(0, 0);
float radius = 200;
float[] dist = { 0.0f, 1.0f };
return new RadialGradientPaint(center, radius, dist, new Color[] { c1, c2 });
}
use of java.awt.RadialGradientPaint in project gephi-plugins-bootcamp by gephi.
the class GlowRenderer method renderJava2D.
public void renderJava2D(Item item, G2DTarget target, PreviewProperties properties) {
// Params
Float x = item.getData(NodeItem.X);
Float y = item.getData(NodeItem.Y);
Float size = item.getData(NodeItem.SIZE);
Color color = item.getData(NodeItem.COLOR);
Color startColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), 32);
Color endColor = new Color(startColor.getRed(), startColor.getGreen(), startColor.getBlue(), 0);
float radius = size * 6;
// Get Java2D canvas
Graphics2D g2 = target.getGraphics();
RadialGradientPaint p = new RadialGradientPaint(new Point2D.Double(x, y), radius, new float[] { 0.0f, 1.0f }, new Color[] { startColor, endColor });
g2.setPaint(p);
g2.fillOval((int) (x - radius), (int) (y - radius), (int) (radius * 2), (int) (radius * 2));
}
Aggregations