package at.ac.uni_linz.tk.vchat;
import java.applet.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.net.*;
import symantec.itools.awt.*;
/**
* Provides the Chat's main client functionality, it administrates users and takes
* control over UserEvents. The user interface shown in the applet area is the
* LoginPanel only, the ChatPanel is part of an own Frame (ChatFrame).
*
* @author Arno Huetter
* (C)opyright by the Institute for Computer Science, Telecooperation Department, University of Linz
*/
public class ChatApplet extends Applet implements ChatRepository, Runnable {
private LoginPanel loginPanel;
private ChatFrame chatFrame;
private ChatClient chatClient;
private Image[] moodIcon, defaultAvatar;
private Image emptyIcon, unknownIcon, defaultBackAvatar, imgSlider;
private IntegerHashtable userTable, roomTable, userRoomTable;
private int currentUserId;
private Date histDate, chatStartDate;
private boolean historyMode, chatRunning;
private String status;
private Simulator simulator;
private HistoryPanel pnlHistory;
private Hashtable hashHistory;
private Thread thrMoodTimeout;
private ImageCanvas logoCanvas;
private MediaTracker tracker;
public static String SERVER_POTRAIT_FILENAME[][] = { { "smiley6.gif", "smiley0.gif", "smiley1.gif", "smiley2.gif", "smiley3.gif", "smiley4.gif", "smiley5.gif" },
{ "man1.gif", "man1.gif", "man1.gif", "man1.gif", "man1.gif", "man1.gif", "man1.gif" },
{ "man2.gif", "man2.gif", "man2.gif", "man2.gif", "man2.gif", "man2.gif", "man2.gif" },
{ "woman1.gif", "woman1.gif", "woman1.gif", "woman1.gif", "woman1.gif", "woman1.gif", "woman1.gif" },
{ "woman2.gif", "woman2.gif", "woman2.gif", "woman2.gif", "woman2.gif", "woman2.gif", "woman2.gif" },
{ "baghead.gif", "baghead.gif", "baghead.gif", "baghead.gif", "baghead.gif", "baghead.gif", "baghead.gif" },
{ "teddy.gif", "teddy.gif", "teddy.gif", "teddy.gif", "teddy.gif", "teddy.gif", "teddy.gif" },
{ "moonmask.gif", "moonmask.gif", "moonmask.gif", "moonmask.gif", "moonmask.gif", "moonmask.gif", "moonmask.gif" },
{ "devilmask.gif", "devilmask.gif", "devilmask.gif", "devilmask.gif", "devilmask.gif", "devilmask.gif", "devilmask.gif" },
{ "darkmask.gif", "darkmask.gif", "darkmask.gif", "darkmask.gif", "darkmask.gif", "darkmask.gif", "darkmask.gif" }
};
public static String SERVER_POTRAIT_NAME[] = { "Smiley", "Man 1", "Man 2", "Woman 1", "Woman 2", "Baghead", "Teddy", "Moon Mask", "Devil Mask", "Dark Mask" };
private class AvatarParam {
public String name;
public String[] image = new String[ChatRepository.PREDEFINED_NR_OF_MOODS + 1];
}
protected boolean getBooleanParam(String name, boolean defaultVal) {
return getParameter(name) == null ? defaultVal : new Boolean(getParameter(name)).booleanValue();
}
/**
* Initializes the ChatApplet.
*/
public void init() {
String param;
Vector avatars = new Vector();
for (int i = 0; (param = getParameter("PredefinedAvatar[" + i + "]")) != null; i++) {
StringTokenizer tok = new StringTokenizer(param, ":");
if (tok.countTokens() == 2) {
AvatarParam avatar = new AvatarParam();
avatar.name = tok.nextToken();
StringTokenizer tokAv = new StringTokenizer(tok.nextToken(), ",");
for (int j = 0; j <= ChatRepository.PREDEFINED_NR_OF_MOODS; j++) {
avatar.image[j] = tokAv.hasMoreTokens() ? tokAv.nextToken() : ( j > 1 ? avatar.image[1] : new String(""));
}
avatars.addElement(avatar);
}
}
if (avatars.size() > 0) {
SERVER_POTRAIT_NAME = new String[avatars.size()];
SERVER_POTRAIT_FILENAME = new String[avatars.size()][ChatRepository.PREDEFINED_NR_OF_MOODS + 1];
for (int i = 0; i < avatars.size(); i++) {
SERVER_POTRAIT_NAME[i] = ((AvatarParam)avatars.elementAt(i)).name;
for (int j = 0; j <= ChatRepository.PREDEFINED_NR_OF_MOODS; j++) {
SERVER_POTRAIT_FILENAME[i][j] = ((AvatarParam)avatars.elementAt(i)).image[j];
}
}
}
logoCanvas = new ImageCanvas(getImage(LOGO_FILENAME, true), LOGO_DIMENSION);
logoCanvas.showDocumentOnClick(this, LOGO_URL);
moodIcon = new Image[PREDEFINED_NR_OF_MOODS];
defaultAvatar = new Image[PREDEFINED_NR_OF_MOODS];
defaultBackAvatar = getImage(SERVER_POTRAIT_FILENAME[0][0]);
for (int i = 0; i < PREDEFINED_NR_OF_MOODS; i++) {
moodIcon[i] = getImage(MOOD_ICON_NAME[i]);
defaultAvatar[i] = getImage(SERVER_POTRAIT_FILENAME[0][i + 1]);
}
emptyIcon = getImage(EMPTY_ICON_NAME);
unknownIcon = getImage(UNKNOWN_ICON_NAME);
setBackground(CONTAINER_BACKGROUND);
imgSlider = getImage(IMAGE_SLIDER, true);
setLayout(new GridLayout());
loginPanel = new LoginPanel(this, getParameter("LoginMode") == null ? LoginPanel.MODE_DEFAULT : ChatUtil.getInt(getParameter("LoginMode")));
add(loginPanel);
chatClient = new ChatClient(getHost(), this);
startChat(getBooleanParam("DemoMode", true));
}
/**
* Called by the browser or applet viewer to inform this applet that it is
* being reclaimed.
*/
public void destroy() {
/*
* Stop the chat on Netscape browsers
*/
if (System.getProperty("java.vendor").indexOf("Netscape") != -1)
stopChat();
}
/**
* Called by the browser or applet viewer to inform this applet that it should
* stop its execution.
*/
public void stop() {
/*
* Netscape is buggy on the stop-method() - it might also be called when
* resizing the browser window
*/
if (System.getProperty("java.vendor").indexOf("Netscape") == -1)
stopChat();
}
public void setFrameVisibility(boolean visible) {
chatFrame.setVisible(visible);
}
/**
* Starts the chat. Initializes variables, opens the ChatFrame and runs the
* simulator.
*/
public void startChat(boolean demoMode) {
User robot[];
Random random;
Room room;
userTable = new IntegerHashtable();
roomTable = new IntegerHashtable();
hashHistory = new Hashtable();
chatStartDate = new Date();
for (int i = 0; i < STANDARD_ROOM_NAME.length; i++) {
room = new Room(i, STANDARD_ROOM_NAME[i], ChatRepository.ROOM_DIMENSION);
room.setPrivate(STANDARD_ROOM_PRIVATE[i]);
room.setDemo(i != 0);
if (STANDARD_ROOM_INVITED[i]) {
room.inviteUser("Guest");
}
addRoom(room);
}
/*
* Init the demo-version's Users
*/
User user = new User(UNKNOWN_USER_ID, "Guest", "", Color.red, new Point (ROOM_DIMENSION.width / 2, ROOM_DIMENSION.height / 2), 0, 0, User.HUMAN_RACE);
user.setBackAvatar(defaultBackAvatar);
for (int i = 0; i < PREDEFINED_NR_OF_MOODS; i++)
user.setAvatar(i, defaultAvatar[i]);
setCurrentUser(user);
if (demoMode) {
/*
* Start the simulator and add the Users
*/
simulator = new Simulator(this);
simulator.start();
random = new Random();
robot = new User[ROBOT_NAME.length];
for (int i = 0; i <
没有合适的资源?快使用搜索试试~ 我知道了~
基于java的聊天软件Visual Chat v1.91源码.zip
共181个文件
class:81个
java:64个
gif:31个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 173 浏览量
2023-05-28
00:18:58
上传
评论
收藏 384KB ZIP 举报
温馨提示
基于java的聊天软件Visual Chat v1.91源码.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于java的聊天软件Visual Chat v1.91源码.zip (181个子文件)
banned_ip 32B
ChatApplet.class 23KB
ChatServer.class 18KB
XList.class 13KB
BaseTabbedPanel.class 12KB
UserPanel.class 10KB
ViewCanvas.class 9KB
ServerAdministrationApplet.class 9KB
RoomCanvas.class 8KB
ChatPanel.class 8KB
EditableUserPanel.class 7KB
ButtonBase.class 7KB
ChatClient.class 7KB
ChatFrame.class 7KB
TabPanel.class 7KB
LoginPanel.class 6KB
User.class 6KB
HistoryPanel.class 6KB
EditableRoomPanel.class 5KB
ChatUtil.class 5KB
MoodCanvas.class 5KB
NavigationCanvas.class 5KB
RoomPanel.class 4KB
ChatRepository.class 4KB
UserUpdateThread.class 4KB
RoomListPanel.class 4KB
Simulator.class 4KB
Balloon.class 4KB
Room.class 3KB
InfoPanel.class 3KB
DirectionButton.class 3KB
Object3D.class 3KB
Polygon3D.class 3KB
Connection.class 3KB
SerializableImage.class 3KB
Image3D.class 2KB
URLLabel.class 2KB
ImageCanvas.class 2KB
PortraitCanvas.class 2KB
Cube3D.class 2KB
FramedPanel.class 2KB
IntegerHashtable.class 1KB
ViewPoint.class 1KB
OS.class 1KB
FocusPanel.class 1KB
Vertex3D.class 1KB
Square3D.class 1KB
UneditableUserPanel.class 893B
RoomListEvent.class 862B
Orientation.class 762B
Light.class 742B
UserLoginRequest.class 702B
UserUpdateEvent.class 690B
RoomUpdateEvent.class 687B
RoomCreateEvent.class 687B
UneditableRoomPanel.class 659B
Rotation.class 632B
ChatApplet$AvatarParam.class 625B
MessageEntry.class 612B
HistoryEntry.class 584B
ServerAdministrationRequest.class 550B
DeprecatedException.class 550B
InsetsPanel.class 542B
ServerGetUserDataRequest.class 472B
UserLoginEvent.class 462B
ServerUpdateUserDataRequest.class 431B
UserPositionEvent.class 426B
ServerUserListRequest.class 407B
ServerDeleteUserRequest.class 403B
ExistingUserLoginRequest.class 399B
UserRoomEvent.class 396B
Plane3D.class 382B
UserMessageEvent.class 368B
RoomEvent.class 353B
UserHeadingEvent.class 334B
UserMoodEvent.class 325B
ServerRestartRequest.class 296B
NewUserLoginRequest.class 295B
UserEvent.class 295B
ServerStopRequest.class 290B
UserLogoutEvent.class 251B
RoomRemoveEvent.class 251B
teddy.gif 8KB
darkmask.gif 7KB
devilmask.gif 6KB
moonmask.gif 6KB
man1.gif 5KB
woman2.gif 5KB
man2.gif 4KB
smiley4.gif 4KB
smiley5.gif 4KB
smiley0.gif 4KB
smiley1.gif 4KB
woman1.gif 4KB
smiley3.gif 3KB
smiley2.gif 3KB
smiley6.gif 3KB
baghead.gif 3KB
logo.gif 787B
icon4.gif 298B
共 181 条
- 1
- 2
资源评论
易小侠
- 粉丝: 6453
- 资源: 9万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功