### Example Java Program Using Methods Source: https://studio.code.org/docs/ide/javalab/classes/Methods Demonstrates the implementation and usage of user-defined and standard library methods in Java. It shows how to define a method in one class ('Calculator') and call it from another class ('MyConsole') within the 'main' method. The example includes variable initialization, method invocation, and printing the result to the console. ```java public class Calculator { public static int doubleIt(int num) { return num * 2; } } public class MyConsole { public static void main(String[] args) { // initialize a variable, and then print the variable doubled int value = 4; int doubledValue = Calculator.doubleIt(value); System.out.println("The double of " + value + " is " + doubledValue + "."); } } ``` -------------------------------- ### Initialize Session Replay Recorder Source: https://studio.code.org/docs/ide/javalab/index Initializes the session replay recorder, importing necessary modules and starting recording based on configuration. It handles potential errors during import and provides methods to start recording in different modes (PRELOAD, API). ```javascript E{static featureName=Ke.TZ;#n;recorder;constructor(e){var t;let r;super(e,Ke.TZ),t=e,p(u.CH,(function(){(0,s.p)(u.CH,[],void 0,n.K7.sessionReplay,t.ee)}),t),function(e){p(u.Tb,(function(){(0,s.p)(u.Tb,[],void 0,n.K7.sessionReplay,e.ee)}),e)}(e);try{r=JSON.parse(localStorage.getItem("".concat(S.H3,"_").concat(S.uh)))}catch(e){}(0,w.SR)(e.init)&&this.ee.on(Ke.G4.RECORD,(()=>this.#i())),this.#o(r)&&this.importRecorder().then((e=>{e.startRecording(Ke.Qb.PRELOAD,r?.sessionReplayMode)})),this.importAggregator(this.agentRef,(()=>i.e(478).then(i.bind(i,6167))),this),this.ee.on("err",(e=>{this.blocked||this.agentRef.runtime.isRecording&&(this.errorNoticed=!0,(0,s.p)(Ke.G4.ERROR_DURING_REPLAY,[e],void 0,this.featureName,this.ee))}))}#o(e){return e&&(e.sessionReplayMode===S.g.FULL||e.sessionReplayMode===S.g.ERROR)||(0,w.Aw)(this.agentRef.init)}importRecorder(){return this.recorder?Promise.resolve(this.recorder):(this.#n??=Promise.all([i.e(478),i.e(249)]).then(i.bind(i,8589)).then((({Recorder:e})=>(this.recorder=new e(this),this.recorder))).catch((e=>{throw this.ee.emit("internal-error",[e]),this.blocked=!0,e})),this.#n)}#i(){this.blocked||(this.featAggregate?this.featAggregate.mode!==S.g.FULL&&this.featAggregate.initializeRecording(S.g.FULL,!0,Ke.Qb.API):this.importRecorder().then((()=>{this.recorder.startRecording(Ke.Qb.API,S.g.FULL)})))}}var Fe=i(3962); ``` -------------------------------- ### Initialize and Import Feature Aggregator (JavaScript) Source: https://studio.code.org/docs/ide/javalab/index Initializes a feature with agent identifier and configurations. It imports an aggregator module using dynamic imports and handles the asynchronous setup. Errors during aggregator import or setup are caught and reported. ```JavaScript importAggregator(e, t, r = {}) { if (this.featAggregate) return; let n; this.onAggregateImported = new Promise((e => { n = e })); const o = async () => { let o; await this.deferred; try { if ((0, R.V)(e.init)) { const { setupAgentSession: t } = await i.e(478).then(i.bind(i, 2955)); o = t(e) } } catch (e) { (0, l.R)(20, e), this.ee.emit("internal-error", [e]), (0, s.p)(T.qh, [e], void 0, this.featureName, this.ee) } try { if (!this.#t(this.featureName, o, e.init)) return (0, m.Ze)(this.agentIdentifier, this.featureName), void n(!1); const { Aggregate: i } = await t(); this.featAggregate = new i(e, r), e.runtime.harvester.initializedAggregates.push(this.featAggregate), n(!0) } catch (e) { (0, l.R)(34, e), this.abortHandler?.(), (0, m.Ze)(this.agentIdentifier, this.featureName, !0), n(!1), this.ee && this.ee.abort() } }; y.RI ? (0, b.GG)((() => o()), !0) : o() } ``` -------------------------------- ### Initialize Painter Object Source: https://studio.code.org/docs/ide/javalab/classes/Painter Creates a Painter object at the default starting position (0,0) facing East with no paint. This is the simplest way to begin using the Painter class. ```java Painter myPainter = new Painter(); ``` -------------------------------- ### Image Manipulation Methods Source: https://studio.code.org/docs/ide/javalab/classes/Image Methods for getting and setting pixels, retrieving dimensions, and clearing the image. ```APIDOC ## Image Manipulation Methods ### `public Pixel getPixel(int x, int y)` Gets the `Pixel` object at the specified x and y coordinate. **Parameters** - **x** (int) - The x coordinate of the `Pixel`. - **y** (int) - The y coordinate of the `Pixel`. **Example** ```java Image myImage = new Image("sample.jpg"); Pixel singlePixel = myImage.getPixel(10, 20); // singlePixel points to the Pixel object located at (10, 20) in myImage ``` ### `public void setPixel(int x, int y, Color color)` Sets the `Pixel` at the specified x and y coordinate to the `Color` provided. **Parameters** - **x** (int) - The x coordinate to set the `Pixel`. - **y** (int) - The y coordinate to set the `Pixel`. - **color** (Color) - The `Color` to use to set the `Pixel`. **Example** ```java Image myImage = new Image("sample.jpg"); Color myColor = new Color(166, 99, 204); myImage.setPixel(10, 20, myColor); ``` ### `public int getWidth()` Returns the width of this `Image` in pixels. **Example** ```java Image myImage = new Image("sample.jpg"); int myImageWidth = myImage.getWidth(); ``` ### `public int getHeight()` Returns the height of this `Image` in pixels. **Example** ```java Image myImage = new Image("sample.jpg"); int myImageHeight = myImage.getHeight(); ``` ### `public void clear(Color color)` Clears this `Image` and fills it with the specified `Color`. **Parameters** - **color** (Color) - The `Color` to fill this `Image`. **Example** ```java Image myImage = new Image("sample.jpg"); myImage.clear(Color.VIOLET); ``` ``` -------------------------------- ### Initialize Painter with Custom Parameters Source: https://studio.code.org/docs/ide/javalab/classes/Painter Creates a Painter object at a specified x and y coordinate, facing a given direction, and with an initial amount of paint. This allows for more precise control over the Painter's starting state. ```java Painter myPainter = new Painter(2, 4, "South", 10); ``` -------------------------------- ### Java Relational Operators Example Source: https://studio.code.org/docs/ide/javalab/classes/ComparingNumbers Demonstrates the use of relational operators (==, <) in Java to compare two integer variables. The output depends on the boolean evaluation of the comparison. ```java int a = 4; int b = 7; if (a == b) { System.out.println("they are equal."); } // This expression will evaluate to false, so the print statement will not be executed. if (a < b) { System.out.println("a is less than b"); } // This expression will evaluate to true because 4 < 7, so the print statement will be executed. ``` -------------------------------- ### Instrumenting Function Calls for Performance Monitoring Source: https://studio.code.org/docs/ide/javalab/index This snippet provides a high-level wrapper for instrumenting function calls to monitor their performance, including start, end, and error events. It utilizes a callback mechanism for event emission and error handling. Dependencies include performance API and an event emitter. ```javascript function nrWrapper(){var o,a,d,l;let f;try{a=this,o=[...arguments],d="function"==typeof n?n(o,a):n||{}}catch(t){u([t,"",[o,a,s],d],e)}i(r+"start",[o,a,s],d,c);const h=performance.now();let p=h;try{return l=t.apply(a,o),p=performance.now(),l}catch(e){throw p=performance.now(),i(r+"err",[o,a,e],d,c),f=e,f}finally{const e=p-h,t={duration:e,isLongTask:e>=50,methodName:s,thrownError:f};t.isLongTask&&i("long-task",[t],d,c),i(r+"end",[o,a,l,t],d,c)}}}function i(r,n,i,o){if(!s||t){var a=s;s=!0;try{e.emit(r,n,i,t,o)}catch(t){u([t,r,n,i],e)}s=a}}}function u(e,t){t||(t=n.ee);try{t.emit("internal-error",e)}catch(e){}}function d(e){return!(e&&"function"==typeof e&&e.apply&&!e[o])}} ``` -------------------------------- ### Playing Bass Note with Java Lab Source: https://studio.code.org/docs/ide/javalab/classes/Instrument Illustrates playing a musical note with the BASS instrument in Java Lab. Similar to the piano example, this uses the playNote method, specifying the BASS instrument, a note, and its duration. ```java myScene.playNote(Instrument.BASS, 40, 1); ``` -------------------------------- ### Java: Declare and Print Integer Variable Source: https://studio.code.org/docs/ide/javalab/classes/Variables This snippet demonstrates how to declare an integer variable in Java, perform an arithmetic operation on it, and then print its value to the console. It shows a basic example of variable manipulation and output. ```java int x = 7; x = x + 2; System.out.println("The value of x is " + x + "."); ``` -------------------------------- ### Java Object toString() Method Example Source: https://studio.code.org/docs/ide/javalab/classes/Class Illustrates the use of the toString() method in Java, which provides a String representation of an object. This method is frequently overridden to offer a more informative output. The default output includes the class name and hash code. ```java Object obj1 = new Object(); System.out.println(obj1.toString()); ``` -------------------------------- ### Java: Traverse ArrayList Source: https://studio.code.org/docs/ide/javalab/classes/ArrayLists Provides an example of traversing an ArrayList using a standard `for` loop. It iterates through the list by index, accessing each element using `get(index)`. ```java ArrayList numbers = new ArrayList(); numbers.add(1); numbers.add(2); numbers.add(3); numbers.add(4); for (int index = 0; index < numbers.size(); index++) { System.out.print(numbers.get(index)); } ``` -------------------------------- ### Get Size of Java ArrayList Source: https://studio.code.org/docs/ide/javalab/classes/ArrayList Explains how to get the number of elements currently in an ArrayList. The size method returns an integer representing the list's element count. ```java ArrayList myNumbers = new ArrayList(); myNumbers.add(10); myNumbers.add(20); myNumbers.add(30); int totalNumbers = myNumbers.size(); System.out.println("Size of list is " + totalNumbers); ``` -------------------------------- ### Initialize Performance Observer for Resources Source: https://studio.code.org/docs/ide/javalab/index This snippet sets up a `PerformanceObserver` to monitor resource loading performance. It captures resource entries and sends them for browser performance analysis when the relevant feature is enabled. ```javascript e.init.performance.resources.enabled&& y.gm.PerformanceObserver?.supportedEntryTypes.includes("resource"))){ new PerformanceObserver((e=>{ e.getEntries().forEach((e=>{ (0,s.p)("browserPerformance.resource",[e],void 0,this.featureName,this.ee) })) })).observe({type:"resource",buffered:!0}) } ``` -------------------------------- ### Java: General Syntax for a for Loop Source: https://studio.code.org/docs/ide/javalab/classes/ForLoops Provides the fundamental syntax for a 'for' loop in Java. It outlines the three essential components: the initial expression to set up the loop variable, the condition to determine loop continuation, and the update expression to modify the loop variable after each iteration. The code within the curly braces represents the body of the loop that gets executed. ```Java for (initialExpression; condition; updateExpression) { // body of code } ``` -------------------------------- ### Draw Line on Canvas Source: https://studio.code.org/docs/ide/javalab/classes/Scene Illustrates how to draw a straight line on the canvas by specifying the starting and ending coordinates. The drawLine method takes four integer arguments for the start and end points. ```java Scene myScene = new Scene(); myScene.drawLine(50, 100, 250, 200); Theater.playScenes(myScene); ``` -------------------------------- ### Initialize and Configure Java Lab IDE Source: https://studio.code.org/docs/ide/javalab/index This snippet demonstrates the initialization of the Studio Code IDE with various features enabled, including user actions, performance monitoring, and logger configurations. It handles feature dependencies and conditional loading based on runtime configurations. ```javascript new class extends r{ constructor(e){ var t; (super(),y.gm)&&(this.features={},(0,N.bQ)(this.agentIdentifier,this),this.desiredFeatures=new Set(e.features|| []),this.desiredFeatures.add(_),this.runSoftNavOverSpa=[...this.desiredFeatures].some((e=>e.featureName===n.K7.softNav)), (0,a.j)(this,e,e.loaderType||"agent"),t=this,p(u.cD,(function(e,r,n=!1){ if("string"==typeof e){ if(["string","number","boolean"].includes(typeof r)|| null===r) return g(t,e,r,u.cD,n); (0,l.R)(40,typeof r) } else (0,l.R)(39,typeof e) }),t),function(e){ p(u.Dl,(function(t){ if("string"==typeof t|| null===t) return g(e,"enduser.id",t,u.Dl,!0); (0,l.R)(41,typeof t) }),e) }(this),function(e){ p(u.nb,(function(t){ if("string"==typeof t|| null===t) return g(e,"application.version",t,u.nb,!1); (0,l.R)(42,typeof t) }),e) }(this),function(e){ p(u.d3,(function(){ e.ee.emit("manual-start-all") }),e) }(this), this.run()) } } get config(){ return{ info:this.info, init:this.init, loader_config:this.loader_config, runtime:this.runtime } } get api(){ return this } run(){ try{ const e=function(e){ const t={}; return o.forEach((r=>{ t[r]=!!e[r]?.enabled })),t }(this.init),t=[...this.desiredFeatures]; t.sort(((e,t)=>n.P3[e.featureName]-n.P3[t.featureName])); t.forEach((t=>{ if(!e[t.featureName]&&t.featureName!==n.K7.pageViewEvent) return; if(this.runSoftNavOverSpa&&t.featureName===n.K7.spa) return; if(!this.runSoftNavOverSpa&&t.featureName===n.K7.softNav) return; const r=function(e){ switch(e){ case n.K7.ajax: return[n.K7.jserrors]; case n.K7.sessionTrace: return[n.K7.ajax,n.K7.pageViewEvent]; case n.K7.sessionReplay: return[n.K7.sessionTrace]; case n.K7.pageViewTiming: return[n.K7.pageViewEvent]; default: return[] } }(t.featureName).filter((e=>!(e in this.features))); r.length>0&& (0,l.R)(36,{ targetFeature:t.featureName, missingDependencies:r }), this.features[t.featureName]=new t(this) })) } catch(e){ (0,l.R)(22,e); for(const e in this.features) this.features[e].abortHandler?.(); const t=(0,N.Zm)(); delete t.initializedAgents[this.agentIdentifier]?.features, delete this.sharedAggregator; return t.ee.get(this.agentIdentifier).abort(),!1 } } }({features:[Te,_,j,De,Ue,k,q,vt,xt,Be,gt],loaderType:"spa"}) )()} ``` -------------------------------- ### Logging Configuration (New Relic) Source: https://studio.code.org/docs/ide/javalab/index This snippet sets up logging levels and constants for the New Relic SDK. It defines log levels (ERROR, WARN, INFO, DEBUG, TRACE) and their corresponding numeric severities, along with a 'logging' module from K7. Requires the New Relic SDK. ```javascript r.d(t,{A$:()=>o,ET:()=>a,TZ:()=>s,p_:()=>i});var n=r(860);const i={ERROR:"ERROR",WARN:"WARN",INFO:"INFO",DEBUG:"DEBUG",TRACE:"TRACE"},o={OFF:0,ERROR:1,WARN:2,INFO:3,DEBUG:4,TRACE:5},a="log",s=n.K7.logging ``` -------------------------------- ### Java Main Method Entry Point Source: https://studio.code.org/docs/ide/javalab/classes/MainMethod The 'main' method is the entry point for any Java program, identified by the JVM. It must follow a specific public static void main(String[] args) signature to be executable. The 'args' parameter allows for command-line arguments. ```java public static void main(String [] args) { System.out.println("Main Method"); } ``` -------------------------------- ### Java String Substring Extraction Source: https://studio.code.org/docs/ide/javalab/classes/String Extracts a portion of a string based on the start and end indices. The start index is inclusive, and the end index is exclusive. This method is useful for parsing and manipulating string data. ```java String test = "welcome"; System.out.println(test.substring(2,4)); ``` -------------------------------- ### Java: Extract a substring from a starting index Source: https://studio.code.org/docs/ide/javalab/classes/String Shows how to use the substring() method in Java to extract a portion of a string starting from a specified index to the end of the string. This is useful for manipulating or isolating parts of a string. ```java String test = "welcome"; System.out.println(test.substring(2)); ``` -------------------------------- ### New Relic API Registration and Event Handling in JavaScript Source: https://studio.code.org/docs/ide/javalab/index This snippet demonstrates the initialization and event handling for New Relic's API within a JavaScript environment. It covers setting custom attributes, user IDs, application versions, and handling connection logic for the agent. It also includes functions for sending data like page actions, logs, and errors, with options to manage duplicate data registration. ```javascript function Z(e){p(u.eY,(function(t){return function(e,t){const r={};let i,o;(0,l.R)(54,"newrelic.register"),e.init.api.allow_registered_children||(i=()=>(0,l.R)(55));t&&(0,W.I)(t)||(i=()=>(0,l.R)(48,t));const a={addPageAction:(n,i={})=>{u(z,[n,{...r,...i},e],t)},log:(n,i={})=>{u(V,[n,{...i,customAttributes:{...r,...i.customAttributes||{}}},e],t)},noticeError:(n,i={})=>{u(F,[n,{...r,...i},e],t)},setApplicationVersion:e=>{r["application.version"]=e},setCustomAttribute:(e,t)=>{r[e]=t},setUserId:e=>{r["enduser.id"]=e},metadata:{customAttributes:r,target:t,get connected(){return o||Promise.reject(new Error("Failed to connect"))}}};i?i():o=new Promise(((n,i)=>{try{const o=e.runtime?.entityManager;let s=!!o?.get().entityGuid,c=o?.getEntityGuidFor(t.licenseKey,t.applicationID),u=!!c;if(s&&u)t.entityGuid=c,n(a);else{const d=setTimeout((()=>i(new Error("Failed to connect - Timeout"))),15e3);function l(r){(0,W.A)(r,e)?s||=!0:t.licenseKey===r.licenseKey&&t.applicationID===r.applicationID&&(u=!0,t.entityGuid=r.entityGuid),s&&u&&(clearTimeout(d),e.ee.removeEventListener("entity-added",l),n(a))}e.ee.emit("api-send-rum",[r,t]),e.ee.on("entity-added",l)}}catch(f){i(f)}}));const u=async(t,r,a)=>{if(i)return i();const u=(0,c.t)();(0,s.p)(h.xV,["API/register/".concat(t.name,"/called")],void 0,n.K7.metrics,e.ee);try{await o;const n=e.init.api.duplicate_registered_data;(!0===n||Array.isArray(n)&&n.includes(a.entityGuid))&&t(...r,void 0,u),t(...r,a.entityGuid,u)}catch(e){(0,l.R)(50,e)}};return a}(e,t)}),e)}function q extends E{static featureName=C.T;constructor(e){var t;super(e,C.T),t=e,p(u.o5,((e,r)=>F(e,r,t)),t),function(e){p(u.bt,(function(t){e.runtime.onerror=t}),e)}(e),function(e){let t=0;p(u.k6,(function(e,r){++t>10||(this.runtime.releaseIds[e.slice(-200)]=(""+r).slice(-200))}),e)}(e),Z(e);try{this.removeOnAbort=new AbortController}catch(e){}this.ee.on("internal-error",((t,r)=>{this.abortHandler&&(0,s.p)("ierr",[H(t),(0,c.t)(),!0,{},e.runtime.isRecording,r],void 0,this.featureName,this.ee)})),y.gm.addEventListener("unhandledrejection",(t=>{this.abortHandler&&(0,s.p)("err",[D(t),(0,c.t)(),!1,{unhandledPromiseRejection:1},e.runtime.isRecording],void 0,this.featureName,this.ee)}),(0,I.jT)(!1,this.removeOnAbort?.signal)),y.gm.addEventListener("error",(t=>{this.abortHandler&&(0,s.p)("err",[K(t),(0,c.t)(),!1,{},e.runtime.isRecording],void 0,this.featureName,this.ee)}),(0,I.jT)(!1,this.removeOnAbort?.signal)),this.abortHandler=this.#r,this.importAggregator(e,(()=>i.e(478).then(i.bind(i,2176))))}#r(){this.removeOnAbort?.abort(),this.abortHandler=void 0}} ``` -------------------------------- ### Initialize New Relic Agent and Core Functionality (JavaScript) Source: https://studio.code.org/docs/ide/javalab/index Initializes the New Relic agent and essential functionalities. It sets up global objects like NREUM and newrelic, configures core timings (setTimeout, setInterval), and registers essential modules like XMLHttpRequest and fetch. This is a foundational step for performance monitoring. ```javascript r.d(t,{NT:()=>a,US:()=>d,Zm:()=>s,bQ:()=>u,dV:()=>c,pV:()=>l});var n=r(6154),i=r(1863),o=r(1910);const a={beacon:"bam.nr-data.net",errorBeacon:"bam.nr-data.net"};function s(){return n.gm.NREUM||(n.gm.NREUM={}),void 0===n.gm.newrelic&&(n.gm.newrelic=n.gm.NREUM),n.gm.NREUM}function c(){let e=s();return e.o||(e.o={ST:n.gm.setTimeout,SI:n.gm.setImmediate||n.gm.setInterval,CT:n.gm.clearTimeout,XHR:n.gm.XMLHttpRequest,REQ:n.gm.Request,EV:n.gm.Event,PR:n.gm.Promise,MO:n.gm.MutationObserver,FETCH:n.gm.fetch,WS:n.gm.WebSocket},(0,o.i)(...Object.values(e.o))),e}function u(e,t){let r=s();r.initializedAgents??={},t.initializedAt={ms:(0,i.t)(),date:new Date},r.initializedAgents[e]=t}function d(e,t){s()[e]=t}function l(){return function(){let e=s();const t=e.info||{};e.info={beacon:a.beacon,errorBeacon:a.errorBeacon,...t}}(),function(){let e=s();const t=e.init||{};e.init={...t}}(),c(),function(){let e=s();const t=e.loader_config||{};e.loader_config={...t}}(),s()}} ``` -------------------------------- ### Java Main Method Syntax Source: https://studio.code.org/docs/ide/javalab/index Shows the standard structure of the main method, which serves as the entry point for Java applications. This is where program execution begins. ```Java public static void main(String[] args) ``` -------------------------------- ### Get Image Height (Java) Source: https://studio.code.org/docs/ide/javalab/classes/Image Returns the height of the Image in pixels. This is a read-only property of the Image object. ```Java Image myImage = new Image("sample.jpg"); int myImageHeight = myImage.getHeight(); ``` -------------------------------- ### Initialize and Display Painter Paint (Java) Source: https://studio.code.org/docs/ide/javalab/classes/Painter This snippet demonstrates how to create a Painter object, retrieve its initial paint amount, and print it to the console. It assumes the Painter class has a constructor and a getMyPaint() method. The output is the initial paint amount. ```java Painter myPainter = new Painter(0); int paintAmount = myPainter.getMyPaint(); System.out.println("Painter has " + paintAmount + " units of paint."); ``` -------------------------------- ### Get Image Width (Java) Source: https://studio.code.org/docs/ide/javalab/classes/Image Returns the width of the Image in pixels. This is a read-only property of the Image object. ```Java Image myImage = new Image("sample.jpg"); int myImageWidth = myImage.getWidth(); ``` -------------------------------- ### Initialize and Configure Agent with Sentry Source: https://studio.code.org/docs/ide/javalab/index This JavaScript function `S` is responsible for initializing and configuring an agent, likely for performance monitoring or error tracking. It sets up various properties, merges configurations, and registers the agent identifier. It handles features like proxy assets, beacon URLs, and soft navigations. ```javascript function S(e,t={},r,a){let{init:s,info:c,loader_config:u,runtime:d={},exposed:l=!0}=t;if(!c){const e=(0,n.pV)();s=e.init,c=e.info,u=e.loader_config}e.init=f(s||{}),e.loader_config=E(u||{}),c.jsAttributes??={},h.bv&&(c.jsAttributes.isWorker=!0),e.info=(0,o.D)(c);const p=e.init,g=[c.beacon,c.errorBeacon];A.has(e.agentIdentifier)||(p.proxy.assets&&(w(p.proxy.assets),g.push(p.proxy.assets)),p.proxy.beacon&&g.push(p.proxy.beacon),function(e){const t=(0,n.pV)();Object.getOwnPropertyNames(i.W.prototype).forEach((r=>{const n=i.W.prototype[r];if("function"!=typeof n||"constructor"===n)return;let o=t[r];e[r]&&!1!==e.exposed&&"micro-agent"!==e.runtime?.loaderType&&(t[r]=(...t)=>{const n=e[r](...t);return o?o(...t):n})}))}(e),(0,n.US)("activatedFeatures",y.B),e.runSoftNavOverSpa&&=!0===p.soft_navigations.enabled&&p.feature_flags.includes("soft_nav")),d.denyList=[...p.ajax.deny_list||[],...p.ajax.block_internal?g:[]],d.ptid=e.agentIdentifier,d.loaderType=r,e.runtime=b(d),A.has(e.agentIdentifier)||(e.ee=R.ee.get(e.agentIdentifier),e.exposed=l,(0,x.W)({agentIdentifier:e.agentIdentifier,drained:!!y.B?.[e.agentIdentifier],type:"lifecycle",name:"initialize",feature:void 0,data:e.config})),A.add(e.agentIdentifier)} ``` -------------------------------- ### Get Painter's current Y coordinate Source: https://studio.code.org/docs/ide/javalab/classes/Painter Retrieves the current vertical (y) coordinate of the Painter object on the canvas. This is a read-only property. ```java int currentYLocation= myPainter.getY(); System.out.println("Painter is at y location " + currentYLocation); ``` -------------------------------- ### Module Initialization and Webpack Configuration Source: https://studio.code.org/docs/ide/javalab/index This JavaScript code demonstrates a typical Webpack module initialization pattern. It defines functions for loading modules (`i`), defining exports (`i.d`), and handling module loading errors (`i.l`). It also includes configurations for script loading and integrity checks, common in front-end build processes. ```javascript n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={exports:{}};return r[e](o,o.exports,i),o.exports}i.m=r,i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((t,r)=>(i.f[r](e,t),t)),[])),i.u=e=>({212:"nr-spa-compressor",249:"nr-spa-recorder",478:"nr-spa"}[e]+"-1.297.1.min.js"),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="NRBA-1.297.1.PROD:",i.l=(r,n,o,a)=>{if(e[r])e[r].push(n);else{var s,c;if(void 0!==o)for(var u=document.getElementsByTagName("script"),d=0;d{s.onerror=s.onload=null,clearTimeout(p);var i=e[r];if(delete e[r],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach((e=>e(n))),t)return t(n)},p=setTimeout(h.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=h.bind(null,s.onerror),s.onload=h.bind(null,s.onload),c&&document.head.appendChild(s)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.p="https://js-agent.newrelic.com/",(()=>{var e={38:0,788:0};i.f.j=(t,r)=>{var n=i.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var o=new Promise(((r,i)=>n=e[t]=[r,i]));r.push(n[2]=o);var a=i.p+i.u(t),s=new Error;i.l(a,(r=>{if(i.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var o=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+o+": "+a+")",s.name="ChunkLoadError",s.type=o,s.request=a,n[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var n,o,[a,s,c]=r,u=0;if(a.some((t=>0!==e[t]))){for(n in s)i.o(s,n)&&(i.m[n]=s[n]);if(c)c(i)}for(t&&t(r);uV(e,r,t)),t), function(e){ p(u.Wb,((t,r,{customAttributes:n={},level:i=B.p_.INFO}={})=>{ wt(e.ee,t,r,{customAttributes:n,level:i}) }),e) }(e), Z(e); const r=this.ee; ["log","error","warn","info","debug","trace"].forEach((e=>{ (0,Rt.i)(y.gm.console[e]), wt(r,y.gm.console,e,{level:"log"===e?"info":e}) })), this.ee.on("wrap-logger-end",(function([e]){ const{level:t,customAttributes:n}=this; (0,G.R)(r,e,n,t) })), this.importAggregator(e,(()=>i.e(478).then(i.bind(i,5288)))) } } ``` -------------------------------- ### Get Element from Java ArrayList Source: https://studio.code.org/docs/ide/javalab/classes/ArrayList Shows how to retrieve an element from an ArrayList at a specific index. The method returns the element at the given position. ```java ArrayList test = new ArrayList(4); test.add(1); test.add(2); test.add(3); test.add(4); int element = test.get(2); System.out.println("The element at index 2 is " + element); ``` -------------------------------- ### Get Pixel Color in Java Source: https://studio.code.org/docs/ide/javalab/classes/pixel Retrieves the Color object associated with a Pixel. This allows you to inspect the current color of a pixel. ```Java Pixel currentPixel = imagePixels[10][20]; Color pixelColor = currentPixel.getColor(); ``` -------------------------------- ### Initialize a Scene Object in Java Source: https://studio.code.org/docs/ide/javalab/classes/Scene Demonstrates how to create a new Scene object, which is the foundation for building animations and scenes in the Java Lab environment. This object will contain animation steps, drawings, text, and sounds. ```java Scene myScene = new Scene(); ``` -------------------------------- ### Observe Performance Entries (JavaScript) Source: https://studio.code.org/docs/ide/javalab/index This code sets up a PerformanceObserver to capture various performance metrics from the browser. It specifically looks for resource timing information and sends these entries to a collector for analysis. ```javascript class De extends E { static featureName = Ce; constructor(e) { var t; super(e, Ce), (t = e), p(u.U2, (() => { if (!(e && "object" == typeof e && e.name && e.start)) return; const r = { n: e.name, s: e.start - y.WN, e: (e.end || e.start) - y.WN, o: e.origin || "", t: "api", }; r.s < 0 || r.e < 0 || r.e < r.s ? (0, l.R)(61, { start: r.s, end: r.e }) : (0, s.p)("bstApi", [r], void 0, n.K7.sessionTrace, t), r; }), t), Oe(e); if (!(0, R.V)(e.init)) return void this.deregisterDrain(); const r = this.ee; let o; _e(r), (this.eventsEE = (0, ee.u)(r)), this.eventsEE.on(Me, (() => { this.bstStart = (0, c.t)(); })), this.eventsEE.on(Le, (() => { (0, s.p)("bst", [e[0], t, this.bstStart, (0, c.t)()], void 0, n.K7.sessionTrace, r); })), r.on(He + je, (() => { this.time = (0, c.t)(); this.startPath = location.pathname + location.hash; })), r.on(He + ke, (() => { (0, s.p)("bstHist", [location.pathname + location.hash, this.startPath, this.time], void 0, n.K7.sessionTrace, r); })); try { o = new PerformanceObserver(e => { const t = e.getEntries(); (0, s.p)(Ie, [t], void 0, n.K7.sessionTrace, r); }); o.observe({ type: Pe, buffered: !0 }); } catch (e) {} this.importAggregator(e, (() => i.e(478).then(i.bind(i, 6974))), { resourceObserver: o, }); } } ``` -------------------------------- ### Get Painter's current X coordinate Source: https://studio.code.org/docs/ide/javalab/classes/Painter Retrieves the current horizontal (x) coordinate of the Painter object on the canvas. This is a read-only property. ```java int currentXLocation= myPainter.getX(); System.out.println("Painter is at x location" + currentXLocation); ``` -------------------------------- ### Get Pixel Y Coordinate in Java Source: https://studio.code.org/docs/ide/javalab/classes/pixel Retrieves the y-coordinate of a Pixel object within an image. This method helps in determining the vertical position of a pixel. ```Java Pixel currentPixel = imagePixels[10][20]; int yLocation = currentPixel.getY(); System.out.println("This pixel is located at y position " + yLocation); ``` -------------------------------- ### Soft Navigation and Interaction Tracking (New Relic) Source: https://studio.code.org/docs/ide/javalab/index This snippet defines constants and event types for tracking soft navigations and user interactions within the New Relic monitoring system. It includes event types like 'click', 'keydown', 'submit', and states for API calls and navigations. Requires the New Relic SDK. ```javascript r.d(t,{AM:()=>o,O2:()=>c,Qu:()=>u,TZ:()=>s,ih:()=>d,pP:()=>a,tC:()=>i});var n=r(860);const i=["click","keydown","submit","popstate"],o="api",a="initialPageLoad",s=n.K7.softNav,c={INITIAL_PAGE_LOAD:"",ROUTE_CHANGE:1,UNSPECIFIED:2},u={INTERACTION:1,AJAX:2,CUSTOM_END:3,CUSTOM_TRACER:4},d={IP:"in progress",FIN:"finished",CAN:"cancelled"} ``` -------------------------------- ### Get Pixel at Coordinates (Java) Source: https://studio.code.org/docs/ide/javalab/classes/Image Retrieves the Pixel object at a specific x and y coordinate within the Image. This allows for inspection or modification of individual pixels. ```Java Image myImage = new Image("sample.jpg"); Pixel singlePixel = myImage.getPixel(10, 20); ``` -------------------------------- ### Session Replay Configuration (New Relic) Source: https://studio.code.org/docs/ide/javalab/index This snippet defines constants and configurations for Session Replay functionality within New Relic. It includes actions like recording, pausing, error handling, and various snapshot types (Full, Incremental). Dependencies include New Relic SDK modules. ```javascript r.d(t,{BB:()=>d,G4:()=>o,Qb:()=>l,TZ:()=>i,Ug:()=>a,_s:()=>s,bc:()=>u,yP:()=>c});var n=r(2614);const i=r(860).K7.sessionReplay,o={RECORD:"recordReplay",PAUSE:"pauseReplay",ERROR_DURING_REPLAY:"errorDuringReplay"},a=.12,s={DomContentLoaded:0,Load:1,FullSnapshot:2,IncrementalSnapshot:3,Meta:4,Custom:5},c={[n.g.ERROR]:15e3,[n.g.FULL]:3e5,[n.g.OFF]:0},u={RESET:{message:"Session was reset",sm:"Reset"},IMPORT:{message:"Recorder failed to import",sm:"Import"},TOO_MANY:{message:"429: Too Many Requests",sm:"Too-Many"},TOO_BIG:{message:"Payload was too large",sm:"Too-Big"},CROSS_TAB:{message:"Session Entity was set to OFF on another tab",sm:"Cross-Tab"},ENTITLEMENTS:{message:"Session Replay is not allowed and will not be started",sm:"Entitlement"}},d=5e3,l={API:"api",RESUME:"resume",SWITCH_TO_FULL:"switchToFull",INITIALIZE:"initialize",PRELOAD:"preload"}} ``` -------------------------------- ### Performance Timing Utility (JavaScript) Source: https://studio.code.org/docs/ide/javalab/index Provides a utility function to get the current high-resolution timestamp using `performance.now()`. This is crucial for accurate performance measurements and timing events within the application. ```javascript function n(){return Math.floor(performance.now())}r.d(t,{t:()=>n}) ``` -------------------------------- ### Single Page Application (SPA) Monitoring (New Relic) Source: https://studio.code.org/docs/ide/javalab/index This snippet defines constants and event names for monitoring Single Page Applications (SPAs) using New Relic. It includes events related to navigation, interactions, API calls, and timing metrics. Dependencies include New Relic SDK modules. ```javascript r.d(t,{$p:()=>x,BR:()=>b,Kp:()=>R,L3:()=>y,Lc:()=>c,NC:()=>o,SG:()=>d,TZ:()=>i,U6:()=>p,UT:()=>m,d3:()=>w,dT:()=>f,e5:()=>E,gx:()=>v,l9:()=>l,oW:()=>h,op:()=>g,rw:()=>u,tH:()=>A,uP:()=>s,wW:()=>T,xq:()=>a});var n=r(384);const i=r(860).K7.spa,o=["click","submit","keypress","keydown","keyup","change"],a=999,s="fn-start",c="fn-end",u="cb-start",d="api-ixn-",l="remaining",f="interaction",h="spaNode",p="jsonpNode",g="fetch-start",m="fetch-done",v="fetch-body-",b="jsonp-end",y=(0,n.dV)().o.ST,w="-start",R="-end",x="-body",T="cb"+R,E="jsTime",A="fetch" ``` -------------------------------- ### Get Painter's current direction Source: https://studio.code.org/docs/ide/javalab/classes/Painter Retrieves the current direction the Painter object is facing, returned as a String (e.g., 'North', 'South', 'East', 'West'). ```java String currentDirection = myPainter.getDirection(); System.out.println("Painter is facing " + currentDirection); ``` -------------------------------- ### Java Inheritance Syntax Source: https://studio.code.org/docs/ide/javalab/classes/Inheritance Demonstrates the basic syntax for implementing inheritance in Java. It shows how to declare a subclass that extends a superclass using the 'extends' keyword. ```java public class Subclass extends Superclass { // body of class here (instance variables, constructors, and methods) } ``` -------------------------------- ### Get Pixel X Coordinate in Java Source: https://studio.code.org/docs/ide/javalab/classes/pixel Retrieves the x-coordinate of a Pixel object within an image. This method is useful for understanding the horizontal position of a pixel. ```Java Pixel currentPixel = imagePixels[10][20]; int xLocation = currentPixel.getX(); System.out.println("This pixel is located at x position " + xLocation); ``` -------------------------------- ### Draw Ellipse on Canvas Source: https://studio.code.org/docs/ide/javalab/classes/Scene Provides an example of drawing an ellipse (or circle) on the canvas using its center coordinates, width, and height. The drawEllipse method is used for this operation. ```java Scene myScene = new Scene(); myScene.drawEllipse(100, 50, 200, 100); Theater.playScenes(myScene); ```