package com.example.saver;

import java.awt.geom.Point2D;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;

import org.semanticweb.owl.apibinding.OWLManager;
import org.semanticweb.owl.inference.OWLReasoner;
import org.semanticweb.owl.inference.OWLReasonerFactory;
import org.semanticweb.owl.model.OWLClass;
import org.semanticweb.owl.model.OWLConstant;
import org.semanticweb.owl.model.OWLDataPropertyExpression;
import org.semanticweb.owl.model.OWLDataRange;
import org.semanticweb.owl.model.OWLDescription;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLOntology;
import org.semanticweb.owl.model.OWLOntologyManager;
import org.semanticweb.owl.model.SWRLDataFactory;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLDataProperty;
import org.semanticweb.owlapi.model.OWLLiteral;
import org.semanticweb.owlapi.model.OWLObject;
import org.semanticweb.reasonerfactory.factpp.FaCTPlusPlusReasonerFactory;
import org.vaadin.hezamu.googlemapwidget.GoogleMap;
import org.vaadin.hezamu.googlemapwidget.overlay.BasicMarker;
import org.vaadin.hezamu.googlemapwidget.overlay.Polygon;


import com.hp.hpl.jena.ontology.AnnotationProperty;
import com.hp.hpl.jena.ontology.DatatypeProperty;
import com.hp.hpl.jena.ontology.Individual;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.ontology.OntProperty;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.util.FileManager;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
import com.ibm.icu.text.SimpleDateFormat;
import com.vaadin.Application;
import com.vaadin.terminal.ClassResource;
import com.vaadin.ui.*;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.ui.Button;
import com.vaadin.ui.Form;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.SplitPanel;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.MenuBar.MenuItem;

import com.github.wolfie.refresher.Refresher;
import com.github.wolfie.refresher.Refresher.RefreshListener;
import com.google.gwt.maps.client.geom.LatLng;
import com.google.gwt.maps.client.overlay.Marker;

//import com.github.wolfie.refresher.Refresher;
//import com.github.wolfie.refresher.Refresher.RefreshListener;


public class SaverApplication extends Application {
	@SuppressWarnings("deprecation")
	
	
	String filePath="file:D:/tests/saver/SAVERExample5.owl";
	
	// test chat 
	 public class ChatRefreshListener implements RefreshListener {
		    public void refresh(final Refresher source) {
		      updateChatLog();
		    }
		  }
		  
		  private class ChatListener implements ClickListener, ValueChangeListener {
		    
		    public void valueChange(final ValueChangeEvent event) {
		      addNewChatLine();
		    }
		    
		    public void buttonClick(final ClickEvent event) {
		      addNewChatLine();
		    }
		    
		    private void addNewChatLine() {
		      final String name = nameInput.getValue().toString();
		      final String message = chatInput.getValue().toString();
		      final Date timestamp = new Date();
		      
		      if (message != null && !message.isEmpty()) {
		        entries.add(new ChatEntry(name, timestamp, message));
		        clearChat();
		        updateChatLog();
		      }
		    }
		    
		    private void clearChat() {
		      chatInput.setValue("");
		      chatInput.focus();
		    }
		  }
		  
		  private static final List<ChatEntry> entries = new ArrayList<ChatEntry>();
		  private static int visitor = 1;
		  
		  private Panel chatLayout;
		  private TextField nameInput;
		  private TextField chatInput;
		  private Date latestupdate = new Date();
		  final ComboBox opinion_combo = new ComboBox();
		 
		  
		  private final ChatListener chatListener = new ChatListener();

		  private void updateChatLog() {
			    Date newLatestUpdate = null;
			    for (final ChatEntry entry : entries) {
			      final Date timestamp = entry.getTimestamp();
			      if (timestamp.after(latestupdate)) {
			        newLatestUpdate = timestamp;
			        print(entry);
			      }
			    }
			    
			    if (newLatestUpdate != null) {
			      latestupdate = newLatestUpdate;
			    }
			  }
			  
			  private void print(final ChatEntry entry) {
			    final Date timestamp = entry.getTimestamp();
			    final String name = entry.getName();
			    final String message = entry.getMessage();
			    
			    final HorizontalLayout chatLine = new HorizontalLayout();
			    
			    final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
			    final Label timeLabel = new Label(dateFormat.format(timestamp)+" : ");
		//	    timeLabel.setWidth("130px");
		        chatLine.addComponent(timeLabel);
			    
			    final Label nameLabel = new Label(name + " : "+opinion_combo.getValue()+" : ");
		//	    nameLabel.setWidth("150px");
			    chatLine.addComponent(nameLabel);
			    
			    final Label messageLabel = new Label(message);
			    chatLine.addComponent(messageLabel);
			    chatLine.setExpandRatio(messageLabel, 1);
			    
			    chatLayout.addComponent(chatLine);
			    
			    getMainWindow().showNotification(timeLabel.getValue()+" "+nameLabel.getValue()+" "+messageLabel.getValue(),Window.Notification.TYPE_WARNING_MESSAGE );
			//    getMainWindow().scrollIntoView(chatLine);
			  }
	
