use of org.jdesktop.swingx.painter.ImagePainter in project gephi by gephi.
the class AbstractSparklinesGraphicsComponentProvider method setImagePainter.
public void setImagePainter(Object value, boolean isSelected) {
if (value == null) {
rendererLabel.setPainter(null);
return;
}
Number[][] values = getSparklinesXAndYNumbers(value);
Number[] xValues = values[0];
Number[] yValues = values[1];
//If there is less than 1 element, don't show anything.
if (yValues.length < 1) {
rendererLabel.setPainter(null);
return;
}
if (yValues.length == 1) {
//SparklineGraph needs at least 2 values, duplicate the only one we have to get a sparkline with a single line showing that the value does not change over time
xValues = null;
yValues = new Number[] { yValues[0], yValues[0] };
}
Color background;
if (isSelected) {
background = SELECTED_BACKGROUND;
} else {
background = UNSELECTED_BACKGROUND;
}
//Note: Can't use interactive SparklineComponent because TableCellEditors don't receive mouse events.
final SparklineParameters sparklineParameters = new SparklineParameters(rendererLabel.getWidth() - 1, rendererLabel.getHeight() - 1, Color.BLUE, background, Color.RED, Color.GREEN, null);
final BufferedImage image = SparklineGraph.draw(xValues, yValues, sparklineParameters);
rendererLabel.setPainter(new ImagePainter(image));
}
use of org.jdesktop.swingx.painter.ImagePainter in project gephi by gephi.
the class AbstractTimeSetGraphicsComponentProvider method setImagePainter.
public void setImagePainter(TimeSet value, boolean isSelected) {
if (value == null) {
rendererLabel.setPainter(null);
return;
}
Color background;
if (isSelected) {
background = SELECTED_BACKGROUND;
} else {
background = UNSELECTED_BACKGROUND;
}
TimeIntervalGraphicsParameters params = getTimeIntervalGraphicsParameters(value);
final BufferedImage image = timeIntervalGraphics.createTimeIntervalImage(params.starts, params.ends, rendererLabel.getWidth() - 1, rendererLabel.getHeight() - 1, FILL_COLOR, BORDER_COLOR, background);
rendererLabel.setPainter(new ImagePainter(image));
}
Aggregations