Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lab07 submissions #16

Open
wants to merge 50 commits into
base: lab07branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d5d0480
added updated version of SimpleGui1 to my src directory - done with S…
Feb 13, 2014
7c9d42c
added updated version of SimpleGUI1 to my src directory - done with S…
menaiskander Feb 13, 2014
d98537f
copied source files and updated package names into simple directory -…
Feb 13, 2014
ba307c9
added updated verssion of SimpleGUI1, done with step 5
Feb 14, 2014
5bc3ea1
added updated version of SimpleGUI1 to my src directory - done with S…
vinlara Feb 14, 2014
dc4091c
Added an updated version of SimpleGui1 to my src directory- Step 5 co…
ashedden Feb 14, 2014
799ea59
Added updated version of SimpleGUI1 to my src directory - done with S…
Feb 14, 2014
fc32f77
added snowman head and copied advanced files
Feb 14, 2014
2fcc1fe
added updated version of SimpleGui1.java to my src directory - done w…
Feb 16, 2014
29698a4
snoman head added
Feb 16, 2014
fe6d120
In the process of finishing final step
Feb 17, 2014
bd891d5
added updated version of SimpleGUI1 to my src directory - done with S…
rkjha7 Feb 17, 2014
3c111b0
completed step 8, fixed the snowman
rkjha7 Feb 17, 2014
d60cb4f
created Cat and FancyCat in place of House, HouseWithWindows, and Cof…
Feb 20, 2014
0a35327
finished with step 8 fix the snowman
vinlara Feb 24, 2014
2236ab4
added updated version of SimpleGUI1 to my src directory - done with S…
ashedden Feb 24, 2014
682293e
Gave the snowman a head; made a CerealBowl.java and CerealBowlWithChe…
ashedden Feb 24, 2014
67036e3
Drawings done, the hockey sticks are beautiful
rkjha7 Feb 24, 2014
949e80f
finished lab06 and updated javadoc comments
Feb 25, 2014
ecafcd8
Delete .#TicTacToeTable.java
Feb 25, 2014
b6c791e
Delete #TicTacToeTable.java#
Feb 25, 2014
3bc6d69
added updated version of SimpleGUI1 to my src directory - done with S…
Feb 26, 2014
6dc4ef5
Fixed the coordinates of the hourglass
vinlara Feb 26, 2014
2ccb8fd
Completed the Hourglass and HourglassFull shape.
vinlara Feb 26, 2014
8444689
added updated version of SimpleGUI1 to my src directory - did this ea…
ashedden Feb 27, 2014
3550088
Finished with lab06
Feb 27, 2014
178f132
Fixed a comment
ashedden Feb 28, 2014
25c4e54
completed lab06
menaiskander Feb 28, 2014
4bdb4e9
final changes made to lab 6
Feb 28, 2014
66bf7d7
added Mushroom and MarioMushroom classes
Feb 28, 2014
c13f9b0
removed some unnecessary files
Feb 28, 2014
c7109a5
Finished drawings
Feb 28, 2014
cd952b7
Updated AllMyDrawings and Hourglass
vinlara Mar 1, 2014
6a32705
Merge pull request #1 from j-so/master
bronhuston Mar 5, 2014
a17180c
Merge pull request #2 from ashedden/master
bronhuston Mar 5, 2014
2d16508
Merge pull request #3 from rkjha7/master
bronhuston Mar 5, 2014
554397f
Merge pull request #4 from xgmak94/master
bronhuston Mar 5, 2014
020941d
Merge pull request #6 from barasuishou/master
bronhuston Mar 5, 2014
ac169b2
Merge pull request #7 from menaiskander/master
bronhuston Mar 5, 2014
305986f
Merge pull request #8 from sarahdarwiche/master
bronhuston Mar 5, 2014
88f94c0
Merge pull request #9 from nissayeva/master
bronhuston Mar 5, 2014
f9e18e1
Merge pull request #10 from l-y-s/master
bronhuston Mar 5, 2014
4452600
Merge pull request #11 from vinlara/master
bronhuston Mar 5, 2014
3bf065f
Merge branch 'lab07branch' of github.com:UCSB-CS56-W14/CS56-W14-lab06…
Mar 7, 2014
8547033
Merge branch 'lab07branch' of github.com:UCSB-CS56-W14/CS56-W14-lab06…
vinlara Mar 13, 2014
d1053f4
simple Hourglass animation is working
vinlara Mar 13, 2014
1312e43
Changed animation to scaling bigger and diagonal
vinlara Mar 14, 2014
fbfc32f
animation of Face bouncing around screen
Mar 14, 2014
12f4c63
Merge pull request #17 from vinlara/lab07branch
kjorg50 Mar 22, 2014
23dddeb
Merge pull request #16 from nissayeva/lab07branch
kjorg50 Mar 22, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/edu/ucsb/cs56/W14/drawings/allisonshedden/SimpleGui1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package edu.ucsb.cs56.w14.drawings.allisonshedden;
import javax.swing.*;

