★ wanayoo — archive 1999 http://java.webdeveloper.com/AbstractSpace/source.htmlNouvelle recherche | Portail wanayoo
Computer Digital Expo

The Event For Leading Edge Flash Development


Find a Web Host With:
CGI Access
DB Support
NT Servers
UNIX Servers
Telnet Access

advanced search
Internet News
Internet Investing
IT
Windows Technology
Linux/Open Source
Developer
Interactive Marketing
xSP Resources
Small Business
Wireless Internet
Downloads
Internet Resources
Internet Lists
International
EarthWeb
Career Resources

Search internet.com
Advertise
Corporate Info
Newsletters
E-mail Offers
Be a Commerce Partner
Business Search
Compare Prices & Shop
Tax Consultants
Build an Online Store
Shop For Computers
FREE Credit Report
Best Deals on PDAs!
Top Selling Books
Web Hosting
Hacker's Secrets
FlashKit
Gif.com
HierMenusCentral
JavaBoutique
JavaScript.com
JavaScriptSource
WebDev Jobs
JustSMIL
ScriptSearch
StreamingMediaWorld
Web Hosts
WebDevelopersJournal WDVL
WebDeveloper.com
WebReference.com
XMLFiles.com
CGI
HTML
Java
JavaScript
Web Design and Promotion
Web Site Development
E-mail Address:


Can you receive
HTML e-mail?

Yes   No

Zip Code:



Aabstract Space


Java Source:

// Abstract space
// Copyright (C) 2002 Charles Foster
// Please visit www.cfoster.net

import java.awt.*;
import java.applet.*;

public class AbstractSpace extends Applet implements Runnable
{
	double[][] stars;
	double centerx, centery;

	Thread myThread = null;
	Image myImage = null;
	Graphics g2;

	boolean clicked = false;
	boolean credits = true;

	double speedx = 0.02, speedy = 0.02, angrot = 0.05;
	double oldx = 0, oldy = 0;
	int stramt, j;

	public void init()
	{
		centerx = (int)size().width/2;
		centery = (int)size().height/2;
		getParameters();
		for(int i=0;i<stars.length;i++)
		{
			buildStar(i);
		}
		myImage = createImage(size().width,size().height);
		g2 = myImage.getGraphics();
	}
	public void getParameters()
	{
		speedx = (double)(Integer.parseInt(getParameter("speedx")))/100;
		speedy = (double)(Integer.parseInt(getParameter("speedy")))/100;
		angrot = (double)(Integer.parseInt(getParameter("angrot")))/100;
		stramt = Integer.parseInt(getParameter("stramt"));
		stars = new double[stramt][6];
	}
	public void buildStar(int s)
	{
		stars[s][0] = 0;
		stars[s][1] = 0;

		stars[s][2] = 0;
		stars[s][3] = 0;

		stars[s][4] = Math.random()*360; // angle to start
		stars[s][5] = Math.random()*size().width*2; // life expectancy
	}
	public void start()
	{
		if(myThread == null)
		{
			myThread = new Thread(this);
			myThread.start();
		}
	}
	public void stop()
	{
		if(myThread != null)
		{
			myThread.stop();
			myThread = null;
		}
	}
	public void run()
	{
		while(true)
		{
			g2.setColor(Color.black);
			g2.fillRect(0,0,size().width,size().height);
			if(credits)
			{
				g2.setColor(Color.green);
				g2.drawString("Abstract Space, Copyright (C) Charles Foster 2002",20,20);
				g2.drawString("www.cfoster.net",20,35);
				if(++j > 400) { credits = false; }
			}
			g2.setColor(Color.white);
			for(int i=0;i<stars.length;i++)
			{
				if(!clicked)
				{
					if(stars[i][0] > stars[i][5]) { buildStar(i); }
					stars[i][0] = Math.cos(oldx+stars[i][4])*stars[i][2]*180/Math.PI+centerx;
					stars[i][1] = Math.sin(oldy+stars[i][4])*stars[i][3]*180/Math.PI+centery;
					stars[i][2] += speedx;
					stars[i][3] += speedy;
					stars[i][4] += angrot;
				}
				else
				{
					stars[i][0] = Math.cos(oldx+stars[i][4])*stars[i][2]*180/Math.PI+centerx;
					stars[i][1] = Math.sin(oldy+stars[i][4])*stars[i][3]*180/Math.PI+centery;
				}
				g2.fillRect((int)stars[i][0],(int)stars[i][1],2,2);
			}
			repaint();
			try { myThread.sleep(25); } catch(InterruptedException e) {}
		}
	}
	public boolean mouseDrag(Event evt,int x,int y)
	{
		clicked = true;
		oldy = (double)(y-oldy)/180*Math.PI;
		oldx = (double)(oldx-x)/180*Math.PI;
		return true;
	}
	public boolean mouseUp(Event e, int x, int y)
	{
		clicked = false;
		return true;
	}
	public void paint(Graphics g){}
	public void update(Graphics g)
	{
		paint(g2);
		g.drawImage(myImage, 0, 0, this);
	}
}

