<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with #java - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23java</link>
      <pubDate>Sun, 08 Aug 2021 19:39:02 +0000</pubDate>
         <description>Tagged with #java - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23java/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Transitioning from Processing to Java</title>
      <link>https://forum.processing.org/two/discussion/25900/transitioning-from-processing-to-java</link>
      <pubDate>Wed, 10 Jan 2018 17:41:01 +0000</pubDate>
      <dc:creator>EdwinCarlsson</dc:creator>
      <guid isPermaLink="false">25900@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone!</p>

<p>I have for about a year now(I think??) been programming in Processing to understand the basics of coding, the mindset of programming and the underlaying syntax etc.</p>

<p>However, my education, industrial engineering, requires me to transition from Processing to Java and C++. I have never written a word in pure Java. We are to use Eclipse, but I presume that any IDE works.</p>

<p>My question is this: how do I, in the most efficient way, understand the new syntax and the new concepts? I reckon that "just write a lot of code" won't do, seeing as how I am to write a final in basic Java programming in 2 months.</p>

<p>Thank you!</p>
]]></description>
   </item>
   <item>
      <title>Importing libraries in .java tabs</title>
      <link>https://forum.processing.org/two/discussion/16203/importing-libraries-in-java-tabs</link>
      <pubDate>Sat, 23 Apr 2016 13:19:33 +0000</pubDate>
      <dc:creator>[Deleted User]</dc:creator>
      <guid isPermaLink="false">16203@/two/discussions</guid>
      <description><![CDATA[<div class="Deleted">The user and all related content has been deleted.</div>]]></description>
   </item>
   <item>
      <title>How and when does processing delete objects</title>
      <link>https://forum.processing.org/two/discussion/11398/how-and-when-does-processing-delete-objects</link>
      <pubDate>Mon, 22 Jun 2015 08:27:53 +0000</pubDate>
      <dc:creator>nikolaj</dc:creator>
      <guid isPermaLink="false">11398@/two/discussions</guid>
      <description><![CDATA[<p>In processing the word <code>new</code> initializes a new instance of an object, for instance</p>

<pre><code>Cat myCat = new Cat()
</code></pre>

<p>Means make a new object, from the class Cat, which can be accesed by the name myCat.</p>

<p>Making a new object of the class Cat, means allocating memory to store all the variables in the class Cat, the location of this data, (its adress) is then stored at the variable myCat. At some point, the object cat, won't be used anymore (at the latest when the program is terminated), then the allocated memory must be freed, but you can't write in the code when, and how you want to do that.</p>

<p>In the programming language C++ ,  you will have to  use the keyword <code>delete</code> (or <code>delete[]</code>) to delete each of the objects you initialized using <code>new</code>.  In C++ you also get to make a destructer-function when you make a class.</p>

<p>In processing you can't delete objects manually, so i asume, it happens automatically, but i would like to know how it works. And what about objects stored in other objects, or if more objects of the same or different class, are storring the same other object in them?</p>

<p>and are there a way to manually delete objects?</p>
]]></description>
   </item>
   <item>
      <title>Program fails to terminate on Linux</title>
      <link>https://forum.processing.org/two/discussion/10688/program-fails-to-terminate-on-linux</link>
      <pubDate>Thu, 07 May 2015 13:46:22 +0000</pubDate>
      <dc:creator>mtimur</dc:creator>
      <guid isPermaLink="false">10688@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,</p>

<p>I'm using Processing libraries in Eclipse for an optimization process. I export my code as a runnable jar and that's how I'm using it. But whenever my code works on Linux I get the following message at the end of each run:</p>

<p>X11Util.Display: Shutdown (JVM shutdown: true, open (no close attempt): 1/1, reusable (open, marked uncloseable): 0, pending (open in creation order): 1)
X11Util: Open X11 Display Connections: 1
X11Util: Open[0]: NamedX11Display[:0, 0x7fc62956bfd0, refCount 1, unCloseable false]</p>

<p>even though I'm just using exit() to terminate my code rather than System.exit(int). When I run my code just one time I get this error but the process is terminated in the end. However for the optimization I need to run this piece of code hundreds of times, and when I do that optimization process gets stuck at some point and I can only keep it going by killing the java processes with:</p>

<p>$ pkill -f 'java -jar'</p>

<p>I assume this command kills the processes that couldn't be terminated. Can anyone understand why I'm getting the message I stated above and why the processes are not being terminated?</p>
]]></description>
   </item>
   <item>
      <title>How to download images from computer LAN?</title>
      <link>https://forum.processing.org/two/discussion/10333/how-to-download-images-from-computer-lan</link>
      <pubDate>Wed, 15 Apr 2015 13:01:21 +0000</pubDate>
      <dc:creator>anthony20</dc:creator>
      <guid isPermaLink="false">10333@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I am trying to download an image from my computer on my local network to smartphone.