	// end test chat
	

	
	public void init() {
		final Window mainWindow = new Window("Saver Application");
		
		Label label = new Label("<h1>Welcome to Situation Aware Vigilant Emergency Reasoner(SAVER)</h1>", Label.CONTENT_XHTML);
	
		AbsoluteLayout mainLayout = new AbsoluteLayout();
		mainLayout.setWidth("1400px");
		mainLayout.setHeight("1200px");
		 final int dataCollectionTime[]= new int[10];

		mainLayout.addComponent(label, "left: 360px; top: 50px;");
		 final Window tsa1_window= new Window ("TSA 1");
		 final Window tsa2_window= new Window ("TSA 2");
		 
/*		 final Refresher refresher = new Refresher();
		    refresher.setRefreshInterval(500);
		    refresher.addListener(new ChatRefreshListener());
		 mainLayout.addComponent(refresher);
*/
		
		final TextField shared_sa_TF = new TextField();
		final TextField shared_sa_TF2 = new TextField();
		final TextField ssa2_TF = new TextField();
		final TextField tsa1_TF = new TextField();
		final TextField tsa2_TF = new TextField();
		final TextField simulation_tsa_TF = new TextField();
		
		Button profileBuilder= new Button ("Simulation");
		Button processPalette= new Button ("Scenario");
		final Button softwareInventoryButton= new Button ("Situation Awareness");
		Button softwareSelection= new Button ("SSA 1");
		Button ssa2_button= new Button ("SSA 2");
		Button tsa1_button= new Button ("TSA 1");
		Button tsa2_button= new Button ("TSA 2");
		final MenuBar menubar = new MenuBar();
	   
		final Embedded image = new Embedded("",
			    new ClassResource("plz1.jpg", this));
        mainLayout.addComponent(image, "left: 525px; top: 120px;");
        
        final Embedded eq_image = new Embedded("",
			    new ClassResource("time.jpg", this));
        eq_image.setWidth("300");
        eq_image.setHeight("300");
        mainLayout.addComponent(eq_image, "left: 250px; top: 400px;");
		
        final Embedded eq_image1 = new Embedded("",
			    new ClassResource("tsunami2.jpg", this));
        eq_image1.setWidth("300");
        eq_image1.setHeight("300");
        mainLayout.addComponent(eq_image1, "left: 600px; top: 400px;");
        
        final Embedded eq_image2 = new Embedded("",
			    new ClassResource("volcano1.jpg", this));
        eq_image2.setWidth("300");
        eq_image2.setHeight("300");
        mainLayout.addComponent(eq_image2, "left: 950px; top: 400px;");
        
        
        
        
		profileBuilder.setImmediate(true);
		profileBuilder.setHeight("30px");
		profileBuilder.setWidth("150px");
		mainLayout.addComponent(profileBuilder, "left: 275px; top: 250px;");

		processPalette.setImmediate(true);
		processPalette.setHeight("30px");
		processPalette.setWidth("150px");
		mainLayout.addComponent(processPalette, "left: 475px; top: 250px;");
		
	
		softwareInventoryButton.setImmediate(true);
		softwareInventoryButton.setHeight("30px");
		softwareInventoryButton.setWidth("150px");
		mainLayout.addComponent(softwareInventoryButton, "left: 675px; top: 250px;");
		
	
		softwareSelection.setImmediate(true);
		softwareSelection.setHeight("30px");
		softwareSelection.setWidth("150px");
		mainLayout.addComponent(softwareSelection, "left: 875px; top: 250px;");
		
		ssa2_button.setImmediate(true);
		ssa2_button.setHeight("30px");
		ssa2_button.setWidth("150px");
		mainLayout.addComponent(ssa2_button, "left: 1075px; top: 250px;");
		
		tsa1_button.setImmediate(true);
		tsa1_button.setHeight("30px");
		tsa1_button.setWidth("150px");
		mainLayout.addComponent(tsa1_button, "left: 575px; top: 300px;");
		
		tsa2_button.setImmediate(true);
		tsa2_button.setHeight("30px");
		tsa2_button.setWidth("150px");
		mainLayout.addComponent(tsa2_button, "left: 775px; top: 300px;");
		
		mainWindow.addComponent(mainLayout);

		
		
		
		
		// start of Simulation button implementation
		profileBuilder.addListener(new Button.ClickListener() {
			
				
			public void buttonClick(ClickEvent event) {
			
	
		//	mainWindow.removeAllComponents();
	
	    	 final Window sub3= new Window ("Scenario");
		      sub3.setWidth("1800px");
		      sub3.setHeight("1000px");
		      sub3.setPositionX(0);
		      sub3.setPositionY(0);
		//      sub3.setSizeFull();
		      
		      final AbsoluteLayout aLayout1 = new AbsoluteLayout();
				aLayout1.setWidth("1800px");
				aLayout1.setHeight("1000px");
		//		aLayout1.setSizeFull();
		      
		      
				 Label sa_heading_label = new Label ("<h2>Simulate input to user</h2>", Label.CONTENT_XHTML);
				 Label shared_sa_heading_label = new Label ("<h2>Shared SA Report</h4>", Label.CONTENT_XHTML);
			  
			  final TextField send_sa_TF = new TextField();
			  send_sa_TF.setHeight("75");
			  send_sa_TF.setWidth("300");
			  send_sa_TF.setCaption("Opinion / Comment:");
	//		  Label request_sa_label = new Label ("Your opinion on SA:");
			  final ComboBox opinion_combo = new ComboBox();
			  opinion_combo.setCaption("Your opinion on SA: ");
			  opinion_combo.setImmediate(true);
			  opinion_combo.addItem("Agree: ");
			  opinion_combo.addItem("Partially Agree: ");
			  opinion_combo.addItem("Disagree: ");
			  
			    
			  final ComboBox role_combo = new ComboBox();
			  role_combo.setCaption("Please choose role:");
			  role_combo.setImmediate(true);
			  role_combo.addItem("Planning and Intelligence");
			  role_combo.addItem("Logistics");
			  role_combo.addItem("Welfare");
			  role_combo.addItem("Operations");
			  role_combo.addItem("Controller");
			  role_combo.addItem("SAG Expert");
			  role_combo.addItem("Scientist");
		//	  opinion_combo.setEnabled(true);
			  Button send_sa_button = new Button ("Send Opinion");
			  Button ok_button = new Button ("Send Opinion");
			  Button cancel_button = new Button ("Send Opinion");
			  
		//	  final TextField shared_sa_TF2 = new TextField();
			  shared_sa_TF2.setHeight("400");
			  shared_sa_TF2.setWidth("300");
			  
			  aLayout1.addComponent(sa_heading_label, "left: 600px; top: 50px;");
		      aLayout1.addComponent(role_combo, "left: 500px; top: 200px;");
			  aLayout1.addComponent(opinion_combo, "left: 500px; top: 300px;");
			  aLayout1.addComponent(send_sa_TF, "left: 500px; top: 400px;");
			  aLayout1.addComponent(send_sa_button, "left: 700px; top: 500px;");
			  aLayout1.addComponent(shared_sa_heading_label, "left: 1370px; top: 200px;");
			  aLayout1.addComponent(shared_sa_TF2, "left: 1300px; top: 250px;");
			  
			  send_sa_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
					//	  getMainWindow().removeWindow(sub4);
						shared_sa_TF.setValue(shared_sa_TF.getValue()+"\n "+role_combo.getValue()+": "+opinion_combo.getValue()+" "+send_sa_TF.getValue());
						shared_sa_TF2.setValue(shared_sa_TF2.getValue()+"\n "+role_combo.getValue()+": "+opinion_combo.getValue()+" "+send_sa_TF.getValue());
						ssa2_TF.setValue(ssa2_TF.getValue()+"\n "+role_combo.getValue()+": "+opinion_combo.getValue()+" "+send_sa_TF.getValue());
						
					}});
			  
			  ok_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
						  getMainWindow().removeWindow(sub3);
						
					}});
		      
		      cancel_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
						getMainWindow().removeWindow(sub3);
				    
					}});
			  
	    	sub3.addComponent(aLayout1);
	    	mainWindow.addWindow(sub3);
		}
	});
  // end of simulation button implementation		
		
	
		
		// start of TSA 1 button implementation
		tsa1_button.addListener(new Button.ClickListener(){
			
				
			public void buttonClick(ClickEvent event) {
			
	
	//		mainWindow.removeAllComponents();
	
	    //	 final Window tsa1_window= new Window ("TSA 1");
		      tsa1_window.setWidth("1800px");
		      tsa1_window.setHeight("1000px");
		      
		      final AbsoluteLayout aLayout1 = new AbsoluteLayout();
				aLayout1.setWidth("1800px");
				aLayout1.setHeight("1000px");
		      
		      
				 Label sa_heading_label = new Label ("<h2>Team Situation Awareness</h2>", Label.CONTENT_XHTML);
				 Label shared_sa_heading_label = new Label ("<h2>TSA Chat</h4>", Label.CONTENT_XHTML);
			  
			  final TextField send_sa_TF = new TextField();
			  send_sa_TF.setHeight("75");
			  send_sa_TF.setWidth("300");
			  send_sa_TF.setCaption("Opinion / Comment:");
	//		  Label request_sa_label = new Label ("Your opinion on SA:");
			  final ComboBox opinion_combo = new ComboBox();
			  opinion_combo.setCaption("Your opinion on SA: ");
			  opinion_combo.setImmediate(true);
			  opinion_combo.addItem("Agree: ");
			  opinion_combo.addItem("Partially Agree: ");
			  opinion_combo.addItem("Disagree: ");
			  
			    
			  final ComboBox time_combo = new ComboBox();
		      time_combo.setImmediate(true);
		      time_combo.addItem("Time before confirmation");
		      time_combo.addItem("Time of confirmation");
		      time_combo.addItem("Time of Evacuation decision");
		      time_combo.addItem("Time of evacuation");
		      time_combo.addItem("Time of Post evacuation");
		      time_combo.addItem("Time of return");
		      time_combo.addItem("Time of post return");
		      time_combo.setCaption("Choose phase:");
			  
			  final ComboBox role_combo = new ComboBox();
			  role_combo.setCaption("Please choose role:");
			  role_combo.setImmediate(true);
			  role_combo.addItem("Planning and Intelligence");
			  role_combo.addItem("Logistics");
			  role_combo.addItem("Welfare");
			  role_combo.addItem("Operations");
			  role_combo.addItem("Controller");
			  role_combo.addItem("SAG Expert");
			  role_combo.addItem("Scientist");
		      role_combo.setCaption("Choose your role:");
			  
			  final ComboBox role_combo2 = new ComboBox();
			  role_combo2.setCaption("Please choose role:");
			  role_combo2.setImmediate(true);
			  role_combo2.addItem("Planning and Intelligence");
			  role_combo2.addItem("Logistics");
			  role_combo2.addItem("Welfare");
			  role_combo2.addItem("Operations");
			  role_combo2.addItem("Controller");
			  role_combo2.addItem("SAG Expert");
			  role_combo2.addItem("Scientist");
			  role_combo2.setCaption("Message to:");
			  
			  final ListSelect selectTask = new ListSelect("Your Tasks:");
			  //.setCaption("Your Tasks:");
			  selectTask.addItem("Task 1 due at 1200 on July 12, 2011");
			  selectTask.addItem("Task 2 due at 1300 on July 12, 2011");
			  selectTask.setImmediate(true);
			  
			  final TextField info_req_TF= new TextField();
		//	  info_req_TF.setValue("OK:");
			  
              selectTask.addListener(new Property.ValueChangeListener(){
		    	
		       	  public void valueChange(Property.ValueChangeEvent event) {
			  if (selectTask.getValue().toString().contains("Task 1"))
				  info_req_TF.setValue("Information required for Task 1 is as: \n 1. Info from Local councils \n 2. Information from USGS \n \n \n");
			  else 
				  info_req_TF.setValue("Information required for Task 2 is as: \n 1. Info from Operation function about requests from other organizations \n 2. Information from Welfare about welfare camps \n \n \n");
		       	  }  });
			  
			  Button send_sa_button = new Button ("Send Message");
			  Button ok_button = new Button ("OK");
			  Button cancel_button = new Button ("Cancel");
			 
			  ok_button.setHeight("30px");
		      ok_button.setWidth("100px");
		      
		      cancel_button.setHeight("30px");
		      cancel_button.setWidth("100px");
		      
		//	  final TextField shared_sa_TF2 = new TextField();
			  tsa1_TF.setHeight("390");
			  tsa1_TF.setWidth("300");
			  
			  selectTask.setHeight("190");
			  selectTask.setWidth("400");
			  
			  info_req_TF.setHeight("200");
			  info_req_TF.setWidth("400");
			  info_req_TF.setCaption("Information Requirements:");
			  
			  aLayout1.addComponent(sa_heading_label, "left: 600px; top: 50px;");
		      aLayout1.addComponent(role_combo, "left: 500px; top: 150px;");
			  aLayout1.addComponent(time_combo, "left: 500px; top: 200px;");
			  aLayout1.addComponent(selectTask, "left: 500px; top: 250px;");
			  aLayout1.addComponent(info_req_TF, "left: 500px; top: 460px;");
		//	  aLayout1.addComponent(role_combo2, "left: 1300px; top: 560px;");
		//	  aLayout1.addComponent(send_sa_TF, "left: 1300px; top: 600px;");
		//	  aLayout1.addComponent(send_sa_button, "left: 1400px; top: 680px;");
			  aLayout1.addComponent(shared_sa_heading_label, "left: 1380px; top: 100px;");
		//	  aLayout1.addComponent(tsa1_TF, "left: 1300px; top: 150px;");
			  aLayout1.addComponent(ok_button, "left: 600px; top: 680px;");
			  aLayout1.addComponent(cancel_button, "left: 700px; top: 680px;");
			  
			/*  send_sa_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
					//	  getMainWindow().removeWindow(sub4);
						tsa1_TF.setValue(tsa1_TF.getValue()+"\n "+role_combo.getValue()+": "+send_sa_TF.getValue());
						tsa2_TF.setValue(tsa2_TF.getValue()+"\n "+role_combo.getValue()+": "+send_sa_TF.getValue());
			
						tsa2_window.getWindow().showNotification("Message from "+role_combo.getValue()+": \n"+send_sa_TF.getValue(),Window.Notification.TYPE_WARNING_MESSAGE);
						mainWindow.requestRepaintAll();
					}});
			  
			 */
			  nameInput = new TextField();
			  role_combo.addListener(new Property.ValueChangeListener(){
			    	
		       	  public void valueChange(Property.ValueChangeEvent event) {
			  if(role_combo.getValue()!= null)
				  nameInput.setValue(role_combo.getValue());
		       	  }});
				  
			  
			  // chat test code
			  
		//	  final VerticalLayout layout = new VerticalLayout();
			  final AbsoluteLayout layout = new AbsoluteLayout();
		//	    final Window mainWindow = new Window("Chat Application", layout);
	//		    setMainWindow(mainWindow);
	//		    mainWindow.setSizeFull();
			//    layout.setSizeFull();
			    
			    layout.setHeight("580");
			    layout.setWidth("450");
			    
			    final Refresher refresher = new Refresher();
			    refresher.setRefreshInterval(500);
			    refresher.addListener(new ChatRefreshListener());
			//   aLayout1.addComponent(refresher);
			    layout.addComponent(refresher);
			    chatLayout = new Panel(new CssLayout());
		//	    chatLayout.setSizeFull();
			    chatLayout.setHeight("400");
			    chatLayout.setWidth("400");
			    layout.addComponent(chatLayout,"left: 10px; top: 10px;");
		//	    layout.setExpandRatio(chatLayout, 1);
			    
			    final HorizontalLayout footer = new HorizontalLayout();
			    footer.setWidth("100%");
			    layout.addComponent(footer);
			    
			    nameInput = new TextField();
			    nameInput.setValue("Anonymous " + visitor);
		//	    nameInput.setValue(role_combo.getValue());
			    visitor++;
		//	    footer.addComponent(nameInput);
			    layout.addComponent(nameInput,"left: 140px; top: 415px;");
			    
			    chatInput = new TextField();
			    chatInput.focus();
		//	    chatInput.setWidth("100%");
			    chatInput.setWidth("400");
			    chatInput.setHeight("100");
			    chatInput.setImmediate(true);
			    chatInput.addListener(chatListener);
		//	    footer.addComponent(chatInput);
		//	    footer.setExpandRatio(chatInput, 1);
			    layout.addComponent(chatInput,"left: 10px; top: 445px;");
			    
		//	    footer.addComponent(new Button("Send", chatListener));
			    layout.addComponent(new Button("Send", chatListener),"left: 190px; top: 550px;");
                
			    aLayout1.addComponent(layout, "left: 1200px; top: 150px;");
		       
			  // End of test chat code
			  ok_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
						  getMainWindow().removeWindow(tsa1_window);
						
					}});
		      
		      cancel_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
						getMainWindow().removeWindow(tsa1_window);
				    
					}});
			  
	    	tsa1_window.addComponent(aLayout1);
	    	mainWindow.addWindow(tsa1_window);
		}
	});
  // end of TSA 1 button implementation			
		
  
  // start of TSA 2 button implementation
		tsa2_button.addListener(new Button.ClickListener(){
			
				
			public void buttonClick(ClickEvent event) {
			
	
	//		mainWindow.removeAllComponents();
	
	    	 final Window tsa2_window= new Window ("TSA 2");
		      tsa2_window.setWidth("1800px");
		      tsa2_window.setHeight("1000px");
		      
		      final AbsoluteLayout aLayout1 = new AbsoluteLayout();
				aLayout1.setWidth("1800px");
				aLayout1.setHeight("1000px");
		      
				  
		      
			 Label sa_heading_label = new Label ("<h2>Team Situation Awareness</h2>", Label.CONTENT_XHTML);
			 Label shared_sa_heading_label = new Label ("<h2>TSA Chat</h4>", Label.CONTENT_XHTML);
			  
			  final TextField send_sa_TF = new TextField();
			  send_sa_TF.setHeight("75");
			  send_sa_TF.setWidth("300");
			  send_sa_TF.setCaption("Opinion / Comment:");
	//		  Label request_sa_label = new Label ("Your opinion on SA:");
			  final ComboBox opinion_combo = new ComboBox();
			  opinion_combo.setCaption("Your opinion on SA: ");
			  opinion_combo.setImmediate(true);
			  opinion_combo.addItem("Agree: ");
			  opinion_combo.addItem("Partially Agree: ");
			  opinion_combo.addItem("Disagree: ");
			  
			    
			  final ComboBox time_combo = new ComboBox();
		      time_combo.setImmediate(true);
		      time_combo.addItem("Time before confirmation");
		      time_combo.addItem("Time of confirmation");
		      time_combo.addItem("Time of Evacuation decision");
		      time_combo.addItem("Time of evacuation");
		      time_combo.addItem("Time of Post evacuation");
		      time_combo.addItem("Time of return");
		      time_combo.addItem("Time of post return");
		      time_combo.setCaption("Choose phase:");
			  
			  final ComboBox role_combo = new ComboBox();
		//	  role_combo.setCaption("Please choose role:");
			  role_combo.setImmediate(true);
			  role_combo.addItem("Planning and Intelligence");
			  role_combo.addItem("Logistics");
			  role_combo.addItem("Welfare");
			  role_combo.addItem("Operations");
			  role_combo.addItem("Controller");
			  role_combo.addItem("SAG Expert");
			  role_combo.addItem("Scientist");
			  role_combo.addItem("SAVER");
		      role_combo.setCaption("Choose your role:");
			  
			  final ComboBox role_combo2 = new ComboBox();
		//	  role_combo2.setCaption("Please choose role:");
			  role_combo2.setImmediate(true);
			  role_combo2.addItem("Planning and Intelligence");
			  role_combo2.addItem("Logistics");
			  role_combo2.addItem("Welfare");
			  role_combo2.addItem("Operations");
			  role_combo2.addItem("Controller");
			  role_combo2.addItem("SAG Expert");
			  role_combo2.addItem("Scientist");
			  role_combo2.addItem("SAVER");
			  role_combo2.setCaption("Message to:");
			  
			  final ListSelect selectTask = new ListSelect("Your Tasks:");
			  //.setCaption("Your Tasks:");
			  selectTask.addItem("Sitrep 2 due at 1200 on July 12, 2011");
			  selectTask.addItem("Incident Action Plan due at 1400 on July 12, 2011");
			  selectTask.setImmediate(true);
			  
			  final TextField info_req_TF= new TextField();
		//	  info_req_TF.setValue("OK:");
			  
              selectTask.addListener(new Property.ValueChangeListener(){
		    	
		       	  public void valueChange(Property.ValueChangeEvent event) {
			  if (selectTask.getValue().toString().contains("Sitrep"))
				  info_req_TF.setValue("Information required for Sitrip is as: \n 1. Earthquake Magnitude \n 2. Earthquake source location \n 3. Earthquake source depth \n \n \n");
			  else 
				  info_req_TF.setValue("Information required for Task 2 is as: \n 1. Info from Operation function about requests from other organizations \n 2. Information from Welfare about welfare camps \n \n \n");
		       	  }  });
			  
			  Button send_sa_button = new Button ("Send Message");
			  Button ok_button = new Button ("OK");
			  Button cancel_button = new Button ("Cancel");
			 
			  ok_button.setHeight("30px");
		      ok_button.setWidth("100px");
		      
		      cancel_button.setHeight("30px");
		      cancel_button.setWidth("100px");
		      
		//	  final TextField shared_sa_TF2 = new TextField();
			  tsa2_TF.setHeight("390");
			  tsa2_TF.setWidth("300");
			  
			  selectTask.setHeight("190");
			  selectTask.setWidth("400");
			  
			  info_req_TF.setHeight("200");
			  info_req_TF.setWidth("400");
			  info_req_TF.setCaption("Information Requirements:");
			  
			  aLayout1.addComponent(sa_heading_label, "left: 600px; top: 50px;");
		      aLayout1.addComponent(role_combo, "left: 500px; top: 150px;");
			  aLayout1.addComponent(time_combo, "left: 500px; top: 200px;");
			  aLayout1.addComponent(selectTask, "left: 500px; top: 250px;");
			  aLayout1.addComponent(info_req_TF, "left: 500px; top: 460px;");
			  aLayout1.addComponent(role_combo2, "left: 1300px; top: 560px;");
			  aLayout1.addComponent(send_sa_TF, "left: 1300px; top: 600px;");
			  aLayout1.addComponent(send_sa_button, "left: 1400px; top: 680px;");
			  aLayout1.addComponent(shared_sa_heading_label, "left: 1400px; top: 100px;");
			  aLayout1.addComponent(tsa2_TF, "left: 1300px; top: 150px;");
			  aLayout1.addComponent(ok_button, "left: 600px; top: 680px;");
			  aLayout1.addComponent(cancel_button, "left: 700px; top: 680px;");
			  
			  send_sa_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
					//	  getMainWindow().removeWindow(sub4);
					tsa1_TF.setValue(tsa1_TF.getValue()+"\n "+role_combo.getValue()+": "+send_sa_TF.getValue());
					tsa2_TF.setValue(tsa2_TF.getValue()+"\n "+role_combo.getValue()+": "+send_sa_TF.getValue());
			//		simulation_tsa_TF.setValue(simulation_tsa_TF.getValue()+"\n "+role_combo.getValue()+": "+send_sa_TF.getValue());
					
					tsa1_window.showNotification("Message from "+role_combo.getValue()+": \n"+send_sa_TF.getValue(),Window.Notification.TYPE_WARNING_MESSAGE);
					mainWindow.requestRepaintAll();
					}});
			  
			  ok_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
						  getMainWindow().removeWindow(tsa2_window);
						
					}});
		      
		      cancel_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
						getMainWindow().removeWindow(tsa2_window);
				    
					}});
			  
	    	tsa2_window.addComponent(aLayout1);
	    	mainWindow.addWindow(tsa2_window);
		}
	});
  // end of TSA 2 button implementation	
		
	// start of SSA 1 button implementation
		
		softwareSelection.addListener(new Button.ClickListener() {
			
			
			public void buttonClick(ClickEvent event) {
			
	
		//	mainWindow.removeAllComponents();
	
	    	 final Window sub4= new Window ("SSA 1");
		      sub4.setWidth("1800px");
		      sub4.setHeight("1000px");
	// new
		      final AbsoluteLayout aLayout1 = new AbsoluteLayout();
				aLayout1.setWidth("1800px");
				aLayout1.setHeight("1000px");
		      
		      Label scenario_name_label = new Label ("<h4>Scenario Name: </h4>", Label.CONTENT_XHTML);
		      Label sa_heading_label = new Label ("<h2>SAVER's Awareness Report</h2>", Label.CONTENT_XHTML);
		      Label shared_sa_heading_label = new Label ("<h2>Shared SA Report</h2>", Label.CONTENT_XHTML);
		      Label time_label = new Label ("<h4>Time in scenario: </h4>", Label.CONTENT_XHTML);
		      Label incoming_info_label = new Label ("<h4>User's Role: </h4>", Label.CONTENT_XHTML);
		      Label sa1_label = new Label ("<h4>Situation Awareness Level 1:</h4>", Label.CONTENT_XHTML);
		      Label sa2_label = new Label ("<h4>Situation Awareness Level 2:</h4>", Label.CONTENT_XHTML);
		      Label sa3_label = new Label ("<h4>Situation Awareness Level 3:</h4>", Label.CONTENT_XHTML);
		      TextField scenario_name_TF = new TextField();
		      TextField incoming_info_TF = new TextField();
	//	      final TextField shared_sa_TF = new TextField();
		      final TextField sa1_TF = new TextField();
		      final TextField sa2_TF = new TextField();
		      final TextField sa3_TF = new TextField();
		      
		      sa1_TF.setWidth("480");
		      sa1_TF.setHeight("130");
		      
		      sa2_TF.setWidth("480");
		      sa2_TF.setHeight("130");
		      
		      sa3_TF.setWidth("480");
		      sa3_TF.setHeight("90");
		      
		      final ComboBox time_combo = new ComboBox();
		      time_combo.setImmediate(true);
		      time_combo.addItem("Time before confirmation");
		      time_combo.addItem("Time of confirmation");
		      time_combo.addItem("Time of Evacuation decision");
		      time_combo.addItem("Time of evacuation");
		      time_combo.addItem("Time of Post evacuation");
		      time_combo.addItem("Time of return");
		      time_combo.addItem("Time of post return");
		      
		      final ComboBox time_combo2 = new ComboBox();
		      time_combo2.setCaption("Select Time");
		      time_combo2.setImmediate(true);
		   /*   time_combo2.addItem("1200");
		      time_combo2.addItem("1215");
		      time_combo2.addItem("1230");
		      time_combo2.addItem("1245");
		      time_combo2.addItem("1300");
		      time_combo2.addItem("1735"); */
		      
		      for (int h=0;h<24;h++)
		      {
		    	  for (int m=0;m<60;m++)
		    	  {
		    		  if(Integer.toString(h).length() == 1)
		    		  {
		    			  if(Integer.toString(m).length() == 1)
		    		  time_combo2.addItem("0"+h+"0"+m);
		    		  }
		    		  
		    			  if(Integer.toString(h).length() == 2)
			    		  {
			    			  if(Integer.toString(m).length() == 1)
			    		  time_combo2.addItem(""+h+"0"+m);
			    		  }
		    			  
			    			  if(Integer.toString(h).length() == 1)
				    		  {
				    			  if(Integer.toString(m).length() == 2)
				    		  time_combo2.addItem("0"+h+""+m);
				    		  }
			    			  
				    			  if(Integer.toString(h).length() == 2)
					    		  {
					    			  if(Integer.toString(m).length() == 2)
					    		  time_combo2.addItem(""+h+""+m);
					    		  }
		    	  }
		      }
		
		
		      
		      
		      OntModel readOnt;
		      String source = "http://example.com/store#";
		      String output= "";
		      String concepts="";
		      String [] temp= new String[100];
		      
		      Boolean find=false;
			  Boolean findClass=false;
			  String test="";
			  String input= "";
			  String inputClassName="Scenario";
			  String inputIndName="tsunami_scenario1";
			  String [] indiv=new String[200];
			  String dataPropertyValue = "";
			  String scenario_name = "No name yet";
			  String earthquake_location = "";
			  String earthquake_Depth = "";
			  String earthquake_InWater = "";
			  String earthquake_time = "";
			  String  earthquake_mag= "";
			  String inferenceResultSA3="";
			  String inferenceResultSA2="";
			  String t2SA1="Wave Height near source Sensor (m): \n";
			  String t2SA2="";
			  String t2SA3="";
			  String t3SA1="Wave Height from various Sensors (m): \n";
			  String t3SA2="";
			  String t3SA3="";
			  String normalWave="Following Sensors have NORMAL Wave height: \n";
			  String mediumWave="Following Sensors have MEDIUM Wave height: \n";
			  String lowWave="Following Sensors have LOW Wave height: \n";
			  String highWave="Following Sensors have HIGH Wave height: \n";
			  String veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
			  double xCoordinate = 0.0;
		      double yCoordinate = 0.0;
		      String lowT1 = null;
		      String normalT1="";
		      String mediumT1="";
		      String highT1="";
		      String veryHighT1="";
				
		      try{
			      readOnt = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null);
			    //  OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
		//	      readOnt.getDocumentManager().addAltEntry( source,"file:D:/tests/saver/SAVERExample6.owl");
			      readOnt.getDocumentManager().addAltEntry( source,filePath);
			      readOnt.read( source );
			      
			 		System.out.println("Entering reasoner");		      
			      OWLReasonerFactory reasonerFactory = new FaCTPlusPlusReasonerFactory();
			      System.out.println("reasoner factory crearted");	
			      
			      
			    	OWLOntologyManager man = OWLManager.createOWLOntologyManager();
			    	
			    	  System.out.println("Ontology manager crearted");	
			    	  
			    	  org.semanticweb.owl.model.OWLDataFactory factory = man.getOWLDataFactory();
			    	  System.out.println("data factory crearted");	
			    	  
				//	OWLOntology ont = man.loadOntologyFromPhysicalURI(URI.create("file:D:/tests/saver/SAVERExample6.owl"));
					OWLOntology ont = man.loadOntologyFromPhysicalURI(URI.create(filePath));
					  System.out.println("Ontology loaded");	
					  
					OWLReasoner reasoner = reasonerFactory.createReasoner(man);
					System.out.println("reasoner created");	
					reasoner.loadOntologies(Collections.singleton(ont));
					System.out.println("Ontology loaded into the reasoner");	
					reasoner.classify();
					System.out.println("reasoner classify done");	
					
			
					OWLClass waveHeight = factory.getOWLClass(URI.create(ont.getURI()+"#WaveHeight"));

					OWLClass firstClass = factory.getOWLClass(URI.create(ont.getURI()+"#CanGenerateTsunami"));
					OWLIndividual ind1 = factory.getOWLIndividual(URI.create(ont.getURI()+"#earthquake1"));  
					
					
					if(reasoner.hasType(ind1, firstClass, true))
					  {
						  inferenceResultSA3= "Tsunami can be generated as: Earthquake has High magnitude and has source location In Water";
					//	  System.out.println("SA3: "+inferenceResultSA3);
						  
					  }
					  else 
					  {
						
						  inferenceResultSA3="Tsunami can not be generated as: Magnitude of Earthquake is not High or source location of Earthquake is not in Water";
		
						  
					  }
					Set<OWLIndividual> individuals = reasoner.getIndividuals(waveHeight, false);
					
					  for( OWLIndividual foundInd : individuals ) {
			    
						  if(foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1).contains("S1T1"))
							    {
							//  System.out.println("found individual: "+foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1));
						
							  String temp2 =  foundInd.getURI().toString();
							  Map<OWLDataPropertyExpression, Set<OWLConstant>> propValue =foundInd.getDataPropertyValues(ont);
							   Iterator it = propValue.entrySet().iterator();
							   
							    while (it.hasNext()) {
							        Map.Entry pairs = (Map.Entry)it.next();
							        Set<OWLConstant> tempCont = propValue.get(pairs.getKey());
							        for(OWLConstant c: tempCont)
							        {
							        System.out.println(pairs.getKey() + " = " + c.getLiteral().toString());
							        t2SA1 = t2SA1+"\n"+temp2.substring(temp2.indexOf('#')+1)+" "+pairs.getKey() + " = " + c.getLiteral().toString();
							        }
							        
							    }
             			  }
		            
                     } 
					  
					  OWLClass tsunamiGeneratedClass = factory.getOWLClass(URI.create(ont.getURI()+"#TsunamiGenerated"));
					  OWLIndividual tsunamiGeneratedInd = factory.getOWLIndividual(URI.create(ont.getURI()+"#DART_sensor1"));
					 
					  if(reasoner.hasType(tsunamiGeneratedInd, tsunamiGeneratedClass, true))
					  {
						  t2SA2= "Tsunami has been generated at Source as Wave height is High";
						  t2SA3 ="Possible Tsunami threat!!";
						 								  
					  } 
					  else
					  {
						  t2SA2= "Tsunami has not been generated at Source as Wave height is normal or low";
						  t2SA3 ="No possible tsunami threat!!";
						  
					  }
					  
					//  Set<OWLIndividual> tsunamiGeneratedIndls = reasoner.getIndividuals(tsunamiGeneratedClass, false);
					  OWLClass normalWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#NormalWaveHeight"));
					  OWLClass mediumWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#MediumWaveHeight"));
					  OWLClass highWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#HighWaveHeight"));
					  OWLClass lowWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#LowWaveHeight"));
					  OWLClass veryHighWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#VeryHighWaveHeight"));
					  
					  
					
					  String wT1="";
					  String wT2="";
					  OWLIndividual [] tempWaveIndT1 = new OWLIndividual[5]; 
					  OWLIndividual [] tempWaveIndT2 = new OWLIndividual[5]; 
					  OWLIndividual [] tempWaveIndT3 = new OWLIndividual[5]; 
					  OWLIndividual [] tempWaveIndT4 = new OWLIndividual[5]; 
					  OWLIndividual [] tempWaveIndT5 = new OWLIndividual[5]; 
						  int t1Count =0;
						  int t2Count =0;
						  int t3Count =0;
						  int t4Count =0;
						  int t5Count =0;
                       for( OWLIndividual foundInd : individuals )
                       {
						  String tempInd= foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1);
						  if (tempInd.contains("T1"))
						  { tempWaveIndT1[t1Count]=foundInd; t1Count++;}
						  else if (tempInd.contains("T2"))
						  {tempWaveIndT2[t2Count]=foundInd; t2Count++;}
						  else if (tempInd.contains("T3"))
						  {tempWaveIndT3[t3Count]=foundInd;t3Count++;}
						  else if (tempInd.contains("T4"))
						  {tempWaveIndT4[t4Count]=foundInd;t4Count++;}
						  else if (tempInd.contains("T5"))
						  {tempWaveIndT5[t5Count]=foundInd; t5Count++;}
						  
						  }

					
                       for (int ind=0;ind<tempWaveIndT1.length;ind++)
                       {
                 		  String tempInd= tempWaveIndT1[ind].getURI().toString().substring(tempWaveIndT1[ind].getURI().toString().indexOf('#')+1);
                 		  
                 		if(reasoner.hasType(tempWaveIndT1[ind], normalWaveHeightClass, true))
						  {
							 
						   normalWave= normalWave +tempInd +"\n";
							
						  } 
						  else if(reasoner.hasType(tempWaveIndT1[ind], mediumWaveHeightClass, true))
						  {
							  
							  mediumWave= mediumWave +tempInd+"\n";
						  }
						  
						  else if(reasoner.hasType(tempWaveIndT1[ind], highWaveHeightClass, true))
						  {
							  
							  highWave= highWave +tempInd+"\n";
						  }
						  
						  else if(reasoner.hasType(tempWaveIndT1[ind], lowWaveHeightClass, true))
						  {
							  
							  lowWave= lowWave +tempInd+"\n";
						  }
						  
						  else if(reasoner.hasType(tempWaveIndT1[ind], veryHighWaveHeightClass, true))
						  {
							  
							  veryHighWave= veryHighWave +tempInd+"\n";
						  }
                 		  
                       }
                       
                       t3SA2= "\n Wave Height Analysis at Time T1 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                       
                       lowT1=lowWave;
                       normalT1=normalWave;
                       mediumT1=mediumWave;
                      highT1=highWave;
                       veryHighT1=veryHighWave;
                       
                    normalWave="Following Sensors have NORMAL Wave height: \n";
 					  mediumWave="Following Sensors have MEDIUM Wave height: \n";
 					  lowWave="Following Sensors have LOW Wave height: \n";
 					  highWave="Following Sensors have HIGH Wave height: \n";
 					  veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
                       
 				   for (int ind=0;ind<tempWaveIndT2.length;ind++)
                 {
           		  String tempInd= tempWaveIndT2[ind].getURI().toString().substring(tempWaveIndT2[ind].getURI().toString().indexOf('#')+1);
           		  
           		if(reasoner.hasType(tempWaveIndT2[ind], normalWaveHeightClass, true))
					  {
						 
					   normalWave= normalWave +tempInd +"\n";
						
					  } 
					  else if(reasoner.hasType(tempWaveIndT2[ind], mediumWaveHeightClass, true))
					  {
						  
						  mediumWave= mediumWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT2[ind], highWaveHeightClass, true))
					  {
						  
						  highWave= highWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT2[ind], lowWaveHeightClass, true))
					  {
						  
						  lowWave= lowWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT2[ind], veryHighWaveHeightClass, true))
					  {
						  
						  veryHighWave= veryHighWave +tempInd+"\n";
					  }
           		  
                 }
                 
                 t3SA2= t3SA2+"\n Wave Height Analysis at Time T2 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                 normalWave="Following Sensors have NORMAL Wave height: \n";
					  mediumWave="Following Sensors have MEDIUM Wave height: \n";
					  lowWave="Following Sensors have LOW Wave height: \n";
					  highWave="Following Sensors have HIGH Wave height: \n";
					  veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
                 
                 for (int ind=0;ind<tempWaveIndT3.length;ind++)
                 {
           		  String tempInd= tempWaveIndT3[ind].getURI().toString().substring(tempWaveIndT3[ind].getURI().toString().indexOf('#')+1);
           		  
           		if(reasoner.hasType(tempWaveIndT3[ind], normalWaveHeightClass, true))
					  {
						 
					   normalWave= normalWave +tempInd +"\n";
						
					  } 
					  else if(reasoner.hasType(tempWaveIndT3[ind], mediumWaveHeightClass, true))
					  {
						  
						  mediumWave= mediumWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT3[ind], highWaveHeightClass, true))
					  {
						  
						  highWave= highWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT3[ind], lowWaveHeightClass, true))
					  {
						  
						  lowWave= lowWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT3[ind], veryHighWaveHeightClass, true))
					  {
						  
						  veryHighWave= veryHighWave +tempInd+"\n";
					  }
           		  
                 }
                 
                 t3SA2= t3SA2+"\n Wave Height Analysis at Time T3 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                 normalWave="Following Sensors have NORMAL Wave height: \n";
					  mediumWave="Following Sensors have MEDIUM Wave height: \n";
					  lowWave="Following Sensors have LOW Wave height: \n";
					  highWave="Following Sensors have HIGH Wave height: \n";
					  veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
					  
                 
                 for (int ind=0;ind<tempWaveIndT4.length;ind++)
                 {
           		  String tempInd= tempWaveIndT4[ind].getURI().toString().substring(tempWaveIndT4[ind].getURI().toString().indexOf('#')+1);
           		  
           		if(reasoner.hasType(tempWaveIndT4[ind], normalWaveHeightClass, true))
					  {
						 
					   normalWave= normalWave +tempInd +"\n";
						
					  } 
					  else if(reasoner.hasType(tempWaveIndT4[ind], mediumWaveHeightClass, true))
					  {
						  
						  mediumWave= mediumWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT4[ind], highWaveHeightClass, true))
					  {
						  
						  highWave= highWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT4[ind], lowWaveHeightClass, true))
					  {
						  
						  lowWave= lowWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT4[ind], veryHighWaveHeightClass, true))
					  {
						  
						  veryHighWave= veryHighWave +tempInd+"\n";
					  }
           		  
                 }
                 
                 t3SA2= t3SA2+"\n Wave Height Analysis at Time T4 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                 
                 normalWave="Following Sensors have NORMAL Wave height: \n";
					  mediumWave="Following Sensors have MEDIUM Wave height: \n";
					  lowWave="Following Sensors have LOW Wave height: \n";
					  highWave="Following Sensors have HIGH Wave height: \n";
					  veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
                       
				       for (int ind=0;ind<tempWaveIndT5.length;ind++)
                     {
               		  String tempInd= tempWaveIndT5[ind].getURI().toString().substring(tempWaveIndT5[ind].getURI().toString().indexOf('#')+1);
               		  
               		if(reasoner.hasType(tempWaveIndT5[ind], normalWaveHeightClass, true))
						  {
							 
						   normalWave= normalWave +tempInd +"\n";
							
						  } 
						  else if(reasoner.hasType(tempWaveIndT5[ind], mediumWaveHeightClass, true))
						  {
							  
							  mediumWave= mediumWave +tempInd+"\n";
						  }
						  
						  else if(reasoner.hasType(tempWaveIndT5[ind], highWaveHeightClass, true))
						  {
							  
							  highWave= highWave +tempInd+"\n";
						  }
						  
						  else if(reasoner.hasType(tempWaveIndT5[ind], lowWaveHeightClass, true))
						  {
							  
							  lowWave= lowWave +tempInd+"\n";
						  }
						  
						  else if(reasoner.hasType(tempWaveIndT5[ind], veryHighWaveHeightClass, true))
						  {
							  
							  veryHighWave= veryHighWave +tempInd+"\n";
						  }
               		  
                     }
                     
                     t3SA2= t3SA2+"\n Wave Height Analysis at Time T5 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
        		  
					  for( OWLIndividual foundInd : individuals ) {
						    
						
							//  System.out.println("found individual: "+foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1));
						
							  String temp2 =  foundInd.getURI().toString();
							  Map<OWLDataPropertyExpression, Set<OWLConstant>> propValue =foundInd.getDataPropertyValues(ont);
							   Iterator it = propValue.entrySet().iterator();
							   
							    while (it.hasNext()) {
							        Map.Entry pairs = (Map.Entry)it.next();
							        Set<OWLConstant> tempCont = propValue.get(pairs.getKey());
							        for(OWLConstant c: tempCont)
							        {
							     //   System.out.println(pairs.getKey() + " = " + c.getLiteral().toString());
							        t3SA1 = t3SA1+"\n"+temp2.substring(temp2.indexOf('#')+1)+" "+pairs.getKey() + " = " + c.getLiteral().toString();
							        }
							        
							    }
             			 
		            
                     }
					
					       
				       
				       
		
				       int countInd=0;
				       
				       
				       for (Iterator<Individual> j = readOnt.listIndividuals(); j.hasNext(); ) {
						Individual thisIndividual = (Individual) j.next();
						String indType = thisIndividual.getRDFType().getLocalName();
						String indName = thisIndividual.getLocalName();
					    indiv[countInd]=indType+"  "+indName.toString();
					    if(indName.equals(inputIndName)|| inputIndName==null || inputIndName=="")
					    {
					    //  	System.out.println("Individual found: "+indName);
					    	String propName = thisIndividual.getLabel(null).toString();
					  //  	System.out.println("Label: "+propName);
					        scenario_name = propName; 
					    }
					    
					    if(indName.equals("magnitude1")|| inputIndName==null || inputIndName=="")
					    {
					    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
						    {
						    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
						    	String propName = thisDataProperty.getLocalName();
						        if (propName.equals("hasEQMagnitudeValue"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						       
						       earthquake_mag = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
					//	       System.out.println("Magnitude: "+earthquake_mag);
						       
						        }
						    }
					    }
					    
					    if(indName.equals("location1")|| inputIndName==null || inputIndName=="")
					    {
					    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
						    {
						    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
						    	String propName = thisDataProperty.getLocalName();
						        if (propName.equals("isLocatedInWater"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						        earthquake_InWater = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
					//	        System.out.println("Location of earthquake: "+earthquake_InWater);
						        }
						        if (propName.equals("hasXCoordinate"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						        earthquake_location = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
						        xCoordinate = Double.parseDouble(earthquake_location);
						        }
						        if (propName.equals("hasXDirection"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						        earthquake_location = earthquake_location + dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
						        if(dataPropertyValue.substring(0, dataPropertyValue.indexOf('^')).equals("W"))
						        		xCoordinate=-(xCoordinate);
						 //       else
						//        	xCoordinate=-(xCoordinate);
						        	
					        		
						        }
						        if (propName.equals("hasYCoordinate"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						        earthquake_location = earthquake_location+" "+dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
						        yCoordinate = Double.parseDouble(dataPropertyValue.substring(0, dataPropertyValue.indexOf('^')));
						        }
						        if (propName.equals("hasYDirection"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						        earthquake_location = earthquake_location+dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
						        if(dataPropertyValue.substring(0, dataPropertyValue.indexOf('^')).equals("S"))
						        	yCoordinate=-(yCoordinate);
						//        else
						    //    	xCoordinate=-(xCoordinate);
						        	
					       
						        }
						       
						    }
					    }
					    
					    if(indName.equals("time_of_earthquake1")|| inputIndName==null || inputIndName=="")
					    {
					    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
						    {
						    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
						    	String propName = thisDataProperty.getLocalName();
						        if (propName.equals("hasEarthquakeTimeValue"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						       
						        earthquake_time = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
						        
						        }
						    }
					    }
					    
				 	    countInd++;
					}
				  
				if(Float.valueOf(earthquake_mag).floatValue()>=7.0)
				{
					System.out.println("Magnitude is High");
					inferenceResultSA2="(1)Magnitude is High";
					
				}
				
				else if ((Float.valueOf(earthquake_mag).floatValue()<7.0) && (Float.valueOf(earthquake_mag).floatValue()>= 4.0))
				{
					System.out.println("Magnitude is Moderate");
					inferenceResultSA2="(1)Magnitude is Moderate";
				}
		//		if(Float.valueOf(earthquake_mag).floatValue()>=7.0)
				else
				{
					System.out.println("Magnitude is Low");
					inferenceResultSA2="(1)Magnitude is Low";
					
				}    
				
				if( Boolean.parseBoolean(earthquake_InWater))
				{
					System.out.println("Earthquake source location is in Water");
					inferenceResultSA2=inferenceResultSA2+"\n (2) Earthquake source location is in Water";
					
				}
				else 
				{
				System.out.println("Earthquake source location is not in Water");
				inferenceResultSA2=inferenceResultSA2+"\n(2) Earthquake source location is not in Water";
				}
						     
			  } catch(Exception e){}; 	      

		          
				  
				  scenario_name_TF.setValue(scenario_name);
				  
				  final GoogleMap googleMap = new GoogleMap(getMainWindow().getApplication(), new Point2D.Double((xCoordinate), -(yCoordinate)), 2);
					googleMap.setWidth("450px");
					googleMap.setHeight("450px");
					googleMap.addMarker(new BasicMarker(1L, new Point2D.Double(20.3, 60.4522), "DART Sensor 1"));
			//		googleMap.addMarker(new BasicMarker(1L, new Point2D.Double(-110.3, 15.4522), "DART Sensor 2"));
					
					Point2D.Double c = new Point2D.Double(-110.3, 15.4522);
				                        
					 double delta = 0.50;
					                         
					 Point2D.Double[] corners = new Point2D.Double[] {
					      new Point2D.Double(c.x - delta, c.y + delta),
					      new Point2D.Double(c.x + delta, c.y + delta),
					      new Point2D.Double(c.x + delta, c.y - delta),
					      new Point2D.Double(c.x - delta, c.y - delta),
					     new Point2D.Double(c.x - delta, c.y + delta)
					};
					
					final Polygon poly = new Polygon(new Random().nextLong(), corners, "#11991A",
					     5, 0.8, "#1010ff", 0.2, true);
					
		//			googleMap.addPolyOverlay(poly);
				
				
					Point2D.Double c2 = new Point2D.Double(-100.3, 12.4522);
                  
										                         
					 Point2D.Double[] corners2 = new Point2D.Double[] {
					      new Point2D.Double(c2.x - delta, c2.y + delta),
					      new Point2D.Double(c2.x + delta, c2.y + delta),
					      new Point2D.Double(c2.x + delta, c2.y - delta),
					      new Point2D.Double(c2.x - delta, c2.y - delta),
					     new Point2D.Double(c2.x - delta, c2.y + delta)
					};
					
					final Polygon poly2 = new Polygon(new Random().nextLong(), corners2, "#11991A",
					     5, 0.8, "#1010ff", 0.2, false);
					
		//			googleMap.addPolyOverlay(poly2);
					
					Point2D.Double c3 = new Point2D.Double(-80.3, 5.4522);
                  
                   
					 Point2D.Double[] corners3 = new Point2D.Double[] {
					      new Point2D.Double(c3.x - delta, c3.y + delta),
					      new Point2D.Double(c3.x + delta, c3.y + delta),
					      new Point2D.Double(c3.x + delta, c3.y - delta),
					      new Point2D.Double(c3.x - delta, c3.y - delta),
					     new Point2D.Double(c3.x - delta, c3.y + delta)
					};
					
					final Polygon poly3 = new Polygon(new Random().nextLong(), corners3, "#11991A",
					     5, 0.8, "#1010ff", 0.2, false);
					
			//		googleMap.addPolyOverlay(poly3);
					
					Point2D.Double c4 = new Point2D.Double(-125.3, -10.4522);
                  
                   
					 Point2D.Double[] corners4 = new Point2D.Double[] {
					      new Point2D.Double(c4.x - delta, c4.y + delta),
					      new Point2D.Double(c4.x + delta, c4.y + delta),
					      new Point2D.Double(c4.x + delta, c4.y - delta),
					      new Point2D.Double(c4.x - delta, c4.y - delta),
					     new Point2D.Double(c4.x - delta, c4.y + delta)
					};
					
					final Polygon poly4 = new Polygon(new Random().nextLong(), corners4, "#11991A",
					     5, 0.8, "#1010ff", 0.2, false);
					
			//		googleMap.addPolyOverlay(poly4);
					
					Point2D.Double c5 = new Point2D.Double(-170.3, -27.4522);
                  
                   
					 Point2D.Double[] corners5 = new Point2D.Double[] {
					      new Point2D.Double(c5.x - delta, c5.y + delta),
					      new Point2D.Double(c5.x + delta, c5.y + delta),
					      new Point2D.Double(c5.x + delta, c5.y - delta),
					      new Point2D.Double(c5.x - delta, c5.y - delta),
					     new Point2D.Double(c5.x - delta, c5.y + delta)
					};
					
					final Polygon poly5 = new Polygon(new Random().nextLong(), corners5, "#11991A",
					     5, 0.8, "#1010ff", 0.2, false);
					
			//		googleMap.addPolyOverlay(poly5);
					
					Point2D.Double c6 = new Point2D.Double(xCoordinate, yCoordinate);
                  
					double delta2 = 45.0;
				/*	 Point2D.Double[] corners6 = new Point2D.Double[] {
					      new Point2D.Double(c6.x , c6.y ),
					      new Point2D.Double(c6.x - (4*delta2) , c6.y - (6*delta2) ),
					      new Point2D.Double(c6.x - (8*delta2) , c6.y - (4*delta2)),
					      new Point2D.Double(c6.x , c6.y ),
					    //  new Point2D.Double(c6.x - (2*delta2), c6.y - (delta2))
					};  */
					
					Point2D.Double[] corners6 = new Point2D.Double[] {
							  new Point2D.Double(c6.x - 50, c6.y + 25),
						      new Point2D.Double(c6.x - 25, c6.y + 50),
						      new Point2D.Double(c6.x + 25, c6.y + 50),
						      new Point2D.Double(c6.x + 50, c6.y + 25),
						      new Point2D.Double(c6.x + 50, c6.y - 25),
						      new Point2D.Double(c6.x + 25, c6.y - 50),
						      new Point2D.Double(c6.x - 25, c6.y - 50),
						      new Point2D.Double(c6.x - 50, c6.y - 25),
						      new Point2D.Double(c6.x - 50, c6.y + 25)

						};
					
					final Polygon poly6 = new Polygon(new Random().nextLong(), corners6, "#f04040",
					     5, 0.8, "#1010ff", 0.2, false);
					
					
					Point2D.Double c7 = new Point2D.Double(-110.3, 15.4522);
                  
					double delta3 = 2.5;
					 Point2D.Double[] corners7 = new Point2D.Double[] {
					      new Point2D.Double(c7.x - delta3, c7.y + delta3),
					      new Point2D.Double(c7.x + delta3, c7.y + delta3),
					      new Point2D.Double(c7.x + delta3, c7.y - delta3),
					      new Point2D.Double(c7.x - delta3, c7.y - delta3),
					      new Point2D.Double(c7.x - delta3, c7.y + delta3)
					};
					
					final Polygon poly7 = new Polygon(new Random().nextLong(), corners7, "#f04040",
					     5, 0.8, "#1010ff", 0.2, false);
					
                Point2D.Double c8 = new Point2D.Double(-100.3, 12.4522);
                  
			//		double delta3 = 2.5;
					 Point2D.Double[] corners8 = new Point2D.Double[] {
					      new Point2D.Double(c8.x - delta3, c8.y + delta3),
					      new Point2D.Double(c8.x + delta3, c8.y + delta3),
					      new Point2D.Double(c8.x + delta3, c8.y - delta3),
					      new Point2D.Double(c8.x - delta3, c8.y - delta3),
					      new Point2D.Double(c8.x - delta3, c8.y + delta3)
					};
					
					final Polygon poly8 = new Polygon(new Random().nextLong(), corners8, "#f04040",
					     5, 0.8, "#1010ff", 0.2, false);
					
                    Point2D.Double c9 = new Point2D.Double(-80.3, 5.4522);
                  
			//		double delta3 = 2.5;
					 Point2D.Double[] corners9 = new Point2D.Double[] {
					      new Point2D.Double(c9.x - delta3, c9.y + delta3),
					      new Point2D.Double(c9.x + delta3, c9.y + delta3),
					      new Point2D.Double(c9.x + delta3, c9.y - delta3),
					      new Point2D.Double(c9.x - delta3, c9.y - delta3),
					      new Point2D.Double(c9.x - delta3, c9.y + delta3)
					};
					
					final Polygon poly9 = new Polygon(new Random().nextLong(), corners9, "#f04040",
					     5, 0.8, "#1010ff", 0.2, false);
					
                 Point2D.Double c10 = new Point2D.Double(-125.3, -10.4522);
                  
				//	double delta3 = 2.5;
					 Point2D.Double[] corners10 = new Point2D.Double[] {
					      new Point2D.Double(c10.x - delta3, c10.y + delta3),
					      new Point2D.Double(c10.x + delta3, c10.y + delta3),
					      new Point2D.Double(c10.x + delta3, c10.y - delta3),
					      new Point2D.Double(c10.x - delta3, c10.y - delta3),
					      new Point2D.Double(c10.x - delta3, c10.y + delta3)
					};
					
					final Polygon poly10 = new Polygon(new Random().nextLong(), corners10, "#f04040",
					     5, 0.8, "#1010ff", 0.2, false);
					
					 Point2D.Double c11 = new Point2D.Double(-170.3, -27.4522);
                      
						//	double delta3 = 2.5;
							 Point2D.Double[] corners11 = new Point2D.Double[] {
							      new Point2D.Double(c11.x - delta3, c11.y + delta3),
							      new Point2D.Double(c11.x + delta3, c11.y + delta3),
							      new Point2D.Double(c11.x + delta3, c11.y - delta3),
							      new Point2D.Double(c11.x - delta3, c11.y - delta3),
							      new Point2D.Double(c11.x - delta3, c11.y + delta3)
							};
							
							final Polygon poly11 = new Polygon(new Random().nextLong(), corners11, "#f04040",
							     5, 0.8, "#1010ff", 0.2, false);
							
							 Point2D.Double c12 = new Point2D.Double( (xCoordinate), yCoordinate);
		                        
								//	double delta3 = 2.5;
									 Point2D.Double[] corners12 = new Point2D.Double[] {
									      new Point2D.Double(c12.x - delta3, c12.y + delta3),
									      new Point2D.Double(c12.x + delta3, c12.y + delta3),
									      new Point2D.Double(c12.x + delta3, c12.y - delta3),
									      new Point2D.Double(c12.x - delta3, c12.y - delta3),
									      new Point2D.Double(c12.x - delta3, c12.y + delta3)
									};
									
									final Polygon poly12 = new Polygon(new Random().nextLong(), corners12, "#f04040",
									     5, 0.8, "#1010ff", 0.2, false);
					
									Point2D.Double c77 = new Point2D.Double(-110.3, 15.4522);
			                        
									//		double delta3 = 2.5;
											 Point2D.Double[] corners77 = new Point2D.Double[] {
											      new Point2D.Double(c77.x - delta3, c77.y + delta3),
											      new Point2D.Double(c77.x + delta3, c77.y + delta3),
											      new Point2D.Double(c77.x + delta3, c77.y - delta3),
											      new Point2D.Double(c77.x - delta3, c77.y - delta3),
											      new Point2D.Double(c77.x - delta3, c77.y + delta3)
											};
											
											final Polygon poly77 = new Polygon(new Random().nextLong(), corners77, "#f04040",
											     5, 0.8, "#1010ff", 0.2, false);
											
					                      Point2D.Double c88 = new Point2D.Double(-100.3, 12.4522);
					                        
									//		double delta3 = 2.5;
											 Point2D.Double[] corners88 = new Point2D.Double[] {
											      new Point2D.Double(c88.x - delta3, c88.y + delta3),
											      new Point2D.Double(c88.x + delta3, c88.y + delta3),
											      new Point2D.Double(c88.x + delta3, c88.y - delta3),
											      new Point2D.Double(c88.x - delta3, c88.y - delta3),
											      new Point2D.Double(c88.x - delta3, c88.y + delta3)
											};
											
											final Polygon poly88 = new Polygon(new Random().nextLong(), corners88, "#f04040",
											     5, 0.8, "#1010ff", 0.2, false);
											
					                       Point2D.Double c99 = new Point2D.Double(-80.3, 5.4522);
					                        
									//		double delta3 = 2.5;
											 Point2D.Double[] corners99 = new Point2D.Double[] {
											      new Point2D.Double(c99.x - delta3, c99.y + delta3),
											      new Point2D.Double(c99.x + delta3, c99.y + delta3),
											      new Point2D.Double(c99.x + delta3, c99.y - delta3),
											      new Point2D.Double(c99.x - delta3, c99.y - delta3),
											      new Point2D.Double(c99.x - delta3, c99.y + delta3)
											};
											
											final Polygon poly99 = new Polygon(new Random().nextLong(), corners99, "#f04040",
											     5, 0.8, "#1010ff", 0.2, false);
											
					                       Point2D.Double c101 = new Point2D.Double(-125.3, -10.4522);
					                        
										//	double delta3 = 2.5;
											 Point2D.Double[] corners101 = new Point2D.Double[] {
											      new Point2D.Double(c101.x - delta3, c101.y + delta3),
											      new Point2D.Double(c101.x + delta3, c101.y + delta3),
											      new Point2D.Double(c101.x + delta3, c101.y - delta3),
											      new Point2D.Double(c101.x - delta3, c101.y - delta3),
											      new Point2D.Double(c101.x - delta3, c101.y + delta3)
											};
											
											final Polygon poly101 = new Polygon(new Random().nextLong(), corners101, "#f04040",
											     5, 0.8, "#1010ff", 0.2, false);
											
											 Point2D.Double c111 = new Point2D.Double(-170.3, -27.4522);
						                        
												//	double delta3 = 2.5;
													 Point2D.Double[] corners111 = new Point2D.Double[] {
													      new Point2D.Double(c111.x - delta3, c111.y + delta3),
													      new Point2D.Double(c111.x + delta3, c111.y + delta3),
													      new Point2D.Double(c111.x + delta3, c111.y - delta3),
													      new Point2D.Double(c111.x - delta3, c111.y - delta3),
													      new Point2D.Double(c111.x - delta3, c111.y + delta3)
													};
													
													final Polygon poly111 = new Polygon(new Random().nextLong(), corners111, "#f04040",
													     5, 0.8, "#1010ff", 0.2, false);
					aLayout1.addComponent(googleMap, "left: 50px; top: 100px;");

					// Create a marker at the IT Mill offices
					
				  shared_sa_TF.setHeight("400");
				  shared_sa_TF.setWidth("300");
				  
				  final TextField send_sa_TF = new TextField();
				  send_sa_TF.setHeight("75");
				  send_sa_TF.setWidth("300");
				  send_sa_TF.setCaption("Opinion / Comment:");
		//		  Label request_sa_label = new Label ("Your opinion on SA:");
			//	  final ComboBox opinion_combo = new ComboBox();
				  opinion_combo.setCaption("Your opinion on SA: ");
				  opinion_combo.setImmediate(true);
				  opinion_combo.addItem("Agree: ");
				  opinion_combo.addItem("Partially Agree: ");
				  opinion_combo.addItem("Disagree: ");
				  
				    
				  final ComboBox role_combo = new ComboBox();
				//  role_combo.setCaption("Your opinion on SA: ");
				  role_combo.setImmediate(true);
				  role_combo.addItem("Planning and Intelligence");
				  role_combo.addItem("Logistics");
				  role_combo.addItem("Welfare");
				  role_combo.addItem("Operations");
				  role_combo.addItem("Controller");
				  role_combo.addItem("SAG Expert");
				  role_combo.addItem("Scientist");
			//	  opinion_combo.setEnabled(true);
				  Button send_sa_button = new Button ("Send Opinion");
				  
					final Button updateMap_Button = new Button ("Update Map");
				  
				  aLayout1.addComponent(sa_heading_label, "left: 600px; top: 50px;");
		//		  aLayout1.addComponent(shared_sa_TF, "left: 1300px; top: 100px;");
				  aLayout1.addComponent(shared_sa_heading_label, "left: 1350px; top: 50px;");
				//  aLayout1.addComponent(opinion_combo, "left: 1320px; top: 550px;");
				//  aLayout1.addComponent(send_sa_TF, "left: 1300px; top: 600px;");
			//	  aLayout1.addComponent(send_sa_button, "left: 1390px; top: 677px;");
				  aLayout1.addComponent(scenario_name_label, "left: 550px; top: 145px;");
			      aLayout1.addComponent(scenario_name_TF, "left: 716px; top: 150px;");
			      aLayout1.addComponent(incoming_info_label, "left: 550px; top: 195px;");
			      aLayout1.addComponent(role_combo, "left: 716px; top: 200px;");
			      aLayout1.addComponent(time_label, "left: 550px; top: 245px;");
			      aLayout1.addComponent(time_combo, "left: 716px; top: 250px;");
			      aLayout1.addComponent(sa1_label, "left: 550px; top: 295px;");
			      aLayout1.addComponent(sa1_TF, "left: 716px; top: 300px;");
			      aLayout1.addComponent(sa2_label, "left: 550px; top: 425px;");
			      aLayout1.addComponent(sa2_TF, "left: 716px; top: 435px;");
			      aLayout1.addComponent(sa3_label, "left: 550px; top: 575px;");
			      aLayout1.addComponent(sa3_TF, "left: 716px; top: 580px;");
			      
			      
			      
			      
				  nameInput = new TextField();
				  role_combo.addListener(new Property.ValueChangeListener(){
				    	
			       	  public void valueChange(Property.ValueChangeEvent event) {
				  if(role_combo.getValue()!= null)
					  nameInput.setValue(role_combo.getValue());
			       	  }});
					  
				  
				  // chat test code
				  
			//	  final VerticalLayout layout = new VerticalLayout();
				  final AbsoluteLayout layout = new AbsoluteLayout();
			//	    final Window mainWindow = new Window("Chat Application", layout);
		//		    setMainWindow(mainWindow);
		//		    mainWindow.setSizeFull();
				//    layout.setSizeFull();
				    
				    layout.setHeight("580");
				    layout.setWidth("450");
				    
				    final Refresher refresher = new Refresher();
				    refresher.setRefreshInterval(500);
				    refresher.addListener(new ChatRefreshListener());
				//   aLayout1.addComponent(refresher);
				    layout.addComponent(refresher);
				    chatLayout = new Panel(new CssLayout());
			//	    chatLayout.setSizeFull();
				    chatLayout.setHeight("400");
				    chatLayout.setWidth("400");
				    layout.addComponent(chatLayout,"left: 10px; top: 1px;");
			//	    layout.setExpandRatio(chatLayout, 1);
				    
				    final HorizontalLayout footer = new HorizontalLayout();
				    footer.setWidth("100%");
				    layout.addComponent(footer);
				    
				    nameInput = new TextField();
				    nameInput.setValue("Anonymous " + visitor);
			//	    nameInput.setValue(role_combo.getValue());
				    visitor++;
			//	    footer.addComponent(nameInput);
				    layout.addComponent(nameInput,"left: 50px; top: 415px;");
				    
				    chatInput = new TextField();
				    chatInput.focus();
			//	    chatInput.setWidth("100%");
				    chatInput.setWidth("400");
				    chatInput.setHeight("100");
				    chatInput.setImmediate(true);
				    chatInput.addListener(chatListener);
			//	    footer.addComponent(chatInput);
			//	    footer.setExpandRatio(chatInput, 1);
				    layout.addComponent(chatInput,"left: 10px; top: 445px;");
				    
				    layout.addComponent(opinion_combo, "left: 190px; top: 415px;");
				    
			//	    footer.addComponent(new Button("Send", chatListener));
				    layout.addComponent(new Button("Send", chatListener),"left: 190px; top: 550px;");
	                
				    aLayout1.addComponent(layout, "left: 1200px; top: 100px;");
				  
			  Button ok_button = new Button ("OK");
		      Button cancel_button= new Button ("Cancel");
		      ok_button.setHeight("30px");
		      ok_button.setWidth("100px");
		      
		      cancel_button.setHeight("30px");
		      cancel_button.setWidth("100px");
		      
		      
		      aLayout1.addComponent(ok_button, "left: 650px; top: 677px;");  
		      aLayout1.addComponent(cancel_button, "left: 750px; top: 677px;"); 
		      
		      final String tempMag = earthquake_mag;
		      final String tempLoc =  earthquake_location ;
		      final String tempTime = earthquake_time;
		      final String infSA3 = inferenceResultSA3;
		      final String infSA2 = inferenceResultSA2;
		      final String tempT2SA1 = t2SA1;
		      final String tempT2SA2 = t2SA2;
		      final String tempT2SA3 = t2SA3;
		      final String tempT3SA1 = t3SA1;
		      final String tempT3SA2 = t3SA2;
		      
		      final Embedded timeImage = new Embedded("",new ClassResource("time.jpg", getMainWindow().getApplication()));
		      timeImage.setWidth("400");
		      timeImage.setHeight("450");
		 
		      
		      
		      final BasicMarker eqMarker1 = new BasicMarker(1L, new Point2D.Double((xCoordinate), yCoordinate), " Earthquake Magnitude:"+tempMag+ " Earthquake Location: "+tempLoc+" Time: "+tempTime);
		      final BasicMarker sensorMarker1 = new BasicMarker(2L, new Point2D.Double(-110.3, 15.4522), "DART Sensor 1");
		      final BasicMarker sensorMarker2 = new BasicMarker(3L, new Point2D.Double(-100.3, 12.4522), "DART Sensor 2");
		      final BasicMarker sensorMarker3 = new BasicMarker(4L, new Point2D.Double(-80.3, 5.4522), "DART Sensor 3");
		      final BasicMarker sensorMarker4 = new BasicMarker(5L, new Point2D.Double(-125.3, -10.4522), "DART Sensor 4");
		      final BasicMarker sensorMarker5 = new BasicMarker(6L, new Point2D.Double(-170.3, -27.4522), "DART Sensor 5");
		      
		     eqMarker1.setIconUrl("http://alert.air-worldwide.com/Images/Icons/EarthquakeIcon.gif");
		     eqMarker1.setIconAnchor(new Point2D.Double(8.0, 8.0));
		    	  
		     final String tempLowWave2=lowT1;
		     final String tempNormalWave2=normalT1;
		     final String tempMediumWave2=mediumT1;
		     final String tempHighWave2=highT1;
		     final String tempVeryHighWave2=veryHighT1;
		     time_combo.addListener(new Property.ValueChangeListener(){
		    	
		    	  
		    	  public void valueChange(Property.ValueChangeEvent event) {
		    		 
		    		  if (time_combo.getValue().toString().equals("Time before confirmation")) {
		    			  
		    			//  googleMap.addMarker(new BasicMarker(1L, new Point2D.Double(-120.3, 15.4522), " Earthquake Magnitude:"+tempMag+ " Earthquake Location: "+tempLoc+" Time: "+tempTime));
		    			  googleMap.addMarker(eqMarker1);
		    			  googleMap.requestRepaint();
		    			  sa1_TF.setValue(" Earthquake Magnitude:"+tempMag+ " Earthquake Location: "+tempLoc+" Time: "+tempTime);
		    			  sa2_TF.setValue(""+infSA2 );
		    			  sa3_TF.setValue(""+infSA3);
		    	    	
		    	      }else if (time_combo.getValue().toString().equals("Time of confirmation"))
		    	      {
		    	    	  if(tempLowWave2.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: Low Wave Height");
		    	    		  poly7.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave2.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: Normal Wave Height");
		    	    		  poly7.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave2.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: Medium Wave Height");
		    	    		  poly7.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave2.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: High Wave Height");
		    	    		  poly7.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave2.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: Very High Wave Height");
		    	    		  poly7.setColor("#FC0B03");
		    	    	  }
		    			  googleMap.addPolyOverlay(poly7);
		    			
		   
		    	 
		    	      
		    	     
		    	    	  if(tempLowWave2.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: Low Wave Height");
		    	    		  poly8.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave2.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: Normal Wave Height");
		    	    		  poly8.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave2.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: Medium Wave Height");
		    	    		  poly8.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave2.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: High Wave Height");
		    	    		  poly8.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave2.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: Very High Wave Height");
		    	    		  poly8.setColor("#FC0B03");
		    	    	  }
		    	    	  googleMap.addPolyOverlay(poly8);
		    			
		    		  
		    	      
		    	    	  if(tempLowWave2.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: Low Wave Height");
		    	    		  poly9.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave2.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: Normal Wave Height");
		    	    		  poly9.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave2.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: Medium Wave Height");
		    	    		  poly9.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave2.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: High Wave Height");
		    	    		  poly9.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave2.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: Very High Wave Height");
		    	    		  poly9.setColor("#FC0B03");
		    	    	  }
		    	    	  googleMap.addPolyOverlay(poly9);
		    			 
		    	     
		    	    	  if(tempLowWave2.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: Low Wave Height");
		    	    		  
		    	    		  poly10.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave2.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: Normal Wave Height");
		    	    		  poly10.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave2.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: Medium Wave Height");
		    	    		  poly10.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave2.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: High Wave Height");
		    	    		  poly10.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave2.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: Very High Wave Height");
		    	    		  poly10.setColor("#FC0B03");
		    	    	  }
		    	    	  googleMap.addPolyOverlay(poly10);
		    			  
		    	      
		    	    	  if(tempLowWave2.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: Low Wave Height");
		    	    		  poly11.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave2.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: Normal Wave Height");
		    	    		  poly11.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave2.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: Medium Wave Height");
		    	    		  poly11.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave2.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: High Wave Height");
		    	    		  poly11.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave2.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: Very High Wave Height");
		    	    		  poly11.setColor("#FC0B03");
		    	    	  }
		    	    	  googleMap.addPolyOverlay(poly11);
	    			  
	    			  
	    	//    	  googleMap.addPolyOverlay(poly);
	    	    	 
	    	    	  
	    	    	  //googleMap.addMarker(new BasicMarker(2L, new Point2D.Double(-110.3, 15.4522), "DART Sensor 1"));
	    	    	  googleMap.addMarker(sensorMarker2);
	    	    	  googleMap.addMarker(sensorMarker3);
	    	    	  googleMap.addMarker(sensorMarker4);
	    	    	  googleMap.addMarker(sensorMarker5);
	    	    	  googleMap.addMarker(sensorMarker1);
	    	    	  
	    	    	  googleMap.requestRepaint();
	    	    	  sa1_TF.setValue(""+tempT2SA1);
	    	    	  sa2_TF.setValue(""+tempT2SA2);
	    	    	  sa3_TF.setValue(""+tempT2SA3);
		    	 
		    	      }
		    	      else if (time_combo.getValue().toString().equals("Time of Evacuation decision"))
		    	      {
		    	    	  googleMap.addPolyOverlay(poly2);
		    	    	  googleMap.addPolyOverlay(poly3);
		    	    	  googleMap.addPolyOverlay(poly4);
		    	    	  googleMap.addPolyOverlay(poly5);
		    	   // 	  googleMap.addMarker(new BasicMarker(3L, new Point2D.Double(-100.3, 12.4522), "DART Sensor 2"));
		    	   // 	  googleMap.addMarker(new BasicMarker(4L, new Point2D.Double(-80.3, 5.4522), "DART Sensor 3"));
		    	   // 	  googleMap.addMarker(new BasicMarker(5L, new Point2D.Double(-125.3, -10.4522), "DART Sensor 4"));
		    	   // 	  googleMap.addMarker(new BasicMarker(6L, new Point2D.Double(-170.3, -27.4522), "DART Sensor 5"));
		    	    	  googleMap.addMarker(sensorMarker2);
		    	    	  googleMap.addMarker(sensorMarker3);
		    	    	  googleMap.addMarker(sensorMarker4);
		    	    	  googleMap.addMarker(sensorMarker5);
		    	    	  googleMap.requestRepaint();
		    	    	  sa1_TF.setValue(""+tempT3SA1);
		    	    	  sa2_TF.setValue(""+tempT3SA2);
		    	    	  sa3_TF.setValue("See the time Image");
		    	    	  aLayout1.addComponent(timeImage, "left: 1250px; top: 110px;");
		    	    	  aLayout1.addComponent(time_combo2, "left: 180px; top: 580px;");
		    	    	  aLayout1.addComponent(updateMap_Button, "left: 310px; top: 580px;");
		    	    
		    	    	  googleMap.addPolyOverlay(poly6);
		    	       	  googleMap.requestRepaint();
		    	
		    	      }
		    		  
		    	      else if (time_combo.getValue().toString().equals("Time of evacuation"))
		    	      {
		    	    	 
		    	    	 
		    	
		    	      }
		    		  
		    	      	    		  
		    	  }
		    	  
		      });
		      
		      final String tempLowWave=lowWave;
		      final String tempNormalWave=normalWave;
		      final String tempMediumWave=mediumWave;
		      final String tempHighWave=highWave;
		      final String tempVeryHighWave=veryHighWave;
		      
		      updateMap_Button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
						
						for(int i=0;i<5;i++)
						{
			//				if (dataCollectionTime[i]<Integer.parseInt(time_combo2.getValue().toString()))
						
							if (dataCollectionTime[i]<Integer.parseInt(time_combo2.getValue().toString()))
									{
								System.out.println("comboBox time"+Integer.parseInt(time_combo2.getValue().toString())+"is greater than time from array"+dataCollectionTime[i]+" "+i );
								
								if(i==2)
								{
						//			System.out.println("time condition true for sensor 1 and time "+i );
									
								 if(tempLowWave.contains("wave_heightS1"))
				    	    	  {
				    	    		  sensorMarker1.setTitle("DART Sensor 1: Low Wave Height");
				    	    		  poly77.setColor("#FCFC7E");
				    	    		
				    	    	  }
				    	    	  else if(tempNormalWave.contains("wave_heightS1"))
				    	    	  {
				    	    		  sensorMarker1.setTitle("DART Sensor 1: Normal Wave Height");
				    	    		  poly77.setColor("#11991A");
				  //  	    		System.out.println("Normal height for sensor 1 and time "+i );
				    	    	  }
				    	    	  else if(tempMediumWave.contains("wave_heightS1"))
				    	    	  {
				    	    		  sensorMarker1.setTitle("DART Sensor 1: Medium Wave Height");
				    	    		  poly77.setColor("#2340FC");
				    	    	  }
				    	    	  else if(tempHighWave.contains("wave_heightS1"))
				    	    	  {
				    	    		  sensorMarker1.setTitle("DART Sensor 1: High Wave Height");
				    	    		  poly77.setColor("#FC3FEF");
				    //	    		System.out.println("High height for sensor 1 and time "+i );
				    	    	  }
				    	    	  else if(tempVeryHighWave.contains("wave_heightS1"))
				    	    	  {
				    	    		  sensorMarker1.setTitle("DART Sensor 1: Very High Wave Height");
				    	    		  poly77.setColor("#FC0B03");
				    	    	  }
				    			  googleMap.addPolyOverlay(poly77);
				    			  googleMap.requestRepaint();
								}
								else
								if(i==4)
								{
				    			if(tempLowWave.contains("wave_heightS2"))
				    	    	  {
				    	    		  sensorMarker2.setTitle("DART Sensor 2: Low Wave Height");
				    	    		  poly88.setColor("#FCFC7E");
				    	    	  }
				    	    	  else if(tempNormalWave.contains("wave_heightS2"))
				    	    	  {
				    	    		  sensorMarker2.setTitle("DART Sensor 2: Normal Wave Height");
				    	    		  poly88.setColor("#11991A");
				    	    	  }
				    	    	  else if(tempMediumWave.contains("wave_heightS2"))
				    	    	  {
				    	    		  sensorMarker2.setTitle("DART Sensor 2: Medium Wave Height");
				    	    		  poly88.setColor("#2340FC");
				    	    	  }
				    	    	  else if(tempHighWave.contains("wave_heightS2"))
				    	    	  {
				    	    		  sensorMarker2.setTitle("DART Sensor 2: High Wave Height");
				    	    		  poly88.setColor("#FC3FEF");
				    	    	  }
				    	    	  else if(tempVeryHighWave.contains("wave_heightS2"))
				    	    	  {
				    	    		  sensorMarker2.setTitle("DART Sensor 2: Very High Wave Height");
				    	    		  poly88.setColor("#FC0B03");
				    	    	  }
				    	    	  googleMap.addPolyOverlay(poly88);
				    			  googleMap.requestRepaint();
								}
								else
								if(i==1)
								{ 
				    			if(tempLowWave.contains("wave_heightS3"))
				    	    	  {
				    	    		  sensorMarker3.setTitle("DART Sensor 3: Low Wave Height");
				    	    		  poly99.setColor("#FCFC7E");
				    	    	  }
				    	    	  else if(tempNormalWave.contains("wave_heightS3"))
				    	    	  {
				    	    		  sensorMarker3.setTitle("DART Sensor 3: Normal Wave Height");
				    	    		  poly99.setColor("#11991A");
				    	    	  }
				    	    	  else if(tempMediumWave.contains("wave_heightS3"))
				    	    	  {
				    	    		  sensorMarker3.setTitle("DART Sensor 3: Medium Wave Height");
				    	    		  poly99.setColor("#2340FC");
				    	    	  }
				    	    	  else if(tempHighWave.contains("wave_heightS3"))
				    	    	  {
				    	    		  sensorMarker3.setTitle("DART Sensor 3: High Wave Height");
				    	    		  poly99.setColor("#FC3FEF");
				    	    	  }
				    	    	  else if(tempVeryHighWave.contains("wave_heightS3"))
				    	    	  {
				    	    		  sensorMarker3.setTitle("DART Sensor 3: Very High Wave Height");
				    	    		  poly99.setColor("#FC0B03");
				    	    	  }
				    	    	  googleMap.addPolyOverlay(poly99);
				    			  googleMap.requestRepaint();
								}
								else
								if(i==3)
								{
				    			if(tempLowWave.contains("wave_heightS4"))
				    	    	  {
				    	    		  sensorMarker4.setTitle("DART Sensor 4: Low Wave Height");
				    	    		  
				    	    		  poly101.setColor("#FCFC7E");
				    	    	  }
				    	    	  else if(tempNormalWave.contains("wave_heightS4"))
				    	    	  {
				    	    		  sensorMarker4.setTitle("DART Sensor 4: Normal Wave Height");
				    	    		  poly101.setColor("#11991A");
				    	    	  }
				    	    	  else if(tempMediumWave.contains("wave_heightS4"))
				    	    	  {
				    	    		  sensorMarker4.setTitle("DART Sensor 4: Medium Wave Height");
				    	    		  poly101.setColor("#2340FC");
				    	    	  }
				    	    	  else if(tempHighWave.contains("wave_heightS4"))
				    	    	  {
				    	    		  sensorMarker4.setTitle("DART Sensor 4: High Wave Height");
				    	    		  poly101.setColor("#FC3FEF");
				    	    	  }
				    	    	  else if(tempVeryHighWave.contains("wave_heightS4"))
				    	    	  {
				    	    		  sensorMarker4.setTitle("DART Sensor 4: Very High Wave Height");
				    	    		  poly101.setColor("#FC0B03");
				    	    	  }
				    	    	  googleMap.addPolyOverlay(poly101);
				    			  googleMap.requestRepaint();
								}
								else
								if(i==0)
								{
				    			if(tempLowWave.contains("wave_heightS5"))
				    	    	  {
				    	    		  sensorMarker5.setTitle("DART Sensor 5: Low Wave Height");
				    	    		  poly111.setColor("#FCFC7E");
				    	    	  }
				    	    	  else if(tempNormalWave.contains("wave_heightS5"))
				    	    	  {
				    	    		  sensorMarker5.setTitle("DART Sensor 5: Normal Wave Height");
				    	    		  poly111.setColor("#11991A");
				    	    	  }
				    	    	  else if(tempMediumWave.contains("wave_heightS5"))
				    	    	  {
				    	    		  sensorMarker5.setTitle("DART Sensor 5: Medium Wave Height");
				    	    		  poly111.setColor("#2340FC");
				    	    	  }
				    	    	  else if(tempHighWave.contains("wave_heightS5"))
				    	    	  {
				    	    		  sensorMarker5.setTitle("DART Sensor 5: High Wave Height");
				    	    		  poly111.setColor("#FC3FEF");
				    	    	  }
				    	    	  else if(tempVeryHighWave.contains("wave_heightS5"))
				    	    	  {
				    	    		  sensorMarker5.setTitle("DART Sensor 5: Very High Wave Height");
				    	    		  poly111.setColor("#FC0B03");
				    	    	  }
				    	    	  googleMap.addPolyOverlay(poly111);
				    			  googleMap.requestRepaint();
								}
									}
						}
						
				   								
					}});
		      
           /*    time_combo2.addListener(new Property.ValueChangeListener(){
		    	
		    	  
		    	  public void valueChange(Property.ValueChangeEvent event) {
		    		 
		    		  if (time_combo2.getValue().toString().equals("0600")) {
		    			  
		    			
		    	    	
		    	      }
		    		  else if (time_combo2.getValue().toString().equals("0650"))
		    	      {
		    	    	  if(tempLowWave.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: Low Wave Height");
		    	    		  poly7.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: Normal Wave Height");
		    	    		  poly7.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: Medium Wave Height");
		    	    		  poly7.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: High Wave Height");
		    	    		  poly7.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: Very High Wave Height");
		    	    		  poly7.setColor("#FC0B03");
		    	    	  }
		    			  googleMap.addPolyOverlay(poly7);
		    			  googleMap.requestRepaint();
		   
		    	 
		    	      }
		    	      else if (time_combo2.getValue().toString().equals("0755"))
		    	      {
		    	    	  if(tempLowWave.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: Low Wave Height");
		    	    		  poly8.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: Normal Wave Height");
		    	    		  poly8.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: Medium Wave Height");
		    	    		  poly8.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: High Wave Height");
		    	    		  poly8.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: Very High Wave Height");
		    	    		  poly8.setColor("#FC0B03");
		    	    	  }
		    	    	  googleMap.addPolyOverlay(poly8);
		    			  googleMap.requestRepaint();
		    	
		    	      }
		    		  
		    	      else if (time_combo2.getValue().toString().equals("0915"))
		    	      {
		    	    	  if(tempLowWave.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: Low Wave Height");
		    	    		  poly9.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: Normal Wave Height");
		    	    		  poly9.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: Medium Wave Height");
		    	    		  poly9.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: High Wave Height");
		    	    		  poly9.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: Very High Wave Height");
		    	    		  poly9.setColor("#FC0B03");
		    	    	  }
		    	    	  googleMap.addPolyOverlay(poly9);
		    			  googleMap.requestRepaint();
		    	      }
		    	      else if (time_combo2.getValue().toString().equals("0955"))
		    	      {
		    	    	  if(tempLowWave.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: Low Wave Height");
		    	    		  
		    	    		  poly10.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: Normal Wave Height");
		    	    		  poly10.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: Medium Wave Height");
		    	    		  poly10.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: High Wave Height");
		    	    		  poly10.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: Very High Wave Height");
		    	    		  poly10.setColor("#FC0B03");
		    	    	  }
		    	    	  googleMap.addPolyOverlay(poly10);
		    			  googleMap.requestRepaint();
		    	      }
		    	      else if (time_combo2.getValue().toString().equals("1735"))
		    	      {
		    	    	  if(tempLowWave.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: Low Wave Height");
		    	    		  poly11.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: Normal Wave Height");
		    	    		  poly11.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: Medium Wave Height");
		    	    		  poly11.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: High Wave Height");
		    	    		  poly11.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: Very High Wave Height");
		    	    		  poly11.setColor("#FC0B03");
		    	    	  }
		    	    	  googleMap.addPolyOverlay(poly11);
		    			  googleMap.requestRepaint();
		    	      }
		    	      	    		  
		    	  }
		    	  
		      }); */
               
               ok_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
						  getMainWindow().removeWindow(sub4);
						
					}});
		      
		      cancel_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
						getMainWindow().removeWindow(sub4);
				    
					}});
		      
		      
		      send_sa_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
					//	  getMainWindow().removeWindow(sub4);
						shared_sa_TF.setValue(shared_sa_TF.getValue()+"\n "+role_combo.getValue()+": "+opinion_combo.getValue()+" "+send_sa_TF.getValue());
						shared_sa_TF2.setValue(shared_sa_TF2.getValue()+"\n "+role_combo.getValue()+": "+opinion_combo.getValue()+" "+send_sa_TF.getValue());
						ssa2_TF.setValue(ssa2_TF.getValue()+"\n "+role_combo.getValue()+": "+opinion_combo.getValue()+" "+send_sa_TF.getValue());
						
						
						
					}});
		      
		      sub4.addComponent(aLayout1);
		      mainWindow.addWindow(sub4);
	// new end	      
		      
	    	
		}
	});
		
