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

F16 Lab04 Pull Request #2

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3cc3086
added updated version of SimpleGUI to my src dir - done with step 5
thatonesimon Oct 20, 2016
4dd3a69
updated simplegui1
johnnyzhang295 Oct 20, 2016
8aec14d
created Sponge and SpongeBob classes
johnnyzhang295 Oct 23, 2016
f695e83
fixed snowman
thatonesimon Oct 24, 2016
6c7f719
advanced files copied
thatonesimon Oct 25, 2016
ce7fb23
started tree
thatonesimon Oct 25, 2016
ac54e59
updated some tree
thatonesimon Oct 26, 2016
ca67573
trees is pretty good
thatonesimon Oct 26, 2016
9ba423d
Update Tree.java
thatonesimon Oct 26, 2016
5a92ee7
Update Tree.java
thatonesimon Oct 26, 2016
dc0d529
Update Tree.java
thatonesimon Oct 26, 2016
ae190d8
created TreeWithFruits.java
thatonesimon Oct 26, 2016
d371f36
Merge branch 'master' of github.com:thatonesimon/F16-lab04
thatonesimon Oct 26, 2016
6a74fb0
moved some things around
thatonesimon Oct 26, 2016
869e299
added simpleGui, finished step 5
sayalirkakade Oct 28, 2016
3568b44
snowman completed
sayalirkakade Oct 28, 2016
6f3ff5e
i made a tree, and one with fruit
thatonesimon Oct 28, 2016
ed8b349
javadoc commit
thatonesimon Oct 28, 2016
eb23d1d
finished Star.java class
sayalirkakade Oct 28, 2016
49c0968
Christmas Tree extends Tree
mschanteltc Oct 28, 2016
2dc659d
added shooting star class
sayalirkakade Oct 28, 2016
5cef80d
added updated version of SimpleGui1 to my src directory- done with st…
vchandran2 Oct 29, 2016
145094a
made the greatest snowman of all timegit add src/edu/ucsb/cs56/drawin…
vchandran2 Oct 29, 2016
068e03a
VW finished lab 4
Oct 29, 2016
d2fa85a
completed lab
sayalirkakade Oct 29, 2016
925804d
finished advanced
vchandran2 Oct 29, 2016
8ee995b
generate javadoc
vchandran2 Oct 29, 2016
746663c
drew some more trees
thatonesimon Oct 29, 2016
9d010ed
Update AllMyDrawings.java
thatonesimon Oct 29, 2016
82d209e
Update AllMyDrawings.java
thatonesimon Oct 29, 2016
0bfc2b4
Update AllMyDrawings.java
thatonesimon Oct 29, 2016
8df4452
javadoc added?
thatonesimon Oct 29, 2016
c36a767
fixed up some comments
thatonesimon Oct 29, 2016
bfd92be
comments should be good
thatonesimon Oct 29, 2016
0b4b46b
comments updated
thatonesimon Oct 29, 2016
407387d
Update Tree.java
thatonesimon Oct 29, 2016
aeae24a
Update TreeWithFruits.java
thatonesimon Oct 29, 2016
d2247c7
removed javadoc
thatonesimon Oct 31, 2016
395e65b
Merge pull request #1 from johnnyzhang1738/master
jimmylle Nov 2, 2016
f66beb8
Merge pull request #3 from mschanteltc/master
jimmylle Nov 2, 2016
54ce993
Merge pull request #4 from vincentwangg/master
jimmylle Nov 2, 2016
4216ac7
Merge pull request #5 from sayalirkakade/master
jimmylle Nov 2, 2016
f839aef
Merge pull request #6 from vchandran2/master
jimmylle Nov 2, 2016
c49e245
removed case 4 and 5
thatonesimon Nov 2, 2016
45fcea2
removed 4 and 5
thatonesimon Nov 2, 2016
4710c41
fix copy paste error
thatonesimon Nov 2, 2016
edf307d
Update AllMyDrawings.java
thatonesimon Nov 2, 2016
97eab8f
Update AllMyDrawings.java
thatonesimon Nov 2, 2016
878fc81
Merge pull request #9 from thatonesimon/master
jimmylle Nov 3, 2016
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
34 changes: 34 additions & 0 deletions src/edu/ucsb/cs56/drawings/ctc/SimpleGui1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package edu.ucsb.cs56.drawings.ctc;

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 Chantel Chan (who only typed it in and added the Javadoc comments)
@author TODO: Add additional author here
@version CS56, Fall 2016, 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("I LIKE PINK CLICK ME.") ;

