[Q] µ¥ÀÌŸ ÀÔ·Â ½ºÆ®¸²ÀÇ ¹Ýº¹Çؼ­ ¿­±â...


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :ÀÓ»óºó 1998³â 5¿ù 23ÀÏ 00:38:05

¿©·¯ºÐ ¾È³çÇϼ¼¿ä.
Á¦°¡ ¿©Âã°í ½ÍÀº °ÍÀº Á¦°¡ Áö±Ý ÇÏ°í ÀÖ´Â ÀÏÀ» ¼³¸íµå¸°µÚ.
Á¦ ¿¡Çø´°ú A¶ó´Â ÆÄÀÏÀº Á¦ ¼­¹ö °èÁ¤ ȨÆäÀÌÁö µð·ºÅ丮¿¡
ÀÖ´ä´Ï´Ù.


¾ÖÇø´ÀÇ ¸ñÀûÀº ±× ÆÄÀÏÀ» Àд °ÍÀÔ´Ï´Ù .ÆÄÀÏ¿¡´Â 4ÀÚ¸®ÀÇ
¼ýÀÚ°¡ ½á ÀÖ´Â Å×½ºÆ®¿ëÀÔ´Ï´Ù. ´õ Áß¿äÇÑ °ÍÀº Á¦°¡ ÇÏ°í ½ÍÀºÀÏÀÌ
±× ÆÄÀÏÀ» ¾ÖÇø´ÀÌ 4Ãʸ¶´Ù »õ·Î¿î ³»¿ëÀ» ÀÐ°í ½Í´Ù´Â °Ì´Ï´Ù.


±×·¡¼­ init()ÇÔ¼ö¿¡¼­´Â URLÀ» ¿­°í DataInputStreamÀ¸·Î
ÆÄÀÏÀÇ µ¥ÀÌŸ¸¦ ÀÐÀ» ¼ö°¡ ÀÖ¾ú´Âµ¥.
run() ÇÔ¼ö¿¡¼­ sleep(4000)<-4ÃÊ ÈÄ¿¡ ¶È°°Àº ±× ÆÄÀÏÀ»
Àаí ÇÏ´Â ½ÄÀ¸·Î °è¼ÓÇÏ°Ô µÇ¾îÀִµ¥ ´Ù½Ã ¿©´Â °úÁ¤¿¡¼­
¿¡·¯°¡ ÀÖ´Â ¸ð¾çÀÔ´Ï´Ù.

ÀÏ´Ü init()ÇÔ¼ö¿¡ ÀÖ´Â °÷¿¡¼­´Â Àß Àд°Ô
È®ÀεǴµ¥ ÀÌ»óÇÏ°Ô run()ÇÔ¼ö ¿¡¼­´Â ¾ÈµÇ´Â °Å °°½À´Ï´Ù.
Âü°í·Î Appletviewer¿¡¼­´Â ¾îµð¼­³ª Àß Àб¸¿ä.


¸Å¿ì ¸·¸·ÇÏ´ä´Ï´Ù. ±×·¡¼­ Àú´Â ¶È°°Àº URLÀ» ´ÝÁö ¾Ê°í(?)
µÎ¹ø ¿­·Á°í Çؼ­ ¿¡·¯°¡ ÀÖ´Ù°í º¸¾Ò´Âµ¥... ¾Æ ¸·¸·ÇÑ ÀÌ »ç¶÷À»
±¸Á¦ÇØ Áֽñæ...



¼Ò½º´Â ´ÙÀ½°ú °°½À´Ï´Ù.
Áß¿äÇÑ ºÎºÐÀº ####################·Î Ç¥½Ã Çß½À´Ï´Ù.
¹Ì¸® °¨»çµå¸®¸ç ¾È³çÈ÷ °è¼¼¿ä.


import java.awt.*;
import java.util.*;
import java.net.*;
import java.io.*;


