DOC PREVIEW
TRINITY CSCI 1320 - Graphics

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

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

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Graphics10-28-2011Opening DiscussionMinute essay comments:Can't type as fast as me in vi.Deciding between panels.Retails of publisher/reactor model.Coding of graphics intensive games.Sorting the in-class code by date.What is my take on Anonymous.Adding to our GUII want to make the GUIs we wrote last time put data into the tables before we move forward today.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 a shot-chart in basketball.Drawing Dinosaurs.Drawing anything there isn't 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 shearLess Used SettingsComposite – how colors combine when you draw over old stuffClip – where your drawings will appearRender hints – other things like antialiasingMore General Drawing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How do you think we would go about creating


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

11 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 2 2 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?