use of java.awt.image.BufferedImage in project gephi by gephi.
the class GradientSliderUI method createCheckerPaint.
private static void createCheckerPaint() {
int k = 4;
BufferedImage bi = new BufferedImage(2 * k, 2 * k, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bi.createGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, 2 * k, 2 * k);
g.setColor(Color.lightGray);
g.fillRect(0, 0, k, k);
g.fillRect(k, k, k, k);
checkerPaint = new TexturePaint(bi, new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));
}
use of java.awt.image.BufferedImage in project gephi by gephi.
the class Java2dHelper method loadCompatibleImage.
public static BufferedImage loadCompatibleImage(URL resource) throws IOException {
BufferedImage image = ImageIO.read(resource);
BufferedImage compatibleImage = createCompatibleImage(image.getWidth(), image.getHeight());
Graphics g = compatibleImage.getGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
image = null;
return compatibleImage;
}
use of java.awt.image.BufferedImage in project gephi by gephi.
the class Java2dHelper method createThumbnail.
public static BufferedImage createThumbnail(BufferedImage image, int requestedThumbSize) {
float ratio = (float) image.getWidth() / (float) image.getHeight();
int width = image.getWidth();
BufferedImage thumb = image;
do {
width /= 2;
if (width < requestedThumbSize) {
width = requestedThumbSize;
}
BufferedImage temp = new BufferedImage(width, (int) (width / ratio), BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = temp.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2.drawImage(thumb, 0, 0, temp.getWidth(), temp.getHeight(), null);
g2.dispose();
thumb = temp;
} while (width != requestedThumbSize);
return thumb;
}
use of java.awt.image.BufferedImage in project gephi by gephi.
the class Sparkline method getImage.
public BufferedImage getImage(TimelineModel model, int width, int height) {
double newMin = model.getCustomMin();
double newMax = model.getCustomMax();
TimelineChart newChart = model.getChart();
if (chart == null || newMax != max || newMin != min || image.getWidth() != width || image.getHeight() != height || newChart != chart) {
min = newMin;
max = newMax;
chart = newChart;
if (chart != null) {
double minX = chart.getMinX().doubleValue();
double maxX = chart.getMaxX().doubleValue();
int sparklineWidth = (int) (((maxX - minX) / (max - min)) * width);
parameters = new SparklineParameters(sparklineWidth, height);
parameters.setTransparentBackground(true);
parameters.setDrawArea(true);
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
int sparklineX = (int) ((minX - min) / (max - min) * width);
BufferedImage sparklineImage = draw();
Graphics g = image.getGraphics();
g.drawImage(sparklineImage, sparklineX, 0, null);
g.dispose();
} else {
return null;
}
}
return image;
}
use of java.awt.image.BufferedImage in project gephi by gephi.
the class TickGraph method draw.
private BufferedImage draw() {
final BufferedImage image = new BufferedImage(parameters.getWidth(), parameters.getHeight(), BufferedImage.TYPE_INT_ARGB);
final Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (parameters.getType().equals(TickParameters.TickType.DATE)) {
drawDate(g);
} else {
drawReal(g);
}
return image;
}
Aggregations