// end of SSA 1 button implementation
		
		
		

// start of SSA 2 button implementation
		
		ssa2_button.addListener(new Button.ClickListener() {
			
			
			public void buttonClick(ClickEvent event) {
			
	
		//	mainWindow.removeAllComponents();
	
	    	 final Window sub4= new Window ("SSA 2");
		      sub4.setWidth("1800px");
		    //  sub4.setHeight("1000px");
		      sub4.setHeight("1500px");
	// new
		      final AbsoluteLayout aLayout1 = new AbsoluteLayout();
				aLayout1.setWidth("1800px");
			//	aLayout1.setHeight("1000px");
				aLayout1.setHeight("1500px");
		      
		      Label scenario_name_label = new Label ("<h4>Scenario Name: </h4>", Label.CONTENT_XHTML);
		      Label sa_heading_label = new Label ("<h2>SAVER's Awareness Report</h2>", Label.CONTENT_XHTML);
		      Label shared_sa_heading_label = new Label ("<h2>Shared SA Report</h2>", Label.CONTENT_XHTML);
		      Label time_label = new Label ("<h4>Time in scenario: </h4>", Label.CONTENT_XHTML);
		      Label incoming_info_label = new Label ("<h4>User's Role: </h4>", Label.CONTENT_XHTML);
		      Label sa1_label = new Label ("<h4>Situation Awareness Level 1:</h4>", Label.CONTENT_XHTML);
		      Label sa2_label = new Label ("<h4>Situation Awareness Level 2:</h4>", Label.CONTENT_XHTML);
		      Label sa3_label = new Label ("<h4>Situation Awareness Level 3:</h4>", Label.CONTENT_XHTML);
		      TextField scenario_name_TF = new TextField();
		      TextField incoming_info_TF = new TextField();
	//	      final TextField shared_sa_TF = new TextField();
		      final TextField sa1_TF = new TextField();
		      final TextField sa2_TF = new TextField();
		      final TextField sa3_TF = new TextField();
		      
		      sa1_TF.setWidth("530");
		      sa1_TF.setHeight("130");
		      
		      sa2_TF.setWidth("530");
		      sa2_TF.setHeight("130");
		      
		      sa3_TF.setWidth("530");
		      sa3_TF.setHeight("90");
		      
		      final ComboBox time_combo = new ComboBox();
		      time_combo.setImmediate(true);
		      time_combo.addItem("Time before confirmation");
		      time_combo.addItem("Time of confirmation");
		      time_combo.addItem("Time of Evacuation decision");
		      time_combo.addItem("Time of evacuation");
		      time_combo.addItem("Time of Post evacuation");
		      time_combo.addItem("Time of return");
		      time_combo.addItem("Time of post return");
		      
		      final ComboBox time_combo2 = new ComboBox();
		      time_combo2.setCaption("Select Time");
		      time_combo2.setImmediate(true);
		      time_combo2.addItem("0600");
		      time_combo2.addItem("0650");
		      time_combo2.addItem("0755");
		      time_combo2.addItem("0915");
		      time_combo2.addItem("0955");
		      time_combo2.addItem("1735");
		
		      
		      
		      OntModel readOnt;
		      String source = "http://example.com/store#";
		      String output= "";
		      String concepts="";
		      String [] temp= new String[100];
		      
		      Boolean find=false;
			  Boolean findClass=false;
			  String test="";
			  String input= "";
			  String inputClassName="Scenario";
			  String inputIndName="tsunami_scenario1";
			  String [] indiv=new String[200];
			  String dataPropertyValue = "";
			  String scenario_name = "No name yet";
			  String earthquake_location = "";
			  String earthquake_Depth = "";
			  String earthquake_InWater = "";
			  String earthquake_time = "";
			  String  earthquake_mag= "";
			  String inferenceResultSA3="";
			  String inferenceResultSA2="";
			  String t2SA1="Wave Height near source Sensor (m): \n";
			  String t2SA2="";
			  String t2SA3="";
			  String t3SA1="Wave Height from various Sensors (m): \n";
			  String t3SA2="";
			  String t3SA3="";
			  String normalWave="Following Sensors have NORMAL Wave height: \n";
			  String mediumWave="Following Sensors have MEDIUM Wave height: \n";
			  String lowWave="Following Sensors have LOW Wave height: \n";
			  String highWave="Following Sensors have HIGH Wave height: \n";
			  String veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
			  double xCoordinate = 0.0;
		      double yCoordinate = 0.0;
				
		      try{
			      readOnt = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null);
			    //  OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
		//	      readOnt.getDocumentManager().addAltEntry( source,"file:D:/tests/saver/SAVERExample6.owl");
			      readOnt.getDocumentManager().addAltEntry( source,filePath);
			      readOnt.read( source );
			      
			 		System.out.println("Entering reasoner");		      
			      OWLReasonerFactory reasonerFactory = new FaCTPlusPlusReasonerFactory();
			      System.out.println("reasoner factory crearted");	
			      
			      
			    	OWLOntologyManager man = OWLManager.createOWLOntologyManager();
			    	
			    	  System.out.println("Ontology manager crearted");	
			    	  
			    	  org.semanticweb.owl.model.OWLDataFactory factory = man.getOWLDataFactory();
			    	  System.out.println("data factory crearted");	
			    	  
				//	OWLOntology ont = man.loadOntologyFromPhysicalURI(URI.create("file:D:/tests/saver/SAVERExample6.owl"));
					OWLOntology ont = man.loadOntologyFromPhysicalURI(URI.create(filePath));
					  System.out.println("Ontology loaded");	
					  
					OWLReasoner reasoner = reasonerFactory.createReasoner(man);
					System.out.println("reasoner created");	
					reasoner.loadOntologies(Collections.singleton(ont));
					System.out.println("Ontology loaded into the reasoner");	
					reasoner.classify();
					System.out.println("reasoner classify done");	
					
			
					OWLClass waveHeight = factory.getOWLClass(URI.create(ont.getURI()+"#WaveHeight"));

					OWLClass firstClass = factory.getOWLClass(URI.create(ont.getURI()+"#CanGenerateTsunami"));
					OWLIndividual ind1 = factory.getOWLIndividual(URI.create(ont.getURI()+"#earthquake1"));  
					
					
					if(reasoner.hasType(ind1, firstClass, true))
					  {
						  inferenceResultSA3= "Tsunami can be generated as: Earthquake has High magnitude and has source location In Water";
					//	  System.out.println("SA3: "+inferenceResultSA3);
						  
					  }
					  else 
					  {
						
						  inferenceResultSA3="Tsunami can not be generated as: Magnitude of Earthquake is not High or source location of Earthquake is not in Water";
		
						  
					  }
					  
			

					Set<OWLIndividual> individuals = reasoner.getIndividuals(waveHeight, false);
					
					  for( OWLIndividual foundInd : individuals ) {
			    
						  if(foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1).contains("S1T1"))
							    {
							//  System.out.println("found individual: "+foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1));
						
							  String temp2 =  foundInd.getURI().toString();
							  Map<OWLDataPropertyExpression, Set<OWLConstant>> propValue =foundInd.getDataPropertyValues(ont);
							   Iterator it = propValue.entrySet().iterator();
							   
							    while (it.hasNext()) {
							        Map.Entry pairs = (Map.Entry)it.next();
							        Set<OWLConstant> tempCont = propValue.get(pairs.getKey());
							        for(OWLConstant c: tempCont)
							        {
							        System.out.println(pairs.getKey() + " = " + c.getLiteral().toString());
							        t2SA1 = t2SA1+"\n"+temp2.substring(temp2.indexOf('#')+1)+" "+pairs.getKey() + " = " + c.getLiteral().toString();
							        }
							        
							    }
             			  }
		            
                     } 
					  
					  OWLClass tsunamiGeneratedClass = factory.getOWLClass(URI.create(ont.getURI()+"#TsunamiGenerated"));
					  OWLIndividual tsunamiGeneratedInd = factory.getOWLIndividual(URI.create(ont.getURI()+"#DART_sensor1"));
					 
					  if(reasoner.hasType(tsunamiGeneratedInd, tsunamiGeneratedClass, true))
					  {
						  t2SA2= "Tsunami has been generated at Source as Wave height is High";
						  t2SA3 ="Possible Tsunami threat!!";
						 								  
					  } 
					  else
					  {
						  t2SA2= "Tsunami has not been generated at Source as Wave height is normal or low";
						  t2SA3 ="No possible tsunami threat!!";
						  
					  }
					  
					//  Set<OWLIndividual> tsunamiGeneratedIndls = reasoner.getIndividuals(tsunamiGeneratedClass, false);
					  OWLClass normalWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#NormalWaveHeight"));
					  OWLClass mediumWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#MediumWaveHeight"));
					  OWLClass highWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#HighWaveHeight"));
					  OWLClass lowWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#LowWaveHeight"));
					  OWLClass veryHighWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#VeryHighWaveHeight"));
					  
					  
					
					  String wT1="";
					  String wT2="";
					  OWLIndividual [] tempWaveIndT1 = new OWLIndividual[5]; 
					  OWLIndividual [] tempWaveIndT2 = new OWLIndividual[5]; 
					  OWLIndividual [] tempWaveIndT3 = new OWLIndividual[5]; 
					  OWLIndividual [] tempWaveIndT4 = new OWLIndividual[5]; 
					  OWLIndividual [] tempWaveIndT5 = new OWLIndividual[5]; 
						  int t1Count =0;
						  int t2Count =0;
						  int t3Count =0;
						  int t4Count =0;
						  int t5Count =0;
                       for( OWLIndividual foundInd : individuals )
                       {
						  String tempInd= foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1);
						  if (tempInd.contains("T1"))
						  { tempWaveIndT1[t1Count]=foundInd; t1Count++;}
						  else if (tempInd.contains("T2"))
						  {tempWaveIndT2[t2Count]=foundInd; t2Count++;}
						  else if (tempInd.contains("T3"))
						  {tempWaveIndT3[t3Count]=foundInd;t3Count++;}
						  else if (tempInd.contains("T4"))
						  {tempWaveIndT4[t4Count]=foundInd;t4Count++;}
						  else if (tempInd.contains("T5"))
						  {tempWaveIndT5[t5Count]=foundInd; t5Count++;}
						  
						  }

					
                       for (int ind=0;ind<tempWaveIndT1.length;ind++)
                       {
                 		  String tempInd= tempWaveIndT1[ind].getURI().toString().substring(tempWaveIndT1[ind].getURI().toString().indexOf('#')+1);
                 		  
                 		if(reasoner.hasType(tempWaveIndT1[ind], normalWaveHeightClass, true))
						  {
							 
						   normalWave= normalWave +tempInd +"\n";
							
						  } 
						  else if(reasoner.hasType(tempWaveIndT1[ind], mediumWaveHeightClass, true))
						  {
							  
							  mediumWave= mediumWave +tempInd+"\n";
						  }
						  
						  else if(reasoner.hasType(tempWaveIndT1[ind], highWaveHeightClass, true))
						  {
							  
							  highWave= highWave +tempInd+"\n";
						  }
						  
						  else if(reasoner.hasType(tempWaveIndT1[ind], lowWaveHeightClass, true))
						  {
							  
							  lowWave= lowWave +tempInd+"\n";
						  }
						  
						  else if(reasoner.hasType(tempWaveIndT1[ind], veryHighWaveHeightClass, true))
						  {
							  
							  veryHighWave= veryHighWave +tempInd+"\n";
						  }
                 		  
                       }
                       
                       t3SA2= "\n Wave Height Analysis at Time T1 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                       
                       
                    normalWave="Following Sensors have NORMAL Wave height: \n";
 					  mediumWave="Following Sensors have MEDIUM Wave height: \n";
 					  lowWave="Following Sensors have LOW Wave height: \n";
 					  highWave="Following Sensors have HIGH Wave height: \n";
 					  veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
                       
 				   for (int ind=0;ind<tempWaveIndT2.length;ind++)
                 {
           		  String tempInd= tempWaveIndT2[ind].getURI().toString().substring(tempWaveIndT2[ind].getURI().toString().indexOf('#')+1);
           		  
           		if(reasoner.hasType(tempWaveIndT2[ind], normalWaveHeightClass, true))
					  {
						 
					   normalWave= normalWave +tempInd +"\n";
						
					  } 
					  else if(reasoner.hasType(tempWaveIndT2[ind], mediumWaveHeightClass, true))
					  {
						  
						  mediumWave= mediumWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT2[ind], highWaveHeightClass, true))
					  {
						  
						  highWave= highWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT2[ind], lowWaveHeightClass, true))
					  {
						  
						  lowWave= lowWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT2[ind], veryHighWaveHeightClass, true))
					  {
						  
						  veryHighWave= veryHighWave +tempInd+"\n";
					  }
           		  
                 }
                 
                 t3SA2= t3SA2+"\n Wave Height Analysis at Time T2 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                 normalWave="Following Sensors have NORMAL Wave height: \n";
					  mediumWave="Following Sensors have MEDIUM Wave height: \n";
					  lowWave="Following Sensors have LOW Wave height: \n";
					  highWave="Following Sensors have HIGH Wave height: \n";
					  veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
                 
                 for (int ind=0;ind<tempWaveIndT3.length;ind++)
                 {
           		  String tempInd= tempWaveIndT3[ind].getURI().toString().substring(tempWaveIndT3[ind].getURI().toString().indexOf('#')+1);
           		  
           		if(reasoner.hasType(tempWaveIndT3[ind], normalWaveHeightClass, true))
					  {
						 
					   normalWave= normalWave +tempInd +"\n";
						
					  } 
					  else if(reasoner.hasType(tempWaveIndT3[ind], mediumWaveHeightClass, true))
					  {
						  
						  mediumWave= mediumWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT3[ind], highWaveHeightClass, true))
					  {
						  
						  highWave= highWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT3[ind], lowWaveHeightClass, true))
					  {
						  
						  lowWave= lowWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT3[ind], veryHighWaveHeightClass, true))
					  {
						  
						  veryHighWave= veryHighWave +tempInd+"\n";
					  }
           		  
                 }
                 
                 t3SA2= t3SA2+"\n Wave Height Analysis at Time T3 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                 normalWave="Following Sensors have NORMAL Wave height: \n";
					  mediumWave="Following Sensors have MEDIUM Wave height: \n";
					  lowWave="Following Sensors have LOW Wave height: \n";
					  highWave="Following Sensors have HIGH Wave height: \n";
					  veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
					  
                 
                 for (int ind=0;ind<tempWaveIndT4.length;ind++)
                 {
           		  String tempInd= tempWaveIndT4[ind].getURI().toString().substring(tempWaveIndT4[ind].getURI().toString().indexOf('#')+1);
           		  
           		if(reasoner.hasType(tempWaveIndT4[ind], normalWaveHeightClass, true))
					  {
						 
					   normalWave= normalWave +tempInd +"\n";
						
					  } 
					  else if(reasoner.hasType(tempWaveIndT4[ind], mediumWaveHeightClass, true))
					  {
						  
						  mediumWave= mediumWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT4[ind], highWaveHeightClass, true))
					  {
						  
						  highWave= highWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT4[ind], lowWaveHeightClass, true))
					  {
						  
						  lowWave= lowWave +tempInd+"\n";
					  }
					  
					  else if(reasoner.hasType(tempWaveIndT4[ind], veryHighWaveHeightClass, true))
					  {
						  
						  veryHighWave= veryHighWave +tempInd+"\n";
					  }
           		  
                 }
                 
                 t3SA2= t3SA2+"\n Wave Height Analysis at Time T4 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                 
                 normalWave="Following Sensors have NORMAL Wave height: \n";
					  mediumWave="Following Sensors have MEDIUM Wave height: \n";
					  lowWave="Following Sensors have LOW Wave height: \n";
					  highWave="Following Sensors have HIGH Wave height: \n";
					  veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
                       
				       for (int ind=0;ind<tempWaveIndT5.length;ind++)
                     {
               		  String tempInd= tempWaveIndT5[ind].getURI().toString().substring(tempWaveIndT5[ind].getURI().toString().indexOf('#')+1);
               		  
               		if(reasoner.hasType(tempWaveIndT5[ind], normalWaveHeightClass, true))
						  {
							 
						   normalWave= normalWave +tempInd +"\n";
							
						  } 
						  else if(reasoner.hasType(tempWaveIndT5[ind], mediumWaveHeightClass, true))
						  {
							  
							  mediumWave= mediumWave +tempInd+"\n";
						  }
						  
						  else if(reasoner.hasType(tempWaveIndT5[ind], highWaveHeightClass, true))
						  {
							  
							  highWave= highWave +tempInd+"\n";
						  }
						  
						  else if(reasoner.hasType(tempWaveIndT5[ind], lowWaveHeightClass, true))
						  {
							  
							  lowWave= lowWave +tempInd+"\n";
						  }
						  
						  else if(reasoner.hasType(tempWaveIndT5[ind], veryHighWaveHeightClass, true))
						  {
							  
							  veryHighWave= veryHighWave +tempInd+"\n";
						  }
               		  
                     }
                     
                     t3SA2= t3SA2+"\n Wave Height Analysis at Time T5 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                    
                       
			
					  
					  
					  for( OWLIndividual foundInd : individuals ) {
						    
						
							//  System.out.println("found individual: "+foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1));
						
							  String temp2 =  foundInd.getURI().toString();
							  Map<OWLDataPropertyExpression, Set<OWLConstant>> propValue =foundInd.getDataPropertyValues(ont);
							   Iterator it = propValue.entrySet().iterator();
							   
							    while (it.hasNext()) {
							        Map.Entry pairs = (Map.Entry)it.next();
							        Set<OWLConstant> tempCont = propValue.get(pairs.getKey());
							        for(OWLConstant c: tempCont)
							        {
							     //   System.out.println(pairs.getKey() + " = " + c.getLiteral().toString());
							        t3SA1 = t3SA1+"\n"+temp2.substring(temp2.indexOf('#')+1)+" "+pairs.getKey() + " = " + c.getLiteral().toString();
							        }
							        
							    }
             			 
		            
                     }
					
					       
				       
				       
		
				       int countInd=0;
				       
				       
				       for (Iterator<Individual> j = readOnt.listIndividuals(); j.hasNext(); ) {
						Individual thisIndividual = (Individual) j.next();
						String indType = thisIndividual.getRDFType().getLocalName();
						String indName = thisIndividual.getLocalName();
					    indiv[countInd]=indType+"  "+indName.toString();
					    if(indName.equals(inputIndName)|| inputIndName==null || inputIndName=="")
					    {
					    //  	System.out.println("Individual found: "+indName);
					    	String propName = thisIndividual.getLabel(null).toString();
					  //  	System.out.println("Label: "+propName);
					        scenario_name = propName; 
					    }
					    
					    if(indName.equals("magnitude1")|| inputIndName==null || inputIndName=="")
					    {
					    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
						    {
						    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
						    	String propName = thisDataProperty.getLocalName();
						        if (propName.equals("hasEQMagnitudeValue"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						       
						       earthquake_mag = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
					//	       System.out.println("Magnitude: "+earthquake_mag);
						       
						        }
						    }
					    }
					    
					    if(indName.equals("location1")|| inputIndName==null || inputIndName=="")
					    {
					    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
						    {
						    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
						    	String propName = thisDataProperty.getLocalName();
						        if (propName.equals("isLocatedInWater"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						        earthquake_InWater = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
					//	        System.out.println("Location of earthquake: "+earthquake_InWater);
						        }
						        if (propName.equals("hasXCoordinate"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						        earthquake_location = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
						        xCoordinate = Double.parseDouble(earthquake_location);
						        }
						        if (propName.equals("hasXDirection"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						        earthquake_location = earthquake_location + dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
						        if(dataPropertyValue.substring(0, dataPropertyValue.indexOf('^')).equals("W"))
						        		xCoordinate=-(xCoordinate);
						 //       else
						//        	xCoordinate=-(xCoordinate);
						        	
						        		
						        
						        		
						        }
						        if (propName.equals("hasYCoordinate"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						        earthquake_location = earthquake_location+" "+dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
						        yCoordinate = Double.parseDouble(dataPropertyValue.substring(0, dataPropertyValue.indexOf('^')));
						        }
						        if (propName.equals("hasYDirection"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						        earthquake_location = earthquake_location+dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
						        if(dataPropertyValue.substring(0, dataPropertyValue.indexOf('^')).equals("S"))
						        	yCoordinate=-(yCoordinate);
						//        else
						    //    	xCoordinate=-(xCoordinate);
						        	
					       
						        }
						       
						    }
					    }
					    
					    if(indName.equals("time_of_earthquake1")|| inputIndName==null || inputIndName=="")
					    {
					    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
						    {
						    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
						    	String propName = thisDataProperty.getLocalName();
						        if (propName.equals("hasEarthquakeTimeValue"))
						        {
						        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
						       
						        earthquake_time = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
						        
						        }
						    }
					    }
					    
				 	    countInd++;
					}
				  
				if(Float.valueOf(earthquake_mag).floatValue()>=7.0)
				{
					System.out.println("Magnitude is High");
					inferenceResultSA2="(1)Magnitude is High";
					
				}
				
				else if ((Float.valueOf(earthquake_mag).floatValue()<7.0) && (Float.valueOf(earthquake_mag).floatValue()>= 4.0))
				{
					System.out.println("Magnitude is Moderate");
					inferenceResultSA2="(1)Magnitude is Moderate";
				}
		//		if(Float.valueOf(earthquake_mag).floatValue()>=7.0)
				else
				{
					System.out.println("Magnitude is Low");
					inferenceResultSA2="(1)Magnitude is Low";
					
				}    
				
				if( Boolean.parseBoolean(earthquake_InWater))
				{
					System.out.println("Earthquake source location is in Water");
					inferenceResultSA2=inferenceResultSA2+"\n (2) Earthquake source location is in Water";
					
				}
				else 
				{
				System.out.println("Earthquake source location is not in Water");
				inferenceResultSA2=inferenceResultSA2+"\n(2) Earthquake source location is not in Water";
				}
						     
			  } catch(Exception e){}; 	      

		          
				  
				  scenario_name_TF.setValue(scenario_name);
				  
				  final GoogleMap googleMap = new GoogleMap(getMainWindow().getApplication(), new Point2D.Double((xCoordinate), -(yCoordinate)), 2);
					googleMap.setWidth("950px");
					googleMap.setHeight("600px");
				//	googleMap.setWidth("450px");
				//	googleMap.setHeight("450px");
					googleMap.addMarker(new BasicMarker(1L, new Point2D.Double(20.3, 60.4522), "DART Sensor 1"));
			//		googleMap.addMarker(new BasicMarker(1L, new Point2D.Double(-110.3, 15.4522), "DART Sensor 2"));
					
					Point2D.Double c = new Point2D.Double(-110.3, 15.4522);
				                        
					 double delta = 0.50;
					                         
					 Point2D.Double[] corners = new Point2D.Double[] {
					      new Point2D.Double(c.x - delta, c.y + delta),
					      new Point2D.Double(c.x + delta, c.y + delta),
					      new Point2D.Double(c.x + delta, c.y - delta),
					      new Point2D.Double(c.x - delta, c.y - delta),
					     new Point2D.Double(c.x - delta, c.y + delta)
					};
					
					final Polygon poly = new Polygon(new Random().nextLong(), corners, "#11991A",
					     5, 0.8, "#1010ff", 0.2, true);
					
		//			googleMap.addPolyOverlay(poly);
				
				
					Point2D.Double c2 = new Point2D.Double(-100.3, 12.4522);
                  
										                         
					 Point2D.Double[] corners2 = new Point2D.Double[] {
					      new Point2D.Double(c2.x - delta, c2.y + delta),
					      new Point2D.Double(c2.x + delta, c2.y + delta),
					      new Point2D.Double(c2.x + delta, c2.y - delta),
					      new Point2D.Double(c2.x - delta, c2.y - delta),
					     new Point2D.Double(c2.x - delta, c2.y + delta)
					};
					
					final Polygon poly2 = new Polygon(new Random().nextLong(), corners2, "#11991A",
					     5, 0.8, "#1010ff", 0.2, false);
					
		//			googleMap.addPolyOverlay(poly2);
					
					Point2D.Double c3 = new Point2D.Double(-80.3, 5.4522);
                  
                   
					 Point2D.Double[] corners3 = new Point2D.Double[] {
					      new Point2D.Double(c3.x - delta, c3.y + delta),
					      new Point2D.Double(c3.x + delta, c3.y + delta),
					      new Point2D.Double(c3.x + delta, c3.y - delta),
					      new Point2D.Double(c3.x - delta, c3.y - delta),
					     new Point2D.Double(c3.x - delta, c3.y + delta)
					};
					
					final Polygon poly3 = new Polygon(new Random().nextLong(), corners3, "#11991A",
					     5, 0.8, "#1010ff", 0.2, false);
					
			//		googleMap.addPolyOverlay(poly3);
					
					Point2D.Double c4 = new Point2D.Double(-125.3, -10.4522);
                  
                   
					 Point2D.Double[] corners4 = new Point2D.Double[] {
					      new Point2D.Double(c4.x - delta, c4.y + delta),
					      new Point2D.Double(c4.x + delta, c4.y + delta),
					      new Point2D.Double(c4.x + delta, c4.y - delta),
					      new Point2D.Double(c4.x - delta, c4.y - delta),
					     new Point2D.Double(c4.x - delta, c4.y + delta)
					};
					
					final Polygon poly4 = new Polygon(new Random().nextLong(), corners4, "#11991A",
					     5, 0.8, "#1010ff", 0.2, false);
					
			//		googleMap.addPolyOverlay(poly4);
					
					Point2D.Double c5 = new Point2D.Double(-170.3, -27.4522);
                  
                   
					 Point2D.Double[] corners5 = new Point2D.Double[] {
					      new Point2D.Double(c5.x - delta, c5.y + delta),
					      new Point2D.Double(c5.x + delta, c5.y + delta),
					      new Point2D.Double(c5.x + delta, c5.y - delta),
					      new Point2D.Double(c5.x - delta, c5.y - delta),
					     new Point2D.Double(c5.x - delta, c5.y + delta)
					};
					
					final Polygon poly5 = new Polygon(new Random().nextLong(), corners5, "#11991A",
					     5, 0.8, "#1010ff", 0.2, false);
					
			//		googleMap.addPolyOverlay(poly5);
					
					Point2D.Double c6 = new Point2D.Double(xCoordinate, yCoordinate);
                  
					double delta2 = 45.0;
				/*	 Point2D.Double[] corners6 = new Point2D.Double[] {
					      new Point2D.Double(c6.x , c6.y ),
					      new Point2D.Double(c6.x - (4*delta2) , c6.y - (6*delta2) ),
					      new Point2D.Double(c6.x - (8*delta2) , c6.y - (4*delta2)),
					      new Point2D.Double(c6.x , c6.y ),
					    //  new Point2D.Double(c6.x - (2*delta2), c6.y - (delta2))
					};  */
					
					Point2D.Double[] corners6 = new Point2D.Double[] {
							  new Point2D.Double(c6.x - 16, c6.y + 8),
						      new Point2D.Double(c6.x - 8, c6.y + 16),
						      new Point2D.Double(c6.x + 8, c6.y + 16),
						      new Point2D.Double(c6.x + 16, c6.y + 8),
						      new Point2D.Double(c6.x + 16, c6.y - 8),
						      new Point2D.Double(c6.x + 8, c6.y - 16),
						      new Point2D.Double(c6.x - 8, c6.y - 16),
						      new Point2D.Double(c6.x - 16, c6.y - 8),
						      new Point2D.Double(c6.x - 16, c6.y + 8)

						};
					
					final Polygon poly6 = new Polygon(new Random().nextLong(), corners6, "#000099",
					     5, 0.8, "#1010ff", 0.2, false);
					
					
					Point2D.Double c7 = new Point2D.Double(-110.3, 15.4522);
                  
					double delta3 = 2.5;
					 Point2D.Double[] corners7 = new Point2D.Double[] {
					      new Point2D.Double(c7.x - delta3, c7.y + delta3),
					      new Point2D.Double(c7.x + delta3, c7.y + delta3),
					      new Point2D.Double(c7.x + delta3, c7.y - delta3),
					      new Point2D.Double(c7.x - delta3, c7.y - delta3),
					      new Point2D.Double(c7.x - delta3, c7.y + delta3)
					};
					
					final Polygon poly7 = new Polygon(new Random().nextLong(), corners7, "#f04040",
					     5, 0.8, "#1010ff", 0.2, false);
					
                Point2D.Double c8 = new Point2D.Double(-100.3, 12.4522);
                  
			//		double delta3 = 2.5;
					 Point2D.Double[] corners8 = new Point2D.Double[] {
					      new Point2D.Double(c8.x - delta3, c8.y + delta3),
					      new Point2D.Double(c8.x + delta3, c8.y + delta3),
					      new Point2D.Double(c8.x + delta3, c8.y - delta3),
					      new Point2D.Double(c8.x - delta3, c8.y - delta3),
					      new Point2D.Double(c8.x - delta3, c8.y + delta3)
					};
					
					final Polygon poly8 = new Polygon(new Random().nextLong(), corners8, "#0033FF",
					     5, 0.8, "#1010ff", 0.2, false);
					
Point2D.Double c9 = new Point2D.Double(-80.3, 5.4522);
                  
			//		double delta3 = 2.5;
					 Point2D.Double[] corners9 = new Point2D.Double[] {
					      new Point2D.Double(c9.x - delta3, c9.y + delta3),
					      new Point2D.Double(c9.x + delta3, c9.y + delta3),
					      new Point2D.Double(c9.x + delta3, c9.y - delta3),
					      new Point2D.Double(c9.x - delta3, c9.y - delta3),
					      new Point2D.Double(c9.x - delta3, c9.y + delta3)
					};
					
					final Polygon poly9 = new Polygon(new Random().nextLong(), corners9, "#f04040",
					     5, 0.8, "#1010ff", 0.2, false);
					
                 Point2D.Double c10 = new Point2D.Double(-125.3, -10.4522);
                  
				//	double delta3 = 2.5;
					 Point2D.Double[] corners10 = new Point2D.Double[] {
					      new Point2D.Double(c10.x - delta3, c10.y + delta3),
					      new Point2D.Double(c10.x + delta3, c10.y + delta3),
					      new Point2D.Double(c10.x + delta3, c10.y - delta3),
					      new Point2D.Double(c10.x - delta3, c10.y - delta3),
					      new Point2D.Double(c10.x - delta3, c10.y + delta3)
					};
					
					final Polygon poly10 = new Polygon(new Random().nextLong(), corners10, "#f04040",
					     5, 0.8, "#1010ff", 0.2, false);
					
					 Point2D.Double c11 = new Point2D.Double(-170.3, -27.4522);
                      
						//	double delta3 = 2.5;
							 Point2D.Double[] corners11 = new Point2D.Double[] {
							      new Point2D.Double(c11.x - delta3, c11.y + delta3),
							      new Point2D.Double(c11.x + delta3, c11.y + delta3),
							      new Point2D.Double(c11.x + delta3, c11.y - delta3),
							      new Point2D.Double(c11.x - delta3, c11.y - delta3),
							      new Point2D.Double(c11.x - delta3, c11.y + delta3)
							};
							
							final Polygon poly11 = new Polygon(new Random().nextLong(), corners11, "#f04040",
							     5, 0.8, "#1010ff", 0.2, false);
							
							 Point2D.Double c12 = new Point2D.Double( (xCoordinate), yCoordinate);
		                        
								//	double delta3 = 2.5;
				    					 Point2D.Double[] corners12 = new Point2D.Double[] {
									      new Point2D.Double(c12.x - delta3, c12.y + delta3),
									      new Point2D.Double(c12.x + delta3, c12.y + delta3),
									      new Point2D.Double(c12.x + delta3, c12.y - delta3),
									      new Point2D.Double(c12.x - delta3, c12.y - delta3),
									      new Point2D.Double(c12.x - delta3, c12.y + delta3)
									};
									
									final Polygon poly12 = new Polygon(new Random().nextLong(), corners12, "#f04040",
									     5, 0.8, "#1010ff", 0.2, false);
					
									
									Point2D.Double[] cornersE = new Point2D.Double[] {
											  new Point2D.Double(c6.x - 20, c6.y + 45),
									    //    new Point2D.Double(c6.x - 40, c6.y + 80),
										//    new Point2D.Double(c6.x + 40, c6.y + 80),
										 //     new Point2D.Double(c6.x + 80, c6.y + 40),
										//      new Point2D.Double(c6.x + 80, c6.y - 40), removed for screenshot
        								      new Point2D.Double(c6.x + 40, c6.y - 45),
										      new Point2D.Double(c6.x + 30, c6.y - 80),
										      new Point2D.Double(c6.x - 20, c6.y - 80),
										      new Point2D.Double(c6.x - 60, c6.y - 70),
										      new Point2D.Double(c6.x - 70, c6.y - 30),
										      new Point2D.Double(c6.x - 60, c6.y + 35),
										      new Point2D.Double(c6.x - 20, c6.y + 45)

										};
									
									final Polygon polyE = new Polygon(new Random().nextLong(), cornersE, "#ff00cc",
									     5, 0.8, "#FF99FF", 0.2, false);
									
									
				//	aLayout1.addComponent(googleMap, "left: 50px; top: 100px;");
					aLayout1.addComponent(googleMap, "left: 100px; top: 800px;");

					// Create a marker at the IT Mill offices
					
				  ssa2_TF.setHeight("400");
				  ssa2_TF.setWidth("300");
				  
				  final TextField send_sa_TF = new TextField();
				  send_sa_TF.setHeight("75");
				  send_sa_TF.setWidth("300");
				  send_sa_TF.setCaption("Opinion / Comment:");
		//		  Label request_sa_label = new Label ("Your opinion on SA:");
				  final ComboBox opinion_combo = new ComboBox();
				  opinion_combo.setCaption("Your opinion on SA: ");
				  opinion_combo.setImmediate(true);
				  opinion_combo.addItem("Agree: ");
				  opinion_combo.addItem("Partially Agree: ");
				  opinion_combo.addItem("Disagree: ");
				  
				    
				  final ComboBox role_combo = new ComboBox();
				//  role_combo.setCaption("Your opinion on SA: ");
				  role_combo.setImmediate(true);
				  role_combo.addItem("Planning and Intelligence");
				  role_combo.addItem("Logistics");
				  role_combo.addItem("Welfare");
				  role_combo.addItem("Operations");
				  role_combo.addItem("Controller");
				  role_combo.addItem("SAG Expert");
				  role_combo.addItem("Scientist");
			//	  opinion_combo.setEnabled(true);
				  Button send_sa_button = new Button ("Send Opinion");
				  
				  aLayout1.addComponent(sa_heading_label, "left: 600px; top: 50px;");
				  aLayout1.addComponent(ssa2_TF, "left: 1300px; top: 100px;");
				  aLayout1.addComponent(shared_sa_heading_label, "left: 1370px; top: 50px;");
				  aLayout1.addComponent(opinion_combo, "left: 1300px; top: 540px;");
				  aLayout1.addComponent(send_sa_TF, "left: 1300px; top: 600px;");
				  aLayout1.addComponent(send_sa_button, "left: 1390px; top: 677px;");
				  aLayout1.addComponent(scenario_name_label, "left: 550px; top: 145px;");
			      aLayout1.addComponent(scenario_name_TF, "left: 716px; top: 150px;");
			      aLayout1.addComponent(incoming_info_label, "left: 550px; top: 195px;");
			      aLayout1.addComponent(role_combo, "left: 716px; top: 200px;");
			      aLayout1.addComponent(time_label, "left: 550px; top: 245px;");
			      aLayout1.addComponent(time_combo, "left: 716px; top: 250px;");
			      aLayout1.addComponent(sa1_label, "left: 550px; top: 295px;");
			      aLayout1.addComponent(sa1_TF, "left: 716px; top: 300px;");
			      aLayout1.addComponent(sa2_label, "left: 550px; top: 425px;");
			      aLayout1.addComponent(sa2_TF, "left: 716px; top: 435px;");
			      aLayout1.addComponent(sa3_label, "left: 550px; top: 575px;");
			      aLayout1.addComponent(sa3_TF, "left: 716px; top: 580px;");
			      
			      
				  
			  Button ok_button = new Button ("OK");
		      Button cancel_button= new Button ("Cancel");
		      ok_button.setHeight("30px");
		      ok_button.setWidth("100px");
		      
		      cancel_button.setHeight("30px");
		      cancel_button.setWidth("100px");
		      
		      
		      aLayout1.addComponent(ok_button, "left: 650px; top: 677px;");  
		      aLayout1.addComponent(cancel_button, "left: 750px; top: 677px;"); 
		      
		      final String tempMag = earthquake_mag;
		      final String tempLoc =  earthquake_location ;
		      final String tempTime = earthquake_time;
		      final String infSA3 = inferenceResultSA3;
		      final String infSA2 = inferenceResultSA2;
		      final String tempT2SA1 = t2SA1;
		      final String tempT2SA2 = t2SA2;
		      final String tempT2SA3 = t2SA3;
		      final String tempT3SA1 = t3SA1;
		      final String tempT3SA2 = t3SA2;
		      
		      final Embedded timeImage = new Embedded("",new ClassResource("time.jpg", getMainWindow().getApplication()));
		      timeImage.setWidth("400");
		      timeImage.setHeight("450");
		 
		      
		      
		      //final BasicMarker eqMarker1 = new BasicMarker(1L, new Point2D.Double((xCoordinate), yCoordinate), " Earthquake Magnitude:"+tempMag+ " Earthquake Location: "+tempLoc+" Time: "+tempTime);
		 //     final BasicMarker eqMarker1 = new BasicMarker(1L, new Point2D.Double((xCoordinate), yCoordinate), " Earthquake Magnitude:"+tempMag+ " Assessed as HIGH enough to generate a tsunami, Earthquake Location: "+tempLoc+" Time: 1334Z");
		      final BasicMarker eqMarker1 = new BasicMarker(1L, new Point2D.Double((xCoordinate), yCoordinate), " Areas under risk: Expeected time of first wave arrival @ Auckland East - 0332Z 02 APR");
		      
		      final BasicMarker sensorMarker1 = new BasicMarker(2L, new Point2D.Double(-110.3, 15.4522), "DART Sensor 1");
		      final BasicMarker sensorMarker2 = new BasicMarker(3L, new Point2D.Double(-100.3, 12.4522), "DART Sensor 2");
		      final BasicMarker sensorMarker3 = new BasicMarker(4L, new Point2D.Double(-80.3, 5.4522), "DART Sensor 3");
		      final BasicMarker sensorMarker4 = new BasicMarker(5L, new Point2D.Double(-125.3, -10.4522), "DART Sensor 4");
		      final BasicMarker sensorMarker5 = new BasicMarker(6L, new Point2D.Double(-170.3, -27.4522), "DART Sensor 5");
		      
		  //   eqMarker1.setIconUrl("http://alert.air-worldwide.com/Images/Icons/EarthquakeIcon.gif");
		      eqMarker1.setIconUrl("http://www.iris.edu/hq/ssn/img/icons/earthquake_icon2.png"); 
		     eqMarker1.setIconAnchor(new Point2D.Double(8.0, 8.0));
		    	  
		      time_combo.addListener(new Property.ValueChangeListener(){
		    	
		    	  
		    	  public void valueChange(Property.ValueChangeEvent event) {
		    		 
		    		  if (time_combo.getValue().toString().equals("Time before confirmation")) {
		    			  
		    			//  googleMap.addMarker(new BasicMarker(1L, new Point2D.Double(-120.3, 15.4522), " Earthquake Magnitude:"+tempMag+ " Earthquake Location: "+tempLoc+" Time: "+tempTime));
		    			  googleMap.addMarker(eqMarker1);
		    			  googleMap.requestRepaint();
		    			  sa1_TF.setValue(" Earthquake Magnitude:"+tempMag+ " Earthquake Location: "+tempLoc+" Time: "+tempTime);
		    			  sa2_TF.setValue(""+infSA2 );
		    			  sa3_TF.setValue(""+infSA3);
		    	    	
		    	      }else if (time_combo.getValue().toString().equals("Time of confirmation"))
		    	      {
		    	    	  googleMap.addPolyOverlay(poly);
		    	    	  //googleMap.addMarker(new BasicMarker(2L, new Point2D.Double(-110.3, 15.4522), "DART Sensor 1"));
		    	    	  googleMap.addMarker(sensorMarker1);
		    	    	  googleMap.requestRepaint();
		    	    	  sa1_TF.setValue(""+tempT2SA1);
		    	    	  sa2_TF.setValue(""+tempT2SA2);
		    	    	  sa3_TF.setValue(""+tempT2SA3);
		    	 
		    	      }
		    	      else if (time_combo.getValue().toString().equals("Time of Evacuation decision"))
		    	      {
		    	    	  googleMap.addPolyOverlay(poly2);
		    	    	  googleMap.addPolyOverlay(poly3);
		    	    	  googleMap.addPolyOverlay(poly4);
		    	    	  googleMap.addPolyOverlay(poly5);
		    	   // 	  googleMap.addMarker(new BasicMarker(3L, new Point2D.Double(-100.3, 12.4522), "DART Sensor 2"));
		    	   // 	  googleMap.addMarker(new BasicMarker(4L, new Point2D.Double(-80.3, 5.4522), "DART Sensor 3"));
		    	   // 	  googleMap.addMarker(new BasicMarker(5L, new Point2D.Double(-125.3, -10.4522), "DART Sensor 4"));
		    	   // 	  googleMap.addMarker(new BasicMarker(6L, new Point2D.Double(-170.3, -27.4522), "DART Sensor 5"));
		    	    	  googleMap.addMarker(sensorMarker2);
		    	    	  googleMap.addMarker(sensorMarker3);
		    	    	  googleMap.addMarker(sensorMarker4);
		    	    	  googleMap.addMarker(sensorMarker5);
		    	    	  googleMap.requestRepaint();
		    	    	  sa1_TF.setValue(""+tempT3SA1);
		    	    	  sa2_TF.setValue(""+tempT3SA2);
		    	    	  sa3_TF.setValue("See the time Image");
		    	 //   	  aLayout1.addComponent(timeImage, "left: 1250px; top: 110px;");
		    	    	  aLayout1.addComponent(time_combo2, "left: 180px; top: 580px;");
		    	    
		    	    	  googleMap.addPolyOverlay(poly6); // removed for screenshots
		    	    	  googleMap.addPolyOverlay(polyE);
		    	       	  googleMap.requestRepaint();
		    	
		    	      }
		    		  
		    	      else if (time_combo.getValue().toString().equals("Time of evacuation"))
		    	      {
		    	    	 
		    	    	 
		    	
		    	      }
		    		  
		    	      	    		  
		    	  }
		    	  
		      });
		      
		      final String tempLowWave=lowWave;
		      final String tempNormalWave=normalWave;
		      final String tempMediumWave=mediumWave;
		      final String tempHighWave=highWave;
		      final String tempVeryHighWave=veryHighWave;
		      
		      
		      
               time_combo2.addListener(new Property.ValueChangeListener(){
		    	
		    	  
		    	  public void valueChange(Property.ValueChangeEvent event) {
		    		 
		    		  if (time_combo2.getValue().toString().equals("0600")) {
		    			  
		    			
		    	    	
		    	      }
		    		  else if (time_combo2.getValue().toString().equals("0650"))
		    	      {
		    	    	  if(tempLowWave.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: Low Wave Height");
		    	    		  poly7.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: Normal Wave Height");
		    	    		  poly7.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: Medium Wave Height");
		    	    		  poly7.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave.contains("wave_heightS1"))
		    	    	  {
		    	    //		  sensorMarker1.setTitle("DART Sensor 1: High Wave Height"); updated for screenshot
		    	    		  sensorMarker1.setTitle("43412 - 240 NM Southwest of Manzanillo, Mexico: High Wave Height - Tsunami has been generated!");
		    	    		  poly7.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave.contains("wave_heightS1"))
		    	    	  {
		    	    		  sensorMarker1.setTitle("DART Sensor 1: Very High Wave Height");
		    	    		  poly7.setColor("#FC0B03");
		    	    	  }
		    			  googleMap.addPolyOverlay(poly7);
		    			  googleMap.requestRepaint();
		   
		    	 
		    	      }
		    	      else if (time_combo2.getValue().toString().equals("0755"))
		    	      {
		    	    	  if(tempLowWave.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: Low Wave Height");
		    	    		  poly8.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: Normal Wave Height");
		    	    		  poly8.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: Medium Wave Height");
		    	    		  poly8.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave.contains("wave_heightS2"))
		    	    	  {
		    	    	//	  sensorMarker2.setTitle("DART Sensor 2: High Wave Height"); updated for screenshot
		    	    		  sensorMarker2.setTitle("43413 - 360 NM South-Southwest of Acapulco, Mexico: High Wave Height - Tsunami has been generated!");
		    	    		  poly8.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave.contains("wave_heightS2"))
		    	    	  {
		    	    		  sensorMarker2.setTitle("DART Sensor 2: Very High Wave Height");
		    	    		  poly8.setColor("#FC0B03");
		    	    	  }
		    	    	  googleMap.addPolyOverlay(poly8);
		    			  googleMap.requestRepaint();
		    	
		    	      }
		    		  
		    	      else if (time_combo2.getValue().toString().equals("0915"))
		    	      {
		    	    	  if(tempLowWave.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: Low Wave Height");
		    	    		  poly9.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: Normal Wave Height");
		    	    		  poly9.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: Medium Wave Height");
		    	    		  poly9.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave.contains("wave_heightS3"))
		    	    	  {
		    	    		  sensorMarker3.setTitle("DART Sensor 3: High Wave Height");
		    	    		  poly9.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave.contains("wave_heightS3"))
		    	    	  {
		    	    		//  sensorMarker3.setTitle("DART Sensor 3: Very High Wave Height"); updated for screenshots
		    	    		  sensorMarker3.setTitle("32411 - 710 NM West-Southwest of Panama City, Panama: Very High Wave Height - Tsunami is generated!");
		    	    		  poly9.setColor("#FC0B03");
		    	    	  }
		    	    	  googleMap.addPolyOverlay(poly9);
		    			  googleMap.requestRepaint();
		    	      }
		    	      else if (time_combo2.getValue().toString().equals("0955"))
		    	      {
		    	    	  if(tempLowWave.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: Low Wave Height");
		    	    		  
		    	    		  poly10.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: Normal Wave Height");
		    	    		  poly10.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: Medium Wave Height");
		    	    		  poly10.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave.contains("wave_heightS4"))
		    	    	  {
		    	    		//  sensorMarker4.setTitle("DART Sensor 4: High Wave Height"); updated for screenshot
		    	    		  sensorMarker4.setTitle("51406 - 400NM Southeast of Tonga: High Wave Height - Tsunami is generated!");
		    	    		  poly10.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave.contains("wave_heightS4"))
		    	    	  {
		    	    		  sensorMarker4.setTitle("DART Sensor 4: Very High Wave Height");
		    	    		  poly10.setColor("#FC0B03");
		    	    	  }
		    	    	  googleMap.addPolyOverlay(poly10);
		    			  googleMap.requestRepaint();
		    	      }
		    	      else if (time_combo2.getValue().toString().equals("1735"))
		    	      {
		    	    	  if(tempLowWave.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: Low Wave Height");
		    	    		  poly11.setColor("#FCFC7E");
		    	    	  }
		    	    	  else if(tempNormalWave.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: Normal Wave Height");
		    	    		  poly11.setColor("#11991A");
		    	    	  }
		    	    	  else if(tempMediumWave.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: Medium Wave Height");
		    	    		  poly11.setColor("#2340FC");
		    	    	  }
		    	    	  else if(tempHighWave.contains("wave_heightS5"))
		    	    	  {
		    	    	//	  sensorMarker5.setTitle("DART Sensor 5: High Wave Height");
		    	    		  sensorMarker5.setTitle("54401 - 640NM Northeast of Auckland, New Zealand: High Wave Height - Tsunami is generated");
		    	    		  poly11.setColor("#FC3FEF");
		    	    	  }
		    	    	  else if(tempVeryHighWave.contains("wave_heightS5"))
		    	    	  {
		    	    		  sensorMarker5.setTitle("DART Sensor 5: Very High Wave Height");
		    	    		  poly11.setColor("#FC0B03");
		    	    	  }
		    	    	  googleMap.addPolyOverlay(poly11);
		    			  googleMap.requestRepaint();
		    	      }
		    	      	    		  
		    	  }
		    	  
		      });
               
               ok_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
						  getMainWindow().removeWindow(sub4);
						
					}});
		      
		      cancel_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
						getMainWindow().removeWindow(sub4);
				    
					}});
		      
		      
		      send_sa_button.addListener(new Button.ClickListener() {
					
					
					public void buttonClick(ClickEvent event){
					//	  getMainWindow().removeWindow(sub4);
						shared_sa_TF.setValue(shared_sa_TF.getValue()+"\n "+role_combo.getValue()+": "+opinion_combo.getValue()+" "+send_sa_TF.getValue());
						shared_sa_TF2.setValue(shared_sa_TF2.getValue()+"\n "+role_combo.getValue()+": "+opinion_combo.getValue()+" "+send_sa_TF.getValue());
						ssa2_TF.setValue(ssa2_TF.getValue()+"\n "+role_combo.getValue()+": "+opinion_combo.getValue()+" "+send_sa_TF.getValue());
						
						
						
					}});
		      
		      sub4.addComponent(aLayout1);
		      mainWindow.addWindow(sub4);
		      