public class AreaTest extends java.applet.Applet implements Runnable{


byte temp1,temp2;


int state=0;
int oldstate=100;
int Onstate=100;
int Onoldstate=100;
int PositionIndex=0;
int ZoomIndex=0;



boolean done_loading=false;
boolean moveFlag=false;
boolean OnmoveFlag;


int RA=133;
int DIA=20;
int dotDIA=5;
int cenX=160;
int cenY=164;
int sC[][]=new int[15][2];
float Deg;


Graphics g;
Image tempimage;
Thread runner;
Math math1;
URL theURL;


private Graphics gbuffer;
private Image offscreen;
URLConnection conn=null;
DataInputStream data;

public void init(){

for(int i=0;i<15;i++){//Initialization of each of the section center
Deg=(float)(3.1415*(230-i*20)/180);
sC[i][0]=cenX+(int)(RA*math1.cos(Deg));
sC[i][1]=cenY-(int)(RA*math1.sin(Deg));
}
##########################################
#######################################

// ÀÌ ºÎºÐ¿¡¼­ ÆÄÀÏÀ» ¿±´Ï´Ù
##########################################
try{ // ÀÌ ºÎºÐ¿¡¼­ ÆÄÀÏÀ» ¿±´Ï´Ù
this.theURL=new URL(getDocumentBase(),"curpos.txt");
conn=this.theURL.openConnection();
conn.connect();
data=new DataInputStream(new BufferedInputStream(conn.getInputStream()));


// data=new DataInputStream(new FileInputStream("curpos.txt"));


// RandomAccessFile data= new RandomAccessFile(new File("curpos.txt"),"r");


temp1=data.readByte();
temp2=data.readByte();
if(temp2==' '){
PositionIndex=(int)(temp1-48);
temp1=data.readByte();
ZoomIndex=(int)(temp1-48);
}
else{
PositionIndex=(int)(10*(temp1-48)+temp2-48);
temp1=data.readByte();
temp1=data.readByte();
ZoomIndex=(int)(temp1-48);
}
}
catch(IOException e){
System.out.println("Bad URL"+theURL);
}


g=getGraphics();
tempimage=getImage(getCodeBase(),"pot.gif");
g.drawImage(tempimage,0,0,this);


offscreen=createImage(370,300);
gbuffer=offscreen.getGraphics();
}

public boolean imageUpdate(Image img, int infoflag, int x, int y, int w,int h){
if(infoflag==ALLBITS){
done_loading=true;
repaint();
}
return true;
}



public void start(){
if(runner==null){
runner=new Thread(this);
runner.start();
}
}


public void stop(){
if(runner!=null){
runner.stop();
runner=null;
}
}



public void run(){
while(true){
// if(moveFlag==true){
try{
// showStatus("Moving to the target Position");
runner.sleep(4000);// 4 seconds delay
// if(state<15) PositionIndex=state+1;
// else if(state<20) ZoomIndex=state-14;


try{
##############################################
############################
¿©±â¼­ ÆÄÀÏÀ» °è¼Ó 4ÃÊ ´ÜÀ§·Î ¿±´Ï´Ù


################################


this.theURL=new URL(getDocumentBase(),"curpos.txt");
conn=this.theURL.openConnection();
conn.connect();
data=new DataInputStream(new BufferedInputStream(conn.getInputStream()));
// data=new DataInputStream(new FileInputStream("curpos.txt"));


temp1=data.readByte();
temp2=data.readByte();
if(temp2==' '){
PositionIndex=(int)(temp1-48);
temp1=data.readByte();
ZoomIndex=(int)(temp1-48);
}
else{
PositionIndex=(int)(10*(temp1-48)+temp2-48);
temp1=data.readByte();
temp1=data.readByte();
ZoomIndex=(int)(temp1-48);
}
}
catch(IOException e){
showStatus("Bad URL"+theURL);
}



repaint();
moveFlag=false;


}catch(InterruptedException e){
showStatus("ERROR IO");
}


// }


}//End OF while



}// End of run


public boolean mouseDown(Event evt,int x, int y){


for(int i=0;i<15;i++){
if((x-sC[i][0])*(x-sC[i][0])+(y-sC[i][1])*(y-sC[i][1]) <=400){
state=i;
}
}


for(int i=0;i<5;i++){
if(x>320 && y>(76+44*i) && y<(76+44*(i+1)) ){
state=15+i;
}


}

if(oldstate!=state){
moveFlag=true;
/* try {
String cgiurl="http://mclab3.kaist.ac.kr/~garden/cgi-bin/t1.cgi?move"+(state+1);
URL cgiURL = new URL(cgiurl);
DataInputStream dis=new DataInputStream(cgiURL.openStream());
dis.close();
} catch (Exception e) {
System.out.println("Re-run server connection error"+e.toString());
}
*/ }

oldstate=state;
return true;
}


public boolean mouseMove(Event evt,int x, int y){


Onstate=100;// Outsides of the clicking regions
for(int i=0;i<15;i++){
if((x-sC[i][0])*(x-sC[i][0])+(y-sC[i][1])*(y-sC[i][1]) <=400) Onstate=i;
}


for(int i=0;i<5;i++){
if(x>320 && y>(76+44*i) && y<(76+44*(i+1)) ) Onstate=15+i;
}



if(Onoldstate!=Onstate) repaint();

Onoldstate=Onstate;
return true;
}



public void update(Graphics g){
paint(g);
}



public void paint(Graphics g){


if(!done_loading){
// showStatus("Image Loading...");
}
else{
// showStatus("Done");
// gbuffer.drawImage(tempimage,0,0,null);
}


gbuffer.drawImage(tempimage,0,0,this);



for(int i=0;i<15;i++){
if(Onstate==i){
gbuffer.setColor(Color.green);
gbuffer.drawOval(sC[i][0]-DIA,sC[i][1]-DIA,2*DIA,2*DIA);
}
if(PositionIndex==i+1){
gbuffer.setColor(Color.red);
gbuffer.fillOval(sC[i][0]-dotDIA,sC[i][1]-dotDIA,2*dotDIA,2*dotDIA);
gbuffer.drawLine(cenX,cenY,sC[i][0],sC[i][1]);
}
}



for(int i=0;i<5;i++){
if(Onstate==i+15){
gbuffer.setColor(Color.green);
gbuffer.drawRect(324,80+44*i,43,36);
}
if(ZoomIndex==i+1){
gbuffer.setColor(Color.red);
gbuffer.drawRect(324,80+44*i,43,36);
}
}



gbuffer.drawString("Position:"+PositionIndex,120,240);
gbuffer.drawString("Zoom:"+ZoomIndex,120,270);
g.drawImage(offscreen,0,0,this);
}



}




´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]