Back to Abstract Space


Applet Index
(sorted alphabetically)

A B C D E F G H I J K
L M N O P Q R S T U
V W X Y Z #s
The Java Source
(applets w/source code)

A B C D E F G H I J K
L M N O P Q R S T U
V W X Y Z

How to Add Java Applets to Your Site

New on the Java Boutique:

New Article:
A Barebones Guide to Usability Testing
At first glance, usability testing may seem like unnecessary, or additional work. In todays budget slashed world, it is not uncommon for projects not to have the luxury of this valuable phase. This is a dangerous path to tread. Let's look at how we can incorporate usability testing into our design process.
... [more articles]

New Tutorial:
Java Certification Path API
Certificate based security forms the basis for SSL (Secure socket layer) transactions? Every year billions of transactions involving trillions of dollars are done safely using the SSL protocol. This week we'll look at the role of the Java certification path API and see how it provides a mechanism to implement certification path functionality.
... [more Tutorials]

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

internet.com logo






Developer News

Will Users Buy a License from SCO to Run Linux?

Linux Community Doubts SCO Claims

Actional Updates Web Services Management Platform



Database Journal Launched!
Jupiter Media has announced the launch of Database Journal. DBJ offers SQL courses and other database related resources for beginner to expert developers.



DB Dude
DB Dude is a JDBC SQL query tool for real database developers who belive that it's still important to code their SQL statements by hand.
Download of the Week
DS PageFlipText
This applet displays a page-flip effect between texts. Over the animation you can also insert an image and a scroll-text.

JB User Poll
Which version of Java do you use the most?
The JavaBoutique Top 15:
1. ChompText
2. PulseText
3. DJPopMenu
4. NavBar
5. PingPong
6. RushHour
7. Chameleon
8. AScroll2
9. Encyclo
10. 3DMaze
11. AnimLetters_anim
12. Viewer
13. AdvPano
14. MatchIt
15. BMI
Want more? Check out our Top 100!

Refer-It
Affiliate Program and Referral Directory.
New on internet.com
Time Warner to Test Microsoft's iTV Software
Trial runs of the company's re-configured interactive guides are seen as a crucial test for Redmond's ambitions to break into television screens, once and for all.

Industry Responsible for Stopping Overseas Outsourcing?
A majority of Americans think the U.S. government and industry should be doing more to keep jobs at home and forgo overseas outsourcing, according to a new study. However, as fewer and fewer college students are studying computer science, the number of U.S. high-tech jobs going to foreign workers will continue to increase.

Big Changes Ahead for Red Hat
Massive changes are coming to a red fedora near you. Red Hat Linux is moving to a more open development model with less focus on boxed sets and more focus on community involvement.


Jupitermedia is publisher of the internet.com and EarthWeb.com networks.
Copyright 2003 Jupitermedia Corporation All Rights Reserved.

Legal Notices,  Licensing, Reprints, & Permissions,  Privacy Policy.
http://www.earthweb.com/
http://www.internet.com/