/** SimpleGui1 comes from Head First Java 2nd Edition p. 355.
It illustrates a simple GUI with a Button that doesn't do anything yet.

@author Head First Java, 2nd Edition p. 355
@author P. Conrad (who only typed it in and added the Javadoc comments)
@author Allison Shedden
@version CS56, Spring 2013, UCSB
*/

public class SimpleGui1 {

/** main method to fire up a JFrame on the screen
@param args not used
*/

public static void main (String[] args) {
JFrame frame = new JFrame() ;
JButton button = new JButton("Click me, you tall drink of water") ;
java.awt.Color myColor = new java.awt.Color(102,255,255);
button.setBackground(myColor);
button.setOpaque(true);
frame. setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE) ;
frame. getContentPane() . add(button) ;
frame. setSize(300,300) ;
frame. setVisible(true) ;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
package edu.ucsb.cs56.w14.drawings.allisonshedden.advanced;

import java.awt.Graphics2D;
import java.awt.geom.Line2D; // single lines
import java.awt.geom.Ellipse2D; // ellipses and circles
import java.awt.geom.Rectangle2D; // for the bounding box
import java.awt.Rectangle; // squares and rectangles
import java.awt.geom.GeneralPath; // combinations of lines and curves
import java.awt.geom.AffineTransform; // translation, rotation, scale
import java.awt.Shape; // general class for shapes
import java.awt.Color; // class for Colors
import java.awt.Stroke;
import java.awt.BasicStroke;


import edu.ucsb.cs56.w14.drawings.utilities.ShapeTransforms;
import edu.ucsb.cs56.w14.drawings.utilities.GeneralPathWrapper;

/**
* A class with static methods for drawing various pictures
*
* @author Allison Shedden
* @version for CS56, lab06, Spring 2014
*/


public class AllMyDrawings
{
/** Draw a picture with a few Cereal Bowls
*/

public static void drawPicture1(Graphics2D g2) {

CerealBowl c1 = new CerealBowl(100,250,50,75);
g2.setColor(Color.CYAN); g2.draw(c1);

// Make a black bowl that's half the size,
// and moved over 150 pixels in x direction

Shape c2 = ShapeTransforms.scaledCopyOfLL(c1,0.5,0.5);
c2 = ShapeTransforms.translatedCopyOf(c2,150,0);
g2.setColor(Color.BLACK); g2.draw(c2);

// Here's a bowl that's 4x as big (2x the original)
// and moved over 150 more pixels to right.
c2 = ShapeTransforms.scaledCopyOfLL(c2,4,4);
c2 = ShapeTransforms.translatedCopyOf(c2,150,0);

// We'll draw this with a thicker stroke
Stroke thick = new BasicStroke (4.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);

// for hex colors, see (e.g.) http://en.wikipedia.org/wiki/List_of_colors
// #002FA7 is "International Klein Blue" according to Wikipedia
// In HTML we use #, but in Java (and C/C++) its 0x

Stroke orig=g2.getStroke();
g2.setStroke(thick);
g2.setColor(new Color(0x002FA7));
g2.draw(c2);

// Draw two Cereal bowls with Chex

CerealBowlWithChex cc1 = new CerealBowlWithChex(50,350,40,75);
CerealBowlWithChex cc2 = new CerealBowlWithChex(200,350,200,100);

g2.draw(cc1);
g2.setColor(new Color(0x8F00FF)); g2.draw(cc2);


g2.setStroke(orig);
g2.setColor(Color.BLACK);
g2.drawString("A few cereal bowls with and without Chex cereal by Allison Shedden", 20,20);
}


/** Draw a picture with a few houses and coffee cups
*/
public static void drawPicture2(Graphics2D g2) {

// Draw some cereal bowls with and without Chex

CerealBowlWithChex large = new CerealBowlWithChex(100,50,225,150);
CerealBowl smallCB = new CerealBowl(20,50,40,30);
CerealBowlWithChex tallSkinny = new CerealBowlWithChex(20,150,20,40);
CerealBowl shortFat = new CerealBowl(20,250,40,20);

g2.setColor(Color.RED); g2.draw(large);
g2.setColor(Color.GREEN); g2.draw(smallCB);
g2.setColor(Color.BLUE); g2.draw(tallSkinny);
g2.setColor(Color.MAGENTA); g2.draw(shortFat);

CerealBowl c1 = new CerealBowl(100,250,50,75);
g2.setColor(Color.CYAN); g2.draw(c1);

// Make a black bowl that's half the size,
// and moved over 150 pixels in x direction
Shape c2 = ShapeTransforms.scaledCopyOfLL(c1,0.5,0.5);
c2 = ShapeTransforms.translatedCopyOf(c2,150,0);
g2.setColor(Color.BLACK); g2.draw(c2);

// Here's a cereal bowl that's 4x as big (2x the original)
// and moved over 150 more pixels to right.
c2 = ShapeTransforms.scaledCopyOfLL(c2,4,4);
c2 = ShapeTransforms.translatedCopyOf(c2,150,0);

// We'll draw this with a thicker stroke
Stroke thick = new BasicStroke (4.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);

// for hex colors, see (e.g.) http://en.wikipedia.org/wiki/List_of_colors
// #002FA7 is "International Klein Blue" according to Wikipedia
// In HTML we use #, but in Java (and C/C++) its 0x

Stroke orig=g2.getStroke();
g2.setStroke(thick);
g2.setColor(new Color(0x002FA7));
g2.draw(c2);

// Draw two houses with Windows

CerealBowlWithChex cc1 = new CerealBowlWithChex(50,350,40,75);
CerealBowlWithChex cc2 = new CerealBowlWithChex(200,350,200,100);

g2.draw(cc1);
g2.setColor(new Color(0x8F00FF));

// Rotate the second house 45 degrees around its center.
Shape cc3 = ShapeTransforms.rotatedCopyOf(cc2, Math.PI/4.0);

g2.draw(cc3);


g2.setStroke(orig);
g2.setColor(Color.BLACK);
g2.drawString("A few cereal bowls with and without Chex cereal by Allison Shedden", 20,20);
}

/** Draw a different picture with a few cereal bowls
*/

public static void drawPicture3(Graphics2D g2) {

// label the drawing

g2.drawString("A couple of cereal bowls by Allison Shedden", 20,20);


// Draw some ceral bowls

CerealBowl large = new CerealBowl(100,50,225,150);
CerealBowl smallCB = new CerealBowl(20,50,40,30);

g2.setColor(Color.RED); g2.draw(large);
g2.setColor(Color.GREEN); g2.draw(smallCB);


}


}
100 changes: 100 additions & 0 deletions src/edu/ucsb/cs56/W14/drawings/allisonshedden/advanced/CerealBowl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package edu.ucsb.cs56.w14.drawings.allisonshedden.advanced;
import java.awt.geom.GeneralPath; // combinations of lines and curves
import java.awt.geom.AffineTransform; // translation, rotation, scale
import java.awt.Shape; // general class for shapes

// all imports below this line needed if you are implementing Shape
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.Rectangle;
import java.awt.geom.PathIterator;
import java.awt.geom.AffineTransform;

import edu.ucsb.cs56.w14.drawings.utilities.ShapeTransforms;
import edu.ucsb.cs56.w14.drawings.utilities.GeneralPathWrapper;

/**
A Cereal Bowl (wrapper around a General Path, implements Shape)

This provides an example of how you can start with the coordinates
of a hard coded object, and end up with an object that can be
drawn anywhere, with any width or height.


@author Allison Shedden
@version for CS56, W14, UCSB, 02/23/2014

*/
public class CerealBowl extends GeneralPathWrapper implements Shape
{


/**
* Constructor for objects of class CerealBowl
*/
public CerealBowl(double x, double y, double width, double height)
{
// original coordinates for bowl

final double ORIG_ULX = 100.0;
final double ORIG_ULY = 100.0;
final double ORIG_HEIGHT = 300.0;
final double ORIG_WIDTH = 400.0;

GeneralPath leftSide = new GeneralPath();

// left side of bowl

leftSide.moveTo(200,400);
leftSide.lineTo(160,340);
leftSide.lineTo(130,300);
leftSide.lineTo(100,200);
leftSide.lineTo(100,100);

GeneralPath topAndBottom = new GeneralPath();

topAndBottom.moveTo(100,100);
topAndBottom.lineTo(500,100); // top of bowl

topAndBottom.moveTo(200,400);
topAndBottom.lineTo(400,400); // bottom of bowl

GeneralPath stripe = new GeneralPath();

stripe.moveTo(100,150);
stripe.lineTo(500,150); // top of stripe

stripe.moveTo(100,200);
stripe.lineTo(500,200); // bottom of stripe

Shape rightSide = ShapeTransforms.horizontallyFlippedCopyOf(leftSide);

// flip and move over

rightSide = ShapeTransforms.translatedCopyOf(rightSide, 400.0, 0.0);

// now we put the whole thing together ino a single path.

GeneralPath wholeBowl = new GeneralPath ();
wholeBowl.append(topAndBottom, false);
wholeBowl.append(leftSide, false);
wholeBowl.append(rightSide, false);
wholeBowl.append(stripe, false);

// translate to the origin

Shape s = ShapeTransforms.translatedCopyOf(wholeBowl, -ORIG_ULX + x, -ORIG_ULY + y);

// scale to correct height and width
s = ShapeTransforms.scaledCopyOf(s,
width/ORIG_WIDTH,
height/ORIG_HEIGHT) ;

// Use the GeneralPath constructor that takes a shape and returns
// it as a general path to set our instance variable bowl

this.set(new GeneralPath(s));

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package edu.ucsb.cs56.w14.drawings.allisonshedden.advanced;
import java.awt.geom.GeneralPath; // combinations of lines and curves
import java.awt.geom.AffineTransform; // translation, rotation, scale
import java.awt.Shape; // general class for shapes

// all imports below this line needed if you are implementing Shape
import java.awt.geom.Point2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.awt.Rectangle;
import java.awt.geom.PathIterator;
import java.awt.geom.AffineTransform;

import edu.ucsb.cs56.w14.drawings.utilities.ShapeTransforms;
import edu.ucsb.cs56.w14.drawings.utilities.GeneralPathWrapper;
/**
A Cereal Bowl with Chex

@author Allison Shedden
@version for CS56, W14, UCSB, 02/23/2014

*/
public class CerealBowlWithChex extends CerealBowl implements Shape
{
/** Constructor */
public CerealBowlWithChex(double x, double y, double width, double height)
{
// construct the basic cereal bowl shell
super(x,y,width,height);

// get the GeneralPath that we are going to append stuff to
GeneralPath gp = this.get();

// dimensions for Chex

double c = 0.10 * width;
double chexTop = y - 0.10 * height;
double chexHt = 0.10 * height;

Rectangle2D.Double chex1 =
new Rectangle2D.Double(x + c, chexTop, 1.5 * c, chexHt);
Rectangle2D.Double chex2 =
new Rectangle2D.Double(x + 3.0*c, chexTop, 1.5 * c, chexHt);
Rectangle2D.Double chex3 =
new Rectangle2D.Double(x + 6.0*c, chexTop, 1.5 * c, chexHt);
Rectangle2D.Double chex4 =
new Rectangle2D.Double(x + 8.0*c, chexTop, 1.5 * c, chexHt);

GeneralPath splash = new GeneralPath();

splash.moveTo(x + c, chexTop - 1.5*c);
splash.lineTo(x + c + 10, chexTop - c); // left splash

splash.moveTo(x + 9.5*c, chexTop - 1.5*c);
splash.lineTo(x + 9.5*c - 10, chexTop - c); // right splash

// add the Chex to the cereal bowl

GeneralPath wholeBowl = this.get();
wholeBowl.append(chex1, false);
wholeBowl.append(chex2, false);
wholeBowl.append(chex3, false);
wholeBowl.append(chex4, false);
wholeBowl.append(splash, false);
}

}
Loading