I managed to send text messages from pc to mobile using processing.net. How I can "download" images?
Should I use sockets or is there a simpler way to access the contents of the pc?</p>

<p>thanks in advance</p>
]]></description>
   </item>
   <item>
      <title>Export to java applet</title>
      <link>https://forum.processing.org/two/discussion/10162/export-to-java-applet</link>
      <pubDate>Fri, 03 Apr 2015 09:56:47 +0000</pubDate>
      <dc:creator>limbogabi</dc:creator>
      <guid isPermaLink="false">10162@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,
how do i export to java applet in processing 2.2.1?
it seems you only have the export application option?</p>
]]></description>
   </item>
   <item>
      <title>Java and Processing</title>
      <link>https://forum.processing.org/two/discussion/9394/java-and-processing</link>
      <pubDate>Thu, 12 Feb 2015 13:28:06 +0000</pubDate>
      <dc:creator>strinda</dc:creator>
      <guid isPermaLink="false">9394@/two/discussions</guid>
      <description><![CDATA[<p>I grew very interested in learning Java. I got a book, and started reading it. And now I have a number of questions:</p>

<ul>
<li>I got through a number of chapters and now I am looking for the visual library. But...wait... Processing is a visual library for Java, right? 
Does it mean I can install Java and use processing functions on it?</li>
<li>Are there other "truly" graphical libraries? (I found libGDX - but I couldn't understand whether it was the same as Processing, or not?)</li>
</ul>

<p>Kind regards,
Alex</p>
]]></description>
   </item>
   <item>
      <title>Does Processing Understand Java Code?</title>
      <link>https://forum.processing.org/two/discussion/9177/does-processing-understand-java-code</link>
      <pubDate>Mon, 26 Jan 2015 08:15:43 +0000</pubDate>
      <dc:creator>Jabberwocky</dc:creator>
      <guid isPermaLink="false">9177@/two/discussions</guid>
      <description><![CDATA[<p>So, I am wanting to build an application with interactive graphics, but I am wanting to do stuff that requires creating a score and saving that score. Basically, I am probably going to need to write some plain Java code. So, I am wondering, anything I can write in Java, can I also write in Processing? After all, Processing is Java in the end right?</p>
]]></description>
   </item>
   <item>
      <title>Processing.net: High timeout, when the client socket tries to connect and the server does not exist</title>
      <link>https://forum.processing.org/two/discussion/9202/processing-net-high-timeout-when-the-client-socket-tries-to-connect-and-the-server-does-not-exist</link>
      <pubDate>Tue, 27 Jan 2015 14:56:00 +0000</pubDate>
      <dc:creator>anthony20</dc:creator>
      <guid isPermaLink="false">9202@/two/discussions</guid>
      <description><![CDATA[<p>Hello</p>

<p>I am making an android app.</p>

<p>the processing.net library works great while the server is working.</p>

<p>However, when I try to turn on the Android app (client) and the server is idle, the app crashes for over a minute.
Using processing.net in windows, something similar happens, but the waiting time is reduced to about 15-20 seconds.</p>

<p>The main problem is that while java creates the connection, the app is frozen. and a high wait time is an important issue if the server goes down.</p>

<p>How can solved this, is there any way to jump code, if no socket is created in x seconds?</p>

<p>A greeting and thanks in advance,</p>

<p>Emperador_Tico</p>
]]></description>
   </item>
   <item>
      <title>Image mask from Java to Javascript</title>
      <link>https://forum.processing.org/two/discussion/8719/image-mask-from-java-to-javascript</link>
      <pubDate>Thu, 18 Dec 2014 12:58:49 +0000</pubDate>
      <dc:creator>mandrale</dc:creator>
      <guid isPermaLink="false">8719@/two/discussions</guid>
      <description><![CDATA[<p>Hi!!,</p>

<p>I've written a code that works fine in processing Java mode but doesn't in Javascript.</p>

<p><strong>The idea</strong>
Having a gray plain image shown at the beginning, then swiping with the finger (using a touchscreen) or clicking and moving with the mouse unveils portions of images (randomly from a set). The effect is like painting with different random images.</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/564/YOI0EBC0NW7Q.png" alt="Schermata 2014-12-18 alle 18.40.39" title="Schermata 2014-12-18 alle 18.40.39" />
<img src="http://forum.processing.org/two/uploads/imageupload/204/35Z0BZL4BR7C.png" alt="Schermata 2014-12-18 alle 18.40.52" title="Schermata 2014-12-18 alle 18.40.52" />
<img src="http://forum.processing.org/two/uploads/imageupload/324/UWH3QWPUQGPU.png" alt="Schermata 2014-12-18 alle 18.41.04" title="Schermata 2014-12-18 alle 18.41.04" /></p>

<p><strong>What happens</strong>
The images are correctly and randomly shown when clicking the mouse in javascript version but the "painting effect doesn't works".</p>

<p>I've looked at the guide and found these common possible causes but couldn't figure out how to solve.</p>

<p>no data directory, should provide a file page (but images are shown correctly??)
some functions are just not supported
rendering mode,  (JAVA2D should become something else??)</p>

<p>Can you help me please?</p>

<pre><code>// Example 0-4: unvealing random images

int maxImages = 4; // Total # of images
int imageIndex = 0; // Initial image to be displayed is the first

// Declaring an array of images.
PImage[] images = new PImage[4]; 

void setup() {
  size(500,500);

  // Loading the images into the array

  for (int i = 0; i &lt; images.length; i ++ ) {
    images[i] = loadImage( i + ".jpg" ); 
  }
}

void draw() {



   if (mousePressed == true) {

  PGraphics maskImage;
  maskImage = createGraphics(images[imageIndex].width,images[imageIndex].height, JAVA2D);
  maskImage.beginDraw();
  maskImage.fill(100);
  maskImage.noStroke();
  maskImage.ellipse(mouseX, mouseY, 100, 100);
  maskImage.endDraw();

  PImage imgCopy = images[imageIndex]; // if the mask changes every frame, we need to use a copy of it, keeping the original intact
  imgCopy.mask(maskImage);// apply the mask to  image
  image(imgCopy, 0, 0);
  }


}

void mousePressed() {
  // A new image is picked randomly when the mouse is clicked

  imageIndex = int(random(images.length));
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Please Help , Phone can found but  couldn't connect to Bluetooth (HC-05)</title>
      <link>https://forum.processing.org/two/discussion/4106/please-help-phone-can-found-but-couldn-t-connect-to-bluetooth-hc-05</link>
      <pubDate>Wed, 02 Apr 2014 21:34:43 +0000</pubDate>
      <dc:creator>burak</dc:creator>
      <guid isPermaLink="false">4106@/two/discussions</guid>
      <description><![CDATA[<p>Hello , i upload the sketch into my android phone (galaxy s4 ) . the phone can find device , (says Discovered HC-05).But Couldnt connect to it . (not just HC-05 also to my Pc so i mean any bluetooth device) . the sketch</p>

<pre>
/* SendReceiveBytes: Written by ScottC on 25 March 2013 using 
 Processing version 2.0b8
 Tested on a Samsung Galaxy SII, with Android version 2.3.4
 Android ADK - API 10 SDK platform **/

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.widget.Toast;
import android.view.Gravity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;

import java.util.UUID;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
public BluetoothSocket scSocket;


boolean foundDevice=false; //When true, the screen turns green.
boolean BTisConnected=false; //When true, the screen turns purple.
String serverName = "ArduinoBasicsServer";

// Message types used by the Handler
public static final int MESSAGE_WRITE = 1;
public static final int MESSAGE_READ = 2;
String readMessage="";

//Get the default Bluetooth adapter
BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();

/*The startActivityForResult() within setup() launches an 
 Activity which is used to request the user to turn Bluetooth on. 
 The following onActivityResult() method is called when this 
 Activity exits. */
<a href="/two/profile/Override">@Override</a>
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode==0) {
    if (resultCode == RESULT_OK) {
      ToastMaster("Bluetooth has been switched ON");
    } 
    else {
      ToastMaster("You need to turn Bluetooth ON !!!");
    }
  }
}


/* Create a BroadcastReceiver that will later be used to 
 receive the names of Bluetooth devices in range. */
BroadcastReceiver myDiscoverer = new myOwnBroadcastReceiver();


/* Create a BroadcastReceiver that will later be used to
 identify if the Bluetooth device is connected */
BroadcastReceiver checkIsConnected = new myOwnBroadcastReceiver();


// The Handler that gets information back from the Socket
private final Handler mHandler = new Handler() {
  <a href="/two/profile/Override">@Override</a>
    public void handleMessage(Message msg) {
    switch (msg.what) {
    case MESSAGE_WRITE:
      //Do something when writing
      break;
    case MESSAGE_READ:
      //Get the bytes from the msg.obj
      byte[] readBuf = (byte[]) msg.obj;
      // construct a string from the valid bytes in the buffer
      readMessage = new String(readBuf, 0, msg.arg1);
      break;
    }
  }
};


void setup() {
  orientation(LANDSCAPE);
  /*IF Bluetooth is NOT enabled, then ask user permission to enable it */
  if (!bluetooth.isEnabled()) {
    Intent requestBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
    startActivityForResult(requestBluetooth, 0);
  }


  /*If Bluetooth is now enabled, then register a broadcastReceiver to report any
   discovered Bluetooth devices, and then start discovering */
  if (bluetooth.isEnabled()) {
    registerReceiver(myDiscoverer, new IntentFilter(BluetoothDevice.ACTION_FOUND));
    registerReceiver(checkIsConnected, new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED));

    //Start bluetooth discovery if it is not doing so already
    if (!bluetooth.isDiscovering()) {
      bluetooth.startDiscovery();
    }
  }
}


void draw() {
  //Display a green screen if a device has been found,
  //Display a purple screen when a connection is made to the device
  if (foundDevice) {
    if (BTisConnected) {
      background(170, 50, 255); // purple screen
    }
    else {
      background(10, 255, 10); // green screen
    }
  }

  //Display anything received from Arduino
  text(readMessage, 10, 10);
}


/* This BroadcastReceiver will display discovered Bluetooth devices */
public class myOwnBroadcastReceiver extends BroadcastReceiver {
  ConnectToBluetooth connectBT;

  <a href="/two/profile/Override">@Override</a>
    public void onReceive(Context context, Intent intent) {
    String action=intent.getAction();
    ToastMaster("ACTION:" + action);

    //Notification that BluetoothDevice is FOUND
    if (BluetoothDevice.ACTION_FOUND.equals(action)) {
      //Display the name of the discovered device
      String discoveredDeviceName = intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
      ToastMaster("Discovered: " + discoveredDeviceName);

      //Display more information about the discovered device
      BluetoothDevice discoveredDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
      ToastMaster("getAddress() = " + discoveredDevice.getAddress());
      ToastMaster("getName() = " + discoveredDevice.getName());

      int bondyState=discoveredDevice.getBondState();
      ToastMaster("getBondState() = " + bondyState);

      String mybondState;
      switch(bondyState) {
      case 10: 
        mybondState="BOND_NONE";
        break;
      case 11: 
        mybondState="BOND_BONDING";
        break;
      case 12: 
        mybondState="BOND_BONDED";
        break;
      default: 
        mybondState="INVALID BOND STATE";
        break;
      }
      ToastMaster("getBondState() = " + mybondState);

      //Change foundDevice to true which will make the screen turn green
      foundDevice=true;

      //Connect to the discovered bluetooth device (SeeedBTSlave)
      if (discoveredDeviceName.equals("SeeedBTSlave")) {
        ToastMaster("Connecting you Now !!");
        unregisterReceiver(myDiscoverer);
        connectBT = new ConnectToBluetooth(discoveredDevice);
        //Connect to the the device in a new thread
        new Thread(connectBT).start();
      }
    }

    //Notification if bluetooth device is connected
    if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) {
      ToastMaster("CONNECTED _ YAY");

      while (scSocket==null) {
        //do nothing
      }
      ToastMaster("scSocket" + scSocket);
      BTisConnected=true; //turn screen purple 
      if (scSocket!=null) {
        SendReceiveBytes sendReceiveBT = new SendReceiveBytes(scSocket);
        new Thread(sendReceiveBT).start();
        String red = "r";
        byte[] myByte = stringToBytesUTFCustom(red);
        sendReceiveBT.write(myByte);
      }
    }
  }
}
public static byte[] stringToBytesUTFCustom(String str) {
  char[] buffer = str.toCharArray();
  byte[] b = new byte[buffer.length &lt;&lt; 1];
  for (int i = 0; i &lt; buffer.length; i++) {
    int bpos = i &lt;&lt; 1;
    b[bpos] = (byte) ((buffer[i]&amp;0xFF00)&gt;&gt;8);
    b[bpos + 1] = (byte) (buffer[i]&amp;0x00FF);
  }
  return b;
}

public class ConnectToBluetooth implements Runnable {
  private BluetoothDevice btShield;
  private BluetoothSocket mySocket = null;
  private UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

  public ConnectToBluetooth(BluetoothDevice bluetoothShield) {
    btShield = bluetoothShield;
    try {
      mySocket = btShield.createRfcommSocketToServiceRecord(uuid);
    }
    catch(IOException createSocketException) {
      //Problem with creating a socket
      Log.e("ConnectToBluetooth", "Error with Socket");
    }
  }

  <a href="/two/profile/Override">@Override</a>
    public void run() {
    /* Cancel discovery on Bluetooth Adapter to prevent slow connection */
    bluetooth.cancelDiscovery();

    try {
      /*Connect to the bluetoothShield through the Socket. This will block
       until it succeeds or throws an IOException */
      mySocket.connect();
      scSocket=mySocket;
    } 
    catch (IOException connectException) {
      Log.e("ConnectToBluetooth", "Error with Socket Connection");
      try {
        mySocket.close(); //try to close the socket
      }
      catch(IOException closeException) {
      }
      return;
    }
  }

  /* Will cancel an in-progress connection, and close the socket */
  public void cancel() {
    try {
      mySocket.close();
    } 
    catch (IOException e) {
    }
  }
}


private class SendReceiveBytes implements Runnable {
  private BluetoothSocket btSocket;
  private InputStream btInputStream = null;
  private OutputStream btOutputStream = null;
  String TAG = "SendReceiveBytes";

  public SendReceiveBytes(BluetoothSocket socket) {
    btSocket = socket;
    try {
      btInputStream = btSocket.getInputStream();
      btOutputStream = btSocket.getOutputStream();
    } 
    catch (IOException streamError) { 
      Log.e(TAG, "Error when getting input or output Stream");
    }
  }


  public void run() {
    byte[] buffer = new byte[1024]; // buffer store for the stream
    int bytes; // bytes returned from read()

    // Keep listening to the InputStream until an exception occurs
    while (true) {
      try {
        // Read from the InputStream
        bytes = btInputStream.read(buffer);
        // Send the obtained bytes to the UI activity
        mHandler.obtainMessage(MESSAGE_READ, bytes, -1, buffer)
          .sendToTarget();
      } 
      catch (IOException e) {
        Log.e(TAG, "Error reading from btInputStream");
        break;
      }
    }
  }


  /* Call this from the main activity to send data to the remote device */
  public void write(byte[] bytes) {
    try {
      btOutputStream.write(bytes);
    } 
    catch (IOException e) { 
      Log.e(TAG, "Error when writing to btOutputStream");
    }
  }


  /* Call this from the main activity to shutdown the connection */
  public void cancel() {
    try {
      btSocket.close();
    } 
    catch (IOException e) { 
      Log.e(TAG, "Error when closing the btSocket");
    }
  }
}



/* My ToastMaster function to display a messageBox on the screen */
void ToastMaster(String textToDisplay) {
  Toast myMessage = Toast.makeText(getApplicationContext(), 
  textToDisplay, 
  Toast.LENGTH_SHORT);
  myMessage.setGravity(Gravity.CENTER, 0, 0);
  myMessage.show();
}
</pre>

<p>Please i need your help ,</p>
]]></description>
   </item>
   <item>
      <title>Cannot install processing on OS x 10.9...It seems all java-based programming tools do not run.</title>
      <link>https://forum.processing.org/two/discussion/4107/cannot-install-processing-on-os-x-10-9-it-seems-all-java-based-programming-tools-do-not-run</link>
      <pubDate>Wed, 02 Apr 2014 23:34:07 +0000</pubDate>
      <dc:creator>inyoung</dc:creator>
      <guid isPermaLink="false">4107@/two/discussions</guid>
      <description><![CDATA[<p>Hello all,</p>

<p>Anybody knows why processing icon does just shake; and don't show any reaction when being clicked it?
It has been that my laptop cannot run other java-based programming tools such as BlueJ..
I have updated JAVA.</p>

<p>Thanks.</p>
]]></description>
   </item>
   <item>
      <title>Usage class from .java file - is there a full doc for that?</title>
      <link>https://forum.processing.org/two/discussion/3677/usage-class-from-java-file-is-there-a-full-doc-for-that</link>
      <pubDate>Thu, 13 Mar 2014 17:45:20 +0000</pubDate>
      <dc:creator>outslider</dc:creator>
      <guid isPermaLink="false">3677@/two/discussions</guid>
      <description><![CDATA[<p>Ok, I have some problem with use of tab with pure .java file. I know that's possible, but I can't get it to work.</p>

<p>The code:</p>

<p>main tab:</p>

<pre><code>import processing.core.Foo;
Foo bar;

void setup() {
}

void draw() {
}
</code></pre>

<p>tab called Foo.java:</p>

<pre><code>package processing.core;
import java.io.Serializable;
import processing.core.PApplet;

public class Foo implements Serializable {
}
</code></pre>

<p>The error I get:</p>

<pre><code>The package processing.core.Foo does not exist.
</code></pre>

<p>The Foo.java file is in the sketch folder, along with the main file (which is called fjlea.pde, so no conflict here).</p>

<p>I tried to put the Foo.java in the ./code directory, as well as in the "sketchbook"/libraries - also without success.</p>

<p>How to get it to work? Is there any doc that describes the procedure?</p>
]]></description>
   </item>
   <item>
      <title>Translate from Khan Academy (javascript) to Processing. Help!</title>
      <link>https://forum.processing.org/two/discussion/3666/translate-from-khan-academy-javascript-to-processing-help</link>
      <pubDate>Thu, 13 Mar 2014 02:19:47 +0000</pubDate>
      <dc:creator>GalindoDG</dc:creator>
      <guid isPermaLink="false">3666@/two/discussions</guid>
      <description><![CDATA[<p>Hey I was just wondering what I would need to do to translate this code into Processing. I made it with on Khan Academy using their language. It's supposed to be a minefield. It's a random selection of "mines" or rectangles randomly spawning from the top of the screen, falling down the screen then disappearing off the bottom.</p>

<p>I'm not sure what the correct translations are going from their language to processing. I'm fairly new to programming so it's still new to me. I know that var (declaring variables?) should be -&gt; int on processing, but the brackets such as 
"var b=[];" don't translate at all if I put "int b=[];" in processing. Any help would be awesome, thanks.</p>

<h2>Here's what I got. It works at KhanAcademy's website but not on Processing.</h2>

<pre><code>var b=[];
var mineX=random(50,350);
var mineY=random(-400,-800);
var mine=[];
var bsX=2;
var bsY=4;
var mFill=255;
draw= function() {
    fill(0);
    rect(-1,-1,402,402);

    mine.push([random(-2000,4000),0]);
    for(var i in mine){
        noStroke();
        noFill();
        stroke(255, 255, 255);
        fill(mFill, 0, 0);
        rect(mine[i][0],mine[i][1],20,20,5);
        mine[i][1]+=9;

        if(mine[i][1]&gt;400){
            mine.splice(i,1);
        }
    }

    strokeWeight(2);
    stroke(255, 255, 255);
    fill(255, 0, 0);
    rect(mineX-10,mineY-10,20,20,5);
    mineY+=9;
    if(mineY&gt;400){
        mineY=random(-400,-800);
        mineX=random(50,350);
    }
};
</code></pre>
]]></description>
   </item>
   <item>
      <title>In-built Java Library in Processing</title>
      <link>https://forum.processing.org/two/discussion/3303/in-built-java-library-in-processing</link>
      <pubDate>Wed, 26 Feb 2014 01:05:46 +0000</pubDate>
      <dc:creator>merchantandco</dc:creator>
      <guid isPermaLink="false">3303@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone,</p>

