Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science I Programming in Java (programming using Processing IN Java, using IntelliJ IDE) Classwork/Homework: copy your Processing projects over.

Similar presentations


Presentation on theme: "Computer Science I Programming in Java (programming using Processing IN Java, using IntelliJ IDE) Classwork/Homework: copy your Processing projects over."— Presentation transcript:

1 Computer Science I Programming in Java (programming using Processing IN Java, using IntelliJ IDE) Classwork/Homework: copy your Processing projects over into IntelliJ

2 Recap We have been doing Java, but using the Processing Development Environment and accessing libraries

3 Preview: Layers of software (programs) Operating System: file system, input/output, etc. Processing Development Environment: includes invocation of setup, periodic invocation of draw, when event happens, invocation of mousePressed, etc. Setting of width, mouseX, etc. Your program: your setup, draw, etc. Your functions, your variables, your classes, etc. Java

4 Preview: Layers of software (programs) Operating System: file system, input/output, etc. IntelliJ: Integrated Development Environment Processing Libraries included Your program: your setup, draw, etc. Your functions, your variables, your classes, etc. Java code will be visible. Java

5 Behind the scenes The Processing folks wrote Java code that Invoked setup Invoked draw repeated according to the framerate Invoked mousePressed, etc. as necessary The PDE also has its way of adding image files.

6 JetBrain IntelliJ IDEA Many claim: it is the most Intelligent Java IDE (Integrated Development Environment) – Integrates editing, compiling, building (combining parts), running, debugging Includes code completion Helps with missing curly brackets Can specify styles of coding – Note: latest Processing does have more debugging, editing features than previous. Free for students and faculty Available for OS X, Windows, Linux: http://jetbrains.com

7 Now Demonstrate JetBrains IntelliJ You use it at least today. Note: for next assignment, Virtual Something, spend some time on planning independent of implementationS! Note: Math/CS majors will need to do this in CS2, so it is good to start now.

8 IntelliJ IDEA on your computer Download and install the Java Development Kit (JDK 8) from http://www.oracle.com/technetwork/java/javase /downloads/index.html http://www.oracle.com/technetwork/java/javase /downloads/index.html Download and install the Ultimate Edition of the Jetbrains IntelliJ – IDE from https://www.jetbrains.com/idea/download/. Apply for a free full license https://www.jetbrains.com/shop/eform/students using your Purchase email address. https://www.jetbrains.com/shop/eform/students

9 IntelliJ IDEA Tutorials https://www.jetbrains.com/idea/help/intellij- ideaquick-start- guide.html https://www.jetbrains.com/idea/help/intellij- ideaquick-start- guide.html https://www.jetbrains.com/idea/documentati on/ https://www.jetbrains.com/idea/documentati on/

10 Configuring IDEA Getting comfy in IDEA IDE: http://yfain.github.io/Java4Kids#_getting_com fy_in_idea_ide http://yfain.github.io/Java4Kids#_getting_com fy_in_idea_ide Just specify Project SDK (Standard Development Kit, normally use 1.8)

11 Note There are ways to set up Keyboard Shortcuts (go to Preferences) Specify Code Style (under Editor) Quickly rename identifier (e.g. variable name), called Refactor Right click on identifier and go to its declaration You can explore this later.

12 Running Processing Project in IDEA Download and unzip the processingIdea.zip file from Moodle (this is from previous CS1 class) Open IntelliJ Idea, click Open Navigate to the processingIdea folder (the results of unzipping). You are ready – Need to add some standard boilerplace – Copy over existing sketch or start to write Processing Make a small number of modification – If you forget, IDEA will remind you.

13 Find folder

14 Java terminology Project – Package Java Classes – data folder Jars – core.jar (Processing libraries) … External libraries

15 Another way to say it A project is usually a collection of packages A package is a group of related classes Packages help to organize your code Libraries are collections of "helper" code you can use in your program. They usually have a.jar extension the data folder, as in Processing, contains your resources (images, fonts, etc.) – Use standard copy and paste to get files into the data folder – Notice all your classes will have access to the data folder. You will not have to repeat Add file… when re-using an image, font, etc.

16 Screen shot my computer over the break

17 To add a New Package Just right-click on the project folder, select new==> package. The IDEA will create an empty package folder. You don't have to do this for your initial work.

18 To add a New Java Class (this is how you will create a new program) To add a new Java class, right-click on the Package name, select new  Java class

19 … give class a name Convention is to start with capital letter

20 Now, need to add [some] Java code Recall subclasses, your new class, say it is called MyClass, will extend Papplet. IDEA tells us that we need to import a library.

21 Adding Library (-ies) You can respond to what IntelliJ says and add import processing.core.PApplet; Later, when you try to run, you may get an error and another suggest. For example, I needed to add import processing.core.Pimage; OR you can add an import statement with a wildcard: import processing.core.*;

22 Need some more code: package CourseWorkCS1; import processing.core.*; /** * Created by jeaninemeyer on 12/21/15. */ public class BouncingThings extends PApplet { public static void main(String args[]) { String[] appletArgs = new String[]{"CourseWorkCS1.BouncingThings"}; if (args != null) { PApplet.main(concat(appletArgs,args)); } else { PApplet.main(appletArgs); } } … }

23 Add your Processing sketch Need to make these additions – Add public before setup, draw, mousePressed, etc. as well as any new class definitions. – Change any float constants.75 to.75f – If you declared something of datatype color color cl = color(255,0,0); change to int cl = color(255,0,0); Make sure this is all within the { } for the public class MyClass extends PApplet

24 So… My code defines the setup and draw methods for BouncingThings, the subclass that extends PApplet.

25 Run

26 To stop Click the stop button on the left side of the console

27 Classwork/homework IntelliJ IDEA is set up on these computers. Do download the processingIdea file and go through the steps to run an existing Processing sketch – Remember to add public to setup, draw, other Processing methods.

28 Preview Two assignments over the break Find article on computing in the news. Post a summary and your comments. Plan your virtual something. Will describe next class.


Download ppt "Computer Science I Programming in Java (programming using Processing IN Java, using IntelliJ IDE) Classwork/Homework: copy your Processing projects over."

Similar presentations


Ads by Google