java program structure
hey all i was wondering if you could take a look at this code its driving me nuts basically its a java file used to demonstrate an erosion process its driving me nuts i need to sperate the file into two files really so that it works on behalf of an abstract class. gr programming it confuses me all help and comments appreciated cheers
Chris
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Arc2D;
import java.awt.geom.Point2D;
class structureshapes extends JFrame
{
int lh = 0;
int count = 0;
public structureshapes()
{
setSize(500,500);
setBackground(Color.cyan); /*defines the background colour*/
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
do
{
try
{
Thread.sleep(1); /*draws arcs in 1mm of speed*/
}
catch (InterruptedException e) /*if the program gets interrupted*/
{
}
count = count + 1;
lh = lh+1;
repaint();
}
while (count < 50);
do
{
try
{
Thread.sleep(100);/*adapts the speed of the program*/
}
catch (InterruptedException e)
{
}
lh = lh+1;
repaint();
}
while (lh<100);
do
{
try
{
Thread.sleep(100);
}
catch (InterruptedException e)
{
}
lh = lh + 1;
repaint();
}
while (lh<160);
}
public void paint(Graphics g)
{
Graphics2D g2D = (Graphics2D) g;
if (lh < 100)
{
g.setColor(Color.black);
Point2D.Double position = new Point2D.Double(-35,500-lh);
Arc2D.Double water = new Arc2D.Double(position.x, position.y, 575, 100, 30, 120, Arc2D.OPEN);
Arc2D.Double oil = new Arc2D.Double(position.x, position.y-50, 575, 120, 30, 120, Arc2D.OPEN);
Arc2D.Double shale = new Arc2D.Double(position.x, position.y-100, 575, 120, 30, 120, Arc2D.OPEN);
Arc2D.Double sandstone = new Arc2D.Double(position.x, position.y-150, 575, 120, 30, 120, Arc2D.OPEN);
Arc2D.Double limestone = new Arc2D.Double(position.x, position.y-200, 575, 120, 30, 120, Arc2D.OPEN);
g2D.setPaint(Color.BLUE);/*defines the water layer colour*/
g2D.draw(water);
g2D.setPaint(Color.BLACK);/* defines the oil layer colour*/
g2D.draw(oil);
g2D.setPaint(Color.GRAY);/* defines the shale layer colour*/
g2D.draw(shale);
g2D.setPaint(Color.YELLOW); /* defines the sandstone layer colour*/
g2D.draw(sandstone);
g2D.setPaint(Color.GREEN);/* defines the limestone layer colour*/
g2D.draw(limestone);
g2D.setPaint(Color.YELLOW); /* defines the sun layer colour*/
g2D.fillOval(10, 50,50,50);
}
if (lh > 100)
{
/*erosion process*/
g2D.setPaint(Color.CYAN);
g2D.fillRect(0,200,500, lh-100);
}
}
public static void main (String []args)
{
structureshapes structured = new structureshapes();
}
}
__________________
in opposite world i love programming
|