import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
import static x30_pkg.x30_util.DynamicObject;
class main {
static String dm_showPixelatedImage(MakesBufferedImage image) { return dm_showPixelatedImage(toBufferedImage(image)); }
static String dm_showPixelatedImage(BufferedImage image) {
String mod = dm_showImage(image);
dm_callOpt(mod, "pixelate");
return mod;
}
static String dm_showPixelatedImage(String title, MakesBufferedImage image) { return dm_showPixelatedImage(title, toBufferedImage(image)); }
static String dm_showPixelatedImage(String title, BufferedImage image) {
String mod = dm_showImage(title, image);
dm_callOpt(mod, "pixelate");
return mod;
}
static BufferedImage toBufferedImage(Object o) {
return toBufferedImageOpt(o);
}
static String dm_showImage(MakesBufferedImage image) { return dm_showImage(toBufferedImage(image)); }
static String dm_showImage(BufferedImage image) {
return dm_showNewModuleWithParams("#1027276/AnImageSurface", "image", image);
}
static String dm_showImage(String title, MakesBufferedImage image) { return dm_showImage(title, toBufferedImage(image)); }
static String dm_showImage(String title, BufferedImage image) {
String mod = dm_showImage(image);
dm_set(mod, "title", title);
return mod;
}
static A dm_callOpt(Object moduleOrID, String method, Object... args) {
return dm_callModuleOpt(moduleOrID, method, args);
}
static BufferedImage toBufferedImageOpt(Object o) {
if (o instanceof BufferedImage) return (BufferedImage) o;
if (o instanceof MakesBufferedImage)
return ((MakesBufferedImage) o).getBufferedImage();
if (o instanceof File)
if (isImageFile((File) o))
return loadBufferedImageFile((File) o);
String c = getClassName(o);
// Keep this because it also works on imported objects
if (eqOneOf(c, "main$BWImage", "main$RGBImage"))
return (BufferedImage) call(o, "getBufferedImage");
if (eq(c, "main$PNGFile"))
return (BufferedImage) call(o, "getImage");
return null;
}
static String dm_showNewModuleWithParams(String moduleLibID, Object... params) {
String moduleID = dm_makeNewModuleWithParams(moduleLibID, params);
dm_showModule(moduleID);
return moduleID;
}
static void dm_set(Object moduleOrID, String field, Object value) {
call(dm_getModule(moduleOrID), "setField", field, value);
}
static void dm_set(String field, Object value) {
dm_set(dm_current_generic(), field, value);
}
static A dm_callModuleOpt(Object moduleOrID, String method, Object... args) {
Object mod = dm_getModule(moduleOrID);
if (mod == null) return null;
AutoCloseable __1 = dm_enter(mod); try {
return (A) callOpt_withVarargs(mod, method, args);
} finally { _close(__1); }}
static boolean isImageFile(File f) {
return isImageFileName(fileName(f));
}
static BufferedImage loadBufferedImageFile(File file) { try {
return isFile(file) ? ImageIO.read(file) : null;
} catch (Exception __e) { throw rethrow(__e); } }
static String getClassName(Object o) {
return o == null ? "null" : o instanceof Class ? ((Class) o).getName() : o.getClass().getName();
}
static boolean eqOneOf(Object o, Object... l) {
for (Object x : l) if (eq(o, x)) return true; return false;
}
static Object call(Object o) {
return callF(o);
}
// varargs assignment fixer for a single string array argument
static Object call(Object o, String method, String[] arg) {
return call(o, method, new Object[] {arg});
}
static Object call(Object o, String method, Object... args) {
//ret call_cached(o, method, args);
return call_withVarargs(o, method, args);
}
static boolean eq(Object a, Object b) {
return a == b || a != null && b != null && a.equals(b);
}
// a little kludge for stuff like eq(symbol, "$X")
static boolean eq(Symbol a, String b) {
return eq(str(a), b);
}
static String dm_makeNewModuleWithParams(String moduleLibID, Object... params) {
return (String) dm_callOS("makeNewModule", moduleLibID, false, "beforeStart" , new VF1