★ wanayoo — archive 1999 http://javaboutique.webdeveloper.com/AbstractSpace/source.htmlNouvelle recherche | Portail wanayoo

100's of firms that help your Web site be found


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
Reach IT Professionals
Online Backup
Software Store
Compare Prices & Shop
Tech Magazines - FREE
Internet Jobs
Promote Your Website
Register Domains
Build an Online Store
Track Defects Online
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:
Struts in Action
The newest book excerpt from "Struts in Action" covers validators, bundles and configuration files.
... [more articles]

New Tutorial:
Converting XML documents to Java objects with Castor XML
If you're working with XML documents, and your focus is more on the contents of the documents, and not so much on the XML structure, then Castor XML may be what you're looking for. This month Keld Hansen focuses on the conversion capabilities of Casto XML.
... [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

Is F# a Major or Minor Consideration for Microsoft?

OpenOffice.org 1.1 Beta2 Hits the Web

Java Board Streamlines its Approval Process



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.



FilterTable
This is a JTable extension that provides Microsoft Excel like filtering via a combo box on the header of each column.
Download of the Week
X Images
This is an Image Show applet. All images have a URL. If you double-click on an image you go to that url with specified frame.

JB User Poll
As a JavaBoutique Reader what kind of articles do you prefer?
The JavaBoutique Top 15:
1. ChompText
2. PingPong
3. NavBar
4. BSCOutline
5. DJPopMenu
6. X_ImageS
7. RushHour
8. 3DMaze
9. Distorter
10. Matrixcode
11. SonaliCalendar
12. AScroll2
13. Encyclo
14. AnimLetters_anim
15. Nibbly
Want more? Check out our Top 100!

Refer-It
Affiliate Program and Referral Directory.
New on internet.com
Java Board Streamlines Its Approval Process
The board that oversees the computing language agrees to update the committee framework to version 2.6 and adds a new class of membership - 'Expert Group Observer.'

PeopleSoft's Latest Gambits Make Sense, Unfortunately
If PeopleSoft can flesh out its new Total Ownership Experience initiative and ship its products with pre-built integration, the company may really be on to something, says Datamation's Enterprise Advisor columnist.

A Case of the Business Traveler Blues
Internet hotel and travel sites can be a big help to corporate execs who can afford to book reservations at 5-star hotels, but they have a long way to go to please small business owners. Beth Cox reports from the trenches.


Reports on security issues of ecommerce environments

Copyright 2003 Jupitermedia Corporation All Rights Reserved.
Legal Notices,  Licensing, Reprints, & Permissions,  Privacy Policy.
http://www.internet.com/