Who should be responsible for this?

Hi everybody I need your help. I am working on a Vehicle tracking project using Applet and Swing. I have a form named MapClient. This form contains a MapViewer object that stores and displays Map Image. And I have a Controller class named MapClientController . This class getting requests from MapViewer object like ZoomIn ZoomOut etc... and delegates to Model Objects. I refresh Vehicles locations in every 10 seconds and Controller object then send them as a List to MapViewer object and this object creates a VehicleComponent for each Vehicle domain object and and adds them itself . Here is and Example code

public class MapClientController {

private MapClient mapClient;

private Model model;

private Timer refreshTimer;

private List vehicles ;

public MapClientController(MapClient mapClient, Model model) {

this.mapClient = mapClient;

this.model = model;

}

public void init(){

refreshTimer =new Timer(10000,new ActionListener() {

public void actionPerformed(ActionEvent e) {

refreshVehicles();

}

});

refreshTimer.start();

}

private void refreshVehicles() {

vehicles =model.getVehicles();

mapClient.drawVehicles(vehicles);

}

}

//*****************************************************//

public class MapClient extends JApplet {

private MapViewer mapViewer;

public MapClient(MapViewer mapViewer) throws HeadlessException {

this.mapViewer = mapViewer;

..............etc

}

public void drawVehicles(List vehicles) {

mapViewer.drawVehicles(vehicles);

}..........etc

}

/*******************************************//

public class MapViewer extends JEditorPane {

public void drawVehicles(List vehicles) {

for (int i = 0; i < vehicles.size(); i++) {

Vehicle vehicle =(Vehicle)vehicles.get(i);

VehicleComponent vehicleComp =new VehicleComponent(vehicle);

add(vehicleComp);

}

}

}

//**************************************************//

public class VehicleComponent extends JComponent {

public VehicleComponent(Vehicle vehicle) {

............................etc

}

}

/**********************************************//

Could you help me for this situation. Who should be responsible for creating VehicleComponents and any better idea or suggets for this problem?

Message was edited by:

caltuntas

[2513 byte] By [caltuntasa] at [2007-10-3 8:47:42]
# 1
use the code tags when you post code or nobody will read it or reply
MickeyOnJavaa at 2007-7-15 3:56:44 > top of Java-index,Other Topics,Patterns & OO Design...