Top Banner
page 1 CSC 220 Object Oriented Multimedia Programming, Fall 2018 Dr. Dale E. Parson, Assignment 3, text menu on a remote-control Android, mostly array handling. This assignment is due via D2L Assignment Assignment 3 Android by 11:59 PM on 20 November. Bonus points are available if you have it installed and running for our class in the planetarium on November 15. All students must attend the planetarium testing session on November 15, or take a 10% deduction on the project. CHARGE YOUR ANDROID TEST DEVICE FULLY AS SOON AS POSSIBLE. When using Processing on the Kutztown campus Windows computers, make sure to start out every time by setting your Processing Preferences -> Sketchbook Location to U:\Processing. The U:\ drive is a networked drive that will save your work and make it accessible across campus. If you save it to your desktop or the lab PC you are using, you will lose your work when you log out. You must save it to the U:\ drive. If you do not have a folder 1 called Processing under U:\, you must create one using the Windows Explorer. Processing Preferences is under the File menu on Windows. If you will be downloading Processing 3.X and running it using an off-campus computer (do not use version 2.X for assignments), you can copy your project sketch to a flash drive on one machine, and then copy it from the flash drive to another Processing sketch folder. There are three starting sketches that you must copy & paste into Processing as your starting point. PaintDomeServer2018 at http://faculty.kutztown.edu/parson/fall2018/PaintDomeServer2018.txt is a baseline graphical server that we will enhance considerably in Assignment 4. For now it displays a simple graphical pair of crossed lines with the ability to interpret only speedX and speedY commands. Copy this file into a Processing editor window and Save As PaintDomeServer2018. See page 4 instructions on installing the oscP5 library for testing. PaintDomeAndroid2018 at http://faculty.kutztown.edu/parson/fall2018/PaintDomeAndroid2018.txt is the 1 Another name for a folder is a directory.
9

CSC 220 Object Oriented Multimedia Programming, Fall 2018faculty.kutztown.edu/parson/fall2018/csc220fall2018assn3.pdf · 2018-11-11 · page 1 CSC 220 Object Oriented Multimedia Programming,

Jun 26, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CSC 220 Object Oriented Multimedia Programming, Fall 2018faculty.kutztown.edu/parson/fall2018/csc220fall2018assn3.pdf · 2018-11-11 · page 1 CSC 220 Object Oriented Multimedia Programming,

page 1

CSC 220 Object Oriented Multimedia Programming, Fall 2018 Dr. Dale E. Parson, Assignment 3, text menu on a remote-control Android, mostly array handling. This assignment is due via D2L Assignment Assignment 3 Android by 11:59 PM on 20 November. Bonus points are available if you have it installed and running for our class in the planetarium on November 15. All students must attend the planetarium testing session on November 15, or take a 10% deduction on the project. CHARGE YOUR ANDROID TEST DEVICE FULLY AS SOON AS POSSIBLE. When using Processing on the Kutztown campus Windows computers, make sure to start out every time by setting your Processing Preferences -> Sketchbook Location to U:\Processing. The U:\ drive is a networked drive that will save your work and make it accessible across campus. If you save it to your desktop or the lab PC you are using, you will lose your work when you log out. You must save it to the U:\ drive. If you do not have a folder1 called Processing under U:\, you must create one using the Windows Explorer. Processing Preferences is under the File menu on Windows.

If you will be downloading Processing 3.X and running it using an off-campus computer (do not use version 2.X for assignments), you can copy your project sketch to a flash drive on one machine, and then copy it from the flash drive to another Processing sketch folder. There are three starting sketches that you must copy & paste into Processing as your starting point. PaintDomeServer2018 at http://faculty.kutztown.edu/parson/fall2018/PaintDomeServer2018.txt is a baseline graphical server that we will enhance considerably in Assignment 4. For now it displays a simple graphical pair of crossed lines with the ability to interpret only speedX and speedY commands. Copy this file into a Processing editor window and Save As PaintDomeServer2018. See page 4 instructions on installing the oscP5 library for testing. PaintDomeAndroid2018 at http://faculty.kutztown.edu/parson/fall2018/PaintDomeAndroid2018.txt is the 1 Another name for a folder is a directory.

Page 2: CSC 220 Object Oriented Multimedia Programming, Fall 2018faculty.kutztown.edu/parson/fall2018/csc220fall2018assn3.pdf · 2018-11-11 · page 1 CSC 220 Object Oriented Multimedia Programming,