<p>I am trying to use Random class in Processing, but it turns out that the in-built Java library is not in my Processing environment. Any ideas about what has happened? Or where I can download it if need be?</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>SurfaceMapper GUI - throwing Too many calls to pushMatrix exception</title>
      <link>https://forum.processing.org/two/discussion/2714/surfacemapper-gui-throwing-too-many-calls-to-pushmatrix-exception</link>
      <pubDate>Wed, 29 Jan 2014 06:53:22 +0000</pubDate>
      <dc:creator>KadijaD</dc:creator>
      <guid isPermaLink="false">2714@/two/discussions</guid>
      <description><![CDATA[<p>Hello all!</p>

<p>I am very new to Processing and coding also! so I appreciate any help on here!</p>

<p>I am sure you have come across ixagon's great project SurfaceMapperGUI. I have downloaded all that is needed and placed my libraries as instructed. however I am getting the below error</p>

<pre lang="text">
java.lang.RuntimeException: Too many calls to pushMatrix().
    at processing.core.PGraphics3D.pushMatrix(Unknown Source)
    at codeanticode.glgraphics.GLGraphics.pushMatrix(Unknown Source)
    at processing.core.PApplet.pushMatrix(Unknown Source)
    at controlP5.ControllerGroup.draw(Unknown Source)
    at controlP5.ControlWindow.draw(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at processing.core.PApplet$RegisteredMethods.handle(Unknown Source)
    at processing.core.PApplet$RegisteredMethods.handle(Unknown Source)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)
</pre>

<p>has anyone encountered sth similar or tell me how I can overcome this! thanks a lot for your time :)</p>
]]></description>
   </item>
   <item>
      <title>Open() Not Working</title>
      <link>https://forum.processing.org/two/discussion/2731/open-not-working</link>
      <pubDate>Wed, 29 Jan 2014 23:15:39 +0000</pubDate>
      <dc:creator>Grad_student</dc:creator>
      <guid isPermaLink="false">2731@/two/discussions</guid>
      <description><![CDATA[<p>Hey Everyone,</p>

<p>So I asked this question concerning how to combine 3 different applications into 1 <a href="http://forum.processing.org/two/discussion/2719/combining-applications-into-1-big-executable#Item_3" target="_blank" rel="nofollow">http://forum.processing.org/two/discussion/2719/combining-applications-into-1-big-executable#Item_3</a></p>

<p>From lurking I have learned the following methods I could go about to do this:</p>

<ol>
<li>use Java and embed my sketches in a Swing interface (rewrite programs into some complicated Java monstrosity) </li>
<li>Rewitre code to launch separate windows using G4P <a href="http://www.lagers.org.uk/g4p/ex-windows/index.html" target="_blank" rel="nofollow">http://www.lagers.org.uk/g4p/ex-windows/index.html</a> (seems better than option 1 but still a pain in the ass because trying to write functions to get the LEAP motion api calls to work in the separate windows wont be easy)</li>
<li>Use Open() at the end of each program to run the next program (quick and dirty, just the way I like it!)</li>
</ol>

<p>Now theoretically I could get more functionality from 1 and 2 (in terms of program flow and better user interface) and would probably learn more and be better off in my future efforts, however time is of the essence at the moment. Each of the programs creates csv data files from user input that I will use to create a visualization so the manner in which I get the programs to run is somewhat irrelevant at this point. Only problem is I cant get open() to work correctly. See below:</p>

<pre><code>void setup() {
  size(200, 200);
}

void draw() { 
  // draw() must be present for mousePressed() to work
}

void mousePressed() {

 open("C:/Users/corbett2/Documents/Processing/test/application.windows64/test.bat");  //doesn't work
 open(new String[] { "cmd", "/c", "start", "/w",   "C:/Users/corbett2/Documents/Processing/test/application.windows64/test.bat"}); //also doesn't work

}
</code></pre>

<p>I've tried a bunch of different ways to use open() but it wont run the program. I'm using windows 8. I exported the application "test" which created the "test.bat" located in C:/Users/corbett2/Documents/Processing/test/application.windows64. I believe you have to export your sketch before you can try to use open() on it right? As said before, the idea here is to use a call to open() at the close of each of my 3 applications in order to run them.</p>

<p>So my specific questions are as follows:</p>

<ol>
<li>Which of the 3 methods I listed would you recommend I pursue for my issue? If none, please feel free to suggest something else.</li>
<li>Will option 3 using open() work? Why or why not?</li>
<li>Correct my open() issue.</li>
</ol>

<p>Thanks in advance!</p>
]]></description>
   </item>
   <item>
      <title>Processing - javascript keyboard input</title>
      <link>https://forum.processing.org/two/discussion/2368/processing-javascript-keyboard-input</link>
      <pubDate>Sat, 11 Jan 2014 00:44:29 +0000</pubDate>
      <dc:creator>RFranta</dc:creator>
      <guid isPermaLink="false">2368@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I made just simple application in Java mode with keyboard input and it works fine, when I write somethink I see letters on the screen. I didn't import any library, is just really simple. Now I tried to change Java mode to Javascript, but when I am trying this program in web browser it writes just ASCII nunbers. For exammple if I press 'k' I have 107 on the screen. How to solve this.</p>

