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 processing.core.*;
import oshi.SystemInfo;
import oshi.hardware.*;
import javax.swing.event.AncestorListener;
import javax.swing.event.AncestorEvent;
import javax.swing.Timer;
import javax.net.ssl.*;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import javax.swing.undo.UndoManager;
import java.awt.datatransfer.StringSelection;
import java.text.SimpleDateFormat;
import javax.imageio.metadata.*;
import javax.imageio.stream.*;
import java.text.NumberFormat;
import java.text.*;
public class main {
public static class RAMUsageGuage extends DynModule {
public PGauge gauge;
public JComponent visualize() {
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
gauge = pMainAsComponent(PGauge.class);
JComponent panel = jfullcenter(jFixedSize(gauge.Wsize1, gauge.Wsize2, gauge));
awtEveryAndNow(panel, 1000, new Runnable() {
public void run() {
try {
actualUpdate();
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "actualUpdate();";
}
});
return panel;
}
public void actualUpdate() {
AutoCloseable __0 = enter();
try {
GlobalMemory m = oshi_systemMemory();
double percent = 100 - percentRatio(m.getAvailable() - m.getSwapUsed(), m.getTotal());
if (gauge.setValue(percent, iround(percent) + "% of RAM used"))
gauge.handleDraw();
setModuleName(gauge.title);
} finally {
_close(__0);
}
}
}
public static A pMainAsComponent(Class c) {
final A applet = pMain(c);
Window w = getWindow(applet);
applet.frame = null;
for (WindowListener l : w.getWindowListeners()) w.removeWindowListener(l);
getParent(applet).remove(applet);
disposeWindow(w);
return applet;
}
public static JPanel jfullcenter(Component c) {
return jFullCenter(c);
}
public static A jFixedSize(final int w, final int h, final A c) {
if (c != null) {
swing(new Runnable() {
public void run() {
try {
Dimension d = new Dimension(w, h);
c.setMinimumSize(d);
c.setPreferredSize(d);
c.setMaximumSize(d);
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "Dimension d = new Dimension(w, h);\r\n c.setMinimumSize(d);\r\n c.setPrefer...";
}
});
}
return c;
}
public static A jFixedSize(final A c, Dimension d) {
return jFixedSize(d.width, d.height, c);
}
public static void awtEveryAndNow(JComponent component, long delay, Object r) {
swingEvery(component, delay, 0, r);
}
public static void awtEveryAndNow(RootPaneContainer frame, long delay, Object r) {
swingEvery(frame, delay, 0, r);
}
public static RuntimeException rethrow(Throwable t) {
if (t instanceof Error)
_handleError((Error) t);
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
}
public static GlobalMemory oshi_systemMemory() {
return oshi_hardware().getMemory();
}
public static double percentRatio(double x, double y) {
return ratioToPercent(x, y);
}
public static int iround(double d) {
return (int) Math.round(d);
}
public static int iround(Number n) {
return iround(toDouble(n));
}
public static void _close(AutoCloseable c) {
if (c != null)
try {
c.close();
} catch (Throwable e) {
if (c instanceof javax.imageio.stream.ImageOutputStream)
return;
else
throw rethrow(e);
}
}
public static A pMain(final Class c) {
return first(pMainWithFrame(c));
}
public static Pair pMainWithFrame(final Class c) {
return swing(new F0>() {
public Pair get() {
try {
fixContextClassLoader();
A a = nuInstance(c);
PApplet.runSketch(new String[] { c.getName() }, a);
Frame frame = a.frame;
return pair(a, frame);
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "fixContextClassLoader();\r\n A a = nuInstance(c);\r\n //Set frames =...";
}
});
}
public static PApplet2 pMain() {
return pMain(mc());
}
public static Window getWindow(Object o) {
if (!(o instanceof Component))
return null;
Component c = (Component) o;
while (c != null) {
if (c instanceof Window)
return (Window) c;
c = c.getParent();
}
return null;
}
public static Container getParent(final Component c) {
return c == null ? null : swing(new F0() {
public Container get() {
try {
return c.getParent();
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "ret c.getParent();";
}
});
}
public static void disposeWindow(final Window window) {
if (window != null) {
swing(new Runnable() {
public void run() {
try {
window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
myFrames_list.remove(window);
window.dispose();
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING)); //...";
}
});
}
}
public static void disposeWindow(final Component c) {
disposeWindow(getWindow(c));
}
public static void disposeWindow(Object o) {
if (o != null)
disposeWindow(((Component) o));
}
public static void disposeWindow() {
disposeWindow(heldInstance(Component.class));
}
public static JPanel jFullCenter(final Component c) {
return swing(new F0() {
public JPanel get() {
try {
JPanel panel = new JPanel(new GridBagLayout());
panel.add(c);
return panel;
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "JPanel panel = new JPanel(new GridBagLayout);\r\n panel.add(c);\r\n ret panel;";
}
});
}
public static Object swing(Object f) {
return swingAndWait(f);
}
public static A swing(F0 f) {
return (A) swingAndWait(f);
}
public static void swingEvery(JComponent component, long delay, Object r) {
installTimer(component, delay, r);
}
public static void swingEvery(JComponent component, long delay, long firstDelay, Object r) {
installTimer(component, r, delay, firstDelay);
}
public static void swingEvery(RootPaneContainer frame, long delay, Object r) {
installTimer(frame, delay, r);
}
public static void swingEvery(RootPaneContainer frame, long delay, long firstDelay, Object r) {
installTimer(frame, delay, firstDelay, r);
}
public static void _handleError(Error e) {
call(javax(), "_handleError", e);
}
public static Cache oshi_hardware_cache = new Cache("oshi_hardware_load");
public static HardwareAbstractionLayer oshi_hardware() {
return oshi_hardware_cache.get();
}
public static HardwareAbstractionLayer oshi_hardware_load() {
return new SystemInfo().getHardware();
}
public static double ratioToPercent(double x, double y) {
return x * 100 / y;
}
public static double toDouble(Object o) {
if (o instanceof Number)
return ((Number) o).doubleValue();
if (o instanceof BigInteger)
return ((BigInteger) o).doubleValue();
if (o == null)
return 0.0;
throw fail(o);
}
public static Map myFrames_list = weakHashMap();
public static List myFrames() {
return swing(new F0>() {
public List get() {
try {
return keysList(myFrames_list);
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "ret keysList(myFrames_list);";
}
});
}
public static Object first(Object list) {
return first((Iterable) list);
}
public static A first(List list) {
return empty(list) ? null : list.get(0);
}
public static A first(A[] bla) {
return bla == null || bla.length == 0 ? null : bla[0];
}
public static A first(IterableIterator i) {
return first((Iterator) i);
}
public static A first(Iterator i) {
return i == null || !i.hasNext() ? null : i.next();
}
public static A first(Iterable i) {
if (i == null)
return null;
Iterator it = i.iterator();
return it.hasNext() ? it.next() : null;
}
public static Character first(String s) {
return empty(s) ? null : s.charAt(0);
}
public static A first(Pair p) {
return p == null ? null : p.a;
}
public static A get(List l, int idx) {
return l != null && idx >= 0 && idx < l(l) ? l.get(idx) : null;
}
public static A get(A[] l, int idx) {
return idx >= 0 && idx < l(l) ? l[idx] : null;
}
public static boolean get(boolean[] l, int idx) {
return idx >= 0 && idx < l(l) ? l[idx] : false;
}
public static Object get(Object o, String field) {
try {
if (o == null)
return null;
if (o instanceof Class)
return get((Class) o, field);
if (o instanceof Map)
return ((Map) o).get(field);
Field f = getOpt_findField(o.getClass(), field);
if (f != null) {
f.setAccessible(true);
return f.get(o);
}
if (o instanceof DynamicObject)
return ((DynamicObject) o).fieldValues.get(field);
} catch (Exception e) {
throw asRuntimeException(e);
}
throw new RuntimeException("Field '" + field + "' not found in " + o.getClass().getName());
}
public static Object get_raw(Object o, String field) {
try {
Field f = get_findField(o.getClass(), field);
f.setAccessible(true);
return f.get(o);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static Object get(Class c, String field) {
try {
Field f = get_findStaticField(c, field);
f.setAccessible(true);
return f.get(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static Field get_findStaticField(Class> c, String field) {
Class _c = c;
do {
for (Field f : _c.getDeclaredFields()) if (f.getName().equals(field) && (f.getModifiers() & java.lang.reflect.Modifier.STATIC) != 0)
return f;
_c = _c.getSuperclass();
} while (_c != null);
throw new RuntimeException("Static field '" + field + "' not found in " + c.getName());
}
public static Field get_findField(Class> c, String field) {
Class _c = c;
do {
for (Field f : _c.getDeclaredFields()) if (f.getName().equals(field))
return f;
_c = _c.getSuperclass();
} while (_c != null);
throw new RuntimeException("Field '" + field + "' not found in " + c.getName());
}
public static void fixContextClassLoader() {
Thread.currentThread().setContextClassLoader(myClassLoader());
}
public static A nuInstance(Class c) {
return nuEmptyObject(c);
}
public static Pair pair(A a, B b) {
return new Pair(a, b);
}
public static Pair pair(A a) {
return new Pair(a, a);
}
public static Class mc() {
return main.class;
}
public static A heldInstance(Class c) {
List