java.awt.Color myColor = new java.awt.Color(255,153,153); // PINK
button.setBackground(myColor);
button.setOpaque(true);

frame. setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE) ;
frame. getContentPane() . add(button) ;
frame. setSize(300,300) ;
frame. setVisible(true) ;
}
}
60 changes: 60 additions & 0 deletions src/edu/ucsb/cs56/drawings/ctc/advanced/#HouseWithWindows.java#
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package edu.ucsb.cs56.drawings.ctc.advanced;
import java.awt.geom.GeneralPath;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;

/**
A House

@author Phill Conrad
@version for CS56, W16, UCSB

*/
public class HouseWithWindows extends House implements Shape
{
/**
* Constructor for objects of class CoffeeCup
*/
public HouseWithWindows(double x, double y, double width, double height)
{
// construct the basic house shell
super(x,y,width,height);

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

// Make three windows, spaced like this, where w=width/10.0;
// | +--+ +--+ +--+ |
// | | | | | | | |
// | +--+ +--+ +--+ |
// |w 2w w 2w w w2 w|
//
// The top of window will be at y + 0.5*height and the
// height of the window is 0.25height;

double orna1x = 0.10 * width;
double orna1y = 0.5 * height;
double orna2x = 0.10 * width;
double orna2y = 0.5 * height;
double orna3x = 0.10 * width;
double orna3y = 0.5 * height;

double winHt = 0.25 * height;

Rectangle2D.Double win1 =
new Rectangle2D.Double(x + orna1x, winTop, 2.0 * w, winHt);
Rectangle2D.Double win2 =
new Rectangle2D.Double(x + orna2x, winTop, 2.0 * w, winHt);
Rectangle2D.Double win3 =
new Rectangle2D.Double(x + orna3x, winTop, 2.0 * w, winHt);

// add the windows to the house
// Look up the meaning of the second parameter of append
// (Hint--is a method of "GeneralPath")

GeneralPath wholeHouse = this.get();
wholeHouse.append(win1, false);
wholeHouse.append(win2, false);
wholeHouse.append(win3, false);
}
}
147 changes: 147 additions & 0 deletions src/edu/ucsb/cs56/drawings/ctc/advanced/AllMyDrawings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package edu.ucsb.cs56.drawings.ctc.advanced;

import java.awt.Graphics2D;
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.drawings.utilities.ShapeTransforms;
import edu.ucsb.cs56.drawings.utilities.GeneralPathWrapper;

/**
* A class with static methods for drawing various pictures
*
* @author Chantel Chan
* @version for UCSB CS56, F16
*/