page 2

main part of your sketch. You will NOT modify this file, but you need it in order to run the sketch. Copy this file into a Processing editor window and Save As PaintDomeAndroid2018. Menus at http://faculty.kutztown.edu/parson/fall2018/Menus.txt is the file you will edit and turn in to D2L by the due date. Do NOT create a new sketch for it. Instead, with sketch PaintDomeAndroid2018 already created, saved, and still open per the previous paragraph, create a new TAB in the sketch editor called Menus and copy&paste the contents of Menus.txt into it. Do another save. This is your starting point. We will go over it on November 6. Here are the STUDENT comments from that file. File http://faculty.kutztown.edu/parson/fall2017/CenteredClippingCircle.png contains the clipping circle image that you must save into PaintDomeServer2018’s sketch directory. ATTENDANCE at the planetarium on November 15 test session is worth 10% of the project. An assignment that is loaded onto your Android when you arrive Nov. 15 earns 10 bonus points. STUDENT 1 is worth 10% of the project. // STUDENT 1: Create an array of String objects CommandMenuStrings [], // patterned after SetServerAddressPortStrings above, with each command // string padded out with trailing spaces to the length of the longest // command string + 1; the longest commands with have 1 trailing space, // and all command strings will have the same String length to simplify // alignment on the screen. // See top of PaintDomeAndroid2018.pde for command datagram protocol. // These are the commands: // command names follow STUDENT 2 is worth 10% of the project. // STUDENT 2: Create an array of String objects FloatStrings [], // patterned after SetServerAddressPortStrings above, where there // are exactly 6 characters in each string. The first column // consists of alternating '+' and '-' characters for plus and minus. // The second, third, fifth, and sixth columns consist of digits, // with 0 at the top, increasing by 1 to 9 at the bottom; there // are thus 10 rows. The fourth column consists entirely of '.' // decimal points. With this arrangement, the even digit strings have // '+ at the front, and the odd digit strings have '-' at the front. STUDENT 3 is worth 10% of the project. // STUDENT 3: Rewrite function combineStringArrays to return // an array that has String array brushes as its first element // and String array commands as its second element. See its application // in the CommandMenu constructor below. STUDENT 4 is worth 40% of the project. NOTE – STUDENT 4 relates to the second screen photo below. // STUDENT 4: WRITE doSubmit() to extract the brushname String, the // command String, and the floatValue float from the buttons identified // by each column's activeRowPerColumn, similar to SetServerAddressPortMenu's // doSubmit above. The brushname in buttons column 0, and the command name in column 1, // are complete strings. The floating point digit strings in the remaining // columns are single-character digits, along with a leading '+' or '-' // and a decimal point '.', that you must concatenate into a string, similar

Page 3: CSC 220 Object Oriented Multimedia Programming, Fall 2018faculty.kutztown.edu/parson/fall2018/csc220fall2018assn3.pdf · 2018-11-11 · page 1 CSC 220 Object Oriented Multimedia Programming,

page 3

// to the work in SetServerAddressPortMenu.doSubmit(). Extract a float value // from this string using Float.parseFloat, similar to Integer.parseInt in // SetServerAddressPortMenu.doSubmit(). Finally, call sendOSCMessage(command, brush, fval), // where command is the command String, brush is the brush name String, and fval is // the float value extracted from the displayed menu data. void doSubmit() { // STUDENT CODE GOES HERE. // 1. Get the brush name from the selection in buttons column 0. // 2. Get the command from the selection in buttons column 1. // 3. For each remaining column starting at column 2: // Concatenate the selected character in this column to the floatstring. // 4. Convert the string to a float using Float.parseFloat(floatstring). // 5. Call function sendOSCMessage(command, brush, fval). } STUDENT 5 is worth 10% of the project. // STUDENT 5: Call Processing's exit library function from within doCancel(). void doCancel() { // STUDENT 5 code goes here. } STUDENT 6 is worth 10% of the project. // STUDENT 6: Underline the highlighted text using // Processing's line library function in the same color. // You have the x,y location of the left,top of the // text; call getWidth() and getHeight() to determine // the right and bottom coordinates of the text; put // the underline a little below the bottom. The first screen to come up on the Android tablet gives the display resolution, which is 1536 x 2048 pixels on the department’s Galaxy S3 tablets. Tapping the screen takes you to this screen. Note that the stylus that comes with the tablet works very well at selecting characters.