// new end	      
		      
	    	
		}
	});
		
// end of SSA 2 button implementation		
		
		
		
// start of Sceanario button implementation		
		processPalette.addListener(new Button.ClickListener() {
			
			
			public void buttonClick(ClickEvent event) {
			
	      final Window sub1= new Window ("Scenario");
	      sub1.setWidth("1800px");
	      sub1.setHeight("1000px");
	      
	      final AbsoluteLayout aLayout1 = new AbsoluteLayout();
			aLayout1.setWidth("1800px");
			aLayout1.setHeight("1000px");
	      
	      Label scenario_name_label = new Label ("<h4>Select Scenario:</h4>", Label.CONTENT_XHTML);
	      Label scenario_heading_label = new Label ("<h2>Scenario Management</h2>", Label.CONTENT_XHTML);
	      Label ontology_name_label = new Label ("<h4>Ontology Name:</h4>", Label.CONTENT_XHTML);
	      final Label scenario_detail_label = new Label ("<h4>Tsunami Scenario Details:</h4>", Label.CONTENT_XHTML);
	      final Label scenario_detail_label2 = new Label ("<h4>Volcano Scenario Details:</h4>", Label.CONTENT_XHTML);
	      
	      final ComboBox scenario_name_combo = new ComboBox();
	      final ComboBox ontology_name_combo = new ComboBox();
	      
	      scenario_name_combo.setImmediate(true);
	      scenario_name_combo.setCaption("Select disaster");
	      scenario_name_combo.setWidth("200px");
	      scenario_name_combo.addItem("Volcano");
	      scenario_name_combo.addItem("Tsunami");
	      scenario_name_combo.select("Tsunami");
	      
	      
	      ontology_name_combo.setCaption("Select scenario");
	      ontology_name_combo.setWidth("200px");
	 
	      ontology_name_combo.addItem("Tsunami Scenario 1");
	      ontology_name_combo.addItem("Tsunami Scenario 2");
	      ontology_name_combo.addItem("Tsunami Scenario 3");
	      ontology_name_combo.addItem("Tsunami Scenario 4");
	      ontology_name_combo.select("Tsunami Scenario 1");

	      Button showButton= new Button ("Show");
	      
	      aLayout1.addComponent(scenario_heading_label, "left: 650px; top: 50px;");
	      aLayout1.addComponent(scenario_name_label, "left: 550px; top: 140px;");
	      aLayout1.addComponent(ontology_name_label, "left: 550px; top: 190px;");
	            
	      aLayout1.addComponent(ontology_name_combo, "left: 650px; top: 200px;");
	      aLayout1.addComponent(scenario_name_combo, "left: 650px; top: 150px;");
	      aLayout1.addComponent(showButton, "left: 850px; top: 200px;");
	      
	      
	      try{
 
	      
	        showButton.addListener(new Button.ClickListener() {
				
				
				public void buttonClick(ClickEvent event) {
					
				      OntModel readOnt;
				      String source = "http://example.com/store#";
				      String output= "";
				      String concepts="";
				      String [] temp= new String[100];
				      
				      Boolean find=false;
					  Boolean findClass=false;
					  String test="";
					  String input= "";
					  String inputClassName="Scenario";
					  String inputIndName="tsunami_scenario1";
					  String [] indiv=new String[200];
					  String dataPropertyValue = "";
					  String earthquake_magnitude = "";
					  String earthquake_location = "";
					  String earthquake_Depth = "";
					  String earthquake_InWater = "";
					  String earthquake_time = "";
					  
				      final String scenarioPath1 = "file:D:/tests/saver/SAVERExample5.owl";
				      final String scenarioPath2 = "file:D:/tests/saver/SAVERExample6.owl";
				      final String scenarioPath3 = "file:D:/tests/saver/SAVERExample7.owl";
				      final String scenarioPath4 = "file:D:/tests/saver/SAVERExample8.owl";
				      
					
				   	 if (ontology_name_combo.getValue().toString().equals("Tsunami Scenario 1")) {
		    			  filePath= scenarioPath1;
		    			  System.out.println("Tsunami Scenario 1");
		    	    	  
		    	      }else if (ontology_name_combo.getValue().toString().equals("Tsunami Scenario 2"))
		    	      {
		    	    	  filePath= scenarioPath2;
		    	    	  System.out.println("Tsunami Scenario 2");
		    	      }
		    	      else if (ontology_name_combo.getValue().toString().equals("Tsunami Scenario 3"))
		    	      {
		    	    	  filePath= scenarioPath3;
		    	    	  System.out.println("Tsunami Scenario 3");
		    	      }
		    	      else if (ontology_name_combo.getValue().toString().equals("Tsunami Scenario 4"))
		    	      {
		    	    	  filePath= scenarioPath4;
		    	    	  System.out.println("Tsunami Scenario 4");
		    	      }
				//   	OntModel readOnt2;
				    readOnt = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
				   	 
				    readOnt.getDocumentManager().addAltEntry( source,filePath);
				      readOnt.read( source );

						  
					  int countInd=0;
					  for (Iterator<Individual> j = readOnt.listIndividuals(); j.hasNext(); ) {
							Individual thisIndividual = (Individual) j.next();
							String indType = thisIndividual.getRDFType().getLocalName();
							String indName = thisIndividual.getLocalName();
						    indiv[countInd]=indType+"  "+indName.toString();
						    if(indName.equals(inputIndName)|| inputIndName==null || inputIndName=="")
						    {
						    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
							    {
							    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
							    	String propName = thisDataProperty.getLocalName();
							        if (propName.equals("hasScenarioDescription"))
							        {
							        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
							       
							        concepts = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
							        }
							    }
						    }
						    
						    if(indName.equals("magnitude1")|| inputIndName==null || inputIndName=="")
						    {
						    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
							    {
							    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
							    	String propName = thisDataProperty.getLocalName();
							        if (propName.equals("hasEQMagnitudeValue"))
							        {
							        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
							       
							        earthquake_magnitude = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
							        }
							    }
						    }
						    
						    if(indName.equals("location1")|| inputIndName==null || inputIndName=="")
						    {
						    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
							    {
							    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
							    	String propName = thisDataProperty.getLocalName();
							        if (propName.equals("isLocatedInWater"))
							        {
							        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
							        earthquake_InWater = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
							        }
							        if (propName.equals("hasXCoordinate"))
							        {
							        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
							        earthquake_location = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
							        }
							        if (propName.equals("hasXDirection"))
							        {
							        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
							        earthquake_location = earthquake_location + dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
							        }
							        if (propName.equals("hasYCoordinate"))
							        {
							        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
							        earthquake_location = earthquake_location+" "+dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
							        }
							        if (propName.equals("hasYDirection"))
							        {
							        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
							        earthquake_location = earthquake_location+dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
							        }
							       
							    }
						    }
						    
						    if(indName.equals("time_of_earthquake1")|| inputIndName==null || inputIndName=="")
						    {
						    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
							    {
							    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
							    	String propName = thisDataProperty.getLocalName();
							        if (propName.equals("hasEarthquakeTimeValue"))
							        {
							        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
							       
							        earthquake_time = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
							        }
							    }
						    }
					 	    countInd++;
					  } // end of for
				   	 
					  Label description_label = new Label("<h4>Description:</h4>", Label.CONTENT_XHTML);
				      
				      Label description_label2 = new Label("<h4>Description:</h4>", Label.CONTENT_XHTML );
				       
				      // Earthquake Panel
				      Label earthquake_magnitude_label = new Label("<h4>Earthquake Magnitude:</h4>", Label.CONTENT_XHTML );
				      Label earthquake_location_label = new Label("<h4>Earthquake Location:</h4>", Label.CONTENT_XHTML);
				      Label earthquake_depth_label = new Label("<h4>Earthquake Depth:</h4>", Label.CONTENT_XHTML );
				      Label earthquake_waterORLand_label = new Label("<h4>Earthquake on Land:T/F</h4>", Label.CONTENT_XHTML );
				      Label earthquake_time_label = new Label("<h4>Earthquake Time:</h4>", Label.CONTENT_XHTML );
				      TextField earthquake_description_TF = new TextField();
				      TextField earthquake_magnitude_TF = new TextField();
				      TextField earthquake_location_TF = new TextField();
				      TextField earthquake_depth_TF = new TextField();
				      TextField earthquake_waterORLand_TF = new TextField();
				      TextField earthquake_time_TF = new TextField();
				      
				      
				      
				      earthquake_description_TF.setWidth("830");
				      earthquake_description_TF.setHeight("130");
				      
				      earthquake_description_TF.setValue(""+concepts);
				      earthquake_magnitude_TF.setValue(""+earthquake_magnitude);
				      earthquake_location_TF.setValue(""+earthquake_location);
				      earthquake_depth_TF.setValue(""+earthquake_Depth);
				      earthquake_waterORLand_TF.setValue(""+earthquake_InWater);
				      earthquake_time_TF.setValue(""+earthquake_time);
				      
				      	         
				      final Panel earthquake_panel = new Panel();
				      earthquake_panel.setWidth("1800px");
				      earthquake_panel.setHeight("430px");
				      
				      AbsoluteLayout aLayout2 = new AbsoluteLayout();
				      aLayout2.setWidth("1800px");
				      aLayout2.setHeight("550px");
				      
				      
				      
				      aLayout2.addComponent(scenario_detail_label, "left: 650px; top: 10px;");
				      aLayout2.addComponent(description_label, "left: 550px; top: 50px;");
				      aLayout2.addComponent(earthquake_description_TF, "left: 710px; top: 60px;");
				      aLayout2.addComponent(earthquake_magnitude_label, "left: 550px; top: 200px;");
				      aLayout2.addComponent(earthquake_magnitude_TF, "left: 710px; top: 210px;");
				      aLayout2.addComponent(earthquake_time_label, "left: 910px; top: 200px;");
				      aLayout2.addComponent(earthquake_time_TF, "left: 1030px; top: 210px;");
				      aLayout2.addComponent(earthquake_location_label, "left: 550px; top: 250px;");
				      aLayout2.addComponent(earthquake_location_TF, "left: 710px; top: 260px;");
				      aLayout2.addComponent(earthquake_depth_label, "left: 550px; top: 300px;");
				      aLayout2.addComponent(earthquake_depth_TF, "left: 710px; top: 310px;");
				      aLayout2.addComponent(earthquake_waterORLand_label, "left: 550px; top: 350px;");
				      aLayout2.addComponent(earthquake_waterORLand_TF, "left: 710px; top: 360px;");
				     
				      
				      earthquake_panel.addComponent(aLayout2);
				      
				      //End of Earthquake Panel
				      
				      //Volcano Panel
				      
				      Label date_time_now_label = new Label("<h4>Date / Time: </h4>", Label.CONTENT_XHTML );
				      Label tremors_label = new Label("<h4>No. Of Tremors in last 24 hours:</h4>", Label.CONTENT_XHTML );
				      Label average_depth_label = new Label("<h4>Average depth of tremors:</h4>", Label.CONTENT_XHTML );
				      Label rise_speed_label = new Label("<h4>Speed of rising depth:</h4>", Label.CONTENT_XHTML );
				      Label centric_location_label = new Label("<h4>Centric Location label:</h4>", Label.CONTENT_XHTML );
				      	         
				      final Panel volcano_panel = new Panel();
				      volcano_panel.setWidth("1800px");
				      volcano_panel.setHeight("430px");
				      
				      AbsoluteLayout aLayout3 = new AbsoluteLayout();
				      aLayout3.setWidth("1800px");
				      aLayout3.setHeight("550px");
				      
				      aLayout3.addComponent(scenario_detail_label2, "left: 650px; top: 10px;");
				      aLayout3.addComponent(description_label2, "left: 550px; top: 60px;");
				      aLayout3.addComponent(date_time_now_label, "left: 550px; top: 110px;");
				      aLayout3.addComponent(tremors_label, "left: 550px; top: 160px;");
				      aLayout3.addComponent(average_depth_label, "left: 550px; top: 210px;");
				      aLayout3.addComponent(rise_speed_label, "left: 550px; top: 260px;");
				      aLayout3.addComponent(centric_location_label, "left: 550px; top: 310px;");
				      
				      volcano_panel.addComponent(aLayout3);
					  
					  if (scenario_name_combo.getValue().toString().equals("Tsunami")) {
		    	    	  aLayout1.removeComponent(volcano_panel);
		    	      aLayout1.addComponent(earthquake_panel, "left: 0px; top: 250px;");
		    	      }else if (scenario_name_combo.getValue().toString().equals("Volcano"))
		    	      {
		    	    	  aLayout1.removeComponent(earthquake_panel);  
		    		      aLayout1.addComponent(volcano_panel, "left: 0px; top: 250px;");
		    	      } 	 
		 
			}
		}); 
	    
	  
		  } catch(Exception e){}; 
	      
	     
	      Button ok_button = new Button ("OK");
	      Button cancel_button= new Button ("Cancel");
	      ok_button.setHeight("30px");
	      ok_button.setWidth("100px");
	      
	      cancel_button.setHeight("30px");
	      cancel_button.setWidth("100px");
	      
	      
	      aLayout1.addComponent(ok_button, "left: 650px; top: 700px;");  
	      aLayout1.addComponent(cancel_button, "left: 750px; top: 700px;"); 
	//      aLayout1.addComponent(image, "left: 750px; top: 650px;"); 
	      
	      ok_button.addListener(new Button.ClickListener() {
				
				
				public void buttonClick(ClickEvent event){
					  getMainWindow().removeWindow(sub1);
					
				}});
	      
	      cancel_button.addListener(new Button.ClickListener() {
				
				
				public void buttonClick(ClickEvent event){
					getMainWindow().removeWindow(sub1);
			    
				}});
	      
	      sub1.addComponent(aLayout1);
	      mainWindow.addWindow(sub1);
		}
	});
			
		// End of process pallette (scenario) press button event
	      
		
		
	      
	      // start of situation awareness button event
	      
	      softwareInventoryButton.addListener(new Button.ClickListener() {
				
				
				public void buttonClick(ClickEvent event) {
				
					 final Window sub2= new Window ("SAVER's Situation Report");
				      sub2.setWidth("1800px");
				      sub2.setHeight("1000px");
				      
				      final AbsoluteLayout aLayout1 = new AbsoluteLayout();
						aLayout1.setWidth("1800px");
						aLayout1.setHeight("1000px");
				      
				      Label scenario_name_label = new Label ("<h4>Scenario Name: </h4>", Label.CONTENT_XHTML);
				      Label sa_heading_label = new Label ("<h2>SAVER's Awareness Report</h2>", Label.CONTENT_XHTML);
				      Label time_label = new Label ("<h4>Time in scenario: </h4>", Label.CONTENT_XHTML);
				      Label incoming_info_label = new Label ("<h4>User's Role: </h4>", Label.CONTENT_XHTML);
				      Label sa1_label = new Label ("<h4>Situation Awareness Level 1:</h4>", Label.CONTENT_XHTML);
				      Label sa2_label = new Label ("<h4>Situation Awareness Level 2:</h4>", Label.CONTENT_XHTML);
				      Label sa3_label = new Label ("<h4>Situation Awareness Level 3:</h4>", Label.CONTENT_XHTML);
				      TextField scenario_name_TF = new TextField();
				      TextField incoming_info_TF = new TextField();
				      final TextField sa1_TF = new TextField();
				      final TextField sa2_TF = new TextField();
				      final TextField sa3_TF = new TextField();
				      
				      sa1_TF.setWidth("530");
				      sa1_TF.setHeight("130");
				      
				      sa2_TF.setWidth("530");
				      sa2_TF.setHeight("130");
				      
				      sa3_TF.setWidth("530");
				      sa3_TF.setHeight("110");
				      
				      final ComboBox time_combo = new ComboBox();
				      time_combo.setImmediate(true);
				      time_combo.addItem("Time before confirmation");
				      time_combo.addItem("Time of confirmation");
				      time_combo.addItem("Time of Evacuation decision");
				      time_combo.addItem("Time of evacuation");
				      time_combo.addItem("Time of Post evacuation");
				      time_combo.addItem("Time of return");
				      time_combo.addItem("Time of post return");
				      
				      final ComboBox time_combo2 = new ComboBox();
				      time_combo2.setCaption("Select Time");
				      time_combo2.setImmediate(true);
				   /*   time_combo2.addItem("1200");
				      time_combo2.addItem("1215");
				      time_combo2.addItem("1230");
				      time_combo2.addItem("1245");
				      time_combo2.addItem("1300");
				      time_combo2.addItem("1735"); */
				      
				      for (int h=0;h<24;h++)
				      {
				    	  for (int m=0;m<60;m++)
				    	  {
				    		  if(Integer.toString(h).length() == 1)
				    		  {
				    			  if(Integer.toString(m).length() == 1)
				    		  time_combo2.addItem("0"+h+"0"+m);
				    		  }
				    		  
				    			  if(Integer.toString(h).length() == 2)
					    		  {
					    			  if(Integer.toString(m).length() == 1)
					    		  time_combo2.addItem(""+h+"0"+m);
					    		  }
				    			  
					    			  if(Integer.toString(h).length() == 1)
						    		  {
						    			  if(Integer.toString(m).length() == 2)
						    		  time_combo2.addItem("0"+h+""+m);
						    		  }
					    			  
						    			  if(Integer.toString(h).length() == 2)
							    		  {
							    			  if(Integer.toString(m).length() == 2)
							    		  time_combo2.addItem(""+h+""+m);
							    		  }
				    	  }
				      }
				
				      
				      
				      OntModel readOnt;
				      String source = "http://example.com/store#";
				      String output= "";
				      String concepts="";
				      String [] temp= new String[100];
				      
				      Boolean find=false;
					  Boolean findClass=false;
					  String test="";
					  String input= "";
					  String inputClassName="Scenario";
					  String inputIndName="tsunami_scenario1";
					  String [] indiv=new String[200];
					  String dataPropertyValue = "";
					  String scenario_name = "No name yet";
					  String earthquake_location = "";
					  String earthquake_Depth = "";
					  String earthquake_InWater = "";
					  String earthquake_time = "";
					  String  earthquake_mag= "";
					  String inferenceResultSA3="";
					  String inferenceResultSA2="";
					  String t2SA1="Wave Height near source Sensor (m): \n";
					  String t2SA2="";
					  String t2SA3="";
					  String t3SA1="Wave Height from various Sensors (m): \n";
					  String t3SA2="";
					  String t3SA3="";
					  String normalWave="Following Sensors have NORMAL Wave height: \n";
					  String mediumWave="Following Sensors have MEDIUM Wave height: \n";
					  String lowWave="Following Sensors have LOW Wave height: \n";
					  String highWave="Following Sensors have HIGH Wave height: \n";
					  String veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
					  double xCoordinate = 0.0;
				      double yCoordinate = 0.0;
				      
				      String lowT1 = null;
				      String normalT1="";
				      String mediumT1="";
				      String highT1="";
				      String veryHighT1="";
						
				      try{
					      readOnt = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null);
					    //  OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
				//	      readOnt.getDocumentManager().addAltEntry( source,"file:D:/tests/saver/SAVERExample6.owl");
					      readOnt.getDocumentManager().addAltEntry( source,filePath);
					      readOnt.read( source );
					      
					 		System.out.println("Entering reasoner");		      
					      OWLReasonerFactory reasonerFactory = new FaCTPlusPlusReasonerFactory();
					      System.out.println("reasoner factory crearted");	
					      
					      
					    	OWLOntologyManager man = OWLManager.createOWLOntologyManager();
					    	
					    	  System.out.println("Ontology manager crearted");	
					    	  
					    	  org.semanticweb.owl.model.OWLDataFactory factory = man.getOWLDataFactory();
					    	  System.out.println("data factory crearted");	
					    	  
						//	OWLOntology ont = man.loadOntologyFromPhysicalURI(URI.create("file:D:/tests/saver/SAVERExample6.owl"));
							OWLOntology ont = man.loadOntologyFromPhysicalURI(URI.create(filePath));
							  System.out.println("Ontology loaded");	
							  
							OWLReasoner reasoner = reasonerFactory.createReasoner(man);
							System.out.println("reasoner created");	
							reasoner.loadOntologies(Collections.singleton(ont));
							System.out.println("Ontology loaded into the reasoner");	
							reasoner.classify();
							System.out.println("reasoner classify done");	
							
					
							OWLClass waveHeight = factory.getOWLClass(URI.create(ont.getURI()+"#WaveHeight"));

							OWLClass firstClass = factory.getOWLClass(URI.create(ont.getURI()+"#CanGenerateTsunami"));
							OWLIndividual ind1 = factory.getOWLIndividual(URI.create(ont.getURI()+"#earthquake1"));  
							
							
							if(reasoner.hasType(ind1, firstClass, true))
							  {
								  inferenceResultSA3= "Tsunami can be generated as: Earthquake has High magnitude and has source location In Water";
							//	  System.out.println("SA3: "+inferenceResultSA3);
								  
							  }
							  else 
							  {
								
								  inferenceResultSA3="Tsunami can not be generated as: Magnitude of Earthquake is not High or source location of Earthquake is not in Water";
					
								  
							  }
							
							
				
							Set<OWLIndividual> individuals = reasoner.getIndividuals(waveHeight, false);
							
							  for( OWLIndividual foundInd : individuals ) {
					    
								  if(foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1).contains("T1"))
									    {
									//  System.out.println("found individual: "+foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1));
								
									  String temp2 =  foundInd.getURI().toString();
									  Map<OWLDataPropertyExpression, Set<OWLConstant>> propValue =foundInd.getDataPropertyValues(ont);
									   Iterator it = propValue.entrySet().iterator();
									   
									    while (it.hasNext()) {
									        Map.Entry pairs = (Map.Entry)it.next();
									        Set<OWLConstant> tempCont = propValue.get(pairs.getKey());
									        for(OWLConstant c: tempCont)
									        {
									        System.out.println(foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1)+" "+pairs.getKey() + " = " + c.getLiteral().toString());
									        t2SA1 = t2SA1+"\n"+temp2.substring(temp2.indexOf('#')+1)+" "+pairs.getKey() + " = " + c.getLiteral().toString();
									        }
									        
									    }
                       			  }
				            
	                           } 
							  
							  OWLClass tsunamiGeneratedClass = factory.getOWLClass(URI.create(ont.getURI()+"#TsunamiGenerated"));
							  OWLIndividual tsunamiGeneratedInd = factory.getOWLIndividual(URI.create(ont.getURI()+"#DART_sensor1"));
							 
							  if(reasoner.hasType(tsunamiGeneratedInd, tsunamiGeneratedClass, true))
							  {
								  t2SA2= "Tsunami has been generated at Source as Wave height is High";
								  t2SA3 ="Possible Tsunami threat!!";
								 								  
							  } 
							  else
							  {
								  t2SA2= "Tsunami has not been generated at Source as Wave height is normal or low";
								  t2SA3 ="No possible tsunami threat!!";
								  
							  }
							  
							//  Set<OWLIndividual> tsunamiGeneratedIndls = reasoner.getIndividuals(tsunamiGeneratedClass, false);
							  OWLClass normalWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#NormalWaveHeight"));
							  OWLClass mediumWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#MediumWaveHeight"));
							  OWLClass highWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#HighWaveHeight"));
							  OWLClass lowWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#LowWaveHeight"));
							  OWLClass veryHighWaveHeightClass = factory.getOWLClass(URI.create(ont.getURI()+"#VeryHighWaveHeight"));
							  
							  
							
							  String wT1="";
							  String wT2="";
							  OWLIndividual [] tempWaveIndT1 = new OWLIndividual[5]; 
							  OWLIndividual [] tempWaveIndT2 = new OWLIndividual[5]; 
							  OWLIndividual [] tempWaveIndT3 = new OWLIndividual[5]; 
							  OWLIndividual [] tempWaveIndT4 = new OWLIndividual[5]; 
							  OWLIndividual [] tempWaveIndT5 = new OWLIndividual[5]; 
								  int t1Count =0;
								  int t2Count =0;
								  int t3Count =0;
								  int t4Count =0;
								  int t5Count =0;
						
								  OWLClass DARTTime = factory.getOWLClass(URI.create(ont.getURI()+"#DARTTime"));
									 int collectionTimeCounter=0;
									  Set<OWLIndividual> dataCollTime = reasoner.getIndividuals(DARTTime, false);
										
									  for( OWLIndividual foundInd : dataCollTime ) {
										  System.out.println("found individual: "+foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1));
											
									
										  Map<OWLDataPropertyExpression, Set<OWLConstant>> propValue =foundInd.getDataPropertyValues(ont);
										   Iterator it = propValue.entrySet().iterator();
										   
										    while (it.hasNext()) {
										        Map.Entry pairs = (Map.Entry)it.next();
										        Set<OWLConstant> tempCont = propValue.get(pairs.getKey());
										        for(OWLConstant c: tempCont)
										        {
										//        	System.out.println("before printing literal");
										        System.out.println(pairs.getKey() + " = " + c.getLiteral().toString());
										//        System.out.println("after printing literal");
										       dataCollectionTime[collectionTimeCounter]=Integer.parseInt(c.getLiteral().toString());
										//        System.out.println("after assigning values");
										        }
										 //       System.out.println("Exit internal for loop");
										    }
								//		    System.out.println("Exit internal While loop");
										 						             
										    collectionTimeCounter++;
						            } 
                                 
								  for( OWLIndividual foundInd : individuals )
                                 {
								  String tempInd= foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1);
								  if (tempInd.contains("T1"))
								  { tempWaveIndT1[t1Count]=foundInd; t1Count++;}
								  else if (tempInd.contains("T2"))
								  {tempWaveIndT2[t2Count]=foundInd; t2Count++;}
								  else if (tempInd.contains("T3"))
								  {tempWaveIndT3[t3Count]=foundInd;t3Count++;}
								  else if (tempInd.contains("T4"))
								  {tempWaveIndT4[t4Count]=foundInd;t4Count++;}
								  else if (tempInd.contains("T5"))
								  {tempWaveIndT5[t5Count]=foundInd; t5Count++;}
								  
								  }
 
							
                                 for (int ind=0;ind<tempWaveIndT1.length;ind++)
                                 {
                           		  String tempInd= tempWaveIndT1[ind].getURI().toString().substring(tempWaveIndT1[ind].getURI().toString().indexOf('#')+1);
                           		  
                           		if(reasoner.hasType(tempWaveIndT1[ind], normalWaveHeightClass, true))
								  {
									 
								   normalWave= normalWave +tempInd +"\n";
									
								  } 
								  else if(reasoner.hasType(tempWaveIndT1[ind], mediumWaveHeightClass, true))
								  {
									  
									  mediumWave= mediumWave +tempInd+"\n";
								  }
								  
								  else if(reasoner.hasType(tempWaveIndT1[ind], highWaveHeightClass, true))
								  {
									  
									  highWave= highWave +tempInd+"\n";
								  }
								  
								  else if(reasoner.hasType(tempWaveIndT1[ind], lowWaveHeightClass, true))
								  {
									  
									  lowWave= lowWave +tempInd+"\n";
								  }
								  
								  else if(reasoner.hasType(tempWaveIndT1[ind], veryHighWaveHeightClass, true))
								  {
									  
									  veryHighWave= veryHighWave +tempInd+"\n";
								  }
                           		  
                                 }
                                 
                                 t3SA2= "\n Wave Height Analysis at Time T1 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                                 
                                  lowT1=lowWave;
                                  normalT1=normalWave;
                                  mediumT1=mediumWave;
                                 highT1=highWave;
                                  veryHighT1=veryHighWave;
                                 
                              normalWave="Following Sensors have NORMAL Wave height: \n";
           					  mediumWave="Following Sensors have MEDIUM Wave height: \n";
           					  lowWave="Following Sensors have LOW Wave height: \n";
           					  highWave="Following Sensors have HIGH Wave height: \n";
           					  veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
                                 
           				   for (int ind=0;ind<tempWaveIndT2.length;ind++)
                           {
                     		  String tempInd= tempWaveIndT2[ind].getURI().toString().substring(tempWaveIndT2[ind].getURI().toString().indexOf('#')+1);
                     		  
                     		if(reasoner.hasType(tempWaveIndT2[ind], normalWaveHeightClass, true))
							  {
								 
							   normalWave= normalWave +tempInd +"\n";
								
							  } 
							  else if(reasoner.hasType(tempWaveIndT2[ind], mediumWaveHeightClass, true))
							  {
								  
								  mediumWave= mediumWave +tempInd+"\n";
							  }
							  
							  else if(reasoner.hasType(tempWaveIndT2[ind], highWaveHeightClass, true))
							  {
								  
								  highWave= highWave +tempInd+"\n";
							  }
							  
							  else if(reasoner.hasType(tempWaveIndT2[ind], lowWaveHeightClass, true))
							  {
								  
								  lowWave= lowWave +tempInd+"\n";
							  }
							  
							  else if(reasoner.hasType(tempWaveIndT2[ind], veryHighWaveHeightClass, true))
							  {
								  
								  veryHighWave= veryHighWave +tempInd+"\n";
							  }
                     		  
                           }
                           
                           t3SA2= t3SA2+"\n Wave Height Analysis at Time T2 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                           normalWave="Following Sensors have NORMAL Wave height: \n";
        					  mediumWave="Following Sensors have MEDIUM Wave height: \n";
        					  lowWave="Following Sensors have LOW Wave height: \n";
        					  highWave="Following Sensors have HIGH Wave height: \n";
        					  veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
                           
                           for (int ind=0;ind<tempWaveIndT3.length;ind++)
                           {
                     		  String tempInd= tempWaveIndT3[ind].getURI().toString().substring(tempWaveIndT3[ind].getURI().toString().indexOf('#')+1);
                     		  
                     		if(reasoner.hasType(tempWaveIndT3[ind], normalWaveHeightClass, true))
							  {
								 
							   normalWave= normalWave +tempInd +"\n";
								
							  } 
							  else if(reasoner.hasType(tempWaveIndT3[ind], mediumWaveHeightClass, true))
							  {
								  
								  mediumWave= mediumWave +tempInd+"\n";
							  }
							  
							  else if(reasoner.hasType(tempWaveIndT3[ind], highWaveHeightClass, true))
							  {
								  
								  highWave= highWave +tempInd+"\n";
							  }
							  
							  else if(reasoner.hasType(tempWaveIndT3[ind], lowWaveHeightClass, true))
							  {
								  
								  lowWave= lowWave +tempInd+"\n";
							  }
							  
							  else if(reasoner.hasType(tempWaveIndT3[ind], veryHighWaveHeightClass, true))
							  {
								  
								  veryHighWave= veryHighWave +tempInd+"\n";
							  }
                     		  
                           }
                           
                           t3SA2= t3SA2+"\n Wave Height Analysis at Time T3 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                           normalWave="Following Sensors have NORMAL Wave height: \n";
        					  mediumWave="Following Sensors have MEDIUM Wave height: \n";
        					  lowWave="Following Sensors have LOW Wave height: \n";
        					  highWave="Following Sensors have HIGH Wave height: \n";
        					  veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
        					  
                           
                           for (int ind=0;ind<tempWaveIndT4.length;ind++)
                           {
                     		  String tempInd= tempWaveIndT4[ind].getURI().toString().substring(tempWaveIndT4[ind].getURI().toString().indexOf('#')+1);
                     		  
                     		if(reasoner.hasType(tempWaveIndT4[ind], normalWaveHeightClass, true))
							  {
								 
							   normalWave= normalWave +tempInd +"\n";
								
							  } 
							  else if(reasoner.hasType(tempWaveIndT4[ind], mediumWaveHeightClass, true))
							  {
								  
								  mediumWave= mediumWave +tempInd+"\n";
							  }
							  
							  else if(reasoner.hasType(tempWaveIndT4[ind], highWaveHeightClass, true))
							  {
								  
								  highWave= highWave +tempInd+"\n";
							  }
							  
							  else if(reasoner.hasType(tempWaveIndT4[ind], lowWaveHeightClass, true))
							  {
								  
								  lowWave= lowWave +tempInd+"\n";
							  }
							  
							  else if(reasoner.hasType(tempWaveIndT4[ind], veryHighWaveHeightClass, true))
							  {
								  
								  veryHighWave= veryHighWave +tempInd+"\n";
							  }
                     		  
                           }
                           
                           t3SA2= t3SA2+"\n Wave Height Analysis at Time T4 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                           
                           normalWave="Following Sensors have NORMAL Wave height: \n";
        					  mediumWave="Following Sensors have MEDIUM Wave height: \n";
        					  lowWave="Following Sensors have LOW Wave height: \n";
        					  highWave="Following Sensors have HIGH Wave height: \n";
        					  veryHighWave="Following Sensors have VERY HIGH Wave height: \n";
                                 
        				       for (int ind=0;ind<tempWaveIndT5.length;ind++)
                               {
                         		  String tempInd= tempWaveIndT5[ind].getURI().toString().substring(tempWaveIndT5[ind].getURI().toString().indexOf('#')+1);
                         		  
                         		if(reasoner.hasType(tempWaveIndT5[ind], normalWaveHeightClass, true))
    							  {
    								 
    							   normalWave= normalWave +tempInd +"\n";
    								
    							  } 
    							  else if(reasoner.hasType(tempWaveIndT5[ind], mediumWaveHeightClass, true))
    							  {
    								  
    								  mediumWave= mediumWave +tempInd+"\n";
    							  }
    							  
    							  else if(reasoner.hasType(tempWaveIndT5[ind], highWaveHeightClass, true))
    							  {
    								  
    								  highWave= highWave +tempInd+"\n";
    							  }
    							  
    							  else if(reasoner.hasType(tempWaveIndT5[ind], lowWaveHeightClass, true))
    							  {
    								  
    								  lowWave= lowWave +tempInd+"\n";
    							  }
    							  
    							  else if(reasoner.hasType(tempWaveIndT5[ind], veryHighWaveHeightClass, true))
    							  {
    								  
    								  veryHighWave= veryHighWave +tempInd+"\n";
    							  }
                         		  
                               }
                               
                               t3SA2= t3SA2+"\n Wave Height Analysis at Time T5 \n"+ lowWave +"\n "+ normalWave +"\n"+ mediumWave +"\n"+ highWave +"\n" + veryHighWave +"\n";
                              
                                 
						
							  
							  
							  for( OWLIndividual foundInd : individuals ) {
								    
								
									//  System.out.println("found individual: "+foundInd.getURI().toString().substring(foundInd.getURI().toString().indexOf('#')+1));
								
									  String temp2 =  foundInd.getURI().toString();
									  Map<OWLDataPropertyExpression, Set<OWLConstant>> propValue =foundInd.getDataPropertyValues(ont);
									   Iterator it = propValue.entrySet().iterator();
									   
									    while (it.hasNext()) {
									        Map.Entry pairs = (Map.Entry)it.next();
									        Set<OWLConstant> tempCont = propValue.get(pairs.getKey());
									        for(OWLConstant c: tempCont)
									        {
									     //   System.out.println(pairs.getKey() + " = " + c.getLiteral().toString());
									        t3SA1 = t3SA1+"\n"+temp2.substring(temp2.indexOf('#')+1)+" "+pairs.getKey() + " = " + c.getLiteral().toString();
									        }
									        
									    }
                       			 
				            
	                           }
							
							
						       
				
						       int countInd=0;
						       
						       
						       for (Iterator<Individual> j = readOnt.listIndividuals(); j.hasNext(); ) {
								Individual thisIndividual = (Individual) j.next();
								String indType = thisIndividual.getRDFType().getLocalName();
								String indName = thisIndividual.getLocalName();
							    indiv[countInd]=indType+"  "+indName.toString();
							    if(indName.equals(inputIndName)|| inputIndName==null || inputIndName=="")
							    {
							    //  	System.out.println("Individual found: "+indName);
							    	String propName = thisIndividual.getLabel(null).toString();
							  //  	System.out.println("Label: "+propName);
							        scenario_name = propName; 
							    }
							    
							    if(indName.equals("magnitude1")|| inputIndName==null || inputIndName=="")
							    {
							    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
								    {
								    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
								    	String propName = thisDataProperty.getLocalName();
								        if (propName.equals("hasEQMagnitudeValue"))
								        {
								        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
								       
								       earthquake_mag = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
							//	       System.out.println("Magnitude: "+earthquake_mag);
								       
								        }
								    }
							    }
							    
							    if(indName.equals("location1")|| inputIndName==null || inputIndName=="")
							    {
							    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
								    {
								    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
								    	String propName = thisDataProperty.getLocalName();
								        if (propName.equals("isLocatedInWater"))
								        {
								        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
								        earthquake_InWater = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
							//	        System.out.println("Location of earthquake: "+earthquake_InWater);
								        }
								        if (propName.equals("hasXCoordinate"))
								        {
								        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
								        earthquake_location = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
								        xCoordinate = Double.parseDouble(earthquake_location);
								        }
								        if (propName.equals("hasXDirection"))
								        {
								        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
								        earthquake_location = earthquake_location + dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
								        if(dataPropertyValue.substring(0, dataPropertyValue.indexOf('^')).equals("W"))
								        		xCoordinate=-(xCoordinate);
								 //       else
								//        	xCoordinate=-(xCoordinate);
								        	
								        		
								        
								        		
								        }
								        if (propName.equals("hasYCoordinate"))
								        {
								        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
								        earthquake_location = earthquake_location+" "+dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
								        yCoordinate = Double.parseDouble(dataPropertyValue.substring(0, dataPropertyValue.indexOf('^')));
								        }
								        if (propName.equals("hasYDirection"))
								        {
								        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
								        earthquake_location = earthquake_location+dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
								        if(dataPropertyValue.substring(0, dataPropertyValue.indexOf('^')).equals("S"))
								        	yCoordinate=-(yCoordinate);
								//        else
								    //    	xCoordinate=-(xCoordinate);
								        	
							       
								        }
								       
								    }
							    }
							    
							    if(indName.equals("time_of_earthquake1")|| inputIndName==null || inputIndName=="")
							    {
							    	for (Iterator <DatatypeProperty> k=readOnt.listDatatypeProperties(); k.hasNext();)
								    {
								    	DatatypeProperty thisDataProperty = (DatatypeProperty) k.next();
								    	String propName = thisDataProperty.getLocalName();
								        if (propName.equals("hasEarthquakeTimeValue"))
								        {
								        dataPropertyValue=thisIndividual.getPropertyValue(thisDataProperty).toString();
								       
								        earthquake_time = dataPropertyValue.substring(0, dataPropertyValue.indexOf('^'));
								        
								        }
								    }
							    }
							    
						 	    countInd++;
							}
						  
						if(Float.valueOf(earthquake_mag).floatValue()>=7.0)
						{
							System.out.println("Magnitude is High");
							inferenceResultSA2="(1)Magnitude is High";
							
						}
						
						else if ((Float.valueOf(earthquake_mag).floatValue()<7.0) && (Float.valueOf(earthquake_mag).floatValue()>= 4.0))
						{
							System.out.println("Magnitude is Moderate");
							inferenceResultSA2="(1)Magnitude is Moderate";
						}
				//		if(Float.valueOf(earthquake_mag).floatValue()>=7.0)
						else
						{
							System.out.println("Magnitude is Low");
							inferenceResultSA2="(1)Magnitude is Low";
							
						}    
						
						if( Boolean.parseBoolean(earthquake_InWater))
						{
							System.out.println("Earthquake source location is in Water");
							inferenceResultSA2=inferenceResultSA2+"\n (2) Earthquake source location is in Water";
							
						}
						else 
						{
						System.out.println("Earthquake source location is not in Water");
						inferenceResultSA2=inferenceResultSA2+"\n(2) Earthquake source location is not in Water";
						}
								     
					  } catch(Exception e){}; 	      
		
				          
						  
						  scenario_name_TF.setValue(scenario_name);
						  
						  final GoogleMap googleMap = new GoogleMap(getMainWindow().getApplication(), new Point2D.Double((xCoordinate), -(yCoordinate)), 2);
							googleMap.setWidth("450px");
							googleMap.setHeight("450px");
							googleMap.addMarker(new BasicMarker(1L, new Point2D.Double(20.3, 60.4522), "DART Sensor 1"));
					//		googleMap.addMarker(new BasicMarker(1L, new Point2D.Double(-110.3, 15.4522), "DART Sensor 2"));
							googleMap.setImmediate(true);
							Point2D.Double c = new Point2D.Double(-110.3, 15.4522);
						                        
							 double delta = 0.50;
							                         
							 Point2D.Double[] corners = new Point2D.Double[] {
							      new Point2D.Double(c.x - delta, c.y + delta),
							      new Point2D.Double(c.x + delta, c.y + delta),
							      new Point2D.Double(c.x + delta, c.y - delta),
							      new Point2D.Double(c.x - delta, c.y - delta),
							     new Point2D.Double(c.x - delta, c.y + delta)
							};
							
							final Polygon poly = new Polygon(new Random().nextLong(), corners, "#11991A",
							     5, 0.8, "#1010ff", 0.2, true);
							
				//			googleMap.addPolyOverlay(poly);
						
						
							Point2D.Double c2 = new Point2D.Double(-100.3, 12.4522);
	                        
												                         
							 Point2D.Double[] corners2 = new Point2D.Double[] {
							      new Point2D.Double(c2.x - delta, c2.y + delta),
							      new Point2D.Double(c2.x + delta, c2.y + delta),
							      new Point2D.Double(c2.x + delta, c2.y - delta),
							      new Point2D.Double(c2.x - delta, c2.y - delta),
							     new Point2D.Double(c2.x - delta, c2.y + delta)
							};
							
							final Polygon poly2 = new Polygon(new Random().nextLong(), corners2, "#11991A",
							     5, 0.8, "#1010ff", 0.2, false);
							
				//			googleMap.addPolyOverlay(poly2);
							
							Point2D.Double c3 = new Point2D.Double(-80.3, 5.4522);
	                        
	                         
							 Point2D.Double[] corners3 = new Point2D.Double[] {
							      new Point2D.Double(c3.x - delta, c3.y + delta),
							      new Point2D.Double(c3.x + delta, c3.y + delta),
							      new Point2D.Double(c3.x + delta, c3.y - delta),
							      new Point2D.Double(c3.x - delta, c3.y - delta),
							     new Point2D.Double(c3.x - delta, c3.y + delta)
							};
							
							final Polygon poly3 = new Polygon(new Random().nextLong(), corners3, "#11991A",
							     5, 0.8, "#1010ff", 0.2, false);
							
					//		googleMap.addPolyOverlay(poly3);
							
							Point2D.Double c4 = new Point2D.Double(-125.3, -10.4522);
	                        
	                         
							 Point2D.Double[] corners4 = new Point2D.Double[] {
							      new Point2D.Double(c4.x - delta, c4.y + delta),
							      new Point2D.Double(c4.x + delta, c4.y + delta),
							      new Point2D.Double(c4.x + delta, c4.y - delta),
							      new Point2D.Double(c4.x - delta, c4.y - delta),
							     new Point2D.Double(c4.x - delta, c4.y + delta)
							};
							
							final Polygon poly4 = new Polygon(new Random().nextLong(), corners4, "#11991A",
							     5, 0.8, "#1010ff", 0.2, false);
							
					//		googleMap.addPolyOverlay(poly4);
							
							Point2D.Double c5 = new Point2D.Double(-170.3, -27.4522);
	                        
	                         
							 Point2D.Double[] corners5 = new Point2D.Double[] {
							      new Point2D.Double(c5.x - delta, c5.y + delta),
							      new Point2D.Double(c5.x + delta, c5.y + delta),
							      new Point2D.Double(c5.x + delta, c5.y - delta),
							      new Point2D.Double(c5.x - delta, c5.y - delta),
							     new Point2D.Double(c5.x - delta, c5.y + delta)
							};
							
							final Polygon poly5 = new Polygon(new Random().nextLong(), corners5, "#11991A",
							     5, 0.8, "#1010ff", 0.2, false);
							
					//		googleMap.addPolyOverlay(poly5);
							
							Point2D.Double c6 = new Point2D.Double(xCoordinate, yCoordinate);
	                        
							double delta2 = 45.0;
						
							
							Point2D.Double[] corners6 = new Point2D.Double[] {
									  new Point2D.Double(c6.x - 50, c6.y + 25),
								      new Point2D.Double(c6.x - 25, c6.y + 50),
								      new Point2D.Double(c6.x + 25, c6.y + 50),
								      new Point2D.Double(c6.x + 50, c6.y + 25),
								      new Point2D.Double(c6.x + 50, c6.y - 25),
								      new Point2D.Double(c6.x + 25, c6.y - 50),
								      new Point2D.Double(c6.x - 25, c6.y - 50),
								      new Point2D.Double(c6.x - 50, c6.y - 25),
								      new Point2D.Double(c6.x - 50, c6.y + 25)

								};
							
							final Polygon poly6 = new Polygon(new Random().nextLong(), corners6, "#f04040",
							     5, 0.8, "#1010ff", 0.2, false);
							
							
							Point2D.Double c7 = new Point2D.Double(-110.3, 15.4522);
	                        
							double delta3 = 2.5;
							 Point2D.Double[] corners7 = new Point2D.Double[] {
							      new Point2D.Double(c7.x - delta3, c7.y + delta3),
							      new Point2D.Double(c7.x + delta3, c7.y + delta3),
							      new Point2D.Double(c7.x + delta3, c7.y - delta3),
							      new Point2D.Double(c7.x - delta3, c7.y - delta3),
							      new Point2D.Double(c7.x - delta3, c7.y + delta3)
							};
							
							final Polygon poly7 = new Polygon(new Random().nextLong(), corners7, "#f04040",
							     5, 0.8, "#1010ff", 0.2, false);
							
	                      Point2D.Double c8 = new Point2D.Double(-100.3, 12.4522);
	                        
					//		double delta3 = 2.5;
							 Point2D.Double[] corners8 = new Point2D.Double[] {
							      new Point2D.Double(c8.x - delta3, c8.y + delta3),
							      new Point2D.Double(c8.x + delta3, c8.y + delta3),
							      new Point2D.Double(c8.x + delta3, c8.y - delta3),
							      new Point2D.Double(c8.x - delta3, c8.y - delta3),
							      new Point2D.Double(c8.x - delta3, c8.y + delta3)
							};
							
							final Polygon poly8 = new Polygon(new Random().nextLong(), corners8, "#f04040",
							     5, 0.8, "#1010ff", 0.2, false);
							
	                       Point2D.Double c9 = new Point2D.Double(-80.3, 5.4522);
	                        
					//		double delta3 = 2.5;
							 Point2D.Double[] corners9 = new Point2D.Double[] {
							      new Point2D.Double(c9.x - delta3, c9.y + delta3),
							      new Point2D.Double(c9.x + delta3, c9.y + delta3),
							      new Point2D.Double(c9.x + delta3, c9.y - delta3),
							      new Point2D.Double(c9.x - delta3, c9.y - delta3),
							      new Point2D.Double(c9.x - delta3, c9.y + delta3)
							};
							
							final Polygon poly9 = new Polygon(new Random().nextLong(), corners9, "#f04040",
							     5, 0.8, "#1010ff", 0.2, false);
							
	                       Point2D.Double c10 = new Point2D.Double(-125.3, -10.4522);
	                        
						//	double delta3 = 2.5;
							 Point2D.Double[] corners10 = new Point2D.Double[] {
							      new Point2D.Double(c10.x - delta3, c10.y + delta3),
							      new Point2D.Double(c10.x + delta3, c10.y + delta3),
							      new Point2D.Double(c10.x + delta3, c10.y - delta3),
							      new Point2D.Double(c10.x - delta3, c10.y - delta3),
							      new Point2D.Double(c10.x - delta3, c10.y + delta3)
							};
							
							final Polygon poly10 = new Polygon(new Random().nextLong(), corners10, "#f04040",
							     5, 0.8, "#1010ff", 0.2, false);
							
							 Point2D.Double c11 = new Point2D.Double(-170.3, -27.4522);
		                        
								//	double delta3 = 2.5;
									 Point2D.Double[] corners11 = new Point2D.Double[] {
									      new Point2D.Double(c11.x - delta3, c11.y + delta3),
									      new Point2D.Double(c11.x + delta3, c11.y + delta3),
									      new Point2D.Double(c11.x + delta3, c11.y - delta3),
									      new Point2D.Double(c11.x - delta3, c11.y - delta3),
									      new Point2D.Double(c11.x - delta3, c11.y + delta3)
									};
									
									final Polygon poly11 = new Polygon(new Random().nextLong(), corners11, "#f04040",
									     5, 0.8, "#1010ff", 0.2, false);
									
									 Point2D.Double c12 = new Point2D.Double( (xCoordinate), yCoordinate);
				                        
										//	double delta3 = 2.5;
											 Point2D.Double[] corners12 = new Point2D.Double[] {
											      new Point2D.Double(c12.x - delta3, c12.y + delta3),
											      new Point2D.Double(c12.x + delta3, c12.y + delta3),
											      new Point2D.Double(c12.x + delta3, c12.y - delta3),
											      new Point2D.Double(c12.x - delta3, c12.y - delta3),
											      new Point2D.Double(c12.x - delta3, c12.y + delta3)
											};
											
											final Polygon poly12 = new Polygon(new Random().nextLong(), corners12, "#f04040",
											     5, 0.8, "#1010ff", 0.2, false);
										
											Point2D.Double c77 = new Point2D.Double(-110.3, 15.4522);
					                        
									//		double delta3 = 2.5;
											 Point2D.Double[] corners77 = new Point2D.Double[] {
											      new Point2D.Double(c77.x - delta3, c77.y + delta3),
											      new Point2D.Double(c77.x + delta3, c77.y + delta3),
											      new Point2D.Double(c77.x + delta3, c77.y - delta3),
											      new Point2D.Double(c77.x - delta3, c77.y - delta3),
											      new Point2D.Double(c77.x - delta3, c77.y + delta3)
											};
											
											final Polygon poly77 = new Polygon(new Random().nextLong(), corners77, "#f04040",
											     5, 0.8, "#1010ff", 0.2, false);
											
					                      Point2D.Double c88 = new Point2D.Double(-100.3, 12.4522);
					                        
									//		double delta3 = 2.5;
											 Point2D.Double[] corners88 = new Point2D.Double[] {
											      new Point2D.Double(c88.x - delta3, c88.y + delta3),
											      new Point2D.Double(c88.x + delta3, c88.y + delta3),
											      new Point2D.Double(c88.x + delta3, c88.y - delta3),
											      new Point2D.Double(c88.x - delta3, c88.y - delta3),
											      new Point2D.Double(c88.x - delta3, c88.y + delta3)
											};
											
											final Polygon poly88 = new Polygon(new Random().nextLong(), corners88, "#f04040",
											     5, 0.8, "#1010ff", 0.2, false);
											
					                       Point2D.Double c99 = new Point2D.Double(-80.3, 5.4522);
					                        
									//		double delta3 = 2.5;
											 Point2D.Double[] corners99 = new Point2D.Double[] {
											      new Point2D.Double(c99.x - delta3, c99.y + delta3),
											      new Point2D.Double(c99.x + delta3, c99.y + delta3),
											      new Point2D.Double(c99.x + delta3, c99.y - delta3),
											      new Point2D.Double(c99.x - delta3, c99.y - delta3),
											      new Point2D.Double(c99.x - delta3, c99.y + delta3)
											};
											
											final Polygon poly99 = new Polygon(new Random().nextLong(), corners99, "#f04040",
											     5, 0.8, "#1010ff", 0.2, false);
											
					                       Point2D.Double c101 = new Point2D.Double(-125.3, -10.4522);
					                        
										//	double delta3 = 2.5;
											 Point2D.Double[] corners101 = new Point2D.Double[] {
											      new Point2D.Double(c101.x - delta3, c101.y + delta3),
											      new Point2D.Double(c101.x + delta3, c101.y + delta3),
											      new Point2D.Double(c101.x + delta3, c101.y - delta3),
											      new Point2D.Double(c101.x - delta3, c101.y - delta3),
											      new Point2D.Double(c101.x - delta3, c101.y + delta3)
											};
											
											final Polygon poly101 = new Polygon(new Random().nextLong(), corners101, "#f04040",
											     5, 0.8, "#1010ff", 0.2, false);
											
											 Point2D.Double c111 = new Point2D.Double(-170.3, -27.4522);
						                        
												//	double delta3 = 2.5;
													 Point2D.Double[] corners111 = new Point2D.Double[] {
													      new Point2D.Double(c111.x - delta3, c111.y + delta3),
													      new Point2D.Double(c111.x + delta3, c111.y + delta3),
													      new Point2D.Double(c111.x + delta3, c111.y - delta3),
													      new Point2D.Double(c111.x - delta3, c111.y - delta3),
													      new Point2D.Double(c111.x - delta3, c111.y + delta3)
													};
													
													final Polygon poly111 = new Polygon(new Random().nextLong(), corners111, "#f04040",
													     5, 0.8, "#1010ff", 0.2, false);
													
													 Point2D.Double c122 = new Point2D.Double( (xCoordinate), yCoordinate);
								                        
														//	double delta3 = 2.5;
															 Point2D.Double[] corners122 = new Point2D.Double[] {
															      new Point2D.Double(c122.x - delta3, c122.y + delta3),
															      new Point2D.Double(c122.x + delta3, c122.y + delta3),
															      new Point2D.Double(c122.x + delta3, c122.y - delta3),
															      new Point2D.Double(c122.x - delta3, c122.y - delta3),
															      new Point2D.Double(c122.x - delta3, c122.y + delta3)
															};
															
															final Polygon poly122 = new Polygon(new Random().nextLong(), corners122, "#f04040",
															     5, 0.8, "#1010ff", 0.2, false);
				//			aLayout1.addComponent(googleMap, "left: 50px; top: 100px;");
						
							final Button updateMap_Button = new Button ("Update Map");

							// Create a marker at the IT Mill offices
							
						  
						  aLayout1.addComponent(sa_heading_label, "left: 600px; top: 50px;");
					      aLayout1.addComponent(scenario_name_label, "left: 550px; top: 145px;");
					      aLayout1.addComponent(scenario_name_TF, "left: 716px; top: 150px;");
					      aLayout1.addComponent(incoming_info_label, "left: 550px; top: 195px;");
					      aLayout1.addComponent(incoming_info_TF, "left: 716px; top: 200px;");
					      aLayout1.addComponent(time_label, "left: 550px; top: 245px;");
					      aLayout1.addComponent(time_combo, "left: 716px; top: 250px;");
					      aLayout1.addComponent(sa1_label, "left: 550px; top: 295px;");
					      aLayout1.addComponent(sa1_TF, "left: 716px; top: 300px;");
					      aLayout1.addComponent(sa2_label, "left: 550px; top: 425px;");
					      aLayout1.addComponent(sa2_TF, "left: 716px; top: 435px;");
					      aLayout1.addComponent(sa3_label, "left: 550px; top: 575px;");
					      aLayout1.addComponent(sa3_TF, "left: 716px; top: 580px;");
					    
					      
						  
					  Button ok_button = new Button ("OK");
				      Button cancel_button= new Button ("Cancel");
				      ok_button.setHeight("30px");
				      ok_button.setWidth("100px");
				      
				      cancel_button.setHeight("30px");
				      cancel_button.setWidth("100px");
				      
				      
				      aLayout1.addComponent(ok_button, "left: 650px; top: 695px;");  
				      aLayout1.addComponent(cancel_button, "left: 750px; top: 695px;"); 
				      
				      final String tempMag = earthquake_mag;
				      final String tempLoc =  earthquake_location ;
				      final String tempTime = earthquake_time;
				      final String infSA3 = inferenceResultSA3;
				      final String infSA2 = inferenceResultSA2;
				      final String tempT2SA1 = t2SA1;
				      final String tempT2SA2 = t2SA2;
				      final String tempT2SA3 = t2SA3;
				      final String tempT3SA1 = t3SA1;
				      final String tempT3SA2 = t3SA2;
				      
				      final Embedded timeImage = new Embedded("",new ClassResource("time.jpg", getMainWindow().getApplication()));
				      timeImage.setWidth("400");
				      timeImage.setHeight("450");
				 
				      
				      
				      final BasicMarker eqMarker1 = new BasicMarker(1L, new Point2D.Double((xCoordinate), yCoordinate), " Earthquake Magnitude:"+tempMag+ " Earthquake Location: "+tempLoc+" Time: "+tempTime);
				      final BasicMarker sensorMarker1 = new BasicMarker(2L, new Point2D.Double(-110.3, 15.4522), "DART Sensor 1");
				      final BasicMarker sensorMarker2 = new BasicMarker(3L, new Point2D.Double(-100.3, 12.4522), "DART Sensor 2");
				      final BasicMarker sensorMarker3 = new BasicMarker(4L, new Point2D.Double(-80.3, 5.4522), "DART Sensor 3");
				      final BasicMarker sensorMarker4 = new BasicMarker(5L, new Point2D.Double(-125.3, -10.4522), "DART Sensor 4");
				      final BasicMarker sensorMarker5 = new BasicMarker(6L, new Point2D.Double(-170.3, -27.4522), "DART Sensor 5");
				      
				     eqMarker1.setIconUrl("http://alert.air-worldwide.com/Images/Icons/EarthquakeIcon.gif");
				     eqMarker1.setIconAnchor(new Point2D.Double(8.0, 8.0));
				     
				     final String tempLowWave=lowWave;
				      final String tempNormalWave=normalWave;
				      final String tempMediumWave=mediumWave;
				      final String tempHighWave=highWave;
				      final String tempVeryHighWave=veryHighWave;
				    	  
				      final String tempLowWave2=lowT1;
				      final String tempNormalWave2=normalT1;
				      final String tempMediumWave2=mediumT1;
				      final String tempHighWave2=highT1;
				      final String tempVeryHighWave2=veryHighT1;
				      
				      time_combo.addListener(new Property.ValueChangeListener(){
				    	
				    	  
				    	  public void valueChange(Property.ValueChangeEvent event) {
				    		 
				    		  if (time_combo.getValue().toString().equals("Time before confirmation")) {
				    			  
				    			//  googleMap.addMarker(new BasicMarker(1L, new Point2D.Double(-120.3, 15.4522), " Earthquake Magnitude:"+tempMag+ " Earthquake Location: "+tempLoc+" Time: "+tempTime));
				    			  googleMap.addMarker(eqMarker1);
				    			  googleMap.requestRepaint();
				    			  sa1_TF.setValue(" Earthquake Magnitude:"+tempMag+ " Earthquake Location: "+tempLoc+" Time: "+tempTime);
				    			  sa2_TF.setValue(""+infSA2 );
				    			  sa3_TF.setValue(""+infSA3);
				    	    	
				    	      }else if (time_combo.getValue().toString().equals("Time of confirmation"))
				    	      {
				    	    	  
				    	    	  
					    	    	  if(tempLowWave2.contains("wave_heightS1"))
					    	    	  {
					    	    		  sensorMarker1.setTitle("DART Sensor 1: Low Wave Height");
					    	    		  poly7.setColor("#FCFC7E");
					    	    	  }
					    	    	  else if(tempNormalWave2.contains("wave_heightS1"))
					    	    	  {
					    	    		  sensorMarker1.setTitle("DART Sensor 1: Normal Wave Height");
					    	    		  poly7.setColor("#11991A");
					    	    	  }
					    	    	  else if(tempMediumWave2.contains("wave_heightS1"))
					    	    	  {
					    	    		  sensorMarker1.setTitle("DART Sensor 1: Medium Wave Height");
					    	    		  poly7.setColor("#2340FC");
					    	    	  }
					    	    	  else if(tempHighWave2.contains("wave_heightS1"))
					    	    	  {
					    	    		  sensorMarker1.setTitle("DART Sensor 1: High Wave Height");
					    	    		  poly7.setColor("#FC3FEF");
					    	    	  }
					    	    	  else if(tempVeryHighWave2.contains("wave_heightS1"))
					    	    	  {
					    	    		  sensorMarker1.setTitle("DART Sensor 1: Very High Wave Height");
					    	    		  poly7.setColor("#FC0B03");
					    	    	  }
					    			  googleMap.addPolyOverlay(poly7);
					    			
					   
					    	 
					    	      
					    	     
					    	    	  if(tempLowWave2.contains("wave_heightS2"))
					    	    	  {
					    	    		  sensorMarker2.setTitle("DART Sensor 2: Low Wave Height");
					    	    		  poly8.setColor("#FCFC7E");
					    	    	  }
					    	    	  else if(tempNormalWave2.contains("wave_heightS2"))
					    	    	  {
					    	    		  sensorMarker2.setTitle("DART Sensor 2: Normal Wave Height");
					    	    		  poly8.setColor("#11991A");
					    	    	  }
					    	    	  else if(tempMediumWave2.contains("wave_heightS2"))
					    	    	  {
					    	    		  sensorMarker2.setTitle("DART Sensor 2: Medium Wave Height");
					    	    		  poly8.setColor("#2340FC");
					    	    	  }
					    	    	  else if(tempHighWave2.contains("wave_heightS2"))
					    	    	  {
					    	    		  sensorMarker2.setTitle("DART Sensor 2: High Wave Height");
					    	    		  poly8.setColor("#FC3FEF");
					    	    	  }
					    	    	  else if(tempVeryHighWave2.contains("wave_heightS2"))
					    	    	  {
					    	    		  sensorMarker2.setTitle("DART Sensor 2: Very High Wave Height");
					    	    		  poly8.setColor("#FC0B03");
					    	    	  }
					    	    	  googleMap.addPolyOverlay(poly8);
					    			
					    		  
					    	      
					    	    	  if(tempLowWave2.contains("wave_heightS3"))
					    	    	  {
					    	    		  sensorMarker3.setTitle("DART Sensor 3: Low Wave Height");
					    	    		  poly9.setColor("#FCFC7E");
					    	    	  }
					    	    	  else if(tempNormalWave2.contains("wave_heightS3"))
					    	    	  {
					    	    		  sensorMarker3.setTitle("DART Sensor 3: Normal Wave Height");
					    	    		  poly9.setColor("#11991A");
					    	    	  }
					    	    	  else if(tempMediumWave2.contains("wave_heightS3"))
					    	    	  {
					    	    		  sensorMarker3.setTitle("DART Sensor 3: Medium Wave Height");
					    	    		  poly9.setColor("#2340FC");
					    	    	  }
					    	    	  else if(tempHighWave2.contains("wave_heightS3"))
					    	    	  {
					    	    		  sensorMarker3.setTitle("DART Sensor 3: High Wave Height");
					    	    		  poly9.setColor("#FC3FEF");
					    	    	  }
					    	    	  else if(tempVeryHighWave2.contains("wave_heightS3"))
					    	    	  {
					    	    		  sensorMarker3.setTitle("DART Sensor 3: Very High Wave Height");
					    	    		  poly9.setColor("#FC0B03");
					    	    	  }
					    	    	  googleMap.addPolyOverlay(poly9);
					    			 
					    	     
					    	    	  if(tempLowWave2.contains("wave_heightS4"))
					    	    	  {
					    	    		  sensorMarker4.setTitle("DART Sensor 4: Low Wave Height");
					    	    		  
					    	    		  poly10.setColor("#FCFC7E");
					    	    	  }
					    	    	  else if(tempNormalWave2.contains("wave_heightS4"))
					    	    	  {
					    	    		  sensorMarker4.setTitle("DART Sensor 4: Normal Wave Height");
					    	    		  poly10.setColor("#11991A");
					    	    	  }
					    	    	  else if(tempMediumWave2.contains("wave_heightS4"))
					    	    	  {
					    	    		  sensorMarker4.setTitle("DART Sensor 4: Medium Wave Height");
					    	    		  poly10.setColor("#2340FC");
					    	    	  }
					    	    	  else if(tempHighWave2.contains("wave_heightS4"))
					    	    	  {
					    	    		  sensorMarker4.setTitle("DART Sensor 4: High Wave Height");
					    	    		  poly10.setColor("#FC3FEF");
					    	    	  }
					    	    	  else if(tempVeryHighWave2.contains("wave_heightS4"))
					    	    	  {
					    	    		  sensorMarker4.setTitle("DART Sensor 4: Very High Wave Height");
					    	    		  poly10.setColor("#FC0B03");
					    	    	  }
					    	    	  googleMap.addPolyOverlay(poly10);
					    			  
					    	      
					    	    	  if(tempLowWave2.contains("wave_heightS5"))
					    	    	  {
					    	    		  sensorMarker5.setTitle("DART Sensor 5: Low Wave Height");
					    	    		  poly11.setColor("#FCFC7E");
					    	    	  }
					    	    	  else if(tempNormalWave2.contains("wave_heightS5"))
					    	    	  {
					    	    		  sensorMarker5.setTitle("DART Sensor 5: Normal Wave Height");
					    	    		  poly11.setColor("#11991A");
					    	    	  }
					    	    	  else if(tempMediumWave2.contains("wave_heightS5"))
					    	    	  {
					    	    		  sensorMarker5.setTitle("DART Sensor 5: Medium Wave Height");
					    	    		  poly11.setColor("#2340FC");
					    	    	  }
					    	    	  else if(tempHighWave2.contains("wave_heightS5"))
					    	    	  {
					    	    		  sensorMarker5.setTitle("DART Sensor 5: High Wave Height");
					    	    		  poly11.setColor("#FC3FEF");
					    	    	  }
					    	    	  else if(tempVeryHighWave2.contains("wave_heightS5"))
					    	    	  {
					    	    		  sensorMarker5.setTitle("DART Sensor 5: Very High Wave Height");
					    	    		  poly11.setColor("#FC0B03");
					    	    	  }
					    	    	  googleMap.addPolyOverlay(poly11);
				    			  
				    			  
				    	//    	  googleMap.addPolyOverlay(poly);
				    	    	 
				    	    	  
				    	    	  //googleMap.addMarker(new BasicMarker(2L, new Point2D.Double(-110.3, 15.4522), "DART Sensor 1"));
				    	    	  googleMap.addMarker(sensorMarker2);
				    	    	  googleMap.addMarker(sensorMarker3);
				    	    	  googleMap.addMarker(sensorMarker4);
				    	    	  googleMap.addMarker(sensorMarker5);
				    	    	  googleMap.addMarker(sensorMarker1);
				    	    	  
				    	    	  googleMap.requestRepaint();
				    	    	  sa1_TF.setValue(""+tempT2SA1);
				    	    	  sa2_TF.setValue(""+tempT2SA2);
				    	    	  sa3_TF.setValue(""+tempT2SA3);
				    	 
				    	      }
				    	      else if (time_combo.getValue().toString().equals("Time of Evacuation decision"))
				    	      {
				    	    	  googleMap.addPolyOverlay(poly2);
				    	    	  googleMap.addPolyOverlay(poly3);
				    	    	  googleMap.addPolyOverlay(poly4);
				    	    	  googleMap.addPolyOverlay(poly5);
				    	   // 	  googleMap.addMarker(new BasicMarker(3L, new Point2D.Double(-100.3, 12.4522), "DART Sensor 2"));
				    	   // 	  googleMap.addMarker(new BasicMarker(4L, new Point2D.Double(-80.3, 5.4522), "DART Sensor 3"));
				    	   // 	  googleMap.addMarker(new BasicMarker(5L, new Point2D.Double(-125.3, -10.4522), "DART Sensor 4"));
				    	   // 	  googleMap.addMarker(new BasicMarker(6L, new Point2D.Double(-170.3, -27.4522), "DART Sensor 5"));
				    	    	  googleMap.addMarker(sensorMarker2);
				    	    	  googleMap.addMarker(sensorMarker3);
				    	    	  googleMap.addMarker(sensorMarker4);
				    	    	  googleMap.addMarker(sensorMarker5);
				    	    	  googleMap.requestRepaint();
				    	    	  sa1_TF.setValue(""+tempT3SA1);
				    	    	  sa2_TF.setValue(""+tempT3SA2);
				    	    	  sa3_TF.setValue("See the time Image");
				    	    	  aLayout1.addComponent(timeImage, "left: 1250px; top: 110px;");
				    	    	  aLayout1.addComponent(time_combo2, "left: 150px; top: 580px;");
				    	    	  aLayout1.addComponent(updateMap_Button, "left: 310px; top: 580px;");
				    	    
				    	    	  googleMap.addPolyOverlay(poly6);
				    	       	  googleMap.requestRepaint();
				    	
				    	      }
				    		  
				    	      else if (time_combo.getValue().toString().equals("Time of evacuation"))
				    	      {
				    	    	 
				    	    	 
				    	
				    	      }
				    		  
				    	      	    		  
				    	  }
				    	  
				      });
				      
				     
				      
				      
				      
       /*                  time_combo2.addListener(new Property.ValueChangeListener(){
				    	
				    	  
				    	  public void valueChange(Property.ValueChangeEvent event) {
				    		 
				    		  if (time_combo2.getValue().toString().equals("0600")) {
				    			  
				    			
				    	    	
				    	      }
				    		  else if (time_combo2.getValue().toString().equals("0650"))
				    	      {
				    	    	  if(tempLowWave.contains("wave_heightS1"))
				    	    	  {
				    	    		  sensorMarker1.setTitle("DART Sensor 1: Low Wave Height");
				    	    		  poly7.setColor("#FCFC7E");
				    	    	  }
				    	    	  else if(tempNormalWave.contains("wave_heightS1"))
				    	    	  {
				    	    		  sensorMarker1.setTitle("DART Sensor 1: Normal Wave Height");
				    	    		  poly7.setColor("#11991A");
				    	    	  }
				    	    	  else if(tempMediumWave.contains("wave_heightS1"))
				    	    	  {
				    	    		  sensorMarker1.setTitle("DART Sensor 1: Medium Wave Height");
				    	    		  poly7.setColor("#2340FC");
				    	    	  }
				    	    	  else if(tempHighWave.contains("wave_heightS1"))
				    	    	  {
				    	    		  sensorMarker1.setTitle("DART Sensor 1: High Wave Height");
				    	    		  poly7.setColor("#FC3FEF");
				    	    	  }
				    	    	  else if(tempVeryHighWave.contains("wave_heightS1"))
				    	    	  {
				    	    		  sensorMarker1.setTitle("DART Sensor 1: Very High Wave Height");
				    	    		  poly7.setColor("#FC0B03");
				    	    	  }
				    			  googleMap.addPolyOverlay(poly7);
				    			  googleMap.requestRepaint();
				   
				    	 
				    	      }
				    	      else if (time_combo2.getValue().toString().equals("0755"))
				    	      {
				    	    	  if(tempLowWave.contains("wave_heightS2"))
				    	    	  {
				    	    		  sensorMarker2.setTitle("DART Sensor 2: Low Wave Height");
				    	    		  poly8.setColor("#FCFC7E");
				    	    	  }
				    	    	  else if(tempNormalWave.contains("wave_heightS2"))
				    	    	  {
				    	    		  sensorMarker2.setTitle("DART Sensor 2: Normal Wave Height");
				    	    		  poly8.setColor("#11991A");
				    	    	  }
				    	    	  else if(tempMediumWave.contains("wave_heightS2"))
				    	    	  {
				    	    		  sensorMarker2.setTitle("DART Sensor 2: Medium Wave Height");
				    	    		  poly8.setColor("#2340FC");
				    	    	  }
				    	    	  else if(tempHighWave.contains("wave_heightS2"))
				    	    	  {
				    	    		  sensorMarker2.setTitle("DART Sensor 2: High Wave Height");
				    	    		  poly8.setColor("#FC3FEF");
				    	    	  }
				    	    	  else if(tempVeryHighWave.contains("wave_heightS2"))
				    	    	  {
				    	    		  sensorMarker2.setTitle("DART Sensor 2: Very High Wave Height");
				    	    		  poly8.setColor("#FC0B03");
				    	    	  }
				    	    	  googleMap.addPolyOverlay(poly8);
				    			  googleMap.requestRepaint();
				    	
				    	      }
				    		  
				    	      else if (time_combo2.getValue().toString().equals("0915"))
				    	      {
				    	    	  if(tempLowWave.contains("wave_heightS3"))
				    	    	  {
				    	    		  sensorMarker3.setTitle("DART Sensor 3: Low Wave Height");
				    	    		  poly9.setColor("#FCFC7E");
				    	    	  }
				    	    	  else if(tempNormalWave.contains("wave_heightS3"))
				    	    	  {
				    	    		  sensorMarker3.setTitle("DART Sensor 3: Normal Wave Height");
				    	    		  poly9.setColor("#11991A");
				    	    	  }
				    	    	  else if(tempMediumWave.contains("wave_heightS3"))
				    	    	  {
				    	    		  sensorMarker3.setTitle("DART Sensor 3: Medium Wave Height");
				    	    		  poly9.setColor("#2340FC");
				    	    	  }
				    	    	  else if(tempHighWave.contains("wave_heightS3"))
				    	    	  {
				    	    		  sensorMarker3.setTitle("DART Sensor 3: High Wave Height");
				    	    		  poly9.setColor("#FC3FEF");
				    	    	  }
				    	    	  else if(tempVeryHighWave.contains("wave_heightS3"))
				    	    	  {
				    	    		  sensorMarker3.setTitle("DART Sensor 3: Very High Wave Height");
				    	    		  poly9.setColor("#FC0B03");
				    	    	  }
				    	    	  googleMap.addPolyOverlay(poly9);
				    			  googleMap.requestRepaint();
				    	      }
				    	      else if (time_combo2.getValue().toString().equals("0955"))
				    	      {
				    	    	  if(tempLowWave.contains("wave_heightS4"))
				    	    	  {
				    	    		  sensorMarker4.setTitle("DART Sensor 4: Low Wave Height");
				    	    		  
				    	    		  poly10.setColor("#FCFC7E");
				    	    	  }
				    	    	  else if(tempNormalWave.contains("wave_heightS4"))
				    	    	  {
				    	    		  sensorMarker4.setTitle("DART Sensor 4: Normal Wave Height");
				    	    		  poly10.setColor("#11991A");
				    	    	  }
				    	    	  else if(tempMediumWave.contains("wave_heightS4"))
				    	    	  {
				    	    		  sensorMarker4.setTitle("DART Sensor 4: Medium Wave Height");
				    	    		  poly10.setColor("#2340FC");
				    	    	  }
				    	    	  else if(tempHighWave.contains("wave_heightS4"))
				    	    	  {
				    	    		  sensorMarker4.setTitle("DART Sensor 4: High Wave Height");
				    	    		  poly10.setColor("#FC3FEF");
				    	    	  }
				    	    	  else if(tempVeryHighWave.contains("wave_heightS4"))
				    	    	  {
				    	    		  sensorMarker4.setTitle("DART Sensor 4: Very High Wave Height");
				    	    		  poly10.setColor("#FC0B03");
				    	    	  }
				    	    	  googleMap.addPolyOverlay(poly10);
				    			  googleMap.requestRepaint();
				    	      }
				    	      else if (time_combo2.getValue().toString().equals("1735"))
				    	      {
				    	    	  if(tempLowWave.contains("wave_heightS5"))
				    	    	  {
				    	    		  sensorMarker5.setTitle("DART Sensor 5: Low Wave Height");
				    	    		  poly11.setColor("#FCFC7E");
				    	    	  }
				    	    	  else if(tempNormalWave.contains("wave_heightS5"))
				    	    	  {
				    	    		  sensorMarker5.setTitle("DART Sensor 5: Normal Wave Height");
				    	    		  poly11.setColor("#11991A");
				    	    	  }
				    	    	  else if(tempMediumWave.contains("wave_heightS5"))
				    	    	  {
				    	    		  sensorMarker5.setTitle("DART Sensor 5: Medium Wave Height");
				    	    		  poly11.setColor("#2340FC");
				    	    	  }
				    	    	  else if(tempHighWave.contains("wave_heightS5"))
				    	    	  {
				    	    		  sensorMarker5.setTitle("DART Sensor 5: High Wave Height");
				    	    		  poly11.setColor("#FC3FEF");
				    	    	  }
				    	    	  else if(tempVeryHighWave.contains("wave_heightS5"))
				    	    	  {
				    	    		  sensorMarker5.setTitle("DART Sensor 5: Very High Wave Height");
				    	    		  poly11.setColor("#FC0B03");
				    	    	  }
				    	    	  googleMap.addPolyOverlay(poly11);
				    			  googleMap.requestRepaint();
				    	      }
				    	      	    		  
				    	  }
				    	  
				      });   */
				      
                         updateMap_Button.addListener(new Button.ClickListener() {
 							
 							
 							public void buttonClick(ClickEvent event){
 								
 								for(int i=0;i<5;i++)
 								{
 					//				if (dataCollectionTime[i]<Integer.parseInt(time_combo2.getValue().toString()))
 								
 									if (dataCollectionTime[i]<Integer.parseInt(time_combo2.getValue().toString()))
 											{
 										System.out.println("comboBox time"+Integer.parseInt(time_combo2.getValue().toString())+"is greater than time from array"+dataCollectionTime[i]+" "+i );
 										
 										if(i==2)
 										{
 								//			System.out.println("time condition true for sensor 1 and time "+i );
 		 									
 										 if(tempLowWave.contains("wave_heightS1"))
 	 					    	    	  {
 	 					    	    		  sensorMarker1.setTitle("DART Sensor 1: Low Wave Height");
 	 					    	    		  poly77.setColor("#FCFC7E");
 	 					    	    		
 	 					    	    	  }
 	 					    	    	  else if(tempNormalWave.contains("wave_heightS1"))
 	 					    	    	  {
 	 					    	    		  sensorMarker1.setTitle("DART Sensor 1: Normal Wave Height");
 	 					    	    		  poly77.setColor("#11991A");
 	 					  //  	    		System.out.println("Normal height for sensor 1 and time "+i );
 	 					    	    	  }
 	 					    	    	  else if(tempMediumWave.contains("wave_heightS1"))
 	 					    	    	  {
 	 					    	    		  sensorMarker1.setTitle("DART Sensor 1: Medium Wave Height");
 	 					    	    		  poly77.setColor("#2340FC");
 	 					    	    	  }
 	 					    	    	  else if(tempHighWave.contains("wave_heightS1"))
 	 					    	    	  {
 	 					    	    		  sensorMarker1.setTitle("DART Sensor 1: High Wave Height");
 	 					    	    		  poly77.setColor("#FC3FEF");
 	 					    //	    		System.out.println("High height for sensor 1 and time "+i );
 	 					    	    	  }
 	 					    	    	  else if(tempVeryHighWave.contains("wave_heightS1"))
 	 					    	    	  {
 	 					    	    		  sensorMarker1.setTitle("DART Sensor 1: Very High Wave Height");
 	 					    	    		  poly77.setColor("#FC0B03");
 	 					    	    	  }
 	 					    			  googleMap.addPolyOverlay(poly77);
 	 					    			  googleMap.requestRepaint();
 										}
 										else
 										if(i==4)
 										{
 	 					    			if(tempLowWave.contains("wave_heightS2"))
 	 					    	    	  {
 	 					    	    		  sensorMarker2.setTitle("DART Sensor 2: Low Wave Height");
 	 					    	    		  poly88.setColor("#FCFC7E");
 	 					    	    	  }
 	 					    	    	  else if(tempNormalWave.contains("wave_heightS2"))
 	 					    	    	  {
 	 					    	    		  sensorMarker2.setTitle("DART Sensor 2: Normal Wave Height");
 	 					    	    		  poly88.setColor("#11991A");
 	 					    	    	  }
 	 					    	    	  else if(tempMediumWave.contains("wave_heightS2"))
 	 					    	    	  {
 	 					    	    		  sensorMarker2.setTitle("DART Sensor 2: Medium Wave Height");
 	 					    	    		  poly88.setColor("#2340FC");
 	 					    	    	  }
 	 					    	    	  else if(tempHighWave.contains("wave_heightS2"))
 	 					    	    	  {
 	 					    	    		  sensorMarker2.setTitle("DART Sensor 2: High Wave Height");
 	 					    	    		  poly88.setColor("#FC3FEF");
 	 					    	    	  }
 	 					    	    	  else if(tempVeryHighWave.contains("wave_heightS2"))
 	 					    	    	  {
 	 					    	    		  sensorMarker2.setTitle("DART Sensor 2: Very High Wave Height");
 	 					    	    		  poly88.setColor("#FC0B03");
 	 					    	    	  }
 	 					    	    	  googleMap.addPolyOverlay(poly88);
 	 					    			  googleMap.requestRepaint();
 										}
 										else
 										if(i==1)
 										{ 
 	 					    			if(tempLowWave.contains("wave_heightS3"))
 	 					    	    	  {
 	 					    	    		  sensorMarker3.setTitle("DART Sensor 3: Low Wave Height");
 	 					    	    		  poly99.setColor("#FCFC7E");
 	 					    	    	  }
 	 					    	    	  else if(tempNormalWave.contains("wave_heightS3"))
 	 					    	    	  {
 	 					    	    		  sensorMarker3.setTitle("DART Sensor 3: Normal Wave Height");
 	 					    	    		  poly99.setColor("#11991A");
 	 					    	    	  }
 	 					    	    	  else if(tempMediumWave.contains("wave_heightS3"))
 	 					    	    	  {
 	 					    	    		  sensorMarker3.setTitle("DART Sensor 3: Medium Wave Height");
 	 					    	    		  poly99.setColor("#2340FC");
 	 					    	    	  }
 	 					    	    	  else if(tempHighWave.contains("wave_heightS3"))
 	 					    	    	  {
 	 					    	    		  sensorMarker3.setTitle("DART Sensor 3: High Wave Height");
 	 					    	    		  poly99.setColor("#FC3FEF");
 	 					    	    	  }
 	 					    	    	  else if(tempVeryHighWave.contains("wave_heightS3"))
 	 					    	    	  {
 	 					    	    		  sensorMarker3.setTitle("DART Sensor 3: Very High Wave Height");
 	 					    	    		  poly99.setColor("#FC0B03");
 	 					    	    	  }
 	 					    	    	  googleMap.addPolyOverlay(poly99);
 	 					    			  googleMap.requestRepaint();
 										}
 										else
 										if(i==3)
 										{
 	 					    			if(tempLowWave.contains("wave_heightS4"))
 	 					    	    	  {
 	 					    	    		  sensorMarker4.setTitle("DART Sensor 4: Low Wave Height");
 	 					    	    		  
 	 					    	    		  poly101.setColor("#FCFC7E");
 	 					    	    	  }
 	 					    	    	  else if(tempNormalWave.contains("wave_heightS4"))
 	 					    	    	  {
 	 					    	    		  sensorMarker4.setTitle("DART Sensor 4: Normal Wave Height");
 	 					    	    		  poly101.setColor("#11991A");
 	 					    	    	  }
 	 					    	    	  else if(tempMediumWave.contains("wave_heightS4"))
 	 					    	    	  {
 	 					    	    		  sensorMarker4.setTitle("DART Sensor 4: Medium Wave Height");
 	 					    	    		  poly101.setColor("#2340FC");
 	 					    	    	  }
 	 					    	    	  else if(tempHighWave.contains("wave_heightS4"))
 	 					    	    	  {
 	 					    	    		  sensorMarker4.setTitle("DART Sensor 4: High Wave Height");
 	 					    	    		  poly101.setColor("#FC3FEF");
 	 					    	    	  }
 	 					    	    	  else if(tempVeryHighWave.contains("wave_heightS4"))
 	 					    	    	  {
 	 					    	    		  sensorMarker4.setTitle("DART Sensor 4: Very High Wave Height");
 	 					    	    		  poly101.setColor("#FC0B03");
 	 					    	    	  }
 	 					    	    	  googleMap.addPolyOverlay(poly101);
 	 					    			  googleMap.requestRepaint();
 										}
 										else
 										if(i==0)
 										{
 	 					    			if(tempLowWave.contains("wave_heightS5"))
 	 					    	    	  {
 	 					    	    		  sensorMarker5.setTitle("DART Sensor 5: Low Wave Height");
 	 					    	    		  poly111.setColor("#FCFC7E");
 	 					    	    	  }
 	 					    	    	  else if(tempNormalWave.contains("wave_heightS5"))
 	 					    	    	  {
 	 					    	    		  sensorMarker5.setTitle("DART Sensor 5: Normal Wave Height");
 	 					    	    		  poly111.setColor("#11991A");
 	 					    	    	  }
 	 					    	    	  else if(tempMediumWave.contains("wave_heightS5"))
 	 					    	    	  {
 	 					    	    		  sensorMarker5.setTitle("DART Sensor 5: Medium Wave Height");
 	 					    	    		  poly111.setColor("#2340FC");
 	 					    	    	  }
 	 					    	    	  else if(tempHighWave.contains("wave_heightS5"))
 	 					    	    	  {
 	 					    	    		  sensorMarker5.setTitle("DART Sensor 5: High Wave Height");
 	 					    	    		  poly111.setColor("#FC3FEF");
 	 					    	    	  }
 	 					    	    	  else if(tempVeryHighWave.contains("wave_heightS5"))
 	 					    	    	  {
 	 					    	    		  sensorMarker5.setTitle("DART Sensor 5: Very High Wave Height");
 	 					    	    		  poly111.setColor("#FC0B03");
 	 					    	    	  }
 	 					    	    	  googleMap.addPolyOverlay(poly111);
 	 					    			  googleMap.requestRepaint();
 										}
 											}
 								}
 								
 						   								
 							}});
				      
				      ok_button.addListener(new Button.ClickListener() {
							
							
							public void buttonClick(ClickEvent event){
								  getMainWindow().removeWindow(sub2);
								
							}});
				      
				      cancel_button.addListener(new Button.ClickListener() {
							
							
							public void buttonClick(ClickEvent event){
								getMainWindow().removeWindow(sub2);
						    
							}});
				      
				      
				      
				      aLayout1.addComponent(googleMap, "left: 50px; top: 100px;");
				      sub2.addComponent(aLayout1);
				      mainWindow.addWindow(sub2);
				      
				}
				
				
		});
		     
	     // End of SA report Button
	      
	      
    	
    	    	
   	final Label selection = new Label("-");
    	mainWindow.addComponent(selection);
    	// Define a common menu command for all the menu items.
    	MenuBar.Command mycommand = new MenuBar.Command() {
    	    public void menuSelected(MenuItem selectedItem) {
    	        if(selectedItem.getText()=="New Profile")
    	        {
    	  /*      
    	        profileWizard = new ProfileWizard (new ProfileBuilderOntologyDataAccess());
    	        profileWizard.setSizeFull();
    	        profileWizard.openCompanyProfileWindow();
    	        mainWindow.addWindow(profileWizard);
       	    */	  	        	    
    	        }
    	        
    	        
    	        if(selectedItem.getText()=="Open Profile")
    	        {
    	        /*	    openProfile = new OpenProfile (new ProfileBuilderOntologyDataAccess());
    	    	        openProfile.setSizeFull();
    	    	        openProfile.openCompanyProfileWindow();
    	    	        mainWindow.addWindow(openProfile); */
    	        }
    	        if(selectedItem.getText()=="Export Profile")
    	        {
    	        	selection.setValue("Export Profile");
    	        }
    	        if(selectedItem.getText()=="Import Profile")
    	        {
    	        	selection.setValue("Import Profile");
    	        }
    	        if(selectedItem.getText()=="Close Profile")
    	        {
    	        	selection.setValue("close Profile");
    	        }
    	        
    	        if(selectedItem.getText()=="Exit")
    	        {
    	        	selection.setValue("Exit");
    	        	
    	        }
    	        if(selectedItem.getText()=="Toolbar options")
    	        {
    	        	selection.setValue("Toolbar options");
    	        	
    	        }
    	        	if(selectedItem.getText()=="Company details Wizard")
    	        {
    	  
    	           	        	
    	           	        	
    	        }  
    	            	        	
    	        	if(selectedItem.getText()=="Software inventory Wizard")
    	        {
    	       
    	        	
    	        	
    	        }  if(selectedItem.getText()=="Company Preference Wizard")
    	        {
    	        	selection.setValue("Company Preference Wizard");
    	        	
    	        }
    	        
    	        if(selectedItem.getText()=="Contents")
    	        {
    	        	selection.setValue("Contents");
    	        	
    	        }
    	        if(selectedItem.getText()=="About")
    	        {
    	        	selection.setValue("About");
    	        	
    	        }
    	      
    	} 
    	};
    	
    	
    	// Put some items in the menu hierarchically
    	MenuBar.MenuItem profile =
    	    menubar.addItem("Profile", null, null);
    	    profile.addItem("New Profile", null, mycommand);
    	    profile.addItem("Open Profile", null, mycommand);
    	    profile.addItem("Export Profile", null, mycommand);
    	    profile.addItem("Import Profile", null, mycommand);
    	    profile.addItem("Close Profile", null, mycommand);
    	    profile.addItem("Exit", null, mycommand);
    	
    	// Another top-level item
    	MenuBar.MenuItem tools =
    	    menubar.addItem("Tools", null, null);
    	tools.addItem("Toolbar options", null, mycommand);
    	tools.addItem("Company details Wizard", null, mycommand);
    	tools.addItem("Software inventory Wizard",null, mycommand);
    	tools.addItem("Company Preference Wizard", null, mycommand);
    	
    	
    	// Yet another top-level item
    	MenuBar.MenuItem help =
    	menubar.addItem("Help", null, null);
    	help.addItem("Contents", null, mycommand);
    	help.addItem("About", null, mycommand);
    	
    
    	
    	
		setMainWindow(mainWindow);
		
	}

} 
