⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 drawnwmodel.java

📁 面向对象的设计思想
💻 JAVA
字号:
import java.awt.Shape;
import java.io.Serializable;
import java.util.*;



public class DrawNwModel implements DrawModel,Serializable  {
	  // ArrayList changeListeners = new ArrayList(10);
	  NwClient nwClient;

	  /** Creates new BrokerNwImpl */
	  public DrawNwModel(NwClient nwClient) {
	   		  this.nwClient=nwClient;
	  }
	  public void addModelChangeListener(DrawCanvas c)
	  { }	
	  public void setSel(int x){
	 		Command cmd;
	 	    Object result;
	 	    try {
	 	       	cmd=new SetSelCommand(x);
	 	        nwClient.send(cmd);
	 	        cmd = (Command) nwClient.receive();
	 	        result = cmd.getResult();
	 	 	    } catch(Exception e) { }
	 	}
		public void setP1(int x,int y){
	 		Command cmd;
	 	    Object result;
	 	    try {
	 	       	cmd=new SetP1Command(x,y);
	 	        nwClient.send(cmd);
	 	        cmd = (Command) nwClient.receive();
	 	        result = cmd.getResult();
	 	 	    } catch(Exception e) { }
	 	};
		
		public int getP1x(){
			Command cmd;
		    int result=0;
		    
		    try {
	      	    	cmd=new GetP1xCommand();
	      	    	nwClient.send(cmd);
	      	    	cmd = (Command) nwClient.receive();
	      	    	result =Integer.parseInt(cmd.getResult().toString());
	                
	    } catch(Exception e) {}
	    return result;
		}
		public int getP1y(){
			Command cmd;
		    int result=0;
		    
		    try {
	      	    	cmd=new GetP1yCommand();
	      	    	nwClient.send(cmd);
	      	    	cmd = (Command) nwClient.receive();
	      	    	result =Integer.parseInt(cmd.getResult().toString());
	                
	    } catch(Exception e) {}
	    return result;
		}
		public ArrayList<SubShape> getShapes(){
			Command cmd;
		    Object result;
		    ArrayList<SubShape> list= new ArrayList<SubShape> ();
		    try {
	      	    	cmd=new GetShapesCommand();
	      	    	nwClient.send(cmd);
	      	    	cmd = (Command) nwClient.receive();
	      	    	result = cmd.getResult();
	                list=(ArrayList<SubShape>)result;
	    } catch(Exception e) {}
	    return list;
		}
		public void addShapes(SubShape shape){
			Command cmd;
	 	    Object result;
	 	    try {
	 	       	cmd=new AddShapesCommand(shape);
	 	        nwClient.send(cmd);
	 	        cmd = (Command) nwClient.receive();
	 	        result = cmd.getResult();
	 	 	    } catch(Exception e) { }
	 	}
		public ArrayList<SubShape> deletShapes(){
			Command cmd;
		    Object result;
		    ArrayList<SubShape> list= new ArrayList<SubShape>();
		    try {
	      	    	cmd=new DeletShapesCommand();
	      	    	nwClient.send(cmd);
	      	    	cmd = (Command) nwClient.receive();
	      	    	result = cmd.getResult();
	                list=(ArrayList<SubShape>)result;
	    } catch(Exception e) {}
	    return list;
		}
		public ArrayList<SubShape> add(int x1,int y1,int x2,int y2){
			Command cmd;
		    Object result;
		    ArrayList<SubShape> list= new ArrayList<SubShape>();
		    try {
		    		cmd=new AddCommand(x1,y1,x2,y2);
	      	    	nwClient.send(cmd);
	      	    	cmd = (AddCommand) nwClient.receive();
	      	    	result = cmd.getResult();
	                list=(ArrayList<SubShape>)result;
	                   } catch(Exception e) {}
	    return list;
		}
		
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -