Search in sources :

Example 61 with BufferedImage

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()));
}
Also used : TexturePaint(java.awt.TexturePaint) Rectangle(java.awt.Rectangle) TexturePaint(java.awt.TexturePaint) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 62 with BufferedImage

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;
}
Also used : Graphics(java.awt.Graphics) BufferedImage(java.awt.image.BufferedImage)

Example 63 with BufferedImage

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;
}
Also used : BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 64 with BufferedImage

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;
}
Also used : Graphics(java.awt.Graphics) SparklineParameters(org.gephi.utils.sparklines.SparklineParameters) TimelineChart(org.gephi.timeline.api.TimelineChart) BufferedImage(java.awt.image.BufferedImage)

Example 65 with BufferedImage

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;
}
Also used : BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Aggregations

BufferedImage (java.awt.image.BufferedImage)1702 Graphics2D (java.awt.Graphics2D)376 IOException (java.io.IOException)220 File (java.io.File)195 FunctionException (lucee.runtime.exp.FunctionException)122 Graphics (java.awt.Graphics)104 ByteArrayOutputStream (java.io.ByteArrayOutputStream)89 Color (java.awt.Color)88 ByteArrayInputStream (java.io.ByteArrayInputStream)86 Test (org.junit.Test)81 WritableRaster (java.awt.image.WritableRaster)75 Point (java.awt.Point)71 Rectangle (java.awt.Rectangle)68 AffineTransform (java.awt.geom.AffineTransform)57 Image (java.awt.Image)56 InputStream (java.io.InputStream)51 Dimension (java.awt.Dimension)50 ImageIcon (javax.swing.ImageIcon)50 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)46 ImageWriter (javax.imageio.ImageWriter)45