SlideShare a Scribd company logo
https://www.youtube.com/watch?v=6bzHHmSKCbs
How to Allow Java Applets for physics labs
Windows 7
Open the lab
Copy and paste the lab site given to desired internet browser
Here I’m using google chrome, you can also use internet
explorer or firefox, same results
You will get a security warning click run. It may still not run…
If it doesn’t run go the start menu on your computer. Type java.
I click on the Java 32 bit under control panel.
Once opened properly it should look like this.
Click on the security tab, then click on edit site list
Once the exception site list is up click add
Type in the address given. Make sure to first type http:// you
do not need the entire site just the main web site title for
example http://phy.ntnu.edu.tw
then click add
It will say this is a risk, allow it (click continue) the school
would not give you a website that gives you a virus.
Now you are done. Simply reload your web page and you should
be able to run the java applet.
Note, we have used about 4 different lab sites that use java this
means you have to do this for every new website.
Sample Lab Report:
Please note:
This is a fairly nice lab report of an experiment that should
provide a guide to you for producing your own lab reports.
Your report should usually contain the following ingredients:
1. Introduction of the purpose of the experiment
2. Description of the measurement procedure
3. Listing of the data you obtained, with formulas used in
extraction of these data.
4. Graphic representation of your data and possible
comparison to theoretical
predictions
5. Discussion of possible errors and uncertainties
6. Conclusion with clearly stated outcomes of the experiment
Experiment: Bouncing Golf Ball
Introduction
In this experiment we used the PASCO Science Workshop
Equipment, KaliedaGraph, Microsoft Word and Excel, and a
golf ball in order to investigate the potential, total, and kinetic
energy of a ball that bounces off the ground. Our purpose is to
determine as precisely as possible how much energy is lost in
the bounce of the ball and to observe how well the energy is
conserved throughout the flight. We believe that if the air
resistance is neglected, then the ball that is dropped should
conserve total energy as it falls. However, because the ground is
not a totally elastic surface, some of the energy will be lost. We
will therefore observe the total energy as a function of time so
as to determine whether the energy is lost in the actual bounce
of the ball into an inelastic surface, or due to air friction.
Procedure
First we needed to set up the equipment which contained a
motion sensor and a golf ball. The golf ball was weighed and
the height of the sensor, h, was measured with the digital meter
on the sensor. The distance we are actually measuring, though,
is the distance between the ground and the sensor because we
are subtracting the distance from the motion sensor to the ball.
We need to correct for the diameter of the ball because the
distance from the motion sensor to the top of the ball is what
the sensor is measuring, not the distance from the sensor to the
ground. In order to do this we subtracted the diameter of the
ball from h.
Now that we were ready to begin the experiment, we held the
ball below the sensor enough so its position is recorded and we
began the recording and let the ball drop. After a few practice
drops, we chose the ‘best’ data that allowed us to see a graph of
d, the distance between the motion sensor and the ball versus
time. A graph was created in Science Workshop displaying our
data. More graphs and tables were then created.
Data and Observations
Formulas:
Kinetic energy = ½ m v2
Potential energy = m g h
Total energy = kinetic + potential energy
Kinetic energy is the energy an object has while in motion. An
object loses kinetic energy each time it hits a non-elastic
surface. Kinetic energy is dependent upon the mass of the object
and the velocity the object is moving with. The sharp decreases
at t = 1.2 and 2.0 s are where the ball hit the ground.
Potential energy is the possible amount of energy an object has
before any movement. Potential energy is dependent upon the
mass of the object, acceleration due to gravity and the height of
the object. Each time the object falls it loses potential energy
and each time it returns it gains potential energy. At t = 0.3, 1.2
and 2.0 s the ball hits the ground. This is because potential
energy is lowest when the ball hits the ground.
The total energy is the sum of both the kinetic and potential
energy. At t = 0.3, 1.2, and 2.0 s the ball is striking the ground.
We know this because at these times the ball has it’s lowest
amount of energy. This is a step-like function because when the
kinetic energy is at its peak, potential energy is at its valley,
and vice versa. This creates horizontal lines when they are
added.
Conclusions
Our purpose of the experiment was met because we were able to
successfully investigate and observe kinetic, potential, and the
total energy of a bouncing golf ball. From our observations, we
are able to conclude that the ball loses energy each and every
time the ball hits the ground and bounces back. This is
especially noticeable in the graph of the total energy. In regards
to air resistance versus elasticity, we concluded that the amount
of energy lost through air resistance is negligible compared to
the amount of energy lost through contact of the golf ball with
the ground.
During the motion of the ball, kinetic energy is not being
conserved but rather distributed into the ground. This energy
transfers because the ground is not an elastic surface. The total
energy slightly decreases also due to the inelasticity of the
bounce. The Law of Conservation of Energy does hold for this
case, however, because the energy is not being destroyed rather
it is being transferred.
Each bounce created a total energy loss of approximately 0.9 J.
The energy was lost in the actual bounce rather than in the air.
This is because if the ball bounced on an elastic surface, the
energy of each bounce would be roughly equal and the ball
would return to its starting height. Because the experiment did
not use a perfectly elastic surface, we can be fairly sure that the
bounce was the actual cause of the loss of total energy, rather
than the air resistance.
Prism: Reflection and Refraction
Web Site:
http://www.phy.ntnu.edu.tw/java/optics/prism_e.html
Introduction:
This Java applet let you play with a light source and a prism, to
study the physics of light.
Both reflection and refraction occur at the interface between
two media. (Even total internal reflection might also occur.)
Light will travel with different speed through different media,
which will result in both reflection and refraction.
For reflection: the angle of incidence is equal to angle of
reflection.
For refraction: Snell's law governs the angle
index of refraction for media 1 = n1; angle of incidence = 1
index of refraction for media 2 = n2; angle of refraction = 2
Snell’s Law: n1 sin 1 = n2 sin 2
Part of the energy is reflected and the rest propagate into new
media. This ratio depends on incident angle and index of
refraction (refracted angle).
Usage of this Applet:
Click the red region to change the light direction.
Click another region of light source and you can move the light
pen to different locations (even inside the prism).
Click one of the corner of the prism to change the shape of
prism.
Click inside the prism to change its location.
When tracing of the light will terminate when the ray intensity
is less than 0.4%.
The relative intensity for each ray is shown at the boundary.
The index of refraction for the prism is initially set at 1.5
Instructions:
1. Load up the Java Lab from the web site shown above.
2. Establish a new prism shape if you want, but keep it
generally the shape of what was is displayed at the start of this
experiment.
3. Change the index of refraction of the prism (n2) from 1.5
to 1.0 in increments of 0.1. Sketch the light rays for each value
of the index of refraction.
4. Reset the prism’s index of refraction (n2) back to 1.5.
5. For three different angles of incidence (either change the
shape of the prism, or move the light source around), use a
protractor to measure the angle of incidence of the light ray and
the corresponding angle of refraction. (Remember that both of
these angles are measured from the “normal”, i.e., the line
perpendicular to the surface at the point of incidence.)
6. Record your data, and compare your results to Snell’s Law.
(Assume that the angle of incidence is measured correctly, and
compare the angles of refraction.)
7. List all sources of error (and there should be plenty of
them).
8. Finally, write the report with your favorite word processor
or text editor and submit is to the instructor.
Use the “Sample Laboratory Report” as a guide in preparing
your lab report.
Any problems – please e-mail me. Also if you have any
complaints, comments, suggestions, or kudos concerning this
experiment, please e-mail me. It won’t help your class, but I
will take them into consideration for the next time this course is
offered.
optics/ABline.classsynchronizedclass ABline {
static double eps;
static double PI2;
int xa;
int ya;
int xb;
int yb;
double ca;
double cb;
double m;
double b;
double index;
double x;
double y;
double len;
double cta;
double alpha;
double r12p;
double r12s;
boolean total;
double rc;
double twoPI;
void draw(java.awt.Graphics);
void translate(int, int);
void setPoints(int, int, int, int);
double angle(double, double, double, double);
boolean touch(ray);
ray reflection(ray);
ray refraction(ray);
void ABline(double);
static void <clinit>();
}
optics/box.classpublicsynchronizedclass box extends
java.applet.Applet {
double time;
java.awt.Dimension area;
java.awt.Image bgImage;
java.awt.Image fgImage;
java.awt.Graphics gb;
java.awt.Graphics g;
java.awt.Color bgColor;
String rts;
String[] STR;
int xx;
int yy;
boolean rightClick;
int size;
int size2;
int size4;
int dragLight;
boolean changed;
int xs;
int ys;
java.awt.FontMetrics fm;
int chy;
int tx;
int ty;
int[] b;
int xc;
boolean display;
java.awt.Point[] light;
double len;
double index;
java.awt.Polygon hp;
java.awt.Polygon tp;
double PI6;
double LEN;
boolean showC;
public void init();
String d2String(double);
public boolean mouseDown(java.awt.Event, int, int);
public boolean mouseDrag(java.awt.Event, int, int);
public boolean mouseUp(java.awt.Event, int, int);
public boolean mouseMove(java.awt.Event, int, int);
void clear(boolean);
public void paint(java.awt.Graphics);
void drawPointer(java.awt.Point, java.awt.Point);
public void update(java.awt.Graphics);
void drawRay(double, double, double);
public void box();
}
optics/c1.gif
optics/c2.gif
optics/er.gif
optics/esp.gif
optics/eye.gif
optics/eyescan.gif
optics/fiber.classpublicsynchronizedclass fiber extends
java.applet.Applet {
double time;
java.awt.Dimension area;
java.awt.Image bgImage;
java.awt.Image fgImage;
java.awt.Graphics gb;
java.awt.Graphics g;
java.awt.Color bgColor;
String rts;
String[] STR;
java.awt.TextField tf;
int xs;
int ys;
boolean rightClick;
boolean draghead;
boolean dragtail;
java.awt.FontMetrics fm;
int chy;
int x1;
int y1;
int y2;
int xx;
int yy;
int dd;
java.awt.Point head;
java.awt.Point tail;
double m;
double b;
double x;
double y;
double sc2;
double tc2;
double n;
java.awt.Polygon hp;
java.awt.Polygon tp;
double PI6;
double LEN;
double cta;
public void init();
public boolean action(java.awt.Event, Object);
String d2String(double);
public boolean mouseDown(java.awt.Event, int, int);
public boolean mouseDrag(java.awt.Event, int, int);
public boolean mouseUp(java.awt.Event, int, int);
void clear();
public void paint(java.awt.Graphics);
public void update(java.awt.Graphics);
double drawIt(double, double, double);
void drawPointer(java.awt.Point, java.awt.Point);
public void fiber();
}
optics/fish.swf
optics/i.gif
optics/ie.gif
optics/image.classpublicsynchronizedclass image extends
java.applet.Applet implements Runnable {
java.awt.Dimension area;
java.awt.Image bgImage;
java.awt.Image fgImage;
java.awt.Graphics gb;
java.awt.Graphics g;
java.awt.Color bgColor;
String rts;
String[] STR;
int xx;
int yy;
int xs2;
int ys2;
boolean running;
Thread animThread;
long startTime;
long lastTime;
long delay;
long delta;
double c;
int cnt;
int ns;
double xt;
double yt;
double bt;
boolean rightClick;
boolean dragm;
boolean dragd;
boolean dragd2;
boolean down;
int xs;
int ys;
double cta1;
double cta2;
double ctaa;
double dd;
double PI2;
double m;
int ni;
int nf;
int n;
double V;
double dc2;
java.awt.FontMetrics fm;
int chy;
int xc;
int yc;
int size;
int size2;
int xm;
int ym;
int ym2;
int Nmax;
int NR;
int Nmax1;
double cta;
double rm;
double dc;
double[] CR;
double[] X;
double[] Y;
double[] VX;
double[] VY;
double cst;
int NI;
double[] PXA;
double[] PYA;
double[] PXB;
double[] PYB;
java.awt.Point na;
java.awt.Point nb;
public void init();
public void reset();
public void start();
public void stop();
public void run();
void advanced(double);
public boolean mouseDown(java.awt.Event, int, int);
public boolean mouseDrag(java.awt.Event, int, int);
void setupRay();
public boolean mouseUp(java.awt.Event, int, int);
void clear();
public void paint(java.awt.Graphics);
void imgs(double, double, double[], double[],
java.awt.Point);
public void update(java.awt.Graphics);
public void image();
}
optics/image_e.htmlMultiple
Reflection from two plane mirrors
Rays of lights are reflected from the mirror, each ray satisfying
the
law of reflection.
It is fun to play with two plane mirrors, multiple images are
formed.
Would you like to try it with this java applet?
The inverted moving fish (virtual image) is what the observer
(fish
on the left) will see underwater.
When the moving fish is away from the observer,
light emitter from the moving fish will be totally
reflected at the water-air interface.
So the water-air interface acting like a mirror.
When the distance is too short for the total internal reflection to
occurs,
the virtual image above the water vanished.
You can click and drag the observer left/right to change its
location.
More information will be shown when you drag the observer
(fish).Why does a fish appear to be closer to the surface of
water
than it really is?
The following java applet let you find out the answer,
and learn the physics of refraction, and total internal
reflection.
[removed]
[removed]
Usage:
A scanning eye represent the observer. You can click on it
and drag it to any position you like.
The whole screen will be clear when you drag the scanning eye.
You can draw any pattern you like, and the java program will
draw the
virtual image of it.
( If the virtual can be formed due to refraction or total internal
reflection)
When you draw in the water region,
the region where the total internal reflection
is possible, will be shown.
If you click the right mouse button, it will show you many light
rays
emitted.
(including refraction rays and total internal reflection
rays)
Right click the mouse button twice is another way to clear the
screen.to java applet
This is an image
You can draw any thing within the animation region,
for example: the object shown in the above image.
Light emitted from the object is refracted at the water and air
interface.
The observer trace back those refracted light to find the image
of
the object.
The image appear closer to the water surface and its shape is
different
from the object.
How to determine the location of the image (yellow dot) ?
The world viewed under water is different from what we view it
above
the water surface.
Drag the observer (eye) under the water and find out more
interesting
phenomena.
Your suggestions are highly appreciated! Please click
[email protected]Author¡GFu-Kwun Hwang, Dept. of physics,
National Taiwan Normal University
Last modified :
More
physics related java applets
optics/point.classsynchronizedclass point {
static java.awt.Graphics gb;
static java.awt.Rectangle r;
static double n;
static int cnt;
double x;
double y;
double vx;
double vy;
double v;
double c;
int status;
void set(double, double, double, double);
static void init(java.awt.Graphics, java.awt.Rectangle,
double);
point advanced(double);
void point(double, double, double, double);
}
optics/prism.classpublicclass prism extends java.applet.Applet {
double time;
java.awt.Dimension area;
java.awt.Image bgImage;
java.awt.Image fgImage;
java.awt.Graphics gb;
java.awt.Graphics g;
java.awt.Color bgColor;
int xx;
int yy;
boolean rightClick;
boolean movep;
boolean dragt;
boolean dragh;
boolean dragp;
int xs;
int ys;
boolean check;
double[] C;
double PI2;
java.awt.FontMetrics fm;
prisms p;
int chy;
int xa;
java.awt.Rectangle box;
java.awt.Point head;
java.awt.Point tail;
int N;
int n;
int N2;
double V;
ray light;
double I;
int size;
int size2;
double dist;
double angle;
java.awt.Polygon hp;
java.awt.Polygon tp;
double PI6;
double cta;
double ctaa;
double c2a;
double LEN;
double maxI;
int maxCnt;
int Cnt;
ABline AB;
public void init();
public void reset();
String d2String(double);
public boolean mouseDown(java.awt.Event, int, int);
public boolean mouseDrag(java.awt.Event, int, int);
public boolean mouseUp(java.awt.Event, int, int);
public void changeIndex(double);
void clear();
public void paint(java.awt.Graphics);
public void update(java.awt.Graphics);
void drawPointer(java.awt.Point, java.awt.Point);
ray drawRay(ray);
void drawTo(ray);
ABline getTouch(ray);
public void prism();
}
optics/prisms.classclass prisms {
int N;
int N1;
java.awt.Polygon P;
int xc;
int yc;
double[] L;
double[] C;
double PI2;
ABline[] AB;
java.awt.Rectangle r;
int size;
int size2;
double ax;
double ay;
double bx;
double by;
double ac;
double dv;
double c2a;
int dragID;
void prisms(int, int, double, double);
void setXY();
void setLine(int);
void drawPrism(java.awt.Graphics, java.awt.Color);
void drawAngles(java.awt.Graphics, int, int);
double angleAB(int, int, int);
void fillPrism(java.awt.Graphics, java.awt.Color);
void translate(int, int);
boolean checkDrag(int, int);
void drag(int, int);
}
optics/prism_e.html
Prism: Reflection and refraction
This java applet let you play with a light source and a prism, to
study
the physics of light.
There are reflection and refraction occurs at the interface
between
two media.
(Total internal reflection might also occurs)
[removed]
[removed]
[removed]
refractive indices: air (n1)=
prism(n2)=
Do not forget to hit ENTER key
Usage:
Click the red region to change the light direction.
Click other region of light source can move the light pen to
differ
location( even inside the prism).
Click one of the corner of the prism to change the shape of
prism.
Click inside the prism to change its location.
When tracing of the light will terminated when the ray intensity
is
less than than 0.4%.
The relative intensity for each ray is shown at the boundary.
Intensity of red and green are used to represent two different
polarization.
The yellow light (sum of red light and green light) represent
equal
intensity of two polarization waves.
At Brewster's angle, only one of the polarized light is refracted,
and
other one is totally reflected.
The index of refraction for the prism is 1.5
Things to watch:
1. Total internal reflection
2. Change in light intensity
3. There might be small bugs, did you find out?Light will travel
with different speed at different media,
which cause the reflection and refraction.
For reflection: the angle of incidence is equal to angle of
reflection.
For refraction: the Snell's law govern the angle
index of refraction for media 1:
angle of incidence
index of refraction for media 2:
angle of refraction
Part of the energy is reflected and the rest propagate into new
media.
The ratio depend on incident angle and index of refraction (
refracted
angle )
EM (transverse) wave can have two polarization (perpendicular
to each other and )
The intensity is proportional
to
The intensity of electric field changed when
reflection/refraction
occurs,
where ,
So the intensity for the reflected light
is proportional to
Since the energy is conserved, so we can find out the intensity
of
refraction light.
For normal incident, both
and equal to
zero.
The coefficient are the same =
For light emit from air (n=1.) into glass (n=1.5)
The electric field scale to = (1.5-1)/(1.5+1)=0.2
So the intensity of the reflection scale to 0.22=0.04 (
4% of incident light)
So 96% light will enter the glass and only 4% of light were
reflected.
This java applet use above equations to calculate the relative
intensity
of each ray.to java applet
Your suggestions are highly appreciated! Please click
[email protected]Author:Fu-Kwun Hwang, Dept. of physics,
National Taiwan Normal University
Last modified :
More
physics related java applets
optics/r12p.gif
optics/r12s.gif
optics/ray.classsynchronizedclass ray {
double x;
double y;
double cta;
double r;
double p;
boolean fromAir;
double eps;
java.awt.Color color(float);
void setAngle(int, int, int, int);
void setXY(int, int);
double intensity();
void ray(int, int);
void ray();
void ray(double, double, double, double, double, boolean);
}
optics/refraction.classpublicsynchronizedclass refraction
extends java.applet.Applet implements Runnable {
int yOffset;
double time;
java.awt.Dimension area;
java.awt.Image bgImage;
java.awt.Image fgImage;
java.awt.Graphics gb;
java.awt.Graphics g;
java.awt.Color bgColor;
String rts;
String[] STR;
int xx;
int yy;
boolean running;
Thread animThread;
long startTime;
long lastTime;
long delay;
long delta;
point p;
boolean rightClick;
java.awt.FontMetrics fm;
int chy;
int tx;
int ty;
int yc;
int xp;
int yp;
int N;
int ray2cnt;
double n;
point[] ray;
point[] ray2;
java.awt.Rectangle r;
double vw;
int size;
int size2;
public void init();
public boolean action(java.awt.Event, Object);
public void reset();
String d2String(double);
public void start();
public void stop();
public void run();
void advanced(double);
public boolean mouseDown(java.awt.Event, int, int);
public boolean mouseDrag(java.awt.Event, int, int);
public boolean mouseUp(java.awt.Event, int, int);
void clear();
public void paint(java.awt.Graphics);
public void update(java.awt.Graphics);
public void refraction();
}
optics/shadow.classpublicsynchronizedclass shadow extends
java.applet.Applet implements Runnable {
double time;
java.awt.Dimension area;
java.awt.Image bgImage;
java.awt.Image fgImage;
java.awt.Graphics gb;
java.awt.Graphics g;
java.awt.Color bgColor;
String rts;
String[] STR;
int xx;
int yy;
boolean running;
Thread animThread;
long startTime;
long lastTime;
long delay;
long delta;
boolean rightClick;
boolean dragr;
java.awt.FontMetrics fm;
int chy;
int tx;
int ty;
int x0;
int y0;
int size;
int size2;
int xc;
java.awt.Rectangle r;
java.awt.Rectangle s;
double m;
double b;
double x1;
double x2;
double y1;
double y2;
public void init();
public boolean action(java.awt.Event, Object);
public void reset();
String d2String(double);
public void start();
public void stop();
public void run();
void advanced(double);
public boolean mouseDown(java.awt.Event, int, int);
public boolean mouseDrag(java.awt.Event, int, int);
public boolean mouseUp(java.awt.Event, int, int);
void clear();
public void paint(java.awt.Graphics);
public void update(java.awt.Graphics);
public void shadow();
}
optics/shadow.html
標題
起頭
[removed]
[removed]
[removed]
使用說明:
物理解說:to java applet
歡迎批評指教! 電子郵件 : 請按 [email protected]
作者:國立台灣師範大學物理系黃福坤
最後修訂時間:
Mirrors
Web Site:
http://www.phy.ntnu.edu.tw/java/Lens/lens_e.html
Instructions:
1. Load up the Java Lab from the web site shown above.
2. Select “Mirror”
3. Press toggle button to “+” (if it’s not already shown) to
indicate a converging (concave) mirror.
4. Press the “Reset” button. The value of p (the object’s
location) should be 20.0, the value of q (the image location)
should be 20.0, the value of f should be +10.0, and “Paraxial”
should be checked)
5. Move the object (the blue arrow) to the following positions
(p): 30.0, 25.0, 20.0, 15.0, 10.0, and 5.0. (Click near tip of the
object, and drag it to where you want to place it, and then
release the mouse button.)
6. For each position of the object, record the location of the
image (q) and the type of image (real or virtual), as well as the
magnification (M) of the image.
7. Plot a graph showing the object’s position (x-axis) versus
the image position (y-axis).
8. Plot a graph of the object’s position (x-axis) versus the
magnification (y-axis).
9. Press the toggle button to “-“ to indicate a diverging
(convex) mirror.
10. Repeat steps 5 through 8 for this mirror.
11. Finally, write the report with your favorite word processor
or text editor and submit is to the instructor. In this report
discuss the effects produced when a mirror has a large
curvature.
Use the “Sample Laboratory Report” as a guide in preparing
your lab report.
Any problems – please e-mail me. Also if you have any
complaints, comments, suggestions, or kudos concerning this
experiment, please e-mail me. It won’t help your class, but I
will take them into consideration for the next time this course is
offered.
Lens/back.gif
Lens/lens.gif
Lens/Lens.html
Thin Lens (converging/diverging lens/mirrors)
[url=http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=704.
0]Equation for thin lens[/url]:
$frac{1}{p}+frac{1}{q}=frac{1}{f}$ where [b]p[/b] is
the distance between object and lens, [b]q[/b] is the distance
between image and lens, and [b]f[/b] is the focus length of lens.
blue linestrace of light pathgreen linesbackward tracing for
virtual imagesmall red linesdistances f and 2*f away from the
center of lens.1st textfieldcurrent mouse position (x , y) relative
to lenswhite vertical linereference line (you can click and drag
it left/right)yellow linelight path for paraxial ray
assumption(mirror only)
Parameters can be changed :
Select Lens for thin lens effect(default)select mirror for
concave/convex mirror effectdefault: assume paraxial ray (you
can turn it off)press toggle button +/- to change between
converging/diverginglensMove the objectclick near tip of the
object, and drag it to where you like it and release the mouse
button.Move the lens/mirror:click near center of the lens, and
drag it to left or right.if click with left mouse button, only lens
will move.if click with right mouse button, object will move
with lens.Change the focus length of the lens/mirrorclick near
the top/bottom of the lens/mirrir, then drag the mouse . Try it!if
you adjust the size of window, parameters reset to default
values.you can open more then one window to compare different
cases, close the created window to Quit. Press
[b]You are welcomed to check out a wonderful
[url=http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=139
5.0]thin Len flash animation[/url] created by a teacher in
Taiwan [/b]
[youtube=E2EmowDS0U4][youtube=HIZiiqGcwCc]
More advanced topic
[youtube=brTzn9VoGks][youtube=PlG6ps3i9bo]
This page is translated from Thin Lens (converging/diverging
lens/mirrors) by JoeBova ()
Lens/lens2.gif
Lens/LensWindow.classsynchronizedclass LensWindow extends
java.awt.Frame {
privatestatic boolean working;
boolean is_applet;
boolean is_lens;
int yOffset;
String[] STR;
java.awt.TextField textP;
java.awt.TextField textQ;
java.awt.TextField textF;
java.awt.TextField textM;
java.awt.Checkbox cThin;
java.awt.Button type;
java.awt.Dimension area;
int xc;
int yc;
double scale;
boolean thinMirror;
boolean objectmove;
boolean rightClick;
boolean moveLine;
int xp;
int yp;
String msg;
java.awt.Dimension offDimension;
java.awt.Image offImage;
java.awt.Graphics g;
int ox;
int oy;
int side;
double ix;
double iy;
double magnify;
boolean inrange;
boolean normal;
int lxc;
int lyc;
int lh;
double lr;
double lf;
int lwidth;
boolean moving;
boolean sizing;
int[] X;
int[] Y;
int cnt;
int x0;
int y0;
int ww;
int hh;
public void start();
public boolean handleEvent(java.awt.Event);
void init();
public boolean action(java.awt.Event, Object);
public void reset();
public boolean mouseDown(java.awt.Event, int, int);
public boolean mouseDrag(java.awt.Event, int, int);
public boolean mouseUp(java.awt.Event, int, int);
public boolean mouseMove(java.awt.Event, int, int);
private void writeXY(int, int);
public boolean mouseExit(java.awt.Event, int, int);
public void textInput(int, double);
public void paint(java.awt.Graphics);
public void update(java.awt.Graphics);
private void drawGrid(java.awt.Graphics);
private void writeText(java.awt.TextField, double);
public void drawRay(java.awt.Graphics);
String d2String(double);
private void drawit(java.awt.Graphics, int, int, int);
public void linit(int, int, int, double);
boolean lmouseDown(int, int);
boolean lmouseUp(int, int);
boolean lmouseDrag(int, int);
void lmove(int, int);
void lshow();
void LensWindow(String, boolean, String[]);
static void <clinit>();
}
Lens/thinLens.classpublicsynchronizedclass thinLens extends
java.applet.Applet {
String buttonText;
String windowTitle;
int windowWidth;
int windowHeight;
LensWindow m;
int windowCount;
java.awt.Color bgColor;
String rts;
String[] STR;
public void init();
private void go();
public boolean action(java.awt.Event, Object);
publicstatic void main(String[]);
private void begin();
public void thinLens();
}
Lens/thinLens.javaLens/thinLens.java// Modification history
// May 31,1997 fixed bug when object located at focus point
// May 22,1997 add paraxial ray option for mirror
// Feb 21,1997 major modification, almost rewritten the whole c
ode
// try without frame => very slow for netscape
// Nov. 3, 1996 impletemt double buffering
//-----------------------------------------------------
// written by Fu-Kwun Hwang
// I hope that you enjoy this applet
// Suggestions? E-mail to [email protected]
//-----------------------------------------------------
import java.awt.*;
publicclass thinLens extends java.applet.Applet{
String buttonText="start";
String windowTitle="Thin Lens demonstration by Fu-
Kwun Hwang(1996)";
int windowWidth =600;
int windowHeight =350;
LensWindow m;
int windowCount=0;
Color bgColor=newColor(0xC8,0xDF,0xD0);
String rts,STR[]={"Reset","p","q","f","m","lens","mirror","Para
xial"};
publicvoid init(){
setBackground(bgColor);
for(int i=0;i<STR.length;i++){
if((rts=getParameter(STR[i]))!=null)
STR[i]=newString(rts);
}
String str;
// get parameters
if((str=getParameter("buttonText"))!=null)
buttonText=str;
if((str=getParameter("windowTitle"))!=null)
windowTitle=str;
if((str=getParameter("windowWidth"))!=null)
windowWidth=Integer.parseInt(str);
if((str=getParameter("windowHeight"))!=null)
windowHeight=Integer.parseInt(str);
if((str=getParameter("autoStart"))!=null){
m =newLensWindow(windowTitle,true,STR);
go();
}
add(newButton(buttonText));
}
privatevoid go(){
m.resize(windowWidth,windowHeight);
m.show();
m.start();
}
publicboolean action(Event e,Object arg){
if(e.target instanceofButton&&
((String)arg).equals(buttonText)){
m =newLensWindow(String.valueOf(++windowCount)+
":"+
windowTitle,true,STR);
}
go();
returntrue;
}
//allow the applet to also run as an application.
publicstaticvoid main(String args[]){
new thinLens().begin();
}
privatevoid begin(){
m =newLensWindow(windowTitle,false,STR);
go();
}
}
classLensWindowextendsFrame{
boolean is_applet;
boolean is_lens=true;
int yOffset=30;
String STR[];
LensWindow(String title,boolean isapp,String[] s){
super(title);
is_applet=isapp;
setBackground(Color.lightGray);
STR=s;
init();
}
publicvoid start(){
reset();
repaint();
// lMirror.hide();
// cThin.hide();
}
publicboolean handleEvent(Event e){
if(e.id ==Event.WINDOW_DESTROY){
hide();
removeAll();
dispose();
if(!is_applet)System.exit(0);
}
returnsuper.handleEvent(e);
}
TextField textP,textQ,textF,textM;//,textR;
// Label lMirror;
Checkbox cThin;
Button type;
Dimension area;
int xc,yc;
double scale=10.;
void init(){
Panel p=newPanel();
// p.add(textR=new TextField(" X , Y",6));
p.add(newLabel(STR[1]));
p.add(textP=newTextField("10.",2));
p.add(newLabel(STR[2]));
p.add(textQ=newTextField("10.",2));
p.add(newLabel(STR[3]));
p.add(type=newButton("+"));
p.add(textF=newTextField("5.",2));
p.add(newLabel(STR[4]));
p.add(textM=newTextField("1.",2));
Choice c;
p.add(c=newChoice());
c.addItem(STR[5]);
c.addItem(STR[6]);
p.add(newButton(STR[0]));
// p.add(lMirror=new Label());
p.add(cThin=newCheckbox(STR[7]));
cThin.setState(true);
cThin.show();
thinMirror=cThin.getState();
add("North",p);
show();
}
boolean thinMirror=true;
publicboolean action(Event ev,Object arg){
if(ev.target instanceofButton){
String label =(String)arg;
if(label.equals(STR[0]))reset();
else{
if(label.equals("+")) type.setLabel("-");
elseif(label.equals("-")) type.setLabel("+");
lf*=-1.;
repaint();
}
}elseif( ev.target instanceofTextField){
String label =(String)arg;
double value;
value=Double.valueOf(label).doubleValue();
if(ev.target==textP)
textInput(1,value);
elseif(ev.target==textQ)
textInput(2,value);
elseif(ev.target==textF)
textInput(3,value);
elseif(ev.target==textM)
textInput(4,value);
repaint();
}elseif(ev.target instanceofChoice){
String label =(String)arg;
if(label.equals(STR[5])){
is_lens=true;
// lMirror.hide();
// cThin.hide();
}else{
is_lens=false;
// lMirror.show();
cThin.show();
show();
}
lshow();
repaint();
}elseif(ev.target instanceofCheckbox){
thinMirror=cThin.getState();
lshow();
repaint();
}
returntrue;
}
publicvoid reset(){
area=size();
area.height-=yOffset;
xc=area.width/2;
yc=area.height/2;
double ff=10.*scale;
type.setLabel("+");
textF.setText(Double.toString(ff));
linit(xc,yc,(int)(0.7*yc),ff);
xc-=(int)(2.*lf);// initial object position
yc=yc*3/4;
repaint();
}
boolean objectmove=false,rightClick=false,moveLine=false;
int xp,yp;// vertical reference line
publicboolean mouseDown(Event e,int x,int y){
y-=yOffset;
if(Math.abs(x-xp)<5)moveLine=true;
elseif(!lmouseDown(x,y)){
if(Math.abs(x-xc)<5){
xc=x;
yc=y;
repaint();
objectmove=true;
}
}
if(e.modifiers==Event.META_MASK)//"Right Click, ";
rightClick=true;
returntrue;
}
publicboolean mouseDrag(Event e,int x,int y){
y-=yOffset;
if(working)returntrue;
if(lmouseDrag(x,y)){
if(rightClick)xc=lxc-ox;// also move objects
repaint();// change lens
}elseif(objectmove){// move object
if(!is_lens && x>lxc || lh<Math.abs(y-lyc))returntrue;
xc=x;
yc=y;
if(rightClick)lxc=xc+side*ox;// also move lens
writeXY(x,y);
repaint();
}elseif(moveLine){
xp=x;
yp=y;
writeXY(x,y);
repaint();
}
returntrue;
}
publicboolean mouseUp(Event e,int x,int y){
y-=yOffset;
lmouseUp(x,y);
objectmove=false;
rightClick=false;
moveLine=false;
repaint();
returntrue;
}
publicboolean mouseMove(Event evt,int x,int y){
y-=yOffset;
if(working)returntrue;
if(!objectmove)writeXY(x,y);
repaint();
returntrue;
}
String msg=" X , Y";
privatevoid writeXY(int x,int y){
//textR.setText(
msg=
Double.toString((int)(10.*(lxc-x)/scale)/10.)+
","+
Double.toString((int)(10.*(lyc-y)/scale)/10.);
}
publicboolean mouseExit(Event evt,int x,int y){
y-=yOffset;
// textR.setText(" X , Y");
msg=" X , Y";
repaint();
returntrue;
}
publicvoid textInput(int type,double value){
switch(type){
case1:// P
xc=lxc-(int)(value*scale);
break;
case2:// Q
xc=lxc-(int)(1./(1./lf-1./(scale*value)));
break;
case3:// F
lf=value*scale;
break;
case4:// M
xc=lxc-(int)(Math.abs((1.-1./value)*lf));
Colors
Web Site:
http://www.phy.ntnu.edu.tw/java/image/rgbColor.htmlOR
http://users.hal-
pc.org/~clement/Simulations/Mixing%20Colors/rgbColor.html
(Either website will work for this lab-please use whichever one
loads for you!)
Introduction:
Thomas Young, in the early 1800s, showed that a broad range of
colors can be generated by mixing three beams of light,
provided their frequencies were widely separately. When three
such beams combine to produce white light, they are called
primary colors.
There is no single unique set of these primaries, nor do they
have to be made up of single (monochromatic) colors.
The three components (emitted by three phosphors) that
generate the whole gamut of hues as seen on a color TV set are
Red, Green, and Blue. These are the primary colors.
Looking through a colored window or cloth is another story.
Yellow cloth, paper, dye, paint, and ink all selectively absorb
blue, and reflect what remains – yellow. And that is why they
appear yellow.
When dealing with pigments (paints), the primary pigments are
yellow, magenta (a light violet color), and cyan (a bluish-green
hue).
This Java applet let you play with mixing light beams and paint
pigments.
Instructions:
1. Load up the Java Lab from the web site shown above.
2. Click the right mouse button twice quickly to switch
between two different modes:
a. Mixing light beams (black background)
b. Mixing paint pigments (white background)
3. Set the screen for mixing light beams.
4. Click the left mouse button and drag one of the colored
ovals to move it around.
5. Determine what colors are obtained when two of the ovals
intersect each other. Do this for all combinations of two ovals.
6. What color is obtained when the three ovals intersect each
other?
7. Set the screen for mixing paint pigments.
8. Repeat steps 4 through 6 for paint pigments.
9. Finally, write the report telling what results were obtained
in this experiment with your favorite word processor or text
editor and submit is to the instructor.
Use the “Sample Laboratory Report” as a guide in preparing
your lab report.
Any problems – please e-mail me. Also if you have any
complaints, comments, suggestions, or kudos concerning this
experiment, please e-mail me. It won’t help your class, but I
will take them into consideration for the next time this course is
offered
colors_java/back.gif
colors_java/fkhSprite.classsynchronizedclass fkhSprite extends
java.awt.Rectangle {
staticfinal double PI2 = 1.5707963267948966;
int[] pix;
int index;
int color;
void init(int, int, int, int);
void init(int, int, int, int, java.awt.Color);
void setColor(java.awt.Color);
void setColor(int);
void transparent(java.awt.Color);
void eraseBackground(java.awt.Color);
void fillOval();
void Circles(int, java.awt.Color);
void fkhSprite(int, int);
void fkhSprite(int, int, int, int);
void fkhSprite(int, int, int, int, java.awt.Color);
void fkhSprite(int, int, int, int, java.awt.Image);
}
colors_java/fkhStage.classsynchronizedclass fkhStage extends
fkhSprite {
staticfinal int COPY = 0;
staticfinal int OR = 1;
staticfinal int AND = 2;
int Npts;
int count;
java.util.Vector objs;
boolean changed;
java.awt.Rectangle tmp;
int id;
fkhSprite sprite;
int mode;
void makeClone();
void dirty();
boolean isDirty();
void clean();
public int which(int, int);
public void Drag(int, int, int);
fkhSprite addImage(int, int, int, int, java.awt.Image,
java.awt.Color);
fkhSprite fillOval(int, int, int, int, java.awt.Color);
void drawCircuits(int, int, int, int, java.awt.Color);
void flush();
void setMode(int);
int getColor(int, int);
void operate(fkhSprite, int);
void fkhStage(int, int);
}
colors_java/fkhStage.javacolors_java/fkhStage.javaimport java.
awt.*;
import java.awt.image.*;
import java.util.*;
class fkhStage extends fkhSprite{
intNpts,count;
Vector objs=newVector();
boolean changed=false;
fkhStage(int w,int h){
super(w,h);
}
Rectangle tmp;
void makeClone(){
tmp=(Rectangle)objs.elementAt(0);
for(int i=1;i<count;i++)
tmp=tmp.union((Rectangle)objs.elementAt(i));
tmp=intersection(tmp);
pix=newint[tmp.width*tmp.height];
}
void dirty(){
changed=true;
}
boolean isDirty(){
return changed;
}
void clean(){
changed=false;
}
int id=-1;
fkhSprite sprite;
publicint which(int xi,int yi){
id=-1;
for(int i=0;i<count;i++){
sprite=(fkhSprite)objs.elementAt(i);
if(sprite.inside(xi,yi)){
id=i;
break;
}
}
return id;
}
publicvoidDrag(int i,int dx,int dy){
if(id!=-1){
sprite.x+=dx;
sprite.y+=dy;
dirty();
}
}
fkhSprite addImage(int xi,int yi,int w,int h,Image img,Color
bgColor){
fkhSprite member=new fkhSprite(xi,yi,w,h,img);
member.eraseBackground(bgColor);//transparent
objs.addElement(member);
dirty();
return member;
}
fkhSprite fillOval(int xi,int yi,int w,int h,Color c){
fkhSprite member=new fkhSprite(xi,yi,w,h,c);
member.fillOval();
objs.addElement(member);
dirty();
return member;
}
void drawCircuits(int w,int h,int ri,int N,Color c){
fkhSprite member=new fkhSprite(0,0,w,h);
member.Circles(ri/N,c);
objs.addElement(member);
dirty();
}
void flush(){
count=objs.size();
if(changed)makeClone();
elsereturn;
// if(objs==null)return;
operate((fkhSprite)objs.elementAt(0),COPY);
if(count>0)for(int i=1;i<count;i++){
operate((fkhSprite)objs.elementAt(i),mode);
}
clean();
}
int mode=OR;// or and
finalstaticint COPY=0,OR=1,AND=2;
void setMode(int newmode){
mode=newmode;
dirty();
}
int getColor(int dx,int dy){
if(tmp!=null&& inside(dx-=tmp.x,dy-
=tmp.y))return pix[dy*tmp.width+dx];
elsereturn0;
}
void operate(fkhSprite src,int mode){
int dd,id,xmin=0,xmax=src.width,ymin=0,ymax=src.height;
int id0,xmin0=0,xmax0=tmp.width,ymin0=0,ymax0=tmp.height;
int[] pixs=src.pix;
if(src.x>tmp.x) xmin0=src.x-tmp.x;
else xmin=tmp.x-src.x;
if(src.x+src.width>tmp.x+tmp.width)xmax=tmp.x+tmp.width-
src.x;
else xmax0=src.x+src.width-tmp.x;
if(src.y>tmp.y) ymin0=src.y-tmp.y;
else ymin=tmp.y-src.y;
if(src.y+src.height>tmp.y+tmp.height)ymax=tmp.y+tmp.height-
src.y;
else ymax0=src.y+src.height-tmp.y;
dd=(ymin0-ymin)*tmp.width+xmin0;
switch(mode){
case COPY:
for(int i=ymin;i<ymax;i++){
id0=i*tmp.width+dd;
id=i*src.width+xmin;
for(int j=xmin;j<xmax;j++){
pix[id0++]= pixs[id++];
// if(pixs[id]!=0)pix[id0++] =pixs[id++] ;
}
}
break;
case OR:
for(int i=ymin;i<ymax;i++){
id0=i*tmp.width+dd;
id=i*src.width+xmin;
for(int j=xmin;j<xmax;j++){
pix[id0++]|= pixs[id++];
}
}
break;
case AND:
for(int i=ymin;i<ymax;i++){
id0=i*tmp.width+dd;
id=i*src.width+xmin;
for(int j=xmin;j<xmax;j++,id0++,id++){
if(pix[id0]==0) pix[id0]= pixs[id];
elseif(pixs[id]!=0)pix[id0]&= pixs[id];
}
}
break;
}
}
}
class fkhSprite extendsRectangle{
int[] pix;
int index,color=0;
fkhSprite(int w,int h){
x=y=0;
width=w;
height=h;
}
fkhSprite(int xi,int yi,int w,int h){
init(xi,yi,w,h);
}
fkhSprite(int xi,int yi,int w,int h,Color c){
init(xi,yi,w,h,c);
}
/* How to use this
Image img=createImage(width,height); // in applets
Graphics g=sprite.getGraphic();
g.setColor(Color.yellow); g.fillOval(x,y,w,h);//drawing work
s
fkhSprite sprite=new fkhSprite(x,y,w,h,img);
*/
fkhSprite(int xi,int yi,int w,int h,Image img){
init(xi,yi,w,h);
PixelGrabber pg =newPixelGrabber(img, x, y, w, h, pix,0, w);
try{
pg.grabPixels();
}catch(InterruptedException e){
System.err.println("interrupted waiting for pixels!");
return;
}
}
void init(int xi,int yi,int w,int h){
x=xi;
y=yi;
width=w;
height=h;
pix=newint[w*h];
}
void init(int xi,int yi,int w,int h,Color c){
init(xi,yi,w,h);
index=0;
color=c.getRGB();
for(int i=0;i<height;i++)
for(int j=0;j<width;j++)pix[index++]=color;
}
void setColor(Color c){
setColor(c.getRGB());
}
void setColor(int value){
int N=width*height;
for(int i=0;i<N;i++)
if(pix[i]!=0)pix[i]=value;
}
void transparent(Color bgColor){
int value=bgColor.getRGB();
int N=width*height,code=0xFFFFFF;
for(int i=0;i<N;i++)
if(pix[i]==value)pix[i]&=code;
}
void eraseBackground(Color bgColor){
int value=bgColor.getRGB();
int N=width*height;
for(int i=0;i<N;i++)
if(pix[i]==value)pix[i]=0;
}
void fillOval(){
double w=width/2.,h=height/2.,w2=w*w,h2=h*h;
int wi=(int)w,hi=(int)h,ww=width-1,hh=height-1,
dd=hh*width;
for(int i=0;i<hi;i++){
for(int j=0;j<wi;j++){
if((i-h)*(i-h)/h2+(j-w)*(j-w)/w2>1.){
index=i*width;
pix[index+j]=0;
pix[index+ww-j]=0;
index=dd-index;
pix[index+j]=0;
pix[index+ww-j]=0;
}elsebreak;
}
}
}
finalstaticdouble PI2=Math.PI/2.;
voidCircles(int dr,Color clr){
double dc,cmax;
int xc=width/2,yc=height/2,r;
int xx,yy,color=clr.getRGB(),id0=yc*width+xc,id;
intNmax=width*height;
for(r=dr;r<xc;r+=dr){
dc=1./r;
cmax=PI2*r+dc;
for(double c=0.;c<PI2;c+=dc){
xx=(int)(r*Math.cos(c));
yy=(int)(r*Math.sin(c));
//if(xx<xc && yy<yc){
if((id=id0+yy*width+xx)<Nmax){
pix[id]=color;
pix[id-=2*xx]=color;
if((id-=2*yy*width)>0){
pix[id]=color;
pix[id+=2*xx]=color;
}
}
}
}
}
}
colors_java/image.classpublicsynchronizedclass image extends
java.applet.Applet {
static boolean free;
int yOffset;
double time;
double ts;
java.awt.Dimension area;
java.awt.Image bgImage;
java.awt.Image fgImage;
java.awt.Graphics gb;
java.awt.Graphics g;
java.awt.Color bgColor;
boolean running;
boolean rightClick;
boolean dragging;
int xs;
int ys;
int id;
java.awt.FontMetrics fm;
int chy;
fkhStage stage;
java.awt.Image img;
int xc;
int yc;
int dr;
int xx;
int yy;
int size;
int size2;
int xp;
int yp;
double r1;
double r2;
public void init();
public boolean action(java.awt.Event, Object);
public void reset(boolean);
String d2String(double);
public boolean mouseDown(java.awt.Event, int, int);
public boolean mouseDrag(java.awt.Event, int, int);
public boolean mouseUp(java.awt.Event, int, int);
void clear();
public void paint(java.awt.Graphics);
public void update(java.awt.Graphics);
public void image();
static void <clinit>();
}
colors_java/image.javacolors_java/image.java// template file for
java applet
import java.awt.*;
import java.awt.image.*;
import java.util.*;
publicclass image extends java.applet.Applet{// implements Run
nable{
int yOffset=0;
//TextField timeField; //record time elapse
double time=0.0,ts=0.;
Dimension area;
Image bgImage,fgImage;
Graphics gb,g;//background drawing
Color bgColor=Color.cyan;//lightGray;
publicvoid init(){
setBackground(bgColor);
area=size();
/* area.height-=yOffset;
Panel p=new Panel();
//p.add(timeField=new TextField("0.0",4));
p.add(new Button("Reset"));
p.add(new Button("Start"));
add("North",p);*/
// add("South",img=new fkhImage(area.width,area.height,bg
Color));
reset(true);// false for auto start
}
publicboolean action(Event ev,Object arg){
if(ev.target instanceofButton){
String label =(String)arg;
if(label.equals("Reset")){
reset(true);
}elseif(label.equals("Start")){
running=true;
start();
}
}
returntrue;
}
// int xx=50,yy=50,w=100,h=100;
publicvoid reset(boolean status){
clear();
// stop();
//if(status){
// ts=time=0.;
// timeField.setText("0.00");
//}
}
String d2String(double value){
float f=(float)((int)(value*10.)/10.);
String str=String.valueOf(f);
if(str.indexOf(".")==-1)str+=".0";
return str;
}
// animation code
boolean running=false;
/*
Thread animThread;
long startTime=0,lastTime;
long delay=50,delta;
// This starts the threads.
public void start(){
//Start animating!
if (animThread == null) {
animThread = new Thread(this);
animThread.start();
}
//Remember the starting time. of thread
lastTime=startTime = System.currentTimeMillis();
time=0.;
}
public void stop() {
//Stop the animating thread.
animThread = null;
running=false;
}
public void run() {
//Just to be nice, lower this thread's priority
Thread.currentThread().setPriority(Thread.MIN_PRIORIT
Y);
//This is the animation loop.
while (Thread.currentThread() == animThread) {
//Advance the animation frame. with delta time
delta=System.currentTimeMillis()-lastTime;
lastTime+=delta;
if(running)advanced(delta/1000.);
startTime+=delay;
try {
animThread.sleep(Math.max(0,startTime-
System.currentTimeMillis()));
} catch (InterruptedException e) {
break;
}
}
}
void advanced(double dt){
//time+=dt;
//ts+=dt;
//if(ts>1.){
// ts-=1.;
// timeField.setText(String.valueOf(time));
//}
// .advanced(dt);
//repaint();
}
*/
boolean rightClick=false,dragging=false;
int xs,ys,id;
publicboolean mouseDown(Event e,int x,int y){
if((y-=yOffset)<0)returnfalse;
if(e.modifiers==Event.META_MASK){//"Right Click, ";
rightClick=true;
dragging=true;
}else{
rightClick=false;
/// id=stage.which(x,y);
//if(x-xx<w && y-yy<h)
// if(id>-1)
repaint();
}
xs=x;
ys=y;
running=!running;
returntrue;
}
publicboolean mouseDrag(Event e,int x,int y){
if(!free ||(y-=yOffset)<0)returnfalse;
if(dragging){
// stage.Drag(id,x-xs,y-ys);
xx+=x-xs;
yy+=y-ys;
repaint();
}
xs=x;
ys=y;
returntrue;
}
publicboolean mouseUp(Event e,int x,int y){
if((y-=yOffset)<0)returnfalse;
if(rightClick){
running=!running;
}
dragging=false;
returntrue;
}
FontMetrics fm;
int chy;
fkhStage stage;
Image img;
int xc,yc,dr=6,xx,yy;
int size=2,size2=2*size;
void clear(){
if(g==null){
bgImage = createImage(area.width, area.height);
gb = bgImage.getGraphics();
fgImage = createImage(area.width, area.height);
g = fgImage.getGraphics();
fm=gb.getFontMetrics();
chy=fm.getHeight();
stage=new fkhStage(area.width,area.height);
xc=area.width/2;
yc=area.height/2;
xs=xc+12*dr;
ys=yc-20*dr;
}
gb.setColor(bgColor);
gb.fillRect(0,0, area.width, area.height);
Color clr=Color.gray;
gb.setColor(clr);//Color.black);
for(int i=0,xi=xc-dr,yi=yc-dr,dx=2*dr;xi>0;xi-=dr,yi-
=dr,dx+=2*dr)
gb.drawOval(xi,yi,dx,dx);
gb.setColor(Color.red);
gb.fillOval(xc-size,yc-size,size2,size2);
// gb.setColor(Color.black);
// gb.drawRect(0,0,area.width-1,area.height-1);
stage.drawCircuits(area.width,area.height,xc,xc/dr,clr);//C
olor.black);//magenta);//red);
xx=6*dr;
if(stage.isDirty()){
stage.flush();
img=createImage(newMemoryImageSource(stage.tmp.w
idth, stage.tmp.height, stage.pix,0, stage.tmp.width));
// xx=xc+2*dr;
}
// stage.drawCircuits(60,50,200,20,Color.black);//magenta);/
/red);
// stage.fillOval(50,50,200,100,Color.magenta);//red);
// stage.fillOval(150,60,200,100,Color.yellow);//blue);/
// stage.fillOval(30,80,100,100,Color.cyan);//green);
// repaint();
}
publicvoid paint(Graphics gs){
update(gs);
}
staticboolean free=true;
int xp,yp;
double r1,r2;
publicvoid update(Graphics gs){
free=false;
g.drawImage(bgImage,0,0,this);
// if(img!=null)g.drawImage(img,stage.tmp.x,stage.tmp.y,thi
s);
if(img!=null)g.drawImage(img,xx,yy,this);
xp=xx+xc;
yp=yy+yc;
g.setColor(Color.red);
g.fillOval(xp-size,yp-size,size2,size2);
if(!dragging){
g.setColor(Color.blue);//yellow);
// g.drawLine(xp,yp,xc,yc);
g.drawLine(xc,yc,xs,ys);
g.drawLine(xp,yp,xs,ys);
// g.setColor(Color.blue);
r2=Math.sqrt((xp-xs)*(xp-xs)+(yp-ys)*(yp-ys))/dr;
r1=Math.sqrt((xc-xs)*(xc-xs)+(yc-ys)*(yc-ys))/dr;
g.drawString("r1 = "+d2String(r1)+", r2 = "+d2String(r2)
+
", r1-r2 = "+d2String(r1-r2),10,chy);
}
gs.drawImage(fgImage,0, yOffset,this);
free=true;
}
}
colors_java/rgb.gif
colors_java/RGBcolor - Shortcut.lnk
colors_java/RGBcolor.html
Colors (Mixing color or paint: R/G/B)
Thomas Young, in the early 1800s, showed that a broad range of
colors can be generated by mixing three beams of light,
provided their frequencies were widely separately.
When three such beams combine to produce white light, there
are called primary colors.
There is no single unique set of these primaries, nor do they
have to be monochromatic.
The three components (emitted by three phoshors) that generate
the whole gamut of hues seen on a color TV set are Red, Green,
Blue.
Looking through a colored window or cloth is another story.
Yellow cloth, paper, dye, paint, and ink all selectively absorb
blue and reflect what remains - yellow - and that is why they
appear yellow.
This java applet let you play with mixing light beams and paint
pigments.
[removed]
[removed]
[removed]
[removed]
Click the right mouse button twice quickly to switch between
two different modes:
ModebackgroundMixing light beamsblackMixing paint
pigmentswhite
Click left mouse button and drag one of the colored oval to
move it around.
Enter RGB values into the text field to change the color of the
selected oval.
The color code (RGB value) at the mouse tip are shown in
colored background.
This page is translated from Colors (Mixing color or paint:
R/G/B) by JoeBova ()
colors_java/rgbLight.classpublicsynchronizedclass rgbLight
extends java.applet.Applet {
staticfinal int PAINT = 1;
staticfinal int LIGHT = 0;
static boolean free;
int yOffset;
java.awt.Dimension area;
java.awt.Image bgImage;
java.awt.Image fgImage;
java.awt.Graphics gb;
java.awt.Graphics g;
java.awt.TextField[] tf;
java.awt.Label lbr;
java.awt.Label lbg;
java.awt.Label lbb;
java.awt.Label ltype;
String rts;
String[] STR;
java.awt.Color bgColor;
boolean rightClick;
boolean dragging;
int xs;
int ys;
int id;
java.awt.FontMetrics fm;
int chy;
fkhStage stage;
fkhSprite[] OBJ;
java.awt.Image img;
int xc;
int yc;
int dr;
int xx;
int yy;
int size;
int size2;
java.awt.Color[] clr1;
java.awt.Color[] clr2;
java.awt.Color[] clr;
int mode;
int N;
int xp;
int yp;
double r1;
double r2;
public void init();
public boolean action(java.awt.Event, Object);
int cValue(java.awt.TextField);
String d2String(double);
public boolean mouseDown(java.awt.Event, int, int);
void showValue();
public boolean mouseDrag(java.awt.Event, int, int);
public boolean mouseUp(java.awt.Event, int, int);
public boolean mouseMove(java.awt.Event, int, int);
void showRGB(int, int);
void setMode(int);
void clear();
public void paint(java.awt.Graphics);
public void update(java.awt.Graphics);
public void rgbLight();
static void <clinit>();
}
colors_java/rgbLight.javacolors_java/rgbLight.javaimport java.a
wt.*;
import java.awt.image.*;
import java.util.*;
publicclass rgbLight extends java.applet.Applet{// implements
Runnable{
int yOffset=40;
Dimension area;
Image bgImage,fgImage;
Graphics gb,g;//background drawing
// Color bgColor=Color.cyan;//white;//cyan;//lightGray;
// String tfl[]={"R","G","B"};
TextField tf[]=newTextField[3];
Label lbr,lbg,lbb,ltype;
String rts,STR[]={"R","G","B","MSG1","MSG2"};
Color bgColor=newColor(0xC8,0xDF,0xD0);
publicvoid init(){
for(int i=0;i<STR.length;i++){
if((rts=getParameter(STR[i]))!=null)
STR[i]=newString(rts);
}
setBackground(bgColor);
Panel p=newPanel();
p.add(ltype=newLabel(STR[3]+" "));
p.add(lbr=newLabel(" "));
lbr.setBackground(Color.red);
p.add(lbg=newLabel(" "));
lbg.setBackground(Color.green);
p.add(lbb=newLabel(" "));
for(int i=0;i<3;i++){
p.add(newLabel(STR[i]));
p.add(tf[i]=newTextField(2));
}
lbb.setBackground(Color.blue);
lbb.setForeground(Color.white);
add("North",p);
area=size();
clear();
}
publicboolean action(Event ev,Object arg){
if(id!=-1&& ev.target instanceofTextField){
try{
Color c=newColor(cValue(tf[0]),cValue(tf[1]),cValue(tf[2]));
clr[id]=c;
OBJ[id].setColor(c);
stage.dirty();
repaint();
}catch(NumberFormatException e){
showValue();
}
}
returntrue;
}
int cValue(TextField t){
int value=(int)Integer.parseInt(t.getText())%256;
t.setText(String.valueOf(value));
return value;
}
String d2String(double value){
float f=(float)((int)(value*10.)/10.);
String str=String.valueOf(f);
if(str.indexOf(".")==-1)str+=".0";
return str;
}
boolean rightClick=false,dragging=false;
int xs,ys,id;
publicboolean mouseDown(Event e,int x,int y){
if((y-=yOffset)<0)returnfalse;
if(e.modifiers==Event.META_MASK){//"Right Click, ";
rightClick=true;
if(e.clickCount==2){
if(mode==LIGHT)setMode(PAINT);
else setMode(LIGHT);
for(int i=0;i<N;i++)OBJ[i].setColor(clr[i]);
repaint();
showRGB(x, y);
}
}else{
rightClick=false;
dragging=true;
id=stage.which(x,y);
showValue();
}
xs=x;
ys=y;
returntrue;
}
void showValue(){
if(id!=-1)for(int i=0;i<STR.length;i++){
tf[0].setText(String.valueOf(clr[id].getRed()));
tf[1].setText(String.valueOf(clr[id].getGreen()));
tf[2].setText(String.valueOf(clr[id].getBlue()));
}
}
publicboolean mouseDrag(Event e,int x,int y){
if(!free ||(y-=yOffset)<0)returnfalse;
if(dragging){
stage.Drag(id,x-xs,y-ys);
xx+=x-xs;
yy+=y-ys;
repaint();
showRGB(x, y);
}
xs=x;
ys=y;
returntrue;
}
publicboolean mouseUp(Event e,int x,int y){
if((y-=yOffset)<0)returnfalse;
dragging=false;
returntrue;
}
publicboolean mouseMove(Event e,int x,int y){
if(dragging ||(y-=yOffset)<0)returnfalse;
showRGB(x,y);
returntrue;
}
void showRGB(int x,int y){
int value=stage.getColor(x,y);
Color c;
if(value==0)c=clr[3];
else c=newColor(value);
//clb.setText("("+c.getRed()+","+c.getGreen()+","+c.getBlue()+
")");
lbr.setText(String.valueOf(c.getRed()));
lbg.setText(String.valueOf(c.getGreen()));
lbb.setText(String.valueOf(c.getBlue()));
}
FontMetrics fm;
int chy;
fkhStage stage;
fkhSprite OBJ[]=new fkhSprite[3];
Image img;
int xc,yc,dr=6,xx,yy;
int size=2,size2=2*size;
Color clr1[]={Color.red,Color.green,Color.blue,Color.black};
Color clr2[]={Color.cyan,Color.magenta,Color.yellow,Color.wh
ite};
Color clr[];
finalstaticint PAINT=1,LIGHT=0;
int mode,N=OBJ.length;
void setMode(int newmode){
mode=newmode;
if(newmode==LIGHT){
clr=clr1;
stage.setMode(fkhStage.OR);
ltype.setText(STR[3]);
}else{
clr=clr2;
stage.setMode(fkhStage.AND);
ltype.setText(STR[4]);
}
gb.setColor(clr[N]);
gb.fillRect(0,0, area.width, area.height);
// gb.setColor(cs);
// gb.drawString(msg,5,chy);
}
void clear(){
if(g==null){
bgImage = createImage(area.width, area.height);
gb = bgImage.getGraphics();
fgImage = createImage(area.width, area.height);
g = fgImage.getGraphics();
fm=gb.getFontMetrics();
chy=fm.getHeight();
stage=new fkhStage(area.width,area.height);
xc=area.width/2;
yc=area.height/2;
//mode=LIGHT;
setMode(LIGHT);
// g.setColor(Color.red);
// g.fillOval(25,25,200,100);
// g.setColor(Color.yellow);
// g.fillOval(50,50,50,50);
// OBJ[0]=stage.addImage(5,5,200,100,fgImage,bgColor);
OBJ[0]=stage.fillOval(5,5,200,100,clr[0]);
OBJ[1]=stage.fillOval(xc,5,200,100,clr[1]);
OBJ[2]=stage.fillOval(xc-75,140,150,150,clr[2]);
}
// repaint();
}
publicvoid paint(Graphics gs){
update(gs);
}
staticboolean free=true;
int xp,yp;
double r1,r2;
publicvoid update(Graphics gs){
free=false;
g.drawImage(bgImage,0,0,this);
if(stage.isDirty()){
stage.flush();
img=createImage(newMemoryImageSource(stage.tmp.w
idth, stage.tmp.height, stage.pix,0, stage.tmp.width));
}
if(img!=null)g.drawImage(img,stage.tmp.x,stage.tmp.y,this);
gs.drawImage(fgImage,0, yOffset,this);
free=true;
}
}
colors_java/ripple.classpublicsynchronizedclass ripple extends
java.applet.Applet {
static boolean free;
int yOffset;
double time;
double ts;
java.awt.Dimension area;
java.awt.Image bgImage;
java.awt.Image fgImage;
java.awt.Graphics gb;
java.awt.Graphics g;
java.awt.Color bgColor;
boolean rightClick;
boolean dragging;
int xs;
int ys;
java.awt.FontMetrics fm;
int chy;
fkhStage stage;
java.awt.Image img;
int xc;
int yc;
int dr;
int xx;
int yy;
int size;
int size2;
int xp;
int yp;
double r1;
double r2;
public void init();
String d2String(double);
public boolean mouseDown(java.awt.Event, int, int);
public boolean mouseDrag(java.awt.Event, int, int);
public boolean mouseUp(java.awt.Event, int, int);
void clear();
public void paint(java.awt.Graphics);
public void update(java.awt.Graphics);
public void ripple();
static void <clinit>();
}
colors_java/ripple.html
波的干涉
以下是 兩組同心圓 用以表示 波動的 波前。
是否觀察到有一些 條紋的錯覺呢?
那些條紋與 波動的建設性干涉處是否相關呢?
使用說明:
在區域內按下滑鼠左鍵 將顯示兩波源分別到滑鼠的距離(以波長為單位)。
在同一道條紋內兩波源間的距離差 有何特殊之處呢?
按下滑鼠右鍵後拖動滑鼠 則可以移動其中一個波源的位置。
好好的玩一玩 同時觀察其中的規律性 !
歡迎批評指教! 電子郵件 : 請按
[email protected]作者:國立台灣師範大學物理系黃福坤最後修訂時間:
colors_java/ripple.javacolors_java/ripple.javaimport java.awt.*;
import java.awt.image.*;
import java.util.*;
publicclass ripple extends java.applet.Applet{
int yOffset=0;
double time=0.0,ts=0.;
Dimension area;
Image bgImage,fgImage;
Graphics gb,g;//background drawing
// Color bgColor=Color.cyan;//lightGray;
Color bgColor=newColor(0xC8,0xDF,0xD0);
publicvoid init(){
setBackground(bgColor);
area=size();
clear();
}
String d2String(double value){
float f=(float)((int)(value*10.)/10.);
String str=String.valueOf(f);
if(str.indexOf(".")==-1)str+=".0";
return str;
}
boolean rightClick=false,dragging=false;
int xs,ys;
publicboolean mouseDown(Event e,int x,int y){
if((y-=yOffset)<0)returnfalse;
if(e.modifiers==Event.META_MASK){//"Right Click, ";
rightClick=true;
dragging=true;
}else{
rightClick=false;
repaint();
}
xs=x;
ys=y;
returntrue;
}
publicboolean mouseDrag(Event e,int x,int y){
if(!free ||(y-=yOffset)<0)returnfalse;
if(dragging){
xx+=x-xs;
yy+=y-ys;
repaint();
}
xs=x;
ys=y;
returntrue;
}
publicboolean mouseUp(Event e,int x,int y){
if((y-=yOffset)<0)returnfalse;
dragging=false;
returntrue;
}
FontMetrics fm;
int chy;
fkhStage stage;
Image img;
int xc,yc,dr=6,xx,yy;
int size=2,size2=2*size;
void clear(){
if(g==null){
bgImage = createImage(area.width, area.height);
gb = bgImage.getGraphics();
fgImage = createImage(area.width, area.height);
g = fgImage.getGraphics();
fm=gb.getFontMetrics();
chy=fm.getHeight();
stage=new fkhStage(area.width,area.height);
xc=area.width/2;
yc=area.height/2;
xs=xc+12*dr;
ys=yc-20*dr;
}
gb.setColor(bgColor);
gb.fillRect(0,0, area.width, area.height);
Color clr=Color.darkGray;
gb.setColor(clr);//Color.black);
for(int i=0,xi=xc-dr,yi=yc-dr,dx=2*dr;xi>0;xi-=dr,yi-
=dr,dx+=2*dr)
gb.drawOval(xi,yi,dx,dx);
gb.setColor(Color.red);
gb.fillOval(xc-size,yc-size,size2,size2);
stage.drawCircuits(area.width,area.height,xc,xc/dr,clr);//C
olor.black);//magenta);//red);
xx=6*dr;
if(stage.isDirty()){
stage.flush();
img=createImage(newMemoryImageSource(stage.tmp.w
idth, stage.tmp.height, stage.pix,0, stage.tmp.width));
}
}
publicvoid paint(Graphics gs){
update(gs);
}
staticboolean free=true;
int xp,yp;
double r1,r2;
publicvoid update(Graphics gs){
free=false;
g.drawImage(bgImage,0,0,this);
if(img!=null)g.drawImage(img,xx,yy,this);
xp=xx+xc+1;
yp=yy+yc;
g.setColor(Color.red);
g.fillOval(xp-size,yp-size,size2,size2);
if(!dragging){
g.setColor(Color.blue);//yellow);
// g.drawLine(xp,yp,xc,yc);
g.drawLine(xc,yc,xs,ys);
g.drawLine(xp,yp,xs,ys);
r2=Math.sqrt((xp-xs)*(xp-xs)+(yp-ys)*(yp-ys))/dr;
r1=Math.sqrt((xc-xs)*(xc-xs)+(yc-ys)*(yc-ys))/dr;
g.drawString("r1 = "+d2String(r1)+", r2 = "+d2String(r
2)+
", r1-r2 = "+d2String(r1-r2),10,chy);
}
gs.drawImage(fgImage,0, yOffset,this);
free=true;
}
}

