Modifying GridWorld Classes.

Slides:



Advertisements
Similar presentations
HOW TO USE POWERPOINT By Bryan Kreps.
Advertisements

Microsoft FrontPage Monday January 28, The Basic FrontPage Setup.
PowerPoint Tutorial 2 Adding Media and Special Effects
1 eclipse Tips. 2 What is eclipse? Eclipse is a popular IDE (Integrated Development Environment) that we will use to create, compile, execute, and test.
PowerPoint Scavenger Hunt Lauren Davis EDTD 3011 A Summer 2007.
 Steps how to design a web page using Microsoft Frontage Steps how to design a web page using Microsoft Frontage  Video related to the topic Video related.
Using a different image than normal Multiple images for a class Controlling the mouse click Controlling the keys pressed Launching an input dialog box.
How to prepare a PowerPoint presentation
By Jacqui Sharp Animating a Volcanic Eruption. Step One: You need objects Tip: you need to close the shape before you can see a colour in it. Go to Paint.
Power Point Presentation - Advanced Julia J. Stahl Distributed System Specialist.
PowerPoint 2007 © : The Power of Presentations How can Microsoft PowerPoint 2007 help you finalize a presentation for an audience?
With Alex Conger – President of Webmajik.com FrontPage 2002 Level I (Intro & Training) FrontPage 2002 Level I (Intro & Training)
Google Earth How to create a Google Earth Tour and place it in your Wiki.
Structure of GridWorld classes Creating a GridWorld project without the jar file Modifying GridWorld classes Removing grid lines Changing the color of.
Designing a Classroom Web Site Using NVU Beginning Level.
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
Using Dreamweaver. Slide 1 Dreamweaver has 2 screens that do different things The Document window where you create your WebPages The Site window where.
Web Technologies Website Development Trade & Industrial Education
CIS 205—Web Design & Development Flash Chapter 1 Getting Started with Adobe Flash CS3.
Creating your COLOR THEORY in Art PowerPoint Presentation This presentation was put together for you by Mr. Montgomery, art instructor George Washington.
To download PhotoStory: Go to On the left side under Product Resources, click on Downloads.
Website Development with Dreamweaver
ADOBE WEAVER WEB DESIGN. START THE DW 2 WORKSPACE LAYOUT Application Bar Document Toolbar Document Window Workspace Switcher Property Inspector GroupPanel.
COMPREHENSIVE Windows Tutorial 7 Managing Multimedia Files.
Fall 2005 Using FrontPage to Enhance Blackboard - Darek Sady1 Using FrontPage to Enhance Blackboard 1.Introduction 2.Starting FrontPage 3.Creating Documents.
Microsoft Word 2003 Word Processing. The Word 2003 Screen Menu Bar Title Bar Standard ToolbarFormatting Toolbar Vertical Scroll Bar Horizontal Scroll.
 Definition  Components  Advantages  Limitations Contents  Introduction Introduction  Inserting a Table Inserting a Table  Drawing a Table Drawing.
