DOC PREVIEW
TRINITY CSCI 1320 - Graphics

This preview shows page 1-2-3-4 out of 11 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 11 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Graphics 10 29 2010 Opening Discussion Solutions to the interclass problem Do you have questions about the assignment Minute essay comments Could you write Sudoku or Battleship Fixing in class code Courses that use GUIs Saving changes in Pokemon Motivation You can do lots of things with the standard GUI elements in Swing We could set up quite a bit of a GUI using that However no GUI library can predict everything that you will want to do and we want to be able to add custom drawing to our applications Uses Drawing Pokemon on battlefield Drawing Dinosaurs Drawing anything there is a GUI component for Graphics in Scala Java For this we will rely on the Java2D library Java2D was added about the same time Swing was and it is fundamentally based on the java awt Graphics2D class Let s go find the Java API and find this class in it Making Custom Drawn Components We are going to follow a simple approach to doing this making a new Panel that draws what we want new Panel override def paint g Graphics2D Whatever you draw to g appears in the panel Capabilities of Java2D Let s look a bit at the Graphics2D class to see what some of the possibilities might be for what we can draw The java awt geom package and the java awt image package also have some useful things in them Settings There are several things that we can set on the Graphics2D object that are used when we draw things Here are some Paint could be a color but there are also gradients and textures Stroke determines how lines are drawn Font how you want text to appear Transform AffineTransform allows translate rotate scale or shear Less Used Settings Composite how colors combine when you draw over old stuff Clip where your drawings will appear Render hints other things like antialiasing More General Drawing Of course Graphics2D objects aren t limited to just drawing on components The Image class and it s subtype BufferedImage will let you get Graphics objects that you can draw to and what you draw will be on the image We ll typically do this even if we are drawing to a component to implement buffering which reduces flicker Loading Images The easiest way to load images from disk is using javax imageio ImageIO This class has read methods that take File or URL objects Minute Essay What are your thoughts on Scala What do you see as its strengths and weaknesses for this course Make sure to give me your higher priority courses as soon as you know them Interclass problem Write a script that has a custom drawn panel with something in it Try to listen to the mouse Publisher in the panel and do something with the different MouseEvents


View Full Document

TRINITY CSCI 1320 - Graphics

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Strings

Strings

9 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Download Graphics
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Graphics and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Graphics and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?