More Related Content

Similar to httpswww.youtube.comwatchv=6bzHHmSKCbsHow to Allow Ja.docx

Conservation of energy for web
Conservation of energy for webConservation of energy for web
Conservation of energy for web
Jan Parker
 
Chapter 1924. If you dip your finger repeatedly into a puddle of.docx
Chapter 1924. If you dip your finger repeatedly into a puddle of.docxChapter 1924. If you dip your finger repeatedly into a puddle of.docx
Chapter 1924. If you dip your finger repeatedly into a puddle of.docx
cravennichole326
 
EDS 1021 Week 8 Interactive ActivityAtmospheric Greenhouse .docx
EDS 1021        Week 8 Interactive ActivityAtmospheric Greenhouse .docxEDS 1021        Week 8 Interactive ActivityAtmospheric Greenhouse .docx
EDS 1021 Week 8 Interactive ActivityAtmospheric Greenhouse .docx
greg1eden90113
 
PHYS 181 Physics For Scientists And Engineers II.docx
PHYS 181 Physics For Scientists And Engineers II.docxPHYS 181 Physics For Scientists And Engineers II.docx
PHYS 181 Physics For Scientists And Engineers II.docx
write5
 
On Equivalent Amplitude Motion of the Foucault Pendulum
On Equivalent Amplitude Motion of the Foucault PendulumOn Equivalent Amplitude Motion of the Foucault Pendulum
On Equivalent Amplitude Motion of the Foucault Pendulum
Shuai Yuan
 
