用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

太阳系模型代码

2017-11-22 作者: 筑梦少年举报

[java]代码库

package com.jackie.solarsystem.projects;

import java.awt.Graphics;
import java.awt.Image;

import com.jackie.solarsystem.entities.Planet;
import com.jackie.solarsystem.entities.Star;
import com.jackie.solarsystem.utils.Constant;
import com.jackie.solarsystem.utils.SolarSystemFrame;
import com.jackie.solarsystem.utils.SolarSystemUtils;
/**
 * 太阳系运行程序入口界面
 * @author Administrator
 *
 */
public class SolarMainWin extends SolarSystemFrame{
	private static final long serialVersionUID = 1L;
	Image bg = SolarSystemUtils.getImage("images/solar-bg.jpg");
	Star sun = new Star("images/sun.jpg", Constant.FRAME_WIDTH/2-15, Constant.FRAME_HEIGHT/2-15);
	Planet mercury = new Planet(sun, "images/Mercury.jpg", 40, 20, 0.1);
	Planet venus = new Planet(sun, "images/Venus.jpg", 70, 40, 0.2);
	Planet earth = new Planet(sun, "images/Earth.jpg", 100, 50, 0.3);
	Planet mars = new Planet(sun, "images/Mars.jpg", 130, 80, 0.2);
	Planet jupiter = new Planet(sun, "images/Jupiter.jpg", 170, 100, 0.4);
	Planet saturn = new Planet(sun, "images/Saturn.jpg", 260, 150, 0.4);
	Planet uranus = new Planet(sun, "images/Uranus.jpg", 350, 190, 0.1);
	Planet neptune = new Planet(sun, "images/Neptune.jpg", 500, 250, 0.3);
	Planet moon = new Planet(earth, "images/moon.jpg", 100, 40, 0.5,true);
	
	
	public void paint(Graphics g){
		g.drawImage(bg, Constant.FRAME_LOCATION_X, Constant.FRAME_LOCATION_Y, null);
		
		sun.drawStar(g);
		
		mercury.draw(g);
		venus.draw(g);
		earth.draw(g);
		mars.draw(g);
		jupiter.draw(g);
		saturn.draw(g);
		uranus.draw(g);
		neptune.draw(g);
		moon.draw(g);
	}
	
	public static void main(String[] args) {
		new SolarMainWin().launchFrame();
	}
}

[代码运行效果截图]


太阳系模型代码

[源代码打包下载]




网友评论    (发表评论)

共1 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...