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 java.util.function.*; 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 java.awt.geom.*; import javax.imageio.*; import java.math.*; 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 java.util.function.*; 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 java.awt.geom.*; import javax.imageio.*; import java.math.*; import x30_pkg.x30_util; import static x30_pkg.x30_util.VF1; import static x30_pkg.x30_util.indexOf; import static x30_pkg.x30_util.getOpt; import static x30_pkg.x30_util.setOpt; import static x30_pkg.x30_util.callOpt; import static x30_pkg.x30_util.newWeakHashMap; import static x30_pkg.x30_util.newDangerousWeakHashMap; import static x30_pkg.x30_util.get; import static x30_pkg.x30_util.get_raw; import static x30_pkg.x30_util.assertTrue; import static x30_pkg.x30_util.isHeadless; import static x30_pkg.x30_util.isAndroid; import static x30_pkg.x30_util.isTrue; import x30_pkg.x30_util.DynamicObject; import loadableUtils.utils; import static loadableUtils.utils._threadInfo; import static loadableUtils.utils._threadInheritInfo; import static loadableUtils.utils.dm_current_mandatory; import static loadableUtils.utils.match; import static loadableUtils.utils.setOpt_raw; import static loadableUtils.utils.fieldType; import static loadableUtils.utils.format3; import static loadableUtils.utils.vm_generalIdentityHashSet; import static loadableUtils.utils.vm_generalHashMap; import static loadableUtils.utils.vm_generalWeakSubMap; import static loadableUtils.utils.bindToComponent; import static loadableUtils.utils.struct; import static loadableUtils.utils.structure; import static loadableUtils.utils.loadPage; import static loadableUtils.utils.loadPage_utf8; import static loadableUtils.utils.loadPageSilently; import static loadableUtils.utils.loadSnippet; import static loadableUtils.utils.componentPopupMenu; import static loadableUtils.utils.tablePopupMenu; import static loadableUtils.utils.tablePopupMenuFirst; import static loadableUtils.utils.sexyTableWithoutDrag; import static loadableUtils.utils.dm_current_generic; import static loadableUtils.utils.cset; import static loadableUtils.utils.DynamicObject_loading; import static loadableUtils.utils.concepts_unlisted; import static loadableUtils.utils.dynamicObjectIsLoading; import static loadableUtils.utils.rethrow; import loadableUtils.utils.F0; import loadableUtils.utils.F1; import loadableUtils.utils.IF0; import loadableUtils.utils.IF1; import loadableUtils.utils.IVF1; import loadableUtils.utils.IVF2; import loadableUtils.utils.Matches; import loadableUtils.utils.SingleComponentPanel; import loadableUtils.utils.ImageSurface; import loadableUtils.utils.structure_Data; import loadableUtils.utils.RGBImage; import loadableUtils.utils.RGB; import loadableUtils.utils.BWImage; import loadableUtils.utils.MakesBufferedImage; import loadableUtils.utils.MultiSet; import loadableUtils.utils.Concept; import loadableUtils.utils.Concepts; import loadableUtils.utils.IterableIterator; import loadableUtils.utils.IFieldIndex; import loadableUtils.utils.PersistableThrowable; import loadableUtils.utils.DynModule; import loadableUtils.utils.DynPrintLog; import loadableUtils.utils.GlobalID; import loadableUtils.utils.Rect; import loadableUtils.utils.Pt; import loadableUtils.utils.SecretValue; import static loadableUtils.utils.fixNewLines; import static loadableUtils.utils.getExceptionCause; import static loadableUtils.utils.joinWithSpace; import static loadableUtils.utils.callF; import static loadableUtils.utils.javaTok; import static loadableUtils.utils.jlabel; import static loadableUtils.utils.nohupJavax; import static loadableUtils.utils.withDBLock; import static loadableUtils.utils.join; import static loadableUtils.utils.isAWTThread; import static loadableUtils.utils.set; import static loadableUtils.utils.call; import static loadableUtils.utils.fail; import static loadableUtils.utils.print; import static loadableUtils.utils.printAlsoToSystemOut; import static loadableUtils.utils.cget; import static loadableUtils.utils.newTypeWriterTextArea; import static loadableUtils.utils.db; import loadableUtils.utils.LongRange; import loadableUtils.utils.IntRange; import loadableUtils.utils.MultiMap; import loadableUtils.utils.Meta; import loadableUtils.utils.ITokCondition; import loadableUtils.utils.PingSource; import loadableUtils.utils.ThreadPool; import loadableUtils.utils.SimpleLiveValue; import loadableUtils.utils.Matrix; import loadableUtils.utils.Best; import loadableUtils.utils.IRef; import loadableUtils.utils.F2; import loadableUtils.utils.RandomAccessAbstractList; import loadableUtils.utils.IBWIntegralImage; import loadableUtils.utils.Producer; import loadableUtils.utils.IntBuffer; import loadableUtils.utils.AbstractMatrix; import loadableUtils.utils.WithTimestamp; import loadableUtils.utils.IMeta; import loadableUtils.utils.LiveValue; import loadableUtils.utils.Timestamp; import loadableUtils.utils.DoubleRect; import loadableUtils.utils.Complex; import loadableUtils.utils.Either; import loadableUtils.utils.Steppable; import loadableUtils.utils.T3; import loadableUtils.utils.Swingable; import loadableUtils.utils.Average; import loadableUtils.utils.BWIntegralImage; import loadableUtils.utils.DoubleRange; import loadableUtils.utils.Seconds; import static loadableUtils.utils.withTimestamp; import static loadableUtils.utils.score; import static loadableUtils.utils.stepAll; import static loadableUtils.utils.infoMessage; import static loadableUtils.utils.brightnessToRGBA; import static loadableUtils.utils.withBorder; import static loadableUtils.utils.getPlural; import static loadableUtils.utils.rcallOpt; import static loadableUtils.utils.childrenOfType; import static loadableUtils.utils.nanoTime; import static loadableUtils.utils.activateFrame_v3; import static loadableUtils.utils.b; import static loadableUtils.utils.ewicOneOf; import static loadableUtils.utils.n; import static loadableUtils.utils.abs; import static loadableUtils.utils.callMain; import static loadableUtils.utils.caseInsensitiveComparator; import static loadableUtils.utils.getComponents; import static loadableUtils.utils.rep; import static loadableUtils.utils.area; import static loadableUtils.utils.add; import static loadableUtils.utils.singleComponentPanel; import static loadableUtils.utils.withMargin; import static loadableUtils.utils.addActionListener; import static loadableUtils.utils.hasMethod; import static loadableUtils.utils.containsOneOf; import static loadableUtils.utils.intersectRects; import static loadableUtils.utils.setSCPComponent; import static loadableUtils.utils.hideWindow; import static loadableUtils.utils.ymdMinusHMS; import static loadableUtils.utils.jPopDownButton_noText; import static loadableUtils.utils.swingLater; import static loadableUtils.utils.currentImage; import static loadableUtils.utils._defaultClassFinder; import static loadableUtils.utils.boolOptParam; import static loadableUtils.utils.getOptMC; import static loadableUtils.utils.setImage; import static loadableUtils.utils.regexp; import static loadableUtils.utils.alwaysOnTop; import static loadableUtils.utils.setFrameTitle; import static loadableUtils.utils.getScreenWidth; import static loadableUtils.utils.tsNow; import static loadableUtils.utils.jfind_preprocess; import static loadableUtils.utils.dm_reload; import static loadableUtils.utils.getDBProgramID; import static loadableUtils.utils.setFrameIcon; import static loadableUtils.utils.isIdentifier; import static loadableUtils.utils.getSnippetTitle; import static loadableUtils.utils.jFullCenter; import static loadableUtils.utils.dm_fieldCheckBox; import static loadableUtils.utils.indent; import static loadableUtils.utils.infoBox; import static loadableUtils.utils.toSeconds; import static loadableUtils.utils.rect; import static loadableUtils.utils.cleanUp; import static loadableUtils.utils.forEach; import static loadableUtils.utils.disposeWindow; import static loadableUtils.utils.textFieldFromComboBox; import static loadableUtils.utils.getScore; import static loadableUtils.utils.containsNewLines; import static loadableUtils.utils.stdcompare; import static loadableUtils.utils.centerAndEast; import static loadableUtils.utils.metaMapPut; import static loadableUtils.utils.makeFrame; import static loadableUtils.utils.setDoubleBuffered; import static loadableUtils.utils.asVirtualList; import static loadableUtils.utils.javaTokForJFind_array; import static loadableUtils.utils.withLeftAndRightMargin; import static loadableUtils.utils.dm_doEvery; import static loadableUtils.utils.childOfType; import static loadableUtils.utils.hgrid; import static loadableUtils.utils.getFieldType; import static loadableUtils.utils.ping_v3; import static loadableUtils.utils.flattenArray2; import static loadableUtils.utils.getParent; import static loadableUtils.utils.strOrEmpty; import static loadableUtils.utils.pqO; import static loadableUtils.utils.run; import static loadableUtils.utils.has; import static loadableUtils.utils.last; import static loadableUtils.utils.warn; import static loadableUtils.utils.distance; import static loadableUtils.utils.jrightAlignedLine; import static loadableUtils.utils.toRect; import static loadableUtils.utils.installWindowDragger; import static loadableUtils.utils.addIfNotNull; import static loadableUtils.utils.installTimer; import static loadableUtils.utils.clipBufferedImage; import static loadableUtils.utils.setText; import static loadableUtils.utils.findButton; import static loadableUtils.utils.splitAtSpace; import static loadableUtils.utils.getBounds; import static loadableUtils.utils.northAndCenterWithMargin; import static loadableUtils.utils.renderUserThreadsWithStackTraces; import static loadableUtils.utils.newConceptsWithClassFinder; import static loadableUtils.utils.replaceSublist; import static loadableUtils.utils.selectedItem; import static loadableUtils.utils.joinSubList; import static loadableUtils.utils.onSelectedItem; import static loadableUtils.utils.muricaCredentials; import static loadableUtils.utils.onUpdate; import static loadableUtils.utils.activateFrame; import static loadableUtils.utils.replace; import static loadableUtils.utils.profileToConsole; import static loadableUtils.utils.myLibraryFiles; import static loadableUtils.utils.findCodeTokens; import static loadableUtils.utils.withTypeWriterFont; import static loadableUtils.utils.printWithMS; import static loadableUtils.utils.format; import static loadableUtils.utils.heightForWidth; import static loadableUtils.utils.onEnter; import static loadableUtils.utils.hsplit; import static loadableUtils.utils.containsNewLine; import static loadableUtils.utils.centerAndEastWithMargin; import static loadableUtils.utils.getFrame; import static loadableUtils.utils.countIterator_exclusive; import static loadableUtils.utils.centerAndSouth; import static loadableUtils.utils.dm_fieldLiveValue; import static loadableUtils.utils.isLetter; import static loadableUtils.utils.toObjectArray; import static loadableUtils.utils.rectFromPoints; import static loadableUtils.utils.runnableThread; import static loadableUtils.utils.toolTip; import static loadableUtils.utils.firstToUpper; import static loadableUtils.utils.allScreenBounds; import static loadableUtils.utils.findClass_fullName; import static loadableUtils.utils.copyLocalLog; import static loadableUtils.utils.jscroll_centered; import static loadableUtils.utils.parentFile; import static loadableUtils.utils.gazelle_wavySpacer; import static loadableUtils.utils.callOnLoadMethods; import static loadableUtils.utils.dm_rEnter; import static loadableUtils.utils.toString; import static loadableUtils.utils.mapI_if1; import static loadableUtils.utils.getProgramTitle; import static loadableUtils.utils.renameFile; import static loadableUtils.utils.isDigit; import static loadableUtils.utils.regionMatches; import static loadableUtils.utils.warnIfOddCount; import static loadableUtils.utils.synchronizedMRUCache; import static loadableUtils.utils.printFileInfo; import static loadableUtils.utils.bindLiveValueListenerToComponent; import static loadableUtils.utils.screenBounds; import static loadableUtils.utils.myFrames; import static loadableUtils.utils.callStringifier; import static loadableUtils.utils.toRectangle; import static loadableUtils.utils.widthForHeight; import static loadableUtils.utils.javaxCodeDir; import static loadableUtils.utils.jLiveValueLabel; import static loadableUtils.utils.shortClassName_dropNumberPrefix; import static loadableUtils.utils.minimizeWindow; import static loadableUtils.utils.appendToFileBaseName; import static loadableUtils.utils.jbutton; import static loadableUtils.utils.setEnabled; import static loadableUtils.utils.functionCall; import static loadableUtils.utils.javaTokForStructure; import static loadableUtils.utils.northAndCenter; import static loadableUtils.utils.jline; import static loadableUtils.utils.toMS; import static loadableUtils.utils.creator; import static loadableUtils.utils.vmBus_query; import static loadableUtils.utils.change; import static loadableUtils.utils.assertEquals; import static loadableUtils.utils.getPreferredSize; import static loadableUtils.utils.md5; import static loadableUtils.utils.renderFileInfo; import static loadableUtils.utils.jCheckBoxMenuItem; import static loadableUtils.utils.find; import static loadableUtils.utils.jenableUndoRedo; import static loadableUtils.utils.setChecked; import static loadableUtils.utils.setFont; import static loadableUtils.utils.syncList; import static loadableUtils.utils.takeFirst; import static loadableUtils.utils.isEditableComboBox; import static loadableUtils.utils.numberOfCores; import static loadableUtils.utils.showWindow; import static loadableUtils.utils.plus; import static loadableUtils.utils.dm_watchField; import static loadableUtils.utils.codeTokensAsStringArray; import static loadableUtils.utils.ifloor; import static loadableUtils.utils.hmsWithColonsAndMS; import static loadableUtils.utils.smartIndexOf; import static loadableUtils.utils.repeat; import static loadableUtils.utils.structureForUser; import static loadableUtils.utils.ok; import static loadableUtils.utils.nohup; import static loadableUtils.utils.jCheckBox; import static loadableUtils.utils.onWindowClosing; import static loadableUtils.utils.asArray; import static loadableUtils.utils.pt; import static loadableUtils.utils.showText; import static loadableUtils.utils.setDefaultClassFinder; import static loadableUtils.utils.getBytecodePathForClass; import static loadableUtils.utils.standardCredentials; import static loadableUtils.utils.installWindowResizeDraggerOnBorder; import static loadableUtils.utils.singular; import static loadableUtils.utils.minus; import static loadableUtils.utils.syncAddOrCreate; import static loadableUtils.utils.keysList; import static loadableUtils.utils.intRange; import static loadableUtils.utils.getScreenHeight; import static loadableUtils.utils.boolPar; import static loadableUtils.utils.fillRect; import static loadableUtils.utils.westCenterAndEastWithMargin; import static loadableUtils.utils.indentx; import static loadableUtils.utils.getSelectedItem; import static loadableUtils.utils.loadAllClassesInByteCodePath; import static loadableUtils.utils.isChecked; import static loadableUtils.utils.similarEmptyMap; import static loadableUtils.utils.toFile; import static loadableUtils.utils.tempAdd; import static loadableUtils.utils.appendToBaseName; import static loadableUtils.utils.dropFirst; import static loadableUtils.utils.nClasses; import static loadableUtils.utils.mod; import static loadableUtils.utils.makeUndecoratedFrame; import static loadableUtils.utils.findClass; import static loadableUtils.utils.humanizeFormLabel; import static loadableUtils.utils.wrapForSmartAdd; import static loadableUtils.utils.asSet; import static loadableUtils.utils.autoFrameTitle; import static loadableUtils.utils.restart; import static loadableUtils.utils.installTrayIcon; import static loadableUtils.utils.shootScreen2; import static loadableUtils.utils.filter; import static loadableUtils.utils.mapPut; import static loadableUtils.utils.onChange; import static loadableUtils.utils.pingSource; import static loadableUtils.utils.mapToParams; import static loadableUtils.utils.isNonEmptySingleZip_byMagicHeader; import static loadableUtils.utils.withTopMargin; import static loadableUtils.utils.error; import static loadableUtils.utils.setBackground; import static loadableUtils.utils.sysNow; import static loadableUtils.utils.elapsedSeconds; import static loadableUtils.utils.hotwire; import static loadableUtils.utils.heldInstance; import static loadableUtils.utils.getProgramName; import static loadableUtils.utils.trayIcon_imageAutoSize; import loadableUtils.utils.Pair; import loadableUtils.utils.IBWImage; import loadableUtils.utils.WidthAndHeight; import loadableUtils.utils.Enterable; import loadableUtils.utils.G2Drawable; import static loadableUtils.utils.getPrintLog; import static loadableUtils.utils.unstructure; import static loadableUtils.utils.StefansOS_ConnectToServer; import static loadableUtils.utils._MethodCache; import static loadableUtils.utils.defaultMargin; import static loadableUtils.utils.preferredScreen; import javax.swing.border.*; import java.text.NumberFormat; import javax.imageio.metadata.*; import javax.imageio.stream.*; import java.text.SimpleDateFormat; import java.nio.charset.Charset; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.*; class main { static public String programID; static public void _onLoad_initUtils() { utils.__javax = javax(); } static public void _onLoad_defaultClassFinder() { setDefaultClassFinder(new F1() { public Class get(String name) { name = replacePrefix("loadableUtils.utils$", "main$", name); print("_onLoad_defaultClassFinder " + name); Class c = findClass_fullName(name); if (c != null) return c; if (name.startsWith("main$")) return loadableUtils.utils.findClass_fullName("loadableUtils.utils" + name.substring(4)); return null; } }); } static public ThreadLocal dynamicObjectIsLoading_threadLocal() { return DynamicObject_loading; } static public class GazelleScreenCam extends DynModule { volatile public boolean enabled = true; transient public JPanel buttons; public void setEnabled(boolean b) { setField("enabled", b); } public JComponent visualize_enabled() { return dm_checkBox("enabled"); } public int pixelRows = 128, colors = 8; public String script, testScreenScript; public boolean animate = true; public boolean horizontalLayout = false; public WatchTarget watchTarget; transient public ImageSurface isPosterized, isRegions, isTestScreen; transient public ScreenCamStream images = new ScreenCamStream(); transient public BWIntegralImageStream integralImages = new BWIntegralImageStream(); transient public SourceTriggeredStream scaledAndPosterizedImages = new SourceTriggeredStream(); transient public DoubleFPSCounter fpsCounter = new DoubleFPSCounter(); transient public int fps; transient public WatchTargetSelector watchTargetSelector; transient public RollingAverage remainingMSPerFrame = new RollingAverage(); transient public int remainingMS; transient public FunctionTimings functionTimings = new FunctionTimings(); transient public ReliableSingleThread rstRunScript = dm_rst(me(), new Runnable() { public void run() { try { _runScript(); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "_runScript();"; } }); transient public JGazelleVScriptRunner scriptRunner; transient public JGazelleVScriptRunner testScreenScriptRunner; transient public Animation animation; transient public FastRegions_BWImage mainScreenRegions; transient public ImageSurface_HighlightRegion regionHighlighter; transient public UIURLSystem uiURLs; transient public Concepts concepts; public String uiURL; public void start() { try { super.start(); dm_onFieldChange("horizontalLayout", new Runnable() { public void run() { try { dm_reload(); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "dm_reload();"; } }); if (concepts == null) { db(); concepts = db_mainConcepts(); } uiURLs = new UIURLSystem(me(), dm_fieldLiveValue("uiURL")); scriptRunner = new JGazelleVScriptRunner(dm_fieldLiveValue("script", me())); testScreenScriptRunner = new JGazelleVScriptRunner(dm_fieldLiveValue("testScreenScript", me())); images.directlyFeedInto(integralImages); integralImages.onNewElement(ii -> scaledAndPosterizedImages.newElement(posterizeBWImage_withMeta(colors, scaledBWImageFromBWIntegralImage_withMeta_height(pixelRows, ii)))); integralImages.onNewElement(new Runnable() { public void run() { try { if (shouldRunScript()) rstRunScript.go(); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "if (shouldRunScript()) rstRunScript.go();"; } }); scaledAndPosterizedImages.onNewElement(img -> { fpsCounter.inc(); setField("fps", iround(fpsCounter.get())); { if (isPosterized != null) isPosterized.setImage_thisThread(img); } floodFill(img); }); dm_doEvery(1000 / 20, new Runnable() { public void run() { try { if (enabled) { { if (watchTargetSelector != null) watchTargetSelector.updateScreenCount(); } Timestamp deadline = tsNowPlusMS(1000 / 20); if (watchTarget instanceof WatchScreen) images.useScreen(((WatchScreen) watchTarget).screenNr - 1); else if (watchTarget instanceof WatchMouse) images.area(mouseArea(((WatchMouse) watchTarget).width, ((WatchMouse) watchTarget).height)); images.step(); long remaining = deadline.minus(tsNow()); remainingMSPerFrame.add(remaining); setField("remainingMS", iround(remainingMSPerFrame.get())); } } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "if (enabled) {\r\n watchTargetSelector?.updateScreenCount();\r\n Ti..."; } }); } catch (Exception __e) { throw rethrow(__e); } } public ImageSurface stdImageSurface() { return pixelatedImageSurface().setAutoZoomToDisplay(true).repaintInThread(false); } public JComponent visualize() { isPosterized = stdImageSurface(); regionHighlighter = new ImageSurface_HighlightRegion(isPosterized); regionHighlighter.regionPainter(new RegionFillPainter()); isRegions = stdImageSurface(); isTestScreen = stdImageSurface(); awtEvery(isTestScreen, 1000 / 20, new Runnable() { public void run() { try { stepAnimation(); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "stepAnimation();"; } }); JTextArea taTimings = jTextArea_noUndo(); awtEveryAndNow(taTimings, .5, new Runnable() { public void run() { try { setText(taTimings, renderFunctionTimings()); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "setText(taTimings, renderFunctionTimings())"; } }); var jSpeedInfo = dm_transientCalculatedToolTip(() -> speedInfo_long(), rightAlignLabel(dm_transientCalculatedLabel(() -> speedInfo()))); print("Labels: " + list(concepts, Label.class)); SimpleCRUD_v2 labelCRUD = new SimpleCRUD_v2(concepts, Label.class); labelCRUD.hideFields("globalID"); labelCRUD.addCountToEnclosingTab(true); SimpleCRUD_v2 imageCRUD = new SimpleCRUD_v2(concepts, SavedImage.class); imageCRUD.addCountToEnclosingTab(true); var tabs = scrollingTabs(jTopOrLeftTabs(horizontalLayout, "Posterized", withTools(isPosterized), "Regions", jscroll_centered_borderless(isRegions), "Labels", labelCRUD.make_dontStartBots(), "Saved Images", imageCRUD.make_dontStartBots(), "Script", scriptRunner.scriptAndResultPanel(), "Test Screen", testScreenPanel(), "Timings", withRightAlignedButtons(taTimings, "Reset", new Runnable() { public void run() { try { resetTimings(); } catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "resetTimings();"; } }))); labelCRUD.update(); imageCRUD.update(); watchTargetSelector = new WatchTargetSelector(); var vis = northAndCenter(withSideAndTopMargin(uiURLs.urlBar()), centerAndSouthOrEast(horizontalLayout, horizontalLayout ? withMargin(tabs) : withSideMargin(tabs), (borderlessScrollPane(jHigherScrollPane(jfullcenter(vstack(withLeftAndRightMargin(hstack(dm_rcheckBox("enabled", "Watch"), watchTargetSelector.visualize(), jlabel(" in "), withLabelToTheRight("colors @ ", dm_spinner("colors", 2, 256)), withLabelToTheRight("p", dm_powersOfTwoSpinner("pixelRows", 512)))), verticalStrut(2), withRightMargin(jSpeedInfo)))))))); setHorizontalMarginForAllButtons(vis, 4); return vis; } public String speedInfo() { return "FPS " + fps + " idle " + remainingMS + " ms"; } public String speedInfo_long() { return "Screen cam running at " + nFrames(fps) + "/second. " + n2(remainingMS) + " ms remaining per frame in first core."; } public void floodFill(BWImage img) { FastRegions_BWImage ff = new FastRegions_BWImage(img); ff.collectBounds(); functionTimings.time("Regions", ff); mainScreenRegions = ff; { if (regionHighlighter != null) regionHighlighter.setRegions(ff); } if (isRegions != null && isRegions.isShowing_quick()) { isRegions.setImage_thisThread(ff.regionsImage()); } setEnclosingTabTitle(isRegions, nRegions(ff.regionCount())); } public boolean useErrorHandling() { return false; } public String renderFunctionTimings() { return lines(ciSorted(map(functionTimings.get(), (f, avg) -> firstToUpper(f) + ": " + n2(iround(nsToMicroseconds(avg.get()))) + " " + microSymbol() + "s (" + n2(iround(avg.n())) + ")"))); } transient public long _runScript_idx; public void _runScript() { long n = integralImages.elementCount(); if (n > _runScript_idx) { _runScript_idx = n; scriptRunner.parseAndRunOn(integralImages.get()); } } public boolean shouldRunScript() { return isShowing(scriptRunner.scpScriptResult); } public void stepAnimation() { if (!animate) return; if (animation == null) { animation = new AnimatedLine(); animation.start(); } animation.nextFrame(); var img = whiteImage(animation.w, animation.h); animation.setGraphics(createGraphics(img)); animation.paint(); { if (isTestScreen != null) isTestScreen.setImage(img); } var ii = bwIntegralImage_withMeta(img); testScreenScriptRunner.parseAndRunOn(ii); } public JComponent testScreenPanel() { return centerAndSouthWithMargin(hsplit(northAndCenterWithMargin(centerAndEastWithMargin(jlabel("Input"), dm_fieldCheckBox("animate")), jscroll_centered_borderless(isTestScreen)), northAndCenterWithMargin(centerAndEastWithMargin(jlabel("Output"), testScreenScriptRunner.lblScore), testScreenScriptRunner.scpScriptResult)), testScreenScriptRunner.scriptInputField()); } public List popDownItems() { return ll(jCheckBoxMenuItem_dyn("Horizontal Layout", () -> horizontalLayout, b -> setField("horizontalLayout", b))); } public void unvisualize() { } public void resetTimings() { functionTimings.reset(); } public JComponent withTools(ImageSurface is) { new ImageSurface_PositionToolTip(is); return centerAndEastWithMargin(jscroll_centered_borderless(is), vstackWithSpacing(3, jbutton("A"), jbutton("B"), jbutton("C"))); } public class WatchTargetSelector { public JComboBox cb = jComboBox(); public int screenCount; public JComponent visualize() { updateList(); print("Selecting watchTarget: " + watchTarget); selectItem(cb, watchTarget); loadableUtils.utils.onChange(cb, watchTarget -> { setField("watchTarget", watchTarget); print("Chose watchTarget: " + GazelleScreenCam.this.watchTarget); }); return cb; } public void updateScreenCount() { if (screenCount != screenCount()) updateList(); } public void updateList() { swing(() -> { setComboBoxItems(cb, makeWatchTargets()); }); } public List makeWatchTargets() { return flattenToList(countIteratorAsList_incl(1, screenCount = screenCount(), i -> new WatchScreen(i)), new WatchMouse()); } } } static public boolean _moduleClass_GazelleScreenCam = true; static public class Label extends ConceptWithGlobalID { public String name; public String toString() { return "Label " + name; } } static public class SavedImage extends Concept { public File path; } static public class SavedRegion extends Concept { static final public String _fieldOrder = "image area"; public Concept image; public Rect area; } static public class ExampleForLabel extends Concept { static final public String _fieldOrder = "label example confidence"; public Ref