Module 11 work, energy, power and machines
Module 11 work, energy, power and machinesModule 11 work, energy, power and machines
Module 11 work, energy, power and machines
dionesioable
 
Conservation of Energy
Conservation of Energy Conservation of Energy
Conservation of Energy
Jan Parker
 
09-LinearMomentumandCollisions.pdf
09-LinearMomentumandCollisions.pdf09-LinearMomentumandCollisions.pdf
09-LinearMomentumandCollisions.pdf
RanaBustami1
 
A method for determining a physical law using the simple pendu.docx
A method for determining a physical law using the simple pendu.docxA method for determining a physical law using the simple pendu.docx
A method for determining a physical law using the simple pendu.docx
ransayo
 
Conservation of energy
Conservation of energyConservation of energy
Conservation of energy
Jan Parker
 
13f impulse momentum-wireless 3-3-09
13f impulse momentum-wireless 3-3-0913f impulse momentum-wireless 3-3-09
13f impulse momentum-wireless 3-3-09
joseflesco
 
Physics
PhysicsPhysics
Physics
thachsanh86
 
Honors methods of motion-day 7-per4
Honors methods of motion-day 7-per4Honors methods of motion-day 7-per4
Honors methods of motion-day 7-per4
stephm32
 

Similar to httpswww.youtube.comwatchv=6bzHHmSKCbsHow to Allow Ja.docx (13)