Page 4: CSC 220 Object Oriented Multimedia Programming, Fall 2018faculty.kutztown.edu/parson/fall2018/csc220fall2018assn3.pdf · 2018-11-11 · page 1 CSC 220 Object Oriented Multimedia Programming,

page 4

That screen may display without any adjustments on a laptop or PC. However, I found on my laptop it was necessary to adjust this line of code in Menus.pde: class CommandMenu extends Menu { CommandMenu() { super("Send Command to Server (Cancel Exits)", true, true, combineStringArrays(getAllBrushnames(),CommandMenuStrings),FloatStrings, globalFont, round(globalPointSize * .8), 1.5, 1.5); TO THIS: class CommandMenu extends Menu { CommandMenu() { super("Send Command to Server (Cancel Exits)", true, true, combineStringArrays(getAllBrushnames(),CommandMenuStrings),FloatStrings, globalFont, round(globalPointSize * .8), 1.0, 1.0); OR EVEN THIS: class CommandMenu extends Menu { CommandMenu() { super("Send Command to Server (Cancel Exits)", true, true, combineStringArrays(getAllBrushnames(),CommandMenuStrings),FloatStrings, globalFont, round(globalPointSize * .75), 1.0, 1.0); to get everything on the next screen to fit. The stylus that comes with the Galaxy S3 tablet is very handy for selecting from small font. The handout code works fine with respect to size on the S3 tablets.

Page 5: CSC 220 Object Oriented Multimedia Programming, Fall 2018faculty.kutztown.edu/parson/fall2018/csc220fall2018assn3.pdf · 2018-11-11 · page 1 CSC 220 Object Oriented Multimedia Programming,

page 5

SIDE ISSUES: 1. To test on your own laptop or desktop, before going to the Android, you need to install the oscP5

library. With the PaintDomeServer2018 sketch open go to menu item Sketch -> Import Library -> Add Library and install the oscP5 library. You can even do this on campus PCs running Deep Freeze, although it will work only for the duration of that login session.

Page 6: CSC 220 Object Oriented Multimedia Programming, Fall 2018faculty.kutztown.edu/parson/fall2018/csc220fall2018assn3.pdf · 2018-11-11 · page 1 CSC 220 Object Oriented Multimedia Programming,

page 6

2. To actually build and download onto an Android device, you must switch from java mode to android

mode in the upper right corner of your PaintDomeAndroid2018 sketch window. The first time this will install the Android SDK (System Development Kit) somewhere – maybe on the PC, maybe where the Processing executable is located, or maybe in the sketch folder. I have had problems with this on the networked PCs at KU, and will install on the lecture machine in Old Main 158. You can turn in an early copy of Menus.pde via D2L if you want me to download it onto your device during a lab session, although you must do that download yourself before November 15 to earn the 10 bonus points.

3. After successfully putting the client sketch into Android mode (BE CAREFUL NOT TO RUN THE

SERVER IN ANDROID MODE – Processing has a way of switching the server sketch window into Android mode when you do that with the client sketch), you must enable UDP calls on the Android by

Page 7: CSC 220 Object Oriented Multimedia Programming, Fall 2018faculty.kutztown.edu/parson/fall2018/csc220fall2018assn3.pdf · 2018-11-11 · page 1 CSC 220 Object Oriented Multimedia Programming,

page 7

following the Android -> Sketch Permissions menus and enabling Internet options.

4. You also need to enable the Android device for USB debugging. Go into the Settings app and look for

About Tablet. These screen shots (About Phone) are from my phone because the department’s tablets have overridden the screen capture button sequence. Go into Software info, tap on Build number a bunch of times, enabling Developer options. Turn on USB Debugging. You will have to grant permission via a pop-up question on the tablet every time you connect the USB cable from the computer housing Processing’s Android-enabled client sketch to the device.

Assuming that you have not changed file PaintDomeAndroid2018.pde (do not), turn in your file Menus.pde into D2L Assignment Assignment 3 Android by the end of November 20 to avoid the 10% per day late penalty. Note that I will be taking a personal day on November 20 and will not be in class. Instead I will

Page 8: CSC 220 Object Oriented Multimedia Programming, Fall 2018faculty.kutztown.edu/parson/fall2018/csc220fall2018assn3.pdf · 2018-11-11 · page 1 CSC 220 Object Oriented Multimedia Programming,

page 8

post a Zoom video on aspects of Assignment 4 that are essential to your work on that project. However, our last class before this due date is November 15 IN THE PLANETARIUM. Any team who shows up to the planetarium on November 15 with the app installed and running correctly on their Android device, without requiring any in-class download of the app onto the device, will receive 10 bonus points. Of course bugs discovered after November 20 can lead to point deductions, but the 10 bonus points will remain if it is basically running correctly as already installed on the Android on November 15. ATTENDANCE AT THE NOVEMBER 15 planetarium session is mandatory. I will deduct 10 points from the project for anyone missing class. The usual 10% per day late deduction after November 20 via the D2L assignment also applies. Assignment due by end of November 20. I will be testing on an Android tablet. Assuming that you have not changed file PaintDomeAndroid2018.pde (do not), turn in your file Menus.pde into D2L Assignment Assignment 3 Android by the end of November 20 to avoid the 10% per day late penalty. Note that I will be taking a personal day on November 20 and will not be in class. I will post a Zoom video on aspects of Assignment 4 that are essential to your work on that project. However, our last class before this due date is November 15 IN THE PLANETARIUM. Any team who shows up to the planetarium on November 15 with the app installed and running correctly on their Android device, without requiring any in-class download of the app onto the device, will receive 10 bonus points. Of course bugs discovered after November 20 can lead to point deductions, but the 10 bonus points will remain if it is basically running correctly as already installed on the Android on November 15 before you arrive.

Page 9: CSC 220 Object Oriented Multimedia Programming, Fall 2018faculty.kutztown.edu/parson/fall2018/csc220fall2018assn3.pdf · 2018-11-11 · page 1 CSC 220 Object Oriented Multimedia Programming,

page 9

Parson CSC220 Instructions for lab machines in Old Main 156 and Old Main 257. There is a Raspberry Pi 3B in each room with a connected monitor and a mouse. The Pi is able to run server script PaintDomeServer2018, but it cannot program the Android devices because Android mode in Processing requires a 64-bit operating system, and the Pi O.S. is currently a 32-bit system. Bootup logs into account pi with a password of parsonswe. PaintDomeServer2018 reports an incorrect IP address on the Pi, so starting by double-clicking ifconfig.sh on the Desktop, select Execute in Terminal, and observe the wlan0 wireless network IP address labeled inet. Use that address to connect from your Android client. Port 12001 should be reported correctly. To run Processing, open the desktop’s upper left raspberry icon in the toolbar via the mouse, follow Programming -> Processing. Inspect Processing’s Preferences to make sure that /home/pi/csc220fall2018 is the Sketchbook location (directory). Set it to there if it is not. From there you can run the handout PaintDomeServer2018 sketch from the Sketchbook that listens for OSC/UDP messages from your client Android sketch. Each of my wireless routers in those rooms has the same password as the network name. LAN parsonswe has a password of parsonswe, parsonswe4 has password parsonswe4, etc. The Raspberry Pis are already connected. Your Android client must use these wireless LANs for testing. They are not connected to the Internet. BUG FIX TO abstract class Menu 11/11/2018 On 11/11 I have re-posted handout Menus.pde at http://faculty.kutztown.edu/parson/fall2018/Menus.txt because there were some bugs in handout abstract class Menu when the number of brush names differ from the number of brush commands. The original handout PaintDomeServer2018 has exactly 25 brush names and exactly 25 commands, so the bugs in abstract class Menu did not cause any problems. However, when there were more or fewer brush names than commands, ArrayIndexOutOfBoundsExceptions and NullPointerExceptions were happening in the client. It showed up on my Android device, but I was able to debug it running the client on a laptop. You should be safe if you don’t change PaintDomeServer2018 to have a mismatch between number of brushes and number of commands, but if you want to play it safe, just use your mouse to copy ONLY all of the code in abstract class Menu and then paste that code over top of abstract class Menu code in your client sketch in Menus.pde. DO NOT copy&paste either class ResponsiveText (although it did not change) or anything below abstract class Menu. DO NOT paste over top of your work. Make sure the to refresh your browser page for Menus.txt. It should contain some comments like this: // DEBUG 11/11/2018