public class AllMyDrawings
{
/** Draw a picture with a few trees
*/

public static void drawPicture1(Graphics2D g2) {

Tree h1 = new Tree(100,200,50,75);
g2.setColor(new Color(0x194D00)); g2.draw(h1); //dark green regular tree

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

Shape h2 = ShapeTransforms.scaledCopyOfLL(h1,0.5,0.5);
h2 = ShapeTransforms.translatedCopyOf(h2,150,0);
g2.setColor(new Color(0x990000)); g2.draw(h2); //red tree

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

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


Stroke orig=g2.getStroke();
g2.setStroke(thick);
g2.setColor(new Color(0x00E673)); //green tree
g2.draw(h2);

// Draw two Xmas Trees

ChristmasTree hw1 = new ChristmasTree(50,350,40,75);
ChristmasTree hw2 = new ChristmasTree(200,300,200,100);

g2.draw(hw1);
g2.setColor(new Color(0xFF9999)); g2.draw(hw2); //pink Xmas Tree

// @@@ FINALLY, SIGN AND LABEL YOUR DRAWING

g2.setStroke(orig);
g2.setColor(new Color(0xFF9933)); //orange font
g2.drawString("Premature Christmas decorating is an epidemic. -Chantel Chan", 20,20);
}


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

// Draw some irregular sized trees.

Tree large = new Tree(100,50,225,150);
Tree small = new Tree(20,50,40,30);
Tree tallSkinny = new Tree(20,150,20,40);
Tree shortFat = new Tree(20,250,40,20);

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

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

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

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

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


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

// Draw Xmas Trees

ChristmasTree hw1 = new ChristmasTree(50,350,40,75);
ChristmasTree hw2 = new ChristmasTree(200,350,200,100);

g2.draw(hw1);
g2.setColor(new Color(0x3D5C43)); //Dark Green

// Rotate the first and second trees 45 degrees around its center.
Shape hw3 = ShapeTransforms.rotatedCopyOf(hw2, Math.PI/4.0);
Shape hw4 = ShapeTransforms.rotatedCopyOf(hw1, 7.0 * Math.PI/4.0);
g2.draw(hw3);
g2.draw(hw4);

// @@@ FINALLY, SIGN AND LABEL YOUR DRAWING

g2.setStroke(orig);
g2.setColor(Color.BLACK);
g2.drawString("Santa accidentally rode his sleigh through the forest, by Chantel Chan", 20,20);
}

/** Draw a different picture with a few houses and coffee cups
*/

public static void drawPicture3(Graphics2D g2) {

// label the drawing

g2.drawString("A regular ol' primary trees", 20,20);


// Draw some different sized trees

Tree large = new Tree(100, 100, 150, 250);
Tree medium = new Tree(70, 70, 50, 100);
Tree small = new Tree(20,20,40,30);

g2.setColor(Color.RED); g2.draw(large);
g2.setColor(Color.YELLOW); g2.draw(medium);
g2.setColor(Color.BLUE); g2.draw(small);

}
}
94 changes: 94 additions & 0 deletions src/edu/ucsb/cs56/drawings/ctc/advanced/ChristmasTree.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package edu.ucsb.cs56.drawings.ctc.advanced;
import java.awt.geom.GeneralPath;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Ellipse2D;

/**
A House

@author Phill Conrad
@version for CS56, W16, UCSB

*/

public class ChristmasTree extends Tree implements Shape
{
/**
* Constructor for objects of class Tree
*/
public ChristmasTree(double x, double y, double width, double height)
{
// construct the basic Tree shell
super(x,y,width,height);

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

// make three ornaments
//
// will use ellipses instead of circles cause they could be compressed

double t = 0.10 * width;
double treeHt = 0.25 * height;


Ellipse2D.Double orna1 =
new Ellipse2D.Double(x + width, y + 0.3 * height, 2.0 * t, treeHt);
Ellipse2D.Double orna2 =
new Ellipse2D.Double(x + 0.6 * width, y + 0.7 * height, 2.0 * t, treeHt);
Ellipse2D.Double orna3 =
new Ellipse2D.Double(x + 1.3 * width ,y + 1.1 * height, 2.0 * t, treeHt);

// add the ornaments to the tree
// Look up the meaning of the second parameter of append
// (Hint--is a method of "GeneralPath")

GeneralPath wholeTree = this.get();
wholeTree.append(orna1, false);
wholeTree.append(orna2, false);
wholeTree.append(orna3, false);

}
}






/*
public ChristmasTree(double x, double y, double width, double height)
{
// construct the basic tree shell
super(x,y,width,height);

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

// make christmas tree have four ornaments
//
//
//

double radius = 25;

Circle2 orna1 =
new Circle2(width, height, 0.5 * radius);
Circle2 orna2 =
new Circle2(0.3875 * width, 0.5357 * height, radius);
Circle2 orna3 =
new Circle2(0.9375 * width, 0.75 * height, radius);

// add the ornaments to the tree
// Look up the meaning of the second parameter of append
// (Hint--is a method of "GeneralPath")


GeneralPath wholeTree = this.get();
wholeTree.append(orna1, false);
wholeTree.append(orna2, false);
wholeTree.append(orna3, false);
}
}
*/
Loading