Conservation of energy for web
Conservation of energy for webConservation of energy for web
Conservation of energy for web
 
Chapter 1924. If you dip your finger repeatedly into a puddle of.docx
Chapter 1924. If you dip your finger repeatedly into a puddle of.docxChapter 1924. If you dip your finger repeatedly into a puddle of.docx
Chapter 1924. If you dip your finger repeatedly into a puddle of.docx
 
EDS 1021 Week 8 Interactive ActivityAtmospheric Greenhouse .docx
EDS 1021        Week 8 Interactive ActivityAtmospheric Greenhouse .docxEDS 1021        Week 8 Interactive ActivityAtmospheric Greenhouse .docx
EDS 1021 Week 8 Interactive ActivityAtmospheric Greenhouse .docx
 
PHYS 181 Physics For Scientists And Engineers II.docx
PHYS 181 Physics For Scientists And Engineers II.docxPHYS 181 Physics For Scientists And Engineers II.docx
PHYS 181 Physics For Scientists And Engineers II.docx
 
On Equivalent Amplitude Motion of the Foucault Pendulum
On Equivalent Amplitude Motion of the Foucault PendulumOn Equivalent Amplitude Motion of the Foucault Pendulum
On Equivalent Amplitude Motion of the Foucault Pendulum
 
Module 11 work, energy, power and machines
Module 11 work, energy, power and machinesModule 11 work, energy, power and machines
Module 11 work, energy, power and machines
 
Conservation of Energy
Conservation of Energy Conservation of Energy
Conservation of Energy
 
09-LinearMomentumandCollisions.pdf
09-LinearMomentumandCollisions.pdf09-LinearMomentumandCollisions.pdf
09-LinearMomentumandCollisions.pdf
 
A method for determining a physical law using the simple pendu.docx
A method for determining a physical law using the simple pendu.docxA method for determining a physical law using the simple pendu.docx
A method for determining a physical law using the simple pendu.docx
 
Conservation of energy
Conservation of energyConservation of energy
Conservation of energy
 
13f impulse momentum-wireless 3-3-09
13f impulse momentum-wireless 3-3-0913f impulse momentum-wireless 3-3-09
13f impulse momentum-wireless 3-3-09
 
Physics
PhysicsPhysics
Physics
 
Honors methods of motion-day 7-per4
Honors methods of motion-day 7-per4Honors methods of motion-day 7-per4
Honors methods of motion-day 7-per4
 

More from wellesleyterresa

Hw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docx
Hw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docxHw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docx
Hw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docx
wellesleyterresa
 