<p>This is code after void key pressed for keyboard input:</p>

<p>text1+=key;</p>

<p>Another question, is it possible to put Java application from processing Java mode on webpages? Will it work?  Is it hard to make it possible?</p>

<p>RFranta</p>
]]></description>
   </item>
   <item>
      <title>Sort Double Double HashMap Java/Processing</title>
      <link>https://forum.processing.org/two/discussion/2241/sort-double-double-hashmap-java-processing</link>
      <pubDate>Sat, 04 Jan 2014 11:29:32 +0000</pubDate>
      <dc:creator>Grad_student</dc:creator>
      <guid isPermaLink="false">2241@/two/discussions</guid>
      <description><![CDATA[<p>I have this Hashmap of floats and I want to get the top 5 largest values from it:</p>

<pre><code>import java.util.Map;


HashMap&lt;Float,Float&gt; hm = new HashMap&lt;Float,Float&gt;();

// Putting key-value pairs in the HashMap
for (int i = 0; i &lt; 100; i++) {

  float pos = random(-50, 50);
  float time = random(0, 50);
  hm.put(time, pos);

}
// Using an enhanced loop to interate over each entry
for (Map.Entry me : hm.entrySet()) {
  print("key is " + me.getKey());
  println(" value is " + me.getValue());
}
</code></pre>

<p>I assume I would need to sort it first. Question is, how to sort it and will the keys still remain the same after the sort? When I say "same" I mean will the sorted values still have the original key identifier? This is crucial for what I am trying to accomplish.</p>

<p>I posted this question is stackoverflow and someone suggested:</p>

<p>___If it is possible, replace HashMap by an implementation of NavigableMap, such as TreeMap. The iteration order of a HashMap is undefined.</p>

<p>With a NavigableMap you can sort it from higher to lower values by means of;</p>

<hr />

<pre><code>    for (Map.Entry me : tm.descendingMap().entrySet() ()) {
      System.out.print("key is " + me.getKey());
      System.out.println(" value is " + me.getValue());
    }
</code></pre>

<p><em>It is worth noting that descendingMap() does not actually sort the contents of the map (because the TreeMap is already sorted), but just return a reverse view of the original map</em></p>

<p>Not sure if this is possible or if it makes since I am not a java expert (I barely know processing!). I have even less experience with these map data structures.</p>

<p>Please SOS.</p>
]]></description>
   </item>
   <item>
      <title>Error in Java Runtime Environment if I use Plethora libraries</title>
      <link>https://forum.processing.org/two/discussion/2184/error-in-java-runtime-environment-if-i-use-plethora-libraries</link>
      <pubDate>Wed, 18 Dec 2013 05:12:47 +0000</pubDate>
      <dc:creator>Nesolei</dc:creator>
      <guid isPermaLink="false">2184@/two/discussions</guid>
      <description><![CDATA[<p>Yesterday I downloaded Plethora libraries from www.plethora-project.com/Plethora-0.3.0/index.html  for processing 2.1. But now, if i use any examples I have a error. Maybe anybody know, what is this error?</p>

<pre><code> A fatal error has been detected by the Java Runtime Environment:

  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x1893c44d, pid=2908, tid=1604

 JRE version: Java(TM) SE Runtime Environment (7.0_40-b43) (build 1.7.0_40-b43)
 Java VM: Java HotSpot(TM) Client VM (24.0-b56 mixed mode windows-x86 )
 Problematic frame:
 C  [nvoglnt.dll+0x66c44d]

 Failed to write core dump. Minidumps are not enabled by default on client versions of Windows

 An error report file with more information is saved as:
 d:\Processing\processing-2.1\hs_err_pid2908.log

 If you would like to submit a bug report, please visit:
   <a href="http://bugreport.sun.com/bugreport/crash.jsp" target="_blank" rel="nofollow">http://bugreport.sun.com/bugreport/crash.jsp</a>
 The crash happened outside the Java Virtual Machine in native code.
 See problematic frame for where to report the bug.

Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.
</code></pre>
]]></description>
   </item>
   <item>
      <title>Code works fine with Java but not with JavaScript</title>
      <link>https://forum.processing.org/two/discussion/2067/code-works-fine-with-java-but-not-with-javascript</link>
      <pubDate>Fri, 13 Dec 2013 06:59:15 +0000</pubDate>
      <dc:creator>Leupsi</dc:creator>
      <guid isPermaLink="false">2067@/two/discussions</guid>
      <description><![CDATA[<p>Hey mates,<br />
i'm sorry i have to ask again for help for my recent project i'm working on.<br /></p>

<p>The code now works fine in Java, but when i change the mode in Processing to JavaScript or upload the code to Openprocessing, there's something corrupt.<br />
You see three dominoes, everyone should display a certain ammount of ellipses to show the time. My problem is that the stone in the middle never shows anything but it's coded like the third stone. Do you know what line in my code keeps the ellipses on the stone in the middle invisible?<br /></p>

<p>Here's the link to Openprocessing: <a href="http://www.openprocessing.org/sketch/122588" target="_blank" rel="nofollow">http://www.openprocessing.org/sketch/122588</a></p>

<p>Thank's so much in advance! :)</p>
]]></description>
   </item>
   <item>
      <title>Find 5 Largest Values In A Linked List in Processing/Java</title>
      <link>https://forum.processing.org/two/discussion/2036/find-5-largest-values-in-a-linked-list-in-processing-java</link>
      <pubDate>Thu, 12 Dec 2013 04:19:28 +0000</pubDate>
      <dc:creator>Grad_student</dc:creator>
      <guid isPermaLink="false">2036@/two/discussions</guid>
      <description><![CDATA[<p>Hello Community,</p>

<p>So I got this code that is getting x,y positions from a motion sensor tracking a hand. The app draws a circle in the middle of the screen and then I have a function that will detect if the hand is outside of the circle.  While the hand is outside of the circle, I have a function that checks the distance of the hand from the center of the circle. I'm attempting to store the distance data while the hand is outside of the circle into a linked list.</p>

<p><strong>I need to get the top 5 largest values for each time the hand is outside the circle and also length of time.</strong></p>

<p>Here my code thus far; I've left out a bunch of the code for setting up the motion sensor just for simplicity so this is semi pseudocode. In any case, my main issue is getting the values I need from the list. I have the circle class included as well. I do the outside of the circle calculation and how far outside of calculation inside of my circle class.</p>

<p>Please let me know if this makes sense! <strong>The motion sensor is reading in data at 200 fps so efficiency is factor here.</strong> On top of that, I am only expecting the hand to be outside of the circle for a few seconds at a time back and forth.</p>

<pre><code>    import java.util.*;
    LinkedList&lt;Integer&gt; values;

    public void setup() 
    {
      size(800, 300);
      values = new LinkedList&lt;Integer&gt;();
      HandPosition = new PVector(0, 0); //This is getting x,y values from motion sensor
      aCircle = new Circle(); //my class just draws a circle to center of screen
      aCircle.draw();
    }

    public void draw() 
    { 

       if (aCircle.isOut(HandPosition)) /* detects if movement is outside of circle. Would it make more sense for this to be a while loop? I also need to start a timer as soon as this happens but that shouldn't be hard */
        {
        values.add(aCircle.GetDistance(HandPosition));  //gets how far the hand is from center of circle and adds it to linked list. Allegedly at least, I think this will work.
        /*So I need to get the 5 largest value from inside of my linked list here.
        I also need to start a timer*/
        }  
    }


    class Circle {

      PVector mCenter;
      int mRadius;

      Circle()
      {
        // initialize the center position vector
        mCenter = new PVector(0,0);
        mRadius = 150;
        mCenter.set((width/2),(height/2));
      }

      boolean isOut(PVector Position) //detects if hand position is outside of circle 
      {
        return  mCenter.dist(Position) &lt;= mRadius;
      }

      float GetDistance(PVector Position) //detects how far the hand is from the center of circle 
      {
       return mCenter.dist(Position);
      }

      void draw() {
        ellipse(mCenter.x, mCenter.y, mRadius, mRadius); 
      }

    }
</code></pre>

<p>I'm new to Processing as well so don't hold back if any of this works.</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/556/AJN72QW0POTU.png" alt="tmore" title="tmore" /></p>
]]></description>
   </item>
   </channel>
</rss>