Skip to content

Commit

Permalink
code from 2012-04-18_09-11
Browse files Browse the repository at this point in the history
  • Loading branch information
hcientist committed Apr 18, 2012
1 parent c3fd8a4 commit 94af1ae
Show file tree
Hide file tree
Showing 13 changed files with 207 additions and 21 deletions.
Binary file added Hello - Java/Hello/Example.class
Binary file not shown.
5 changes: 5 additions & 0 deletions Hello - Java/Hello/Example.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#BlueJ class context
comment0.params=
comment0.target=Example()
comment0.text=\n\ Creates\ a\ new\ Example\ object.\n
numComments=1
33 changes: 33 additions & 0 deletions Hello - Java/Hello/Example.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

import student.*;

// -------------------------------------------------------------------------
/**
* Write a one-sentence summary of your class here.
* Follow it with additional details about its purpose, what abstraction
* it represents, and how to use it.
*
* @author your-pid (and if in lab, partner's pid on same line)
* @version (place the date here, in this format: yyyy.mm.dd)
*/
public class Example
{
//~ Instance/static variables .............................................



//~ Constructor ...........................................................

// ----------------------------------------------------------
/**
* Creates a new Example object.
*/
public Example()
{
/*# Do any work to initialize your class here. */
}


//~ Methods ...............................................................

}
4 changes: 2 additions & 2 deletions Hello - Java/Hello/Hello.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* Follow it with additional details about its purpose, what abstraction
* it represents, and how to use it.
*
* @author your-pid (and if in lab, partner's pid on same line)
* @version (place the date here, in this format: yyyy.mm.dd)
* @author tgm
* @version 2012.04.15
*/
public class Hello
{
Expand Down
Binary file modified Hello - Java/Hello/MaxRed.class
Binary file not shown.
4 changes: 3 additions & 1 deletion Hello - Java/Hello/MaxRed.ctxt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#BlueJ class context
comment0.params=args
comment0.target=void\ main(java.lang.String[])
numComments=1
comment1.params=
comment1.target=void\ maxGreen()
numComments=2
17 changes: 15 additions & 2 deletions Hello - Java/Hello/MaxRed.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,30 @@
*/
public class MaxRed
{

//~ Methods ...............................................................
public static void main (String[] args)
{
Picture p = new Picture(FileChooser.pickAFile());
p.show();
Pixel[] pixels = p.getPixels();
for (int i = 0; i < pixels.length; i++)
Pixel[ ] pixels = p.getPixels();
for (int i = 0; i < pixels.length; i++) // i++ is the same as i = i + 1 which is the same as i+=1
{
pixels[i].setRed(255);
}
p.repaint();
}

public void maxGreen()
{
Picture p = new Picture(FileChooser.pickAFile());
p.show();
Pixel[ ] pixels = p.getPixels();
for (int i = 0; i < pixels.length; i++) // i++ is the same as i = i + 1 which is the same as i+=1
{
pixels[i].setGreen(255);
}
p.repaint();
}

}
44 changes: 28 additions & 16 deletions Hello - Java/Hello/package.bluej
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
#BlueJ package file
package.editor.height=400
package.editor.width=560
package.editor.x=520
package.editor.y=155
package.editor.height=739
package.editor.width=1101
package.editor.x=59
package.editor.y=22
package.numDependencies=0
package.numTargets=2
package.numTargets=3
package.showExtends=true
package.showUses=true
project.charset=UTF-8
readme.editor.height=700
readme.editor.width=900
readme.editor.x=518
readme.editor.x=380
readme.editor.y=199
target1.editor.height=700
target1.editor.width=900
target1.editor.x=492
target1.editor.y=103
target1.editor.x=97
target1.editor.y=42
target1.height=50
target1.name=MaxRed
target1.name=Example
target1.naviview.expanded=true
target1.showInterface=false
target1.type=ClassTarget
target1.width=80
target1.x=160
target1.y=10
target1.x=380
target1.y=190
target2.editor.height=700
target2.editor.width=900
target2.editor.x=540
target2.editor.y=175
target2.editor.x=380
target2.editor.y=103
target2.height=50
target2.name=Hello
target2.naviview.expanded=true
target2.name=MaxRed
target2.showInterface=false
target2.type=ClassTarget
target2.width=80
target2.x=70
target2.x=160
target2.y=10
target3.editor.height=700
target3.editor.width=900
target3.editor.x=260
target3.editor.y=39
target3.height=50
target3.name=Hello
target3.naviview.expanded=true
target3.showInterface=false
target3.type=ClassTarget
target3.width=80
target3.x=70
target3.y=10
22 changes: 22 additions & 0 deletions TintPicture - Java/TintPicture/README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
------------------------------------------------------------------------
This is the project README file. Here, you should describe your project.
Tell the reader (someone who does not know anything about this project)
all he/she needs to know. The comments should usually include at least:
------------------------------------------------------------------------

Project Title:
Author(s):
Date:

Purpose
=======



How to Start This Project
=========================



User Instructions
=================
Binary file not shown.
13 changes: 13 additions & 0 deletions TintPicture - Java/TintPicture/TintablePicture.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#BlueJ class context
comment0.params=
comment0.target=TintablePicture()
comment0.text=\n\ Creates\ a\ new\ TintablePicture\ object.\n
comment1.params=
comment1.target=void\ tintPicture()
comment2.params=tintColor
comment2.target=void\ tintPicture(java.awt.Color)
comment3.params=p\ c
comment3.target=void\ tintPixel(Pixel,\ java.awt.Color)
comment4.params=c1\ c2
comment4.target=double\ distance(java.awt.Color,\ java.awt.Color)
numComments=5
65 changes: 65 additions & 0 deletions TintPicture - Java/TintPicture/TintablePicture.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

import student.*;
import java.awt.Color;

// -------------------------------------------------------------------------
/**
* Write a one-sentence summary of your class here.
* Follow it with additional details about its purpose, what abstraction
* it represents, and how to use it.
*
* @author your-pid (and if in lab, partner's pid on same line)
* @version (place the date here, in this format: yyyy.mm.dd)
*/
public class TintablePicture extends Picture
{
//~ Instance/static variables .............................................



//~ Constructor ...........................................................

// ----------------------------------------------------------
/**
* Creates a new TintablePicture object.
*/
public TintablePicture()
{
/*# Do any work to initialize your class here. */
this.load(FileChooser.pickAFile());
}

public void tintPicture()
{
this.tintPicture(ColorChooser.pickAColor());
}
public void tintPicture(Color tintColor)
{
Pixel[] pixels = this.getPixels();
for (int i = 0; i < pixels.length; i++)
{
this.tintPixel(pixels[i], tintColor);
}
}

public void tintPixel(Pixel p, Color c)
{
double newRed = p.getRed()/2 + c.getRed()/2;
double newGreen = p.getGreen()/2 + c.getGreen()/2;
double newBlue = p.getBlue()/2 + c.getBlue()/2;
System.out.println(newRed + " " + newGreen + " " + newBlue);
p.setColor(new Color((int)newRed, (int)newGreen, (int)newBlue));
}

//~ Methods ...............................................................
public double distance(Color c1, Color c2)
{
double red = Math.pow(c1.getRed()-c2.getRed(),2);
double green = Math.pow(c1.getGreen()-c2.getGreen(),2);
double blue = Math.pow(c1.getBlue()-c2.getBlue(),2);
double radicand = red + green + blue;

return Math.sqrt(radicand);
}

}
21 changes: 21 additions & 0 deletions TintPicture - Java/TintPicture/package.bluej
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#BlueJ package file
package.editor.height=400
package.editor.width=560
package.editor.x=79
package.editor.y=42
package.numDependencies=0
package.numTargets=1
package.showExtends=true
package.showUses=true
project.charset=UTF-8
target1.editor.height=700
target1.editor.width=900
target1.editor.x=333
target1.editor.y=38
target1.height=50
target1.name=TintablePicture
target1.showInterface=false
target1.type=ClassTarget
target1.width=120
target1.x=70
target1.y=10

0 comments on commit 94af1ae

Please sign in to comment.