HW in teams of 3 studentsAn oil remanufacturing company uses c.docx
HW in teams of 3 studentsAn oil remanufacturing company uses c.docxHW in teams of 3 studentsAn oil remanufacturing company uses c.docx
HW in teams of 3 studentsAn oil remanufacturing company uses c.docx
wellesleyterresa
 
HW 5.docxAssignment 5 – Currency riskYou may do this assig.docx
HW 5.docxAssignment 5 – Currency riskYou may do this assig.docxHW 5.docxAssignment 5 – Currency riskYou may do this assig.docx
HW 5.docxAssignment 5 – Currency riskYou may do this assig.docx
wellesleyterresa
 
HW#3 – Spring 20181. Giulia is traveling from Italy to China. .docx
HW#3 – Spring 20181. Giulia is traveling from Italy to China. .docxHW#3 – Spring 20181. Giulia is traveling from Italy to China. .docx
HW#3 – Spring 20181. Giulia is traveling from Italy to China. .docx
wellesleyterresa
 
HW 2Due July 1 by 500 PM.docx
HW 2Due July 1 by 500 PM.docxHW 2Due July 1 by 500 PM.docx
HW 2Due July 1 by 500 PM.docx
wellesleyterresa
 
HW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docx
HW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docxHW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docx
HW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docx
wellesleyterresa
 
HW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docx
HW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docxHW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docx
HW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docx
wellesleyterresa
 
HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
HW 5-RSAascii2str.mfunction str = ascii2str(ascii)        .docxHW 5-RSAascii2str.mfunction str = ascii2str(ascii)        .docx
HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
wellesleyterresa
 
HW 3 Project Control• Status meeting agenda – shows time, date .docx
HW 3 Project Control• Status meeting agenda – shows time, date .docxHW 3 Project Control• Status meeting agenda – shows time, date .docx
HW 3 Project Control• Status meeting agenda – shows time, date .docx
wellesleyterresa
 
