Java code in dashboard?

I’ve discovered you can import java (not javascript) libraries into dashboard and use them.

Im using this to read colors from swatch pngs for sports.

This seems off-the-books, so I thought I’d ask if there’s any known pitfalls.

Here’s an example script:

// Import the necessary Java classes
var BufferedImage = java.awt.image.BufferedImage;
var File = java.io.File;
var ImageIO = javax.imageio.ImageIO;

ogscript.debug(new java.io.File(“.”).getAbsolutePath());

try {
// Load the PNG image
var file = new File(“C:/test.png”); // Replace with your image path
var image = ImageIO.read(file);

// Get image width and height
var width = image.getWidth();
var height = image.getHeight();

// Loop through each pixel
for (var y = 0; y < height; y++) {
    for (var x = 0; x < width; x++) {
        // Get RGB value of the pixel
        var pixel = image.getRGB(x, y);

        // Extract ARGB components
        var alpha = (pixel >> 24) & 0xff;
        var red = (pixel >> 16) & 0xff;
        var green = (pixel >> 8) & 0xff;
        var blue = pixel & 0xff;

        // Print pixel coordinates and color values
        ogscript.debug("Pixel at (" + x + "," + y + "): " +
            "Alpha: " + alpha + ", Red: " + red + 
            ", Green: " + green + ", Blue: " + blue);
    }
}

} catch (e) {
ogscript.debug(e);
}
ogscript.reload (“test”);

Hi David

The JavaScript processor in DashBoard presently supports this but you are correct in that it is considered ‘off the books’ or an unofficial feature. What this means is that the ability to do this is not guaranteed from release to release or product to product - for example, the Custom Panels feature in Ross Platform Manager (RPM) does not allow this.

Any use of Java code should be done sparingly and carefully to avoid causing instability in the application.