Animate picture to peek from bottom (1 of 3) 1. Right click on picture you want to animate. 2. Click on Custom Animation. 2 1 R.
Getting Started with Fireworks A few tips: –Before you begin an assignment, be sure to create a folder on your drive for it. –If your canvas is checkered,
Making Websites with Dreamweaver BTT. What is Dreamweaver?  “What You See Is What You Get” (WYSIWYG) web design software  Rather than writing code and.
CRSD Technology Training Tony Judice. Quick Access Toolbar – can be modifiedSave as… allows you to save the file to a different location and also as an.
Photoshop Image Slicing. Reasons to Image Slide To create links out of sliced images To optimise different areas. (flat areas of colour, such as logos,
Photo Story. How to use Photo Story Photo Story 3 can be located in the Accessories folder on school computers. You will need to have your pictures already.
Know your computer Make a Folder Copy from Word to Composer Format the Font Change the Alignment Format the Background Format the Colors Insert a Picture.
Introducing Dreamweaver. Dreamweaver The web development application used to create web pages Part of the Adobe creative suite.
1 Place Your Photo AND Logo on Your Home Page Website Manager Tutorials.
Microsoft PowerPoint Prepared by the Academic Faculty Members of IT.
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Building a Website: Layout Fall Overall Structure: Home Page Title Section Title Frame Picture UNCP Math Menu Content Footer Contact Information.
Flash 1. Document Properties Set frame rate and dimensions of project Set frame rate and dimensions of project (default width=550 and height=400)
Cell Column Drawing Toolbar Formatting Toolbar Formula Bar Help Box Menu Bar Name Box Rows Standard Toolbar Title Bar Worksheet.
Access Queries and Forms. Adding a New Field  To insert a field after you have saved your table, open Access, and open the table  It is easier to add.
PhotoShop Creative Suite 3 Chapter 1 The Work Area.
Groups of cells labeled with letters that go up and down (vertical)
1 Chapter 15 Creating a Presentation. Practical Computer Literacy, 2 nd edition Chapter 15 2 What’s inside and on the CD? In this chapter, you will learn.
Flash Slideshow with Fade Transition Slideshow #1-Themed Images Slideshow #2-Instructional Images.
Creating a Presentation
INTRO to PIXLR.com.
PhotoShop Creative Suite 3
Flash Interface, Commands and Functions
Eclipse Navigation & Usage.
Using the INSERT TAB in MS Word 2007
Just a minute Time for Action (Intermediate)  
First text statement positioned here at guide intersection
Chapter 1 Editing a Photo
Hurricanes Nature’s Fury
“Placeholder for a quote to be animated here.”
Economist Report (Advanced)
Embedding Graphics in Web Pages
DIRECTIONS: 1. Click Enable Editing in the yellow bar above.
Animated picture collection: left picture moves to front center
Northwest School Division #203
RYLA Registration System
Windows Tutorial 7 Managing Multimedia Files
Photostory 3.
European Computer Driving Licence
对 话 无 界 限 “对话是两个集合出现交集的一个刹那。” “对话是发现共同点的捷径。”.
Directions are in slide notes. You can view them in two ways
Chapter 1 Introducing Small Basic
Step 1:. Open Microsoft FrontPage application.
Presentation transcript:

Modifying GridWorld Classes

Topics Structure of GridWorld classes Creating a GridWorld project without the jar file Modifying GridWorld classes Removing grid lines Changing the color of grid lines Changing the background color Using an image as the background Changing the text on a button Hiding a button Closing the world Changing the thickness of grid lines Bolding specific grid lines Zooming in automatically Making the world window fill the computer screen Customizing the dimensions of the world window Using images that are transparent

Structure of GridWorld Classes GridWorld source code has been saved to S:\StudentShare\AP Computer Science\GridWorldCode. The source code is saved in specific folders and subfolders. You should keep them in these same folders underneath your project if you are overriding them. For example, folders info\gridworld\actor corresponds to package info.gridworld.actor in eclipse: info\gridworld\actor – contains all the Actor classes and images info\gridworld\grid – contains the Location class and Grid classes, as well as their images info\gridworld\gui – contains classes related to the gui info\gridworld\world – contains the World class

Creating GridWorld projects without a jar file If you eventually want to create an application or applet based on GridWorld, then you will want to use this approach. This will allow someone to play your game without launching eclipse or some other IDE. To do this you will need to include all the GridWorld source code/compiled code in your project. You should NOT add the external GridWorld jar file to your project. Here is how you can accomplish this: Create a project in eclipse. Do not add the GridWorld jar file. Open the GridWorldCode zip file from my website, select all files, and then press Extract. Extract them directly to the project you just created. Note: Do not extract them to a package. Create another package in this project and this will be where you create your custom classes for your game.

Modifying GridWorld classes If you don’t need to create an application or applet based on GridWorld, but you want to modify one of its classes, then use this approach. One example is if you want to change the grid lines by either making them disappear or modifying their color. Here is how you can accomplish this: Create a project in eclipse. Add the external GridWorld jar file to the project as you normally do. Identify the GridWorld class(es) that you want to modify. Create a package in your project named just like the package that the class is in (see previous slide). For example, if you want to modify the Actor class, then create a package named info.gridworld.actor. Copy the class you want to modify from GridWorldCode zip file from my website (see previous slide) and save it into this package. Modify the class as necessary. Create another package in this project and this will be where you create your custom classes for your game.

Removing grid lines To completely remove grid lines: Make sure you have created the package info.gridworld.gui in your project. Modify the GridPanel class as follows: In the paintComponent() method, comment out the line: drawGridlines() . Save the class.

Changing the color of grid lines In certain situations, you may want to change the color of grid lines. For example, you may want the background to be red and if you also make the grid lines red, then the grid appears as one red background with no grid lines. Here is how you can do this: Make sure you have created the package info.gridworld.gui in your project. Modify the GridPanel class as follows: In the drawGridlines() method, change the line g2.setColor(Color.BLACK); to g2.setColor(Color.RED); Save the class. Grid is a row / column structure that stores Objects. The location of each Object is determined by the Location provided when putting the Object in the grid.

Changing the background color In certain situations, you may want to change the background color to something other than white. Here is how you can do this: Make sure you have created the package info.gridworld.gui in your project. Modify the GridPanel class as follows: set the backgroundColor instance variable to Color.BLACK or whatever color you want the background to be. Save the class. Grid is a row / column structure that stores Objects. The location of each Object is determined by the Location provided when putting the Object in the grid. 8

Using an image as the background Make sure you have created the package info.gridworld.gui in your project. Save the image file in the project folder (not the package folder) Modify the GridPanel class as follows: In the paintComponent() method insert the following lines of code: ……... g2.setColor(backgroundColor); g2.fillRect(insets.left, insets.top, numCols * (cellSize + 1) + 1, numRows * (cellSize + 1) + 1); // Begin of code to use an image as the background BufferedImage img = null; try { img = ImageIO.read(new File("starfield.JPG")); } catch (IOException e) { } g2.drawImage(img, insets.left, insets.top, numCols * (cellSize + 1) + 1, numRows * (cellSize + 1) + 1, 0, 0, img.getWidth(), img.getHeight(), null); // End of code to use an image as the background drawWatermark(g2); ……… Grid is a row / column structure that stores Objects. The location of each Object is determined by the Location provided when putting the Object in the grid. 9

Changing the text on a button Make sure you have created the package info.gridworld.gui in your project. Edit the file named WorldFrameResources.properties. This file contains information about buttons and menus used in GridWorld. Modify the line for the button you want to change. For example here are the lines that represent the thre buttons for Step, Run, and Stop. button.gui.step=Step button.gui.run=Run button.gui.run=Play button.gui.stop=Stop slider.gui.slow=Slow slider.gui.fast=Fast Grid is a row / column structure that stores Objects. The location of each Object is determined by the Location provided when putting the Object in the grid. 10

Hiding a button Make sure you have created the package info.gridworld.gui in your project. Modify the makeControls() method in the GUIController class. Find the line of code that is adding the button to the panel and comment it out. The following hides the Step button: Dimension spacer = new Dimension(5, stepButton.getPreferredSize().height + 10); controlPanel.add(Box.createRigidArea(spacer)); //controlPanel.add(stepButton); //controlPanel.add(Box.createRigidArea(spacer)); controlPanel.add(runButton); controlPanel.add(stopButton); runButton.setEnabled(false); stepButton.setEnabled(false); stopButton.setEnabled(false); Grid is a row / column structure that stores Objects. The location of each Object is determined by the Location provided when putting the Object in the grid. 11

Closing the World Make sure you have created the packages named info.gridworld.gui and info.gridworld.world in your project. The frame that the World is based on will need to be closed. The frame is stored in the frame variable in the World class. There is currently no accessor method, so you will need to create one in the World class: public JFrame getFrame() { return frame; } Now you can modify your world class (which extends World). In your logic, you will need to close the frame as follows: Grid is a row / column structure that stores Objects. The location of each Object is determined by the Location provided when putting the Object in the grid. getFrame().dispose(); 12

Changing the thickness of grid lines Make sure you have created the package named info.gridworld.gui. You will need to change the stroke that is used before drawing the grid lines. Modify the drawGridLines() method in the GridPanel class. g2.setStroke(new BasicStroke(10)); //add this g2.setColor(Color.BLACK); for (int y = miny; y <= maxy; y += cellSize + 1) // draw horizontal lines g2.drawLine(minx, y, maxx, y); for (int x = minx; x <= maxx; x += cellSize + 1) // draw vertical lines g2.drawLine(x, miny, x, maxy); Grid is a row / column structure that stores Objects. The location of each Object is determined by the Location provided when putting the Object in the grid. 13

Bolding the grid lines Make sure you have created the package named info.gridworld.gui. You will need to add the following code segment after drawing the grid lines at the bottom of the drawGridLines() method in the GridPanel class. g2.drawLine(146,miny,146,maxy); g2.drawLine(293,miny,293,maxy); g2.drawLine(145,miny,145,maxy); g2.drawLine(292,miny,292,maxy); g2.drawLine(minx,146,maxx,146); g2.drawLine(minx,293,maxx,293); g2.drawLine(minx,145,maxx,145); g2.drawLine(minx,292,maxx,292); Grid is a row / column structure that stores Objects. The location of each Object is determined by the Location provided when putting the Object in the grid. 14

Zooming in automatically Make sure you have created the package named info.gridworld.gui. Modify the setGrid() method in the GridPanel class to call the zoomIn() method. This should be done at the bottom of the method after it calculates the cell size: if (grid.getNumRows() == -1 && grid.getNumCols() == -1) { numRows = numCols = 2000; // This determines the "virtual" size of the pan world } else numRows = grid.getNumRows(); numCols = grid.getNumCols(); recalculateCellSize(MIN_CELL_SIZE); this.zoomIn(); // Zoom in at the beginning Grid is a row / column structure that stores Objects. The location of each Object is determined by the Location provided when putting the Object in the grid. 15

Making the world window fill the screen Make sure you have created the package named info.gridworld.world. Modify the show() method in the World class as follows. Add the line of code that is highlighted: public void show() { if (frame == null) frame = new WorldFrame<T>(this); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setVisible(true); } else frame.repaint(); Grid is a row / column structure that stores Objects. The location of each Object is determined by the Location provided when putting the Object in the grid. 16

Customizing the dimensions of the world window Make sure you have created the packages named info.gridworld.gui and info.gridworld.world in your project. The frame that the World is based on will need to be modified. The frame is stored in the frame variable in the World class. There is currently no accessor method, so you will need to create one in the World class: public JFrame getFrame() { return frame; } Now you can modify your world class (which extends World). In your logic, you will need to customize the frame as follows: Grid is a row / column structure that stores Objects. The location of each Object is determined by the Location provided when putting the Object in the grid. PokerGame game = new PokerGame(new BoundedGrid(6,3)); game.show(); game.getFrame().setSize(345, 750); Width in pixels Height in pixels 17

Using images that are transparent Make sure that all images you are using are saved in .PNG format Modify the instance variable named imageExtension in the ImageDisplay class in the info.gridworld.gui package as follows. Change the line to use .PNG extensions (instead of .gif extensions) for images: private static final String imageExtension = ".png"; Now you need to add transparency to your image: Launch MS Powerpoint and select Insert > Picture to insert your picture into a slide. Select the image and select the Picture Tool: Color and scroll to the bottom and pick Select Transparent Color. Using the cursor, click on the white area in the background of your picture. This will make all white areas transparent. Right click on the picture and select Fill > Picture or text fill and move the Transparency slider bar to 100%. Right click on picture and select Save as picture and save to your workspace as a PNG file. Grid is a row / column structure that stores Objects. The location of each Object is determined by the Location provided when putting the Object in the grid. 18