HW 1January 19 2017Due back Jan 26, in class.1. (T.docx
HW 1January 19 2017Due back Jan 26, in class.1. (T.docxHW 1January 19 2017Due back Jan 26, in class.1. (T.docx
HW 1January 19 2017Due back Jan 26, in class.1. (T.docx
wellesleyterresa
 
Hussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docx
Hussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docxHussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docx
Hussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docx
wellesleyterresa
 
hw1.docxCS 211 Homework #1Please complete the homework problem.docx
hw1.docxCS 211 Homework #1Please complete the homework problem.docxhw1.docxCS 211 Homework #1Please complete the homework problem.docx
hw1.docxCS 211 Homework #1Please complete the homework problem.docx
wellesleyterresa
 
HUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docx
HUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docxHUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docx
HUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docx
wellesleyterresa
 
HW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docx
HW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docxHW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docx
HW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docx
wellesleyterresa
 
HW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docx
HW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docxHW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docx
HW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docx
wellesleyterresa
 
Hunters Son Dialogue Activity1. Please write 1-2 sentences for e.docx
Hunters Son Dialogue Activity1. Please write 1-2 sentences for e.docxHunters Son Dialogue Activity1. Please write 1-2 sentences for e.docx
Hunters Son Dialogue Activity1. Please write 1-2 sentences for e.docx
wellesleyterresa
 
HW 2 - SQL The database you will use for this assignme.docx
HW 2 - SQL   The database you will use for this assignme.docxHW 2 - SQL   The database you will use for this assignme.docx
HW 2 - SQL The database you will use for this assignme.docx
wellesleyterresa
 
Humanities Commons Learning Goals1. Write about primary and seco.docx
Humanities Commons Learning Goals1. Write about primary and seco.docxHumanities Commons Learning Goals1. Write about primary and seco.docx
Humanities Commons Learning Goals1. Write about primary and seco.docx
wellesleyterresa
 
HURRICANE KATRINA A NATION STILL UNPREPARED .docx
HURRICANE KATRINA  A NATION STILL UNPREPARED   .docxHURRICANE KATRINA  A NATION STILL UNPREPARED   .docx
HURRICANE KATRINA A NATION STILL UNPREPARED .docx
wellesleyterresa
 
Humanities 115Short Essay Grading CriteriaExcellentPassing.docx
Humanities 115Short Essay Grading CriteriaExcellentPassing.docxHumanities 115Short Essay Grading CriteriaExcellentPassing.docx
Humanities 115Short Essay Grading CriteriaExcellentPassing.docx
wellesleyterresa
 

More from wellesleyterresa (20)

Hw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docx
Hw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docxHw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docx
Hw059f6dbf-250a-4d74-8f5e-f28f14227edc.jpg__MACOSXHw._059.docx
 
HW in teams of 3 studentsAn oil remanufacturing company uses c.docx
HW in teams of 3 studentsAn oil remanufacturing company uses c.docxHW in teams of 3 studentsAn oil remanufacturing company uses c.docx
HW in teams of 3 studentsAn oil remanufacturing company uses c.docx
 
HW 5.docxAssignment 5 – Currency riskYou may do this assig.docx
HW 5.docxAssignment 5 – Currency riskYou may do this assig.docxHW 5.docxAssignment 5 – Currency riskYou may do this assig.docx
HW 5.docxAssignment 5 – Currency riskYou may do this assig.docx
 
HW#3 – Spring 20181. Giulia is traveling from Italy to China. .docx
HW#3 – Spring 20181. Giulia is traveling from Italy to China. .docxHW#3 – Spring 20181. Giulia is traveling from Italy to China. .docx
HW#3 – Spring 20181. Giulia is traveling from Italy to China. .docx
 
HW 2Due July 1 by 500 PM.docx
HW 2Due July 1 by 500 PM.docxHW 2Due July 1 by 500 PM.docx
HW 2Due July 1 by 500 PM.docx
 
HW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docx
HW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docxHW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docx
HW 4 Gung Ho Commentary DUE Thursday, April 20 at 505 PM on.docx
 
HW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docx
HW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docxHW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docx
HW 5 Math 405. Due beginning of class – Monday, 10 Oct 2016.docx
 
HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
HW 5-RSAascii2str.mfunction str = ascii2str(ascii)        .docxHW 5-RSAascii2str.mfunction str = ascii2str(ascii)        .docx
HW 5-RSAascii2str.mfunction str = ascii2str(ascii) .docx
 
HW 3 Project Control• Status meeting agenda – shows time, date .docx
HW 3 Project Control• Status meeting agenda – shows time, date .docxHW 3 Project Control• Status meeting agenda – shows time, date .docx
HW 3 Project Control• Status meeting agenda – shows time, date .docx
 
HW 1January 19 2017Due back Jan 26, in class.1. (T.docx
HW 1January 19 2017Due back Jan 26, in class.1. (T.docxHW 1January 19 2017Due back Jan 26, in class.1. (T.docx
HW 1January 19 2017Due back Jan 26, in class.1. (T.docx
 
Hussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docx
Hussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docxHussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docx
Hussam Malibari Heckman MAT 242 Spring 2017Assignment Chapte.docx
 
hw1.docxCS 211 Homework #1Please complete the homework problem.docx
hw1.docxCS 211 Homework #1Please complete the homework problem.docxhw1.docxCS 211 Homework #1Please complete the homework problem.docx
hw1.docxCS 211 Homework #1Please complete the homework problem.docx
 
HUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docx
HUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docxHUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docx
HUS 335 Interpersonal Helping SkillsCase Assessment FormatT.docx
 
HW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docx
HW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docxHW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docx
HW #1Tech Alert on IT & Strategy (Ch 3-5Ch 3 -5 IT Strategy opt.docx
 
HW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docx
HW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docxHW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docx
HW 2 (1) Visit Monsanto (httpwww.monsanto.com) again and Goog.docx
 
Hunters Son Dialogue Activity1. Please write 1-2 sentences for e.docx
Hunters Son Dialogue Activity1. Please write 1-2 sentences for e.docxHunters Son Dialogue Activity1. Please write 1-2 sentences for e.docx
Hunters Son Dialogue Activity1. Please write 1-2 sentences for e.docx
 
HW 2 - SQL The database you will use for this assignme.docx
HW 2 - SQL   The database you will use for this assignme.docxHW 2 - SQL   The database you will use for this assignme.docx
HW 2 - SQL The database you will use for this assignme.docx
 
Humanities Commons Learning Goals1. Write about primary and seco.docx
Humanities Commons Learning Goals1. Write about primary and seco.docxHumanities Commons Learning Goals1. Write about primary and seco.docx
Humanities Commons Learning Goals1. Write about primary and seco.docx
 
HURRICANE KATRINA A NATION STILL UNPREPARED .docx
HURRICANE KATRINA  A NATION STILL UNPREPARED   .docxHURRICANE KATRINA  A NATION STILL UNPREPARED   .docx
HURRICANE KATRINA A NATION STILL UNPREPARED .docx
 
Humanities 115Short Essay Grading CriteriaExcellentPassing.docx
Humanities 115Short Essay Grading CriteriaExcellentPassing.docxHumanities 115Short Essay Grading CriteriaExcellentPassing.docx
Humanities 115Short Essay Grading CriteriaExcellentPassing.docx
 

Recently uploaded

Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
Celine George
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
indexPub
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
sanamushtaq922
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
khuleseema60
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
Nguyen Thanh Tu Collection
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
Celine George
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 

Recently uploaded (20)

Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
 
Observational Learning
Observational Learning Observational Learning
Observational Learning
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 

httpswww.youtube.comwatchv=6bzHHmSKCbsHow to Allow Ja.docx

  • 1. https://www.youtube.com/watch?v=6bzHHmSKCbs How to Allow Java Applets for physics labs Windows 7 Open the lab Copy and paste the lab site given to desired internet browser Here I’m using google chrome, you can also use internet explorer or firefox, same results You will get a security warning click run. It may still not run… If it doesn’t run go the start menu on your computer. Type java. I click on the Java 32 bit under control panel. Once opened properly it should look like this.
  • 2. Click on the security tab, then click on edit site list Once the exception site list is up click add Type in the address given. Make sure to first type http:// you do not need the entire site just the main web site title for example http://phy.ntnu.edu.tw then click add It will say this is a risk, allow it (click continue) the school would not give you a website that gives you a virus. Now you are done. Simply reload your web page and you should be able to run the java applet. Note, we have used about 4 different lab sites that use java this means you have to do this for every new website. Sample Lab Report:
  • 3. Please note: This is a fairly nice lab report of an experiment that should provide a guide to you for producing your own lab reports. Your report should usually contain the following ingredients: 1. Introduction of the purpose of the experiment 2. Description of the measurement procedure 3. Listing of the data you obtained, with formulas used in extraction of these data. 4. Graphic representation of your data and possible comparison to theoretical predictions 5. Discussion of possible errors and uncertainties 6. Conclusion with clearly stated outcomes of the experiment Experiment: Bouncing Golf Ball Introduction In this experiment we used the PASCO Science Workshop Equipment, KaliedaGraph, Microsoft Word and Excel, and a golf ball in order to investigate the potential, total, and kinetic energy of a ball that bounces off the ground. Our purpose is to determine as precisely as possible how much energy is lost in the bounce of the ball and to observe how well the energy is conserved throughout the flight. We believe that if the air resistance is neglected, then the ball that is dropped should conserve total energy as it falls. However, because the ground is not a totally elastic surface, some of the energy will be lost. We will therefore observe the total energy as a function of time so
  • 4. as to determine whether the energy is lost in the actual bounce of the ball into an inelastic surface, or due to air friction. Procedure First we needed to set up the equipment which contained a motion sensor and a golf ball. The golf ball was weighed and the height of the sensor, h, was measured with the digital meter on the sensor. The distance we are actually measuring, though, is the distance between the ground and the sensor because we are subtracting the distance from the motion sensor to the ball. We need to correct for the diameter of the ball because the distance from the motion sensor to the top of the ball is what the sensor is measuring, not the distance from the sensor to the ground. In order to do this we subtracted the diameter of the ball from h. Now that we were ready to begin the experiment, we held the ball below the sensor enough so its position is recorded and we began the recording and let the ball drop. After a few practice drops, we chose the ‘best’ data that allowed us to see a graph of d, the distance between the motion sensor and the ball versus time. A graph was created in Science Workshop displaying our data. More graphs and tables were then created. Data and Observations Formulas: Kinetic energy = ½ m v2 Potential energy = m g h Total energy = kinetic + potential energy Kinetic energy is the energy an object has while in motion. An object loses kinetic energy each time it hits a non-elastic
  • 5. surface. Kinetic energy is dependent upon the mass of the object and the velocity the object is moving with. The sharp decreases at t = 1.2 and 2.0 s are where the ball hit the ground. Potential energy is the possible amount of energy an object has before any movement. Potential energy is dependent upon the mass of the object, acceleration due to gravity and the height of the object. Each time the object falls it loses potential energy and each time it returns it gains potential energy. At t = 0.3, 1.2 and 2.0 s the ball hits the ground. This is because potential energy is lowest when the ball hits the ground. The total energy is the sum of both the kinetic and potential energy. At t = 0.3, 1.2, and 2.0 s the ball is striking the ground. We know this because at these times the ball has it’s lowest amount of energy. This is a step-like function because when the kinetic energy is at its peak, potential energy is at its valley, and vice versa. This creates horizontal lines when they are added. Conclusions Our purpose of the experiment was met because we were able to successfully investigate and observe kinetic, potential, and the total energy of a bouncing golf ball. From our observations, we are able to conclude that the ball loses energy each and every time the ball hits the ground and bounces back. This is especially noticeable in the graph of the total energy. In regards to air resistance versus elasticity, we concluded that the amount of energy lost through air resistance is negligible compared to the amount of energy lost through contact of the golf ball with the ground. During the motion of the ball, kinetic energy is not being
  • 6. conserved but rather distributed into the ground. This energy transfers because the ground is not an elastic surface. The total energy slightly decreases also due to the inelasticity of the bounce. The Law of Conservation of Energy does hold for this case, however, because the energy is not being destroyed rather it is being transferred. Each bounce created a total energy loss of approximately 0.9 J. The energy was lost in the actual bounce rather than in the air. This is because if the ball bounced on an elastic surface, the energy of each bounce would be roughly equal and the ball would return to its starting height. Because the experiment did not use a perfectly elastic surface, we can be fairly sure that the bounce was the actual cause of the loss of total energy, rather than the air resistance. Prism: Reflection and Refraction Web Site: http://www.phy.ntnu.edu.tw/java/optics/prism_e.html Introduction: This Java applet let you play with a light source and a prism, to study the physics of light. Both reflection and refraction occur at the interface between two media. (Even total internal reflection might also occur.) Light will travel with different speed through different media, which will result in both reflection and refraction.
  • 7. For reflection: the angle of incidence is equal to angle of reflection. For refraction: Snell's law governs the angle index of refraction for media 1 = n1; angle of incidence = 1 index of refraction for media 2 = n2; angle of refraction = 2 Snell’s Law: n1 sin 1 = n2 sin 2 Part of the energy is reflected and the rest propagate into new media. This ratio depends on incident angle and index of refraction (refracted angle). Usage of this Applet: Click the red region to change the light direction. Click another region of light source and you can move the light pen to different locations (even inside the prism). Click one of the corner of the prism to change the shape of prism. Click inside the prism to change its location. When tracing of the light will terminate when the ray intensity is less than 0.4%. The relative intensity for each ray is shown at the boundary. The index of refraction for the prism is initially set at 1.5 Instructions: 1. Load up the Java Lab from the web site shown above.
  • 8. 2. Establish a new prism shape if you want, but keep it generally the shape of what was is displayed at the start of this experiment. 3. Change the index of refraction of the prism (n2) from 1.5 to 1.0 in increments of 0.1. Sketch the light rays for each value of the index of refraction. 4. Reset the prism’s index of refraction (n2) back to 1.5. 5. For three different angles of incidence (either change the shape of the prism, or move the light source around), use a protractor to measure the angle of incidence of the light ray and the corresponding angle of refraction. (Remember that both of these angles are measured from the “normal”, i.e., the line perpendicular to the surface at the point of incidence.) 6. Record your data, and compare your results to Snell’s Law. (Assume that the angle of incidence is measured correctly, and compare the angles of refraction.) 7. List all sources of error (and there should be plenty of them). 8. Finally, write the report with your favorite word processor or text editor and submit is to the instructor. Use the “Sample Laboratory Report” as a guide in preparing your lab report. Any problems – please e-mail me. Also if you have any complaints, comments, suggestions, or kudos concerning this experiment, please e-mail me. It won’t help your class, but I will take them into consideration for the next time this course is offered.
  • 9. optics/ABline.classsynchronizedclass ABline { static double eps; static double PI2; int xa; int ya; int xb; int yb; double ca; double cb; double m; double b; double index; double x; double y; double len; double cta; double alpha; double r12p; double r12s; boolean total; double rc; double twoPI; void draw(java.awt.Graphics); void translate(int, int); void setPoints(int, int, int, int); double angle(double, double, double, double); boolean touch(ray); ray reflection(ray); ray refraction(ray); void ABline(double); static void <clinit>(); }
  • 10. optics/box.classpublicsynchronizedclass box extends java.applet.Applet { double time; java.awt.Dimension area; java.awt.Image bgImage; java.awt.Image fgImage; java.awt.Graphics gb; java.awt.Graphics g; java.awt.Color bgColor; String rts; String[] STR; int xx; int yy; boolean rightClick; int size; int size2; int size4; int dragLight; boolean changed; int xs; int ys; java.awt.FontMetrics fm; int chy; int tx; int ty; int[] b; int xc; boolean display; java.awt.Point[] light; double len; double index; java.awt.Polygon hp; java.awt.Polygon tp; double PI6; double LEN;
  • 11. boolean showC; public void init(); String d2String(double); public boolean mouseDown(java.awt.Event, int, int); public boolean mouseDrag(java.awt.Event, int, int); public boolean mouseUp(java.awt.Event, int, int); public boolean mouseMove(java.awt.Event, int, int); void clear(boolean); public void paint(java.awt.Graphics); void drawPointer(java.awt.Point, java.awt.Point); public void update(java.awt.Graphics); void drawRay(double, double, double); public void box(); } optics/c1.gif optics/c2.gif optics/er.gif optics/esp.gif optics/eye.gif optics/eyescan.gif optics/fiber.classpublicsynchronizedclass fiber extends java.applet.Applet { double time; java.awt.Dimension area; java.awt.Image bgImage; java.awt.Image fgImage; java.awt.Graphics gb; java.awt.Graphics g;
  • 12. java.awt.Color bgColor; String rts; String[] STR; java.awt.TextField tf; int xs; int ys; boolean rightClick; boolean draghead; boolean dragtail; java.awt.FontMetrics fm; int chy; int x1; int y1; int y2; int xx; int yy; int dd; java.awt.Point head; java.awt.Point tail; double m; double b; double x; double y; double sc2; double tc2; double n; java.awt.Polygon hp; java.awt.Polygon tp; double PI6; double LEN; double cta; public void init(); public boolean action(java.awt.Event, Object); String d2String(double); public boolean mouseDown(java.awt.Event, int, int); public boolean mouseDrag(java.awt.Event, int, int);
  • 13. public boolean mouseUp(java.awt.Event, int, int); void clear(); public void paint(java.awt.Graphics); public void update(java.awt.Graphics); double drawIt(double, double, double); void drawPointer(java.awt.Point, java.awt.Point); public void fiber(); } optics/fish.swf optics/i.gif optics/ie.gif optics/image.classpublicsynchronizedclass image extends java.applet.Applet implements Runnable { java.awt.Dimension area; java.awt.Image bgImage; java.awt.Image fgImage; java.awt.Graphics gb; java.awt.Graphics g; java.awt.Color bgColor; String rts; String[] STR; int xx; int yy; int xs2; int ys2; boolean running; Thread animThread; long startTime; long lastTime; long delay; long delta;
  • 14. double c; int cnt; int ns; double xt; double yt; double bt; boolean rightClick; boolean dragm; boolean dragd; boolean dragd2; boolean down; int xs; int ys; double cta1; double cta2; double ctaa; double dd; double PI2; double m; int ni; int nf; int n; double V; double dc2; java.awt.FontMetrics fm; int chy; int xc; int yc; int size; int size2; int xm; int ym; int ym2; int Nmax; int NR; int Nmax1;
  • 15. double cta; double rm; double dc; double[] CR; double[] X; double[] Y; double[] VX; double[] VY; double cst; int NI; double[] PXA; double[] PYA; double[] PXB; double[] PYB; java.awt.Point na; java.awt.Point nb; public void init(); public void reset(); public void start(); public void stop(); public void run(); void advanced(double); public boolean mouseDown(java.awt.Event, int, int); public boolean mouseDrag(java.awt.Event, int, int); void setupRay(); public boolean mouseUp(java.awt.Event, int, int); void clear(); public void paint(java.awt.Graphics); void imgs(double, double, double[], double[], java.awt.Point); public void update(java.awt.Graphics); public void image(); } optics/image_e.htmlMultiple
  • 16. Reflection from two plane mirrors Rays of lights are reflected from the mirror, each ray satisfying the law of reflection. It is fun to play with two plane mirrors, multiple images are formed. Would you like to try it with this java applet? The inverted moving fish (virtual image) is what the observer (fish on the left) will see underwater. When the moving fish is away from the observer, light emitter from the moving fish will be totally reflected at the water-air interface. So the water-air interface acting like a mirror. When the distance is too short for the total internal reflection to occurs, the virtual image above the water vanished.
  • 17. You can click and drag the observer left/right to change its location. More information will be shown when you drag the observer (fish).Why does a fish appear to be closer to the surface of water than it really is? The following java applet let you find out the answer, and learn the physics of refraction, and total internal reflection. [removed] [removed] Usage: A scanning eye represent the observer. You can click on it and drag it to any position you like. The whole screen will be clear when you drag the scanning eye. You can draw any pattern you like, and the java program will draw the virtual image of it. ( If the virtual can be formed due to refraction or total internal reflection) When you draw in the water region, the region where the total internal reflection is possible, will be shown. If you click the right mouse button, it will show you many light
  • 18. rays emitted. (including refraction rays and total internal reflection rays) Right click the mouse button twice is another way to clear the screen.to java applet This is an image You can draw any thing within the animation region, for example: the object shown in the above image. Light emitted from the object is refracted at the water and air interface. The observer trace back those refracted light to find the image of the object. The image appear closer to the water surface and its shape is different from the object. How to determine the location of the image (yellow dot) ? The world viewed under water is different from what we view it above the water surface.
  • 19. Drag the observer (eye) under the water and find out more interesting phenomena. Your suggestions are highly appreciated! Please click [email protected]Author¡GFu-Kwun Hwang, Dept. of physics, National Taiwan Normal University Last modified : More physics related java applets optics/point.classsynchronizedclass point { static java.awt.Graphics gb; static java.awt.Rectangle r; static double n; static int cnt; double x; double y; double vx; double vy; double v; double c; int status; void set(double, double, double, double); static void init(java.awt.Graphics, java.awt.Rectangle, double); point advanced(double); void point(double, double, double, double);
  • 20. } optics/prism.classpublicclass prism extends java.applet.Applet { double time; java.awt.Dimension area; java.awt.Image bgImage; java.awt.Image fgImage; java.awt.Graphics gb; java.awt.Graphics g; java.awt.Color bgColor; int xx; int yy; boolean rightClick; boolean movep; boolean dragt; boolean dragh; boolean dragp; int xs; int ys; boolean check; double[] C; double PI2; java.awt.FontMetrics fm; prisms p; int chy; int xa; java.awt.Rectangle box; java.awt.Point head; java.awt.Point tail; int N; int n; int N2; double V; ray light; double I;
  • 21. int size; int size2; double dist; double angle; java.awt.Polygon hp; java.awt.Polygon tp; double PI6; double cta; double ctaa; double c2a; double LEN; double maxI; int maxCnt; int Cnt; ABline AB; public void init(); public void reset(); String d2String(double); public boolean mouseDown(java.awt.Event, int, int); public boolean mouseDrag(java.awt.Event, int, int); public boolean mouseUp(java.awt.Event, int, int); public void changeIndex(double); void clear(); public void paint(java.awt.Graphics); public void update(java.awt.Graphics); void drawPointer(java.awt.Point, java.awt.Point); ray drawRay(ray); void drawTo(ray); ABline getTouch(ray); public void prism(); } optics/prisms.classclass prisms { int N; int N1;
  • 22. java.awt.Polygon P; int xc; int yc; double[] L; double[] C; double PI2; ABline[] AB; java.awt.Rectangle r; int size; int size2; double ax; double ay; double bx; double by; double ac; double dv; double c2a; int dragID; void prisms(int, int, double, double); void setXY(); void setLine(int); void drawPrism(java.awt.Graphics, java.awt.Color); void drawAngles(java.awt.Graphics, int, int); double angleAB(int, int, int); void fillPrism(java.awt.Graphics, java.awt.Color); void translate(int, int); boolean checkDrag(int, int); void drag(int, int); } optics/prism_e.html Prism: Reflection and refraction
  • 23. This java applet let you play with a light source and a prism, to study the physics of light. There are reflection and refraction occurs at the interface between two media. (Total internal reflection might also occurs) [removed] [removed] [removed] refractive indices: air (n1)= prism(n2)= Do not forget to hit ENTER key
  • 24. Usage: Click the red region to change the light direction. Click other region of light source can move the light pen to differ location( even inside the prism). Click one of the corner of the prism to change the shape of prism. Click inside the prism to change its location. When tracing of the light will terminated when the ray intensity is less than than 0.4%. The relative intensity for each ray is shown at the boundary. Intensity of red and green are used to represent two different polarization. The yellow light (sum of red light and green light) represent equal intensity of two polarization waves. At Brewster's angle, only one of the polarized light is refracted, and other one is totally reflected. The index of refraction for the prism is 1.5
  • 25. Things to watch: 1. Total internal reflection 2. Change in light intensity 3. There might be small bugs, did you find out?Light will travel with different speed at different media, which cause the reflection and refraction. For reflection: the angle of incidence is equal to angle of reflection. For refraction: the Snell's law govern the angle index of refraction for media 1: angle of incidence index of refraction for media 2: angle of refraction Part of the energy is reflected and the rest propagate into new media. The ratio depend on incident angle and index of refraction ( refracted angle ) EM (transverse) wave can have two polarization (perpendicular to each other and )
  • 26. The intensity is proportional to The intensity of electric field changed when reflection/refraction occurs, where , So the intensity for the reflected light is proportional to Since the energy is conserved, so we can find out the intensity of refraction light. For normal incident, both and equal to zero. The coefficient are the same = For light emit from air (n=1.) into glass (n=1.5) The electric field scale to = (1.5-1)/(1.5+1)=0.2 So the intensity of the reflection scale to 0.22=0.04 ( 4% of incident light) So 96% light will enter the glass and only 4% of light were reflected. This java applet use above equations to calculate the relative
  • 27. intensity of each ray.to java applet Your suggestions are highly appreciated! Please click [email protected]Author:Fu-Kwun Hwang, Dept. of physics, National Taiwan Normal University Last modified : More physics related java applets optics/r12p.gif optics/r12s.gif optics/ray.classsynchronizedclass ray { double x; double y; double cta; double r; double p; boolean fromAir; double eps; java.awt.Color color(float); void setAngle(int, int, int, int); void setXY(int, int); double intensity(); void ray(int, int); void ray(); void ray(double, double, double, double, double, boolean); }
  • 28. optics/refraction.classpublicsynchronizedclass refraction extends java.applet.Applet implements Runnable { int yOffset; double time; java.awt.Dimension area; java.awt.Image bgImage; java.awt.Image fgImage; java.awt.Graphics gb; java.awt.Graphics g; java.awt.Color bgColor; String rts; String[] STR; int xx; int yy; boolean running; Thread animThread; long startTime; long lastTime; long delay; long delta; point p; boolean rightClick; java.awt.FontMetrics fm; int chy; int tx; int ty; int yc; int xp; int yp; int N; int ray2cnt; double n; point[] ray; point[] ray2; java.awt.Rectangle r;
  • 29. double vw; int size; int size2; public void init(); public boolean action(java.awt.Event, Object); public void reset(); String d2String(double); public void start(); public void stop(); public void run(); void advanced(double); public boolean mouseDown(java.awt.Event, int, int); public boolean mouseDrag(java.awt.Event, int, int); public boolean mouseUp(java.awt.Event, int, int); void clear(); public void paint(java.awt.Graphics); public void update(java.awt.Graphics); public void refraction(); } optics/shadow.classpublicsynchronizedclass shadow extends java.applet.Applet implements Runnable { double time; java.awt.Dimension area; java.awt.Image bgImage; java.awt.Image fgImage; java.awt.Graphics gb; java.awt.Graphics g; java.awt.Color bgColor; String rts; String[] STR; int xx; int yy; boolean running; Thread animThread;
  • 30. long startTime; long lastTime; long delay; long delta; boolean rightClick; boolean dragr; java.awt.FontMetrics fm; int chy; int tx; int ty; int x0; int y0; int size; int size2; int xc; java.awt.Rectangle r; java.awt.Rectangle s; double m; double b; double x1; double x2; double y1; double y2; public void init(); public boolean action(java.awt.Event, Object); public void reset(); String d2String(double); public void start(); public void stop(); public void run(); void advanced(double); public boolean mouseDown(java.awt.Event, int, int); public boolean mouseDrag(java.awt.Event, int, int); public boolean mouseUp(java.awt.Event, int, int); void clear(); public void paint(java.awt.Graphics);
  • 31. public void update(java.awt.Graphics); public void shadow(); } optics/shadow.html 標題 起頭 [removed] [removed] [removed] 使用說明: 物理解說:to java applet 歡迎批評指教! 電子郵件 : 請按 [email protected] 作者:國立台灣師範大學物理系黃福坤 最後修訂時間: Mirrors Web Site:
  • 32. http://www.phy.ntnu.edu.tw/java/Lens/lens_e.html Instructions: 1. Load up the Java Lab from the web site shown above. 2. Select “Mirror” 3. Press toggle button to “+” (if it’s not already shown) to indicate a converging (concave) mirror. 4. Press the “Reset” button. The value of p (the object’s location) should be 20.0, the value of q (the image location) should be 20.0, the value of f should be +10.0, and “Paraxial” should be checked) 5. Move the object (the blue arrow) to the following positions (p): 30.0, 25.0, 20.0, 15.0, 10.0, and 5.0. (Click near tip of the object, and drag it to where you want to place it, and then release the mouse button.) 6. For each position of the object, record the location of the image (q) and the type of image (real or virtual), as well as the magnification (M) of the image. 7. Plot a graph showing the object’s position (x-axis) versus the image position (y-axis). 8. Plot a graph of the object’s position (x-axis) versus the magnification (y-axis). 9. Press the toggle button to “-“ to indicate a diverging (convex) mirror. 10. Repeat steps 5 through 8 for this mirror. 11. Finally, write the report with your favorite word processor or text editor and submit is to the instructor. In this report discuss the effects produced when a mirror has a large curvature. Use the “Sample Laboratory Report” as a guide in preparing your lab report.
  • 33. Any problems – please e-mail me. Also if you have any complaints, comments, suggestions, or kudos concerning this experiment, please e-mail me. It won’t help your class, but I will take them into consideration for the next time this course is offered. Lens/back.gif Lens/lens.gif Lens/Lens.html Thin Lens (converging/diverging lens/mirrors) [url=http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=704. 0]Equation for thin lens[/url]: $frac{1}{p}+frac{1}{q}=frac{1}{f}$ where [b]p[/b] is the distance between object and lens, [b]q[/b] is the distance between image and lens, and [b]f[/b] is the focus length of lens. blue linestrace of light pathgreen linesbackward tracing for virtual imagesmall red linesdistances f and 2*f away from the center of lens.1st textfieldcurrent mouse position (x , y) relative to lenswhite vertical linereference line (you can click and drag it left/right)yellow linelight path for paraxial ray assumption(mirror only) Parameters can be changed : Select Lens for thin lens effect(default)select mirror for concave/convex mirror effectdefault: assume paraxial ray (you
  • 34. can turn it off)press toggle button +/- to change between converging/diverginglensMove the objectclick near tip of the object, and drag it to where you like it and release the mouse button.Move the lens/mirror:click near center of the lens, and drag it to left or right.if click with left mouse button, only lens will move.if click with right mouse button, object will move with lens.Change the focus length of the lens/mirrorclick near the top/bottom of the lens/mirrir, then drag the mouse . Try it!if you adjust the size of window, parameters reset to default values.you can open more then one window to compare different cases, close the created window to Quit. Press [b]You are welcomed to check out a wonderful [url=http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=139 5.0]thin Len flash animation[/url] created by a teacher in Taiwan [/b] [youtube=E2EmowDS0U4][youtube=HIZiiqGcwCc] More advanced topic [youtube=brTzn9VoGks][youtube=PlG6ps3i9bo] This page is translated from Thin Lens (converging/diverging lens/mirrors) by JoeBova () Lens/lens2.gif Lens/LensWindow.classsynchronizedclass LensWindow extends java.awt.Frame { privatestatic boolean working; boolean is_applet; boolean is_lens; int yOffset; String[] STR;
  • 35. java.awt.TextField textP; java.awt.TextField textQ; java.awt.TextField textF; java.awt.TextField textM; java.awt.Checkbox cThin; java.awt.Button type; java.awt.Dimension area; int xc; int yc; double scale; boolean thinMirror; boolean objectmove; boolean rightClick; boolean moveLine; int xp; int yp; String msg; java.awt.Dimension offDimension; java.awt.Image offImage; java.awt.Graphics g; int ox; int oy; int side; double ix; double iy; double magnify; boolean inrange; boolean normal; int lxc; int lyc; int lh; double lr; double lf; int lwidth; boolean moving; boolean sizing;
  • 36. int[] X; int[] Y; int cnt; int x0; int y0; int ww; int hh; public void start(); public boolean handleEvent(java.awt.Event); void init(); public boolean action(java.awt.Event, Object); public void reset(); public boolean mouseDown(java.awt.Event, int, int); public boolean mouseDrag(java.awt.Event, int, int); public boolean mouseUp(java.awt.Event, int, int); public boolean mouseMove(java.awt.Event, int, int); private void writeXY(int, int); public boolean mouseExit(java.awt.Event, int, int); public void textInput(int, double); public void paint(java.awt.Graphics); public void update(java.awt.Graphics); private void drawGrid(java.awt.Graphics); private void writeText(java.awt.TextField, double); public void drawRay(java.awt.Graphics); String d2String(double); private void drawit(java.awt.Graphics, int, int, int); public void linit(int, int, int, double); boolean lmouseDown(int, int); boolean lmouseUp(int, int); boolean lmouseDrag(int, int); void lmove(int, int); void lshow(); void LensWindow(String, boolean, String[]); static void <clinit>(); }
  • 37. Lens/thinLens.classpublicsynchronizedclass thinLens extends java.applet.Applet { String buttonText; String windowTitle; int windowWidth; int windowHeight; LensWindow m; int windowCount; java.awt.Color bgColor; String rts; String[] STR; public void init(); private void go(); public boolean action(java.awt.Event, Object); publicstatic void main(String[]); private void begin(); public void thinLens(); } Lens/thinLens.javaLens/thinLens.java// Modification history // May 31,1997 fixed bug when object located at focus point // May 22,1997 add paraxial ray option for mirror // Feb 21,1997 major modification, almost rewritten the whole c ode // try without frame => very slow for netscape // Nov. 3, 1996 impletemt double buffering //----------------------------------------------------- // written by Fu-Kwun Hwang // I hope that you enjoy this applet // Suggestions? E-mail to [email protected] //----------------------------------------------------- import java.awt.*; publicclass thinLens extends java.applet.Applet{
  • 38. String buttonText="start"; String windowTitle="Thin Lens demonstration by Fu- Kwun Hwang(1996)"; int windowWidth =600; int windowHeight =350; LensWindow m; int windowCount=0; Color bgColor=newColor(0xC8,0xDF,0xD0); String rts,STR[]={"Reset","p","q","f","m","lens","mirror","Para xial"}; publicvoid init(){ setBackground(bgColor); for(int i=0;i<STR.length;i++){ if((rts=getParameter(STR[i]))!=null) STR[i]=newString(rts); } String str; // get parameters if((str=getParameter("buttonText"))!=null) buttonText=str; if((str=getParameter("windowTitle"))!=null) windowTitle=str; if((str=getParameter("windowWidth"))!=null) windowWidth=Integer.parseInt(str); if((str=getParameter("windowHeight"))!=null) windowHeight=Integer.parseInt(str); if((str=getParameter("autoStart"))!=null){ m =newLensWindow(windowTitle,true,STR); go(); } add(newButton(buttonText)); } privatevoid go(){ m.resize(windowWidth,windowHeight);
  • 39. m.show(); m.start(); } publicboolean action(Event e,Object arg){ if(e.target instanceofButton&& ((String)arg).equals(buttonText)){ m =newLensWindow(String.valueOf(++windowCount)+ ":"+ windowTitle,true,STR); } go(); returntrue; } //allow the applet to also run as an application. publicstaticvoid main(String args[]){ new thinLens().begin(); } privatevoid begin(){ m =newLensWindow(windowTitle,false,STR); go(); } } classLensWindowextendsFrame{ boolean is_applet; boolean is_lens=true; int yOffset=30; String STR[]; LensWindow(String title,boolean isapp,String[] s){ super(title); is_applet=isapp; setBackground(Color.lightGray); STR=s;
  • 40. init(); } publicvoid start(){ reset(); repaint(); // lMirror.hide(); // cThin.hide(); } publicboolean handleEvent(Event e){ if(e.id ==Event.WINDOW_DESTROY){ hide(); removeAll(); dispose(); if(!is_applet)System.exit(0); } returnsuper.handleEvent(e); } TextField textP,textQ,textF,textM;//,textR; // Label lMirror; Checkbox cThin; Button type; Dimension area; int xc,yc; double scale=10.; void init(){ Panel p=newPanel(); // p.add(textR=new TextField(" X , Y",6)); p.add(newLabel(STR[1])); p.add(textP=newTextField("10.",2)); p.add(newLabel(STR[2])); p.add(textQ=newTextField("10.",2)); p.add(newLabel(STR[3])); p.add(type=newButton("+")); p.add(textF=newTextField("5.",2));
  • 41. p.add(newLabel(STR[4])); p.add(textM=newTextField("1.",2)); Choice c; p.add(c=newChoice()); c.addItem(STR[5]); c.addItem(STR[6]); p.add(newButton(STR[0])); // p.add(lMirror=new Label()); p.add(cThin=newCheckbox(STR[7])); cThin.setState(true); cThin.show(); thinMirror=cThin.getState(); add("North",p); show(); } boolean thinMirror=true; publicboolean action(Event ev,Object arg){ if(ev.target instanceofButton){ String label =(String)arg; if(label.equals(STR[0]))reset(); else{ if(label.equals("+")) type.setLabel("-"); elseif(label.equals("-")) type.setLabel("+"); lf*=-1.; repaint(); } }elseif( ev.target instanceofTextField){ String label =(String)arg; double value; value=Double.valueOf(label).doubleValue(); if(ev.target==textP) textInput(1,value); elseif(ev.target==textQ) textInput(2,value); elseif(ev.target==textF) textInput(3,value);
  • 42. elseif(ev.target==textM) textInput(4,value); repaint(); }elseif(ev.target instanceofChoice){ String label =(String)arg; if(label.equals(STR[5])){ is_lens=true; // lMirror.hide(); // cThin.hide(); }else{ is_lens=false; // lMirror.show(); cThin.show(); show(); } lshow(); repaint(); }elseif(ev.target instanceofCheckbox){ thinMirror=cThin.getState(); lshow(); repaint(); } returntrue; } publicvoid reset(){ area=size(); area.height-=yOffset; xc=area.width/2; yc=area.height/2; double ff=10.*scale; type.setLabel("+"); textF.setText(Double.toString(ff)); linit(xc,yc,(int)(0.7*yc),ff); xc-=(int)(2.*lf);// initial object position yc=yc*3/4;
  • 43. repaint(); } boolean objectmove=false,rightClick=false,moveLine=false; int xp,yp;// vertical reference line publicboolean mouseDown(Event e,int x,int y){ y-=yOffset; if(Math.abs(x-xp)<5)moveLine=true; elseif(!lmouseDown(x,y)){ if(Math.abs(x-xc)<5){ xc=x; yc=y; repaint(); objectmove=true; } } if(e.modifiers==Event.META_MASK)//"Right Click, "; rightClick=true; returntrue; } publicboolean mouseDrag(Event e,int x,int y){ y-=yOffset; if(working)returntrue; if(lmouseDrag(x,y)){ if(rightClick)xc=lxc-ox;// also move objects repaint();// change lens }elseif(objectmove){// move object if(!is_lens && x>lxc || lh<Math.abs(y-lyc))returntrue; xc=x; yc=y; if(rightClick)lxc=xc+side*ox;// also move lens writeXY(x,y); repaint(); }elseif(moveLine){ xp=x;
  • 44. yp=y; writeXY(x,y); repaint(); } returntrue; } publicboolean mouseUp(Event e,int x,int y){ y-=yOffset; lmouseUp(x,y); objectmove=false; rightClick=false; moveLine=false; repaint(); returntrue; } publicboolean mouseMove(Event evt,int x,int y){ y-=yOffset; if(working)returntrue; if(!objectmove)writeXY(x,y); repaint(); returntrue; } String msg=" X , Y"; privatevoid writeXY(int x,int y){ //textR.setText( msg= Double.toString((int)(10.*(lxc-x)/scale)/10.)+ ","+ Double.toString((int)(10.*(lyc-y)/scale)/10.); } publicboolean mouseExit(Event evt,int x,int y){ y-=yOffset; // textR.setText(" X , Y");
  • 45. msg=" X , Y"; repaint(); returntrue; } publicvoid textInput(int type,double value){ switch(type){ case1:// P xc=lxc-(int)(value*scale); break; case2:// Q xc=lxc-(int)(1./(1./lf-1./(scale*value))); break; case3:// F lf=value*scale; break; case4:// M xc=lxc-(int)(Math.abs((1.-1./value)*lf)); Colors Web Site: http://www.phy.ntnu.edu.tw/java/image/rgbColor.htmlOR http://users.hal- pc.org/~clement/Simulations/Mixing%20Colors/rgbColor.html (Either website will work for this lab-please use whichever one loads for you!) Introduction: Thomas Young, in the early 1800s, showed that a broad range of
  • 46. colors can be generated by mixing three beams of light, provided their frequencies were widely separately. When three such beams combine to produce white light, they are called primary colors. There is no single unique set of these primaries, nor do they have to be made up of single (monochromatic) colors. The three components (emitted by three phosphors) that generate the whole gamut of hues as seen on a color TV set are Red, Green, and Blue. These are the primary colors. Looking through a colored window or cloth is another story. Yellow cloth, paper, dye, paint, and ink all selectively absorb blue, and reflect what remains – yellow. And that is why they appear yellow. When dealing with pigments (paints), the primary pigments are yellow, magenta (a light violet color), and cyan (a bluish-green hue). This Java applet let you play with mixing light beams and paint pigments. Instructions: 1. Load up the Java Lab from the web site shown above. 2. Click the right mouse button twice quickly to switch between two different modes: a. Mixing light beams (black background) b. Mixing paint pigments (white background) 3. Set the screen for mixing light beams.
  • 47. 4. Click the left mouse button and drag one of the colored ovals to move it around. 5. Determine what colors are obtained when two of the ovals intersect each other. Do this for all combinations of two ovals. 6. What color is obtained when the three ovals intersect each other? 7. Set the screen for mixing paint pigments. 8. Repeat steps 4 through 6 for paint pigments. 9. Finally, write the report telling what results were obtained in this experiment with your favorite word processor or text editor and submit is to the instructor. Use the “Sample Laboratory Report” as a guide in preparing your lab report. Any problems – please e-mail me. Also if you have any complaints, comments, suggestions, or kudos concerning this experiment, please e-mail me. It won’t help your class, but I will take them into consideration for the next time this course is offered colors_java/back.gif colors_java/fkhSprite.classsynchronizedclass fkhSprite extends java.awt.Rectangle { staticfinal double PI2 = 1.5707963267948966; int[] pix; int index;
  • 48. int color; void init(int, int, int, int); void init(int, int, int, int, java.awt.Color); void setColor(java.awt.Color); void setColor(int); void transparent(java.awt.Color); void eraseBackground(java.awt.Color); void fillOval(); void Circles(int, java.awt.Color); void fkhSprite(int, int); void fkhSprite(int, int, int, int); void fkhSprite(int, int, int, int, java.awt.Color); void fkhSprite(int, int, int, int, java.awt.Image); } colors_java/fkhStage.classsynchronizedclass fkhStage extends fkhSprite { staticfinal int COPY = 0; staticfinal int OR = 1; staticfinal int AND = 2; int Npts; int count; java.util.Vector objs; boolean changed; java.awt.Rectangle tmp; int id; fkhSprite sprite; int mode; void makeClone(); void dirty(); boolean isDirty(); void clean(); public int which(int, int); public void Drag(int, int, int); fkhSprite addImage(int, int, int, int, java.awt.Image,
  • 49. java.awt.Color); fkhSprite fillOval(int, int, int, int, java.awt.Color); void drawCircuits(int, int, int, int, java.awt.Color); void flush(); void setMode(int); int getColor(int, int); void operate(fkhSprite, int); void fkhStage(int, int); } colors_java/fkhStage.javacolors_java/fkhStage.javaimport java. awt.*; import java.awt.image.*; import java.util.*; class fkhStage extends fkhSprite{ intNpts,count; Vector objs=newVector(); boolean changed=false; fkhStage(int w,int h){ super(w,h); } Rectangle tmp; void makeClone(){ tmp=(Rectangle)objs.elementAt(0); for(int i=1;i<count;i++) tmp=tmp.union((Rectangle)objs.elementAt(i)); tmp=intersection(tmp); pix=newint[tmp.width*tmp.height]; } void dirty(){ changed=true; } boolean isDirty(){ return changed;
  • 50. } void clean(){ changed=false; } int id=-1; fkhSprite sprite; publicint which(int xi,int yi){ id=-1; for(int i=0;i<count;i++){ sprite=(fkhSprite)objs.elementAt(i); if(sprite.inside(xi,yi)){ id=i; break; } } return id; } publicvoidDrag(int i,int dx,int dy){ if(id!=-1){ sprite.x+=dx; sprite.y+=dy; dirty(); } } fkhSprite addImage(int xi,int yi,int w,int h,Image img,Color bgColor){ fkhSprite member=new fkhSprite(xi,yi,w,h,img); member.eraseBackground(bgColor);//transparent objs.addElement(member); dirty(); return member; } fkhSprite fillOval(int xi,int yi,int w,int h,Color c){ fkhSprite member=new fkhSprite(xi,yi,w,h,c); member.fillOval(); objs.addElement(member);
  • 51. dirty(); return member; } void drawCircuits(int w,int h,int ri,int N,Color c){ fkhSprite member=new fkhSprite(0,0,w,h); member.Circles(ri/N,c); objs.addElement(member); dirty(); } void flush(){ count=objs.size(); if(changed)makeClone(); elsereturn; // if(objs==null)return; operate((fkhSprite)objs.elementAt(0),COPY); if(count>0)for(int i=1;i<count;i++){ operate((fkhSprite)objs.elementAt(i),mode); } clean(); } int mode=OR;// or and finalstaticint COPY=0,OR=1,AND=2; void setMode(int newmode){ mode=newmode; dirty(); } int getColor(int dx,int dy){ if(tmp!=null&& inside(dx-=tmp.x,dy- =tmp.y))return pix[dy*tmp.width+dx]; elsereturn0; } void operate(fkhSprite src,int mode){ int dd,id,xmin=0,xmax=src.width,ymin=0,ymax=src.height; int id0,xmin0=0,xmax0=tmp.width,ymin0=0,ymax0=tmp.height; int[] pixs=src.pix; if(src.x>tmp.x) xmin0=src.x-tmp.x;
  • 52. else xmin=tmp.x-src.x; if(src.x+src.width>tmp.x+tmp.width)xmax=tmp.x+tmp.width- src.x; else xmax0=src.x+src.width-tmp.x; if(src.y>tmp.y) ymin0=src.y-tmp.y; else ymin=tmp.y-src.y; if(src.y+src.height>tmp.y+tmp.height)ymax=tmp.y+tmp.height- src.y; else ymax0=src.y+src.height-tmp.y; dd=(ymin0-ymin)*tmp.width+xmin0; switch(mode){ case COPY: for(int i=ymin;i<ymax;i++){ id0=i*tmp.width+dd; id=i*src.width+xmin; for(int j=xmin;j<xmax;j++){ pix[id0++]= pixs[id++]; // if(pixs[id]!=0)pix[id0++] =pixs[id++] ; } } break; case OR: for(int i=ymin;i<ymax;i++){ id0=i*tmp.width+dd; id=i*src.width+xmin; for(int j=xmin;j<xmax;j++){ pix[id0++]|= pixs[id++]; } } break; case AND: for(int i=ymin;i<ymax;i++){ id0=i*tmp.width+dd; id=i*src.width+xmin; for(int j=xmin;j<xmax;j++,id0++,id++){
  • 53. if(pix[id0]==0) pix[id0]= pixs[id]; elseif(pixs[id]!=0)pix[id0]&= pixs[id]; } } break; } } } class fkhSprite extendsRectangle{ int[] pix; int index,color=0; fkhSprite(int w,int h){ x=y=0; width=w; height=h; } fkhSprite(int xi,int yi,int w,int h){ init(xi,yi,w,h); } fkhSprite(int xi,int yi,int w,int h,Color c){ init(xi,yi,w,h,c); } /* How to use this Image img=createImage(width,height); // in applets Graphics g=sprite.getGraphic(); g.setColor(Color.yellow); g.fillOval(x,y,w,h);//drawing work s fkhSprite sprite=new fkhSprite(x,y,w,h,img); */ fkhSprite(int xi,int yi,int w,int h,Image img){ init(xi,yi,w,h); PixelGrabber pg =newPixelGrabber(img, x, y, w, h, pix,0, w); try{ pg.grabPixels(); }catch(InterruptedException e){
  • 54. System.err.println("interrupted waiting for pixels!"); return; } } void init(int xi,int yi,int w,int h){ x=xi; y=yi; width=w; height=h; pix=newint[w*h]; } void init(int xi,int yi,int w,int h,Color c){ init(xi,yi,w,h); index=0; color=c.getRGB(); for(int i=0;i<height;i++) for(int j=0;j<width;j++)pix[index++]=color; } void setColor(Color c){ setColor(c.getRGB()); } void setColor(int value){ int N=width*height; for(int i=0;i<N;i++) if(pix[i]!=0)pix[i]=value; } void transparent(Color bgColor){ int value=bgColor.getRGB(); int N=width*height,code=0xFFFFFF; for(int i=0;i<N;i++) if(pix[i]==value)pix[i]&=code; } void eraseBackground(Color bgColor){ int value=bgColor.getRGB(); int N=width*height; for(int i=0;i<N;i++)
  • 55. if(pix[i]==value)pix[i]=0; } void fillOval(){ double w=width/2.,h=height/2.,w2=w*w,h2=h*h; int wi=(int)w,hi=(int)h,ww=width-1,hh=height-1, dd=hh*width; for(int i=0;i<hi;i++){ for(int j=0;j<wi;j++){ if((i-h)*(i-h)/h2+(j-w)*(j-w)/w2>1.){ index=i*width; pix[index+j]=0; pix[index+ww-j]=0; index=dd-index; pix[index+j]=0; pix[index+ww-j]=0; }elsebreak; } } } finalstaticdouble PI2=Math.PI/2.; voidCircles(int dr,Color clr){ double dc,cmax; int xc=width/2,yc=height/2,r; int xx,yy,color=clr.getRGB(),id0=yc*width+xc,id; intNmax=width*height; for(r=dr;r<xc;r+=dr){ dc=1./r; cmax=PI2*r+dc; for(double c=0.;c<PI2;c+=dc){ xx=(int)(r*Math.cos(c)); yy=(int)(r*Math.sin(c)); //if(xx<xc && yy<yc){ if((id=id0+yy*width+xx)<Nmax){ pix[id]=color; pix[id-=2*xx]=color; if((id-=2*yy*width)>0){
  • 56. pix[id]=color; pix[id+=2*xx]=color; } } } } } } colors_java/image.classpublicsynchronizedclass image extends java.applet.Applet { static boolean free; int yOffset; double time; double ts; java.awt.Dimension area; java.awt.Image bgImage; java.awt.Image fgImage; java.awt.Graphics gb; java.awt.Graphics g; java.awt.Color bgColor; boolean running; boolean rightClick; boolean dragging; int xs; int ys; int id; java.awt.FontMetrics fm; int chy; fkhStage stage; java.awt.Image img; int xc; int yc; int dr;
  • 57. int xx; int yy; int size; int size2; int xp; int yp; double r1; double r2; public void init(); public boolean action(java.awt.Event, Object); public void reset(boolean); String d2String(double); public boolean mouseDown(java.awt.Event, int, int); public boolean mouseDrag(java.awt.Event, int, int); public boolean mouseUp(java.awt.Event, int, int); void clear(); public void paint(java.awt.Graphics); public void update(java.awt.Graphics); public void image(); static void <clinit>(); } colors_java/image.javacolors_java/image.java// template file for java applet import java.awt.*; import java.awt.image.*; import java.util.*; publicclass image extends java.applet.Applet{// implements Run nable{ int yOffset=0; //TextField timeField; //record time elapse double time=0.0,ts=0.; Dimension area; Image bgImage,fgImage;
  • 58. Graphics gb,g;//background drawing Color bgColor=Color.cyan;//lightGray; publicvoid init(){ setBackground(bgColor); area=size(); /* area.height-=yOffset; Panel p=new Panel(); //p.add(timeField=new TextField("0.0",4)); p.add(new Button("Reset")); p.add(new Button("Start")); add("North",p);*/ // add("South",img=new fkhImage(area.width,area.height,bg Color)); reset(true);// false for auto start } publicboolean action(Event ev,Object arg){ if(ev.target instanceofButton){ String label =(String)arg; if(label.equals("Reset")){ reset(true); }elseif(label.equals("Start")){ running=true; start(); } } returntrue; } // int xx=50,yy=50,w=100,h=100; publicvoid reset(boolean status){ clear(); // stop(); //if(status){ // ts=time=0.; // timeField.setText("0.00"); //}
  • 59. } String d2String(double value){ float f=(float)((int)(value*10.)/10.); String str=String.valueOf(f); if(str.indexOf(".")==-1)str+=".0"; return str; } // animation code boolean running=false; /* Thread animThread; long startTime=0,lastTime; long delay=50,delta; // This starts the threads. public void start(){ //Start animating! if (animThread == null) { animThread = new Thread(this); animThread.start(); } //Remember the starting time. of thread lastTime=startTime = System.currentTimeMillis(); time=0.; } public void stop() { //Stop the animating thread. animThread = null; running=false; } public void run() { //Just to be nice, lower this thread's priority Thread.currentThread().setPriority(Thread.MIN_PRIORIT Y); //This is the animation loop. while (Thread.currentThread() == animThread) {
  • 60. //Advance the animation frame. with delta time delta=System.currentTimeMillis()-lastTime; lastTime+=delta; if(running)advanced(delta/1000.); startTime+=delay; try { animThread.sleep(Math.max(0,startTime- System.currentTimeMillis())); } catch (InterruptedException e) { break; } } } void advanced(double dt){ //time+=dt; //ts+=dt; //if(ts>1.){ // ts-=1.; // timeField.setText(String.valueOf(time)); //} // .advanced(dt); //repaint(); } */ boolean rightClick=false,dragging=false; int xs,ys,id; publicboolean mouseDown(Event e,int x,int y){ if((y-=yOffset)<0)returnfalse; if(e.modifiers==Event.META_MASK){//"Right Click, "; rightClick=true; dragging=true; }else{ rightClick=false; /// id=stage.which(x,y); //if(x-xx<w && y-yy<h)
  • 61. // if(id>-1) repaint(); } xs=x; ys=y; running=!running; returntrue; } publicboolean mouseDrag(Event e,int x,int y){ if(!free ||(y-=yOffset)<0)returnfalse; if(dragging){ // stage.Drag(id,x-xs,y-ys); xx+=x-xs; yy+=y-ys; repaint(); } xs=x; ys=y; returntrue; } publicboolean mouseUp(Event e,int x,int y){ if((y-=yOffset)<0)returnfalse; if(rightClick){ running=!running; } dragging=false; returntrue; } FontMetrics fm; int chy; fkhStage stage; Image img; int xc,yc,dr=6,xx,yy; int size=2,size2=2*size; void clear(){
  • 62. if(g==null){ bgImage = createImage(area.width, area.height); gb = bgImage.getGraphics(); fgImage = createImage(area.width, area.height); g = fgImage.getGraphics(); fm=gb.getFontMetrics(); chy=fm.getHeight(); stage=new fkhStage(area.width,area.height); xc=area.width/2; yc=area.height/2; xs=xc+12*dr; ys=yc-20*dr; } gb.setColor(bgColor); gb.fillRect(0,0, area.width, area.height); Color clr=Color.gray; gb.setColor(clr);//Color.black); for(int i=0,xi=xc-dr,yi=yc-dr,dx=2*dr;xi>0;xi-=dr,yi- =dr,dx+=2*dr) gb.drawOval(xi,yi,dx,dx); gb.setColor(Color.red); gb.fillOval(xc-size,yc-size,size2,size2); // gb.setColor(Color.black); // gb.drawRect(0,0,area.width-1,area.height-1); stage.drawCircuits(area.width,area.height,xc,xc/dr,clr);//C olor.black);//magenta);//red); xx=6*dr; if(stage.isDirty()){ stage.flush(); img=createImage(newMemoryImageSource(stage.tmp.w idth, stage.tmp.height, stage.pix,0, stage.tmp.width)); // xx=xc+2*dr; } // stage.drawCircuits(60,50,200,20,Color.black);//magenta);/ /red); // stage.fillOval(50,50,200,100,Color.magenta);//red);
  • 63. // stage.fillOval(150,60,200,100,Color.yellow);//blue);/ // stage.fillOval(30,80,100,100,Color.cyan);//green); // repaint(); } publicvoid paint(Graphics gs){ update(gs); } staticboolean free=true; int xp,yp; double r1,r2; publicvoid update(Graphics gs){ free=false; g.drawImage(bgImage,0,0,this); // if(img!=null)g.drawImage(img,stage.tmp.x,stage.tmp.y,thi s); if(img!=null)g.drawImage(img,xx,yy,this); xp=xx+xc; yp=yy+yc; g.setColor(Color.red); g.fillOval(xp-size,yp-size,size2,size2); if(!dragging){ g.setColor(Color.blue);//yellow); // g.drawLine(xp,yp,xc,yc); g.drawLine(xc,yc,xs,ys); g.drawLine(xp,yp,xs,ys); // g.setColor(Color.blue); r2=Math.sqrt((xp-xs)*(xp-xs)+(yp-ys)*(yp-ys))/dr; r1=Math.sqrt((xc-xs)*(xc-xs)+(yc-ys)*(yc-ys))/dr; g.drawString("r1 = "+d2String(r1)+", r2 = "+d2String(r2) + ", r1-r2 = "+d2String(r1-r2),10,chy); } gs.drawImage(fgImage,0, yOffset,this); free=true; } }
  • 64. colors_java/rgb.gif colors_java/RGBcolor - Shortcut.lnk colors_java/RGBcolor.html Colors (Mixing color or paint: R/G/B) Thomas Young, in the early 1800s, showed that a broad range of colors can be generated by mixing three beams of light, provided their frequencies were widely separately. When three such beams combine to produce white light, there are called primary colors. There is no single unique set of these primaries, nor do they have to be monochromatic. The three components (emitted by three phoshors) that generate the whole gamut of hues seen on a color TV set are Red, Green, Blue. Looking through a colored window or cloth is another story. Yellow cloth, paper, dye, paint, and ink all selectively absorb blue and reflect what remains - yellow - and that is why they appear yellow. This java applet let you play with mixing light beams and paint pigments. [removed] [removed] [removed] [removed]
  • 65. Click the right mouse button twice quickly to switch between two different modes: ModebackgroundMixing light beamsblackMixing paint pigmentswhite Click left mouse button and drag one of the colored oval to move it around. Enter RGB values into the text field to change the color of the selected oval. The color code (RGB value) at the mouse tip are shown in colored background. This page is translated from Colors (Mixing color or paint: R/G/B) by JoeBova () colors_java/rgbLight.classpublicsynchronizedclass rgbLight extends java.applet.Applet { staticfinal int PAINT = 1; staticfinal int LIGHT = 0; static boolean free; int yOffset; java.awt.Dimension area; java.awt.Image bgImage; java.awt.Image fgImage; java.awt.Graphics gb; java.awt.Graphics g;
  • 66. java.awt.TextField[] tf; java.awt.Label lbr; java.awt.Label lbg; java.awt.Label lbb; java.awt.Label ltype; String rts; String[] STR; java.awt.Color bgColor; boolean rightClick; boolean dragging; int xs; int ys; int id; java.awt.FontMetrics fm; int chy; fkhStage stage; fkhSprite[] OBJ; java.awt.Image img; int xc; int yc; int dr; int xx; int yy; int size; int size2; java.awt.Color[] clr1; java.awt.Color[] clr2; java.awt.Color[] clr; int mode; int N; int xp; int yp; double r1; double r2; public void init(); public boolean action(java.awt.Event, Object);
  • 67. int cValue(java.awt.TextField); String d2String(double); public boolean mouseDown(java.awt.Event, int, int); void showValue(); public boolean mouseDrag(java.awt.Event, int, int); public boolean mouseUp(java.awt.Event, int, int); public boolean mouseMove(java.awt.Event, int, int); void showRGB(int, int); void setMode(int); void clear(); public void paint(java.awt.Graphics); public void update(java.awt.Graphics); public void rgbLight(); static void <clinit>(); } colors_java/rgbLight.javacolors_java/rgbLight.javaimport java.a wt.*; import java.awt.image.*; import java.util.*; publicclass rgbLight extends java.applet.Applet{// implements Runnable{ int yOffset=40; Dimension area; Image bgImage,fgImage; Graphics gb,g;//background drawing // Color bgColor=Color.cyan;//white;//cyan;//lightGray; // String tfl[]={"R","G","B"}; TextField tf[]=newTextField[3]; Label lbr,lbg,lbb,ltype; String rts,STR[]={"R","G","B","MSG1","MSG2"}; Color bgColor=newColor(0xC8,0xDF,0xD0); publicvoid init(){ for(int i=0;i<STR.length;i++){
  • 68. if((rts=getParameter(STR[i]))!=null) STR[i]=newString(rts); } setBackground(bgColor); Panel p=newPanel(); p.add(ltype=newLabel(STR[3]+" ")); p.add(lbr=newLabel(" ")); lbr.setBackground(Color.red); p.add(lbg=newLabel(" ")); lbg.setBackground(Color.green); p.add(lbb=newLabel(" ")); for(int i=0;i<3;i++){ p.add(newLabel(STR[i])); p.add(tf[i]=newTextField(2)); } lbb.setBackground(Color.blue); lbb.setForeground(Color.white); add("North",p); area=size(); clear(); } publicboolean action(Event ev,Object arg){ if(id!=-1&& ev.target instanceofTextField){ try{ Color c=newColor(cValue(tf[0]),cValue(tf[1]),cValue(tf[2])); clr[id]=c; OBJ[id].setColor(c); stage.dirty(); repaint(); }catch(NumberFormatException e){ showValue(); } } returntrue; } int cValue(TextField t){
  • 69. int value=(int)Integer.parseInt(t.getText())%256; t.setText(String.valueOf(value)); return value; } String d2String(double value){ float f=(float)((int)(value*10.)/10.); String str=String.valueOf(f); if(str.indexOf(".")==-1)str+=".0"; return str; } boolean rightClick=false,dragging=false; int xs,ys,id; publicboolean mouseDown(Event e,int x,int y){ if((y-=yOffset)<0)returnfalse; if(e.modifiers==Event.META_MASK){//"Right Click, "; rightClick=true; if(e.clickCount==2){ if(mode==LIGHT)setMode(PAINT); else setMode(LIGHT); for(int i=0;i<N;i++)OBJ[i].setColor(clr[i]); repaint(); showRGB(x, y); } }else{ rightClick=false; dragging=true; id=stage.which(x,y); showValue(); } xs=x; ys=y; returntrue; } void showValue(){ if(id!=-1)for(int i=0;i<STR.length;i++){ tf[0].setText(String.valueOf(clr[id].getRed()));
  • 70. tf[1].setText(String.valueOf(clr[id].getGreen())); tf[2].setText(String.valueOf(clr[id].getBlue())); } } publicboolean mouseDrag(Event e,int x,int y){ if(!free ||(y-=yOffset)<0)returnfalse; if(dragging){ stage.Drag(id,x-xs,y-ys); xx+=x-xs; yy+=y-ys; repaint(); showRGB(x, y); } xs=x; ys=y; returntrue; } publicboolean mouseUp(Event e,int x,int y){ if((y-=yOffset)<0)returnfalse; dragging=false; returntrue; } publicboolean mouseMove(Event e,int x,int y){ if(dragging ||(y-=yOffset)<0)returnfalse; showRGB(x,y); returntrue; } void showRGB(int x,int y){ int value=stage.getColor(x,y); Color c; if(value==0)c=clr[3]; else c=newColor(value); //clb.setText("("+c.getRed()+","+c.getGreen()+","+c.getBlue()+ ")"); lbr.setText(String.valueOf(c.getRed())); lbg.setText(String.valueOf(c.getGreen()));
  • 71. lbb.setText(String.valueOf(c.getBlue())); } FontMetrics fm; int chy; fkhStage stage; fkhSprite OBJ[]=new fkhSprite[3]; Image img; int xc,yc,dr=6,xx,yy; int size=2,size2=2*size; Color clr1[]={Color.red,Color.green,Color.blue,Color.black}; Color clr2[]={Color.cyan,Color.magenta,Color.yellow,Color.wh ite}; Color clr[]; finalstaticint PAINT=1,LIGHT=0; int mode,N=OBJ.length; void setMode(int newmode){ mode=newmode; if(newmode==LIGHT){ clr=clr1; stage.setMode(fkhStage.OR); ltype.setText(STR[3]); }else{ clr=clr2; stage.setMode(fkhStage.AND); ltype.setText(STR[4]); } gb.setColor(clr[N]); gb.fillRect(0,0, area.width, area.height); // gb.setColor(cs); // gb.drawString(msg,5,chy); } void clear(){ if(g==null){ bgImage = createImage(area.width, area.height); gb = bgImage.getGraphics(); fgImage = createImage(area.width, area.height);
  • 72. g = fgImage.getGraphics(); fm=gb.getFontMetrics(); chy=fm.getHeight(); stage=new fkhStage(area.width,area.height); xc=area.width/2; yc=area.height/2; //mode=LIGHT; setMode(LIGHT); // g.setColor(Color.red); // g.fillOval(25,25,200,100); // g.setColor(Color.yellow); // g.fillOval(50,50,50,50); // OBJ[0]=stage.addImage(5,5,200,100,fgImage,bgColor); OBJ[0]=stage.fillOval(5,5,200,100,clr[0]); OBJ[1]=stage.fillOval(xc,5,200,100,clr[1]); OBJ[2]=stage.fillOval(xc-75,140,150,150,clr[2]); } // repaint(); } publicvoid paint(Graphics gs){ update(gs); } staticboolean free=true; int xp,yp; double r1,r2; publicvoid update(Graphics gs){ free=false; g.drawImage(bgImage,0,0,this); if(stage.isDirty()){ stage.flush(); img=createImage(newMemoryImageSource(stage.tmp.w idth, stage.tmp.height, stage.pix,0, stage.tmp.width)); } if(img!=null)g.drawImage(img,stage.tmp.x,stage.tmp.y,this); gs.drawImage(fgImage,0, yOffset,this); free=true;
  • 73. } } colors_java/ripple.classpublicsynchronizedclass ripple extends java.applet.Applet { static boolean free; int yOffset; double time; double ts; java.awt.Dimension area; java.awt.Image bgImage; java.awt.Image fgImage; java.awt.Graphics gb; java.awt.Graphics g; java.awt.Color bgColor; boolean rightClick; boolean dragging; int xs; int ys; java.awt.FontMetrics fm; int chy; fkhStage stage; java.awt.Image img; int xc; int yc; int dr; int xx; int yy; int size; int size2; int xp; int yp; double r1;
  • 74. double r2; public void init(); String d2String(double); public boolean mouseDown(java.awt.Event, int, int); public boolean mouseDrag(java.awt.Event, int, int); public boolean mouseUp(java.awt.Event, int, int); void clear(); public void paint(java.awt.Graphics); public void update(java.awt.Graphics); public void ripple(); static void <clinit>(); } colors_java/ripple.html 波的干涉 以下是 兩組同心圓 用以表示 波動的 波前。 是否觀察到有一些 條紋的錯覺呢? 那些條紋與 波動的建設性干涉處是否相關呢? 使用說明: 在區域內按下滑鼠左鍵 將顯示兩波源分別到滑鼠的距離(以波長為單位)。 在同一道條紋內兩波源間的距離差 有何特殊之處呢? 按下滑鼠右鍵後拖動滑鼠 則可以移動其中一個波源的位置。 好好的玩一玩 同時觀察其中的規律性 ! 歡迎批評指教! 電子郵件 : 請按 [email protected]作者:國立台灣師範大學物理系黃福坤最後修訂時間: colors_java/ripple.javacolors_java/ripple.javaimport java.awt.*;
  • 75. import java.awt.image.*; import java.util.*; publicclass ripple extends java.applet.Applet{ int yOffset=0; double time=0.0,ts=0.; Dimension area; Image bgImage,fgImage; Graphics gb,g;//background drawing // Color bgColor=Color.cyan;//lightGray; Color bgColor=newColor(0xC8,0xDF,0xD0); publicvoid init(){ setBackground(bgColor); area=size(); clear(); } String d2String(double value){ float f=(float)((int)(value*10.)/10.); String str=String.valueOf(f); if(str.indexOf(".")==-1)str+=".0"; return str; } boolean rightClick=false,dragging=false; int xs,ys; publicboolean mouseDown(Event e,int x,int y){ if((y-=yOffset)<0)returnfalse; if(e.modifiers==Event.META_MASK){//"Right Click, "; rightClick=true; dragging=true; }else{ rightClick=false; repaint(); } xs=x; ys=y;
  • 76. returntrue; } publicboolean mouseDrag(Event e,int x,int y){ if(!free ||(y-=yOffset)<0)returnfalse; if(dragging){ xx+=x-xs; yy+=y-ys; repaint(); } xs=x; ys=y; returntrue; } publicboolean mouseUp(Event e,int x,int y){ if((y-=yOffset)<0)returnfalse; dragging=false; returntrue; } FontMetrics fm; int chy; fkhStage stage; Image img; int xc,yc,dr=6,xx,yy; int size=2,size2=2*size; void clear(){ if(g==null){ bgImage = createImage(area.width, area.height); gb = bgImage.getGraphics(); fgImage = createImage(area.width, area.height); g = fgImage.getGraphics(); fm=gb.getFontMetrics(); chy=fm.getHeight(); stage=new fkhStage(area.width,area.height); xc=area.width/2; yc=area.height/2;
  • 77. xs=xc+12*dr; ys=yc-20*dr; } gb.setColor(bgColor); gb.fillRect(0,0, area.width, area.height); Color clr=Color.darkGray; gb.setColor(clr);//Color.black); for(int i=0,xi=xc-dr,yi=yc-dr,dx=2*dr;xi>0;xi-=dr,yi- =dr,dx+=2*dr) gb.drawOval(xi,yi,dx,dx); gb.setColor(Color.red); gb.fillOval(xc-size,yc-size,size2,size2); stage.drawCircuits(area.width,area.height,xc,xc/dr,clr);//C olor.black);//magenta);//red); xx=6*dr; if(stage.isDirty()){ stage.flush(); img=createImage(newMemoryImageSource(stage.tmp.w idth, stage.tmp.height, stage.pix,0, stage.tmp.width)); } } publicvoid paint(Graphics gs){ update(gs); } staticboolean free=true; int xp,yp; double r1,r2; publicvoid update(Graphics gs){ free=false; g.drawImage(bgImage,0,0,this); if(img!=null)g.drawImage(img,xx,yy,this); xp=xx+xc+1; yp=yy+yc; g.setColor(Color.red); g.fillOval(xp-size,yp-size,size2,size2); if(!dragging){