Package trackerModule.core.datastructure

Examples of trackerModule.core.datastructure.Unit


   * @param xDes the x destination
   * @param yDes the y destination
   * @return true, if is in
   */
  public boolean isIn(String strName, Double xDes, Double yDes ){
    Unit ship    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS." + strName);
    Double X    = ship.get("X").getDataByDouble();
    Double Y    = ship.get("Y").getDataByDouble();
       
    if( Math.abs(X-xDes) <= 10 && Math.abs(Y-yDes) <= 10 ){
        return true;
      }
    
View Full Code Here


   * @param strName the name
   * @param strFriend the friend
   * @return true, if is met
   */
  public boolean isMet(String strName, String strFriend){
    Unit ship1    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS." + strName);
    Unit ship2    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS." + strFriend);
    Double X1    = ship1.get("X").getDataByDouble();
    Double Y1    = ship1.get("Y").getDataByDouble();
    Double X2    = ship2.get("X").getDataByDouble();
    Double Y2    = ship2.get("Y").getDataByDouble();
         
    if( Math.abs(X1-X2) <= 60 && Math.abs(Y1-Y2) <= 60 ){
        return true;
      }
    
View Full Code Here

   * @param strName the name
   * @param strFriend the friend
   * @return true, if is contact
   */
  public boolean isContact(String strName, String strFriend){
    Unit ship1    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS." + strName);
    Unit ship2    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS." + strFriend);
    Double X1    = ship1.get("X").getDataByDouble();
    Double Y1    = ship1.get("Y").getDataByDouble();
    Double X2    = ship2.get("X").getDataByDouble();
    Double Y2    = ship2.get("Y").getDataByDouble();
         
    if( Math.abs(X1-X2) <= 3 && Math.abs(Y1-Y2) <= 3 ){
        return true;
      }
    
View Full Code Here

   * @param xDes the x destination
   * @param yDes the y destination
   * @return true, if successful
   */
  public boolean findLocation(String strName, Double xDes, Double yDes ){
    Unit ship    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS." + strName);
    Double X    = ship.get("X").getDataByDouble();
    Double Y    = ship.get("Y").getDataByDouble();
       
    if( Math.abs(X-xDes) <= 3 && Math.abs(Y-yDes) <= 3 ){
        return true;
      }
    
View Full Code Here

   * @return the most close location
   */
  Tile getMostCloseLocation(Unit ship, String... exception){
    Integer X = ship.get("X").getDataByInt();
    Integer Y = ship.get("Y").getDataByInt();
     Unit shipLocation  = ship.get("Location");
    Integer tileSize = World.This().TILE_SIZE;
         
    double dis = 0;
    double prev = 10000000;
    Tile locationtemp = null;
    for( String str : World.This().tileMap.keySet() ){
      Tile tile = World.This().tileMap.get(str);
      boolean b = true;
   
      if( str.equalsIgnoreCase(shipLocation.getData()))
        b = false
 
      for( String strE: exception ){
        if( str.equalsIgnoreCase(strE) ){
          b = false;
View Full Code Here

   */
  public void InitShape()
  {
     ellipse = new Ellipse2D.Double(GAP*5,GAP*5,getWidth()-1-GAP*2*5,getHeight()-1-GAP*2*5);
      //set back color
     Unit ship = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS."+tUnit.getName());
     if( ship != null ){
      String  type = ship.get("Type").getData();
      if( type.equalsIgnoreCase("FishingShip" ) ||
        type.equalsIgnoreCase("BombingFishingShip" ) ||
        type.equalsIgnoreCase("IllicitCargoFishingShip" )  )
        setBackColor(Color.YELLOW);   
      else
View Full Code Here

    super.paintComponent(g);
   
    InitShape();   
    Graphics2D g2 = (Graphics2D) g;
   
    Unit u = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS."+tUnit.getName());
    if(u == null)
      return;
   
    String strState = u.get("State").getData();
   
    if( strState.indexOf("waiting") >=0 || strState.equalsIgnoreCase("end"))
      return;
   
    //text
View Full Code Here

  /* (non-Javadoc)
   * @see trackerModule.sim.map.draw.UShape#mousePressed(java.awt.event.MouseEvent)
   */
  public void mousePressed(MouseEvent arg0){
    super.mousePressed(arg0);
    Unit ship = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS." +tUnit.getName());
    MapFrame.This().setCurEntity(ship);
  }
View Full Code Here

   * @param className the class name
   * @param attributeList the attribute list
   * @return the weka data from u matrix
   */
  public Instances getWekaDataFromUMatrix( String className, String[] attributeList ){
    Unit ships = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS");
   
    //////////////////////////////////////////////////////////////////////////////////////////
    //create attributes list
    ArrayList<Attribute> atts = new ArrayList<Attribute>();
    
     SortableValueMap<String, ArrayList<String>> mapValues = new SortableValueMap<String, ArrayList<String>>();
    for( String strAtrribute : attributeList){
      ArrayList<String> values =  new ArrayList<String>();
       mapValues.put(strAtrribute, values);
    }
       
     for( Unit s : ships.list ){
       for( String strAtrribute : attributeList){
         Unit c = s.get(strAtrribute);
         ArrayList<String> values =  mapValues.get(strAtrribute);
        
         //fill all data to matrix
         for( Integer t = 0; t < RDB.This().getTime(); t++ ){
           String d = c.getNominal(t);
          
           if( !values.contains(d) && d != null )
             values.add(d);   
         }
        
       }
    }
    
     for( String strAtrribute : attributeList){
       ArrayList<String> values =  mapValues.get(strAtrribute);
      atts.add(new Attribute(strAtrribute, values));
    }    
     
    //////////////////////////////////////////////////////////////////////////////////////////
    //create Instances object
    Instances data = new Instances("MyRelation", atts, 0);
         
    //////////////////////////////////////////////////////////////////////////////////////////
    //fill all matrix data to weka data
    for( Unit s : ships.list ){
       for( Integer t = 0; t < RDB.This().getTime(); t++ ){
         double[] vals = new double[data.numAttributes()];
           
         int j = 0;
          for( String strAtrribute : attributeList){
            Unit c = s.get(strAtrribute);
            ArrayList<String> values =  mapValues.get(strAtrribute);
                       
           String d = c.getNominal(t);
          
           vals[j++] = values.indexOf(d);   
          }
         
          // add
View Full Code Here

   *
   * @param name
   * @return the weka data from sim data
   */
  public Instances getWekaDataFromSimData(String name) {
    Unit printRoot = TDB.This().get(name);
    printRoot.print("");
    
    //////////////////////////////////////////////////////////////////////////////////////////
    //find all Unit having data
    SortableValueMap<String, Unit> mapUnit = new SortableValueMap<String, Unit>();
    printRoot.findUnitsHavingData( "", mapUnit);
   
    //////////////////////////////////////////////////////////////////////////////////////////
    //modify data to fit Weka data
    // EX) 1232.213 -> n1232
    for( String strName: mapUnit.keySet() ){
      Unit u = mapUnit.get(strName);
      u.modifyToNominal();
    }
   
    printRoot.print("");
   
    //////////////////////////////////////////////////////////////////////////////////////////
    //create attributes list
    mapUnit.sortByValue();
    ArrayList<Attribute> atts = new ArrayList<Attribute>();
    
     SortableValueMap<String, ArrayList<String>> mapValues = new SortableValueMap<String, ArrayList<String>>();
    for( String strName: mapUnit.keySet() ){
      Unit u = mapUnit.get(strName);
      ArrayList<String> values =  new ArrayList<String>();
      u.getAllDataVaules( values );
      mapValues.put(strName, values);
     
      atts.add(new Attribute(strName, values));
    }
   
    //////////////////////////////////////////////////////////////////////////////////////////
    //create Instances object
    Instances data = new Instances("MyRelation", atts, 0);
   
    //////////////////////////////////////////////////////////////////////////////////////////
    //fill all TDB data to weka data
    for( Integer t = 0; t < RDB.This().getTime(); t++ ){
      int i = 0;
      double[] vals = new double[data.numAttributes()];
      for( String strName: mapUnit.keySet() ){
        Unit u = mapUnit.get(strName);
        ArrayList<String> values = mapValues.get(strName);
        String strData = u.getLastDataByTime(t);
       
        vals[i] = values.indexOf(strData);
        i++;
      }
     
View Full Code Here

TOP

Related Classes of trackerModule.core.datastructure.Unit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.