Examples of Spot


Examples of net.baguajie.domains.Spot

    if(result.hasErrors()){
      return new AjaxResult(AjaxResultCode.INVALID,
          BindingErrors.from(result));
    }
    // save spot
    Spot spot = Spot.from(vo, signInUser);
    try {
      // get image
      ImageReadyVo ir = webImageUtil
          .prepareImageFromUrl(vo.getImageUrl());
      String resId = imageService.put(ir.getFile());
      Resource res = new Resource();
      res.setOrgSize(ir.getOrgSize());
      res.setResId(resId);
      res.setExt(ir.getExt());
      resourceRepository.save(res);
      spot.setImage(res);
    } catch (Exception e) {
      throw new RuntimeException(e.getMessage(), e);
    }
    if(StringUtils.hasText(vo.getPlaceId())){
      Place place = placeRepository.findOne(vo.getPlaceId());
      if(place!=null){
        CityMeta city = cityMetaRepository.getByName(place.getCity());
        if(city!=null){
          spot.setCity(city.getPinyin());
        }
        spot.setLngLat(place.getLngLat());
        spot.setPlace(place);
      }
    }else if(!StringUtils.hasText(spot.getCity())){
      spot.setCity(ApplicationConfig.defaultCityPinyin);
    }
    spot = spotRepository.save(spot);
    // increase spot count
    signInUser.setSpotCount(signInUser.getSpotCount()+1);
    userRepository.save(signInUser);
    // save activity
    Activity activity = new Activity();
    activity.setOwner(signInUser.getId());
    activity.setCreatedAt(new Date());
    activity.setTargetSpot(spot.getId());
    activity.setType(ActivityType.SPOT);
    activity.setBy(sessionUtil.getBy(session));
    activityRepository.save(activity);
   
    return new AjaxResult(AjaxResultCode.SUCCESS);
View Full Code Here

Examples of net.sourceforge.java_stratego.stratego.Spot

      board.setLayout(new GridLayout(10, 10 , 0, 0));
      board.setBounds(new Rectangle(5, 5, 500, 500));
      for (int j=0;j<10;j++)
      for (int i=0;i<10;i++)
      {
        grid[i][j] = new PieceButton(this, new Spot(i, j));
        board.add(grid[i][j]);
      }
    }
    return board;
  }
View Full Code Here

Examples of net.sourceforge.java_stratego.stratego.Spot

      case GRID:
        x = in.readInt();
        y = in.readInt();
        color = in.readInt();
        rank = in.readInt();
        view.update(new Spot(x, y), new Piece(0, color, Rank.values()[rank]));
        return true;
      case TRAY:
        x = in.readInt();
        color = in.readInt();
        rank = in.readInt();
View Full Code Here

Examples of net.sourceforge.java_stratego.stratego.Spot

            throw new Exception();
         
          for (int k=0;k<board.getTraySize();k++)
            if (board.getTrayPiece(k).getColor() == Settings.topColor)
            {
              engine.aiReturnPlace(board.getTrayPiece(k), new Spot(x, y));
              break;
            }
        }
      }
      catch (IOException e)
      {
        JOptionPane.showMessageDialog(null, "File Format Error: Unexpected end of file.",
            "AI", JOptionPane.INFORMATION_MESSAGE);
      }
      catch (Exception e)
      {
        JOptionPane.showMessageDialog(null, "File Format Error: Invalid File Structure.",
            "AI", JOptionPane.INFORMATION_MESSAGE);
      }
      finally
      {
        try {
          in.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      break;
    }
   
    //double check the ai setup
    for (int i=0;i<10;i++)
    for (int j=0;j<4; j++)
    {
      Piece p = null;
      for (int k=0;k<board.getTraySize();k++)
        if (board.getTrayPiece(k).getColor() == Settings.topColor)
        {
          p = board.getTrayPiece(k);
          break;
        }

      if (p==null)
        break;
       
      engine.aiReturnPlace(p, new Spot(i, j));
    }
   
    //if the user didn't finish placing pieces just put them on
    for (int i=0;i<10;i++)
    for (int j=6;j<10;j++)
    {
      Piece p = null;
      for (int k=0;k<board.getTraySize();k++)
        if (board.getTrayPiece(k).getColor() != Settings.topColor)
        {
          p = board.getTrayPiece(k);
          break;
        }

      if (p==null)
        break;
       
      engine.aiReturnPlace(p, new Spot(i, j));
    }
   
    engine.play();
  }
View Full Code Here

Examples of net.sourceforge.java_stratego.stratego.Spot

    int threadc = 0;
   
    for (int i=0;i<10;i++)
    for (int j=0;j<10;j++)
    {
      Spot f = new Spot(i, j);
      Spot t = null;
      if (b.getPiece(f) == null)
        continue;
      if (b.getPiece(f).getColor() != Settings.topColor)
        continue;
       
      for (int k=0;k<4;k++)
      {
        switch (k)
        {
        case 0:
          if (i==0)
            continue;
          t = new Spot(i-1, j);
          break;
        case 1:
          if (j==0)
            continue;
          t = new Spot(i, j-1);
          break;
        case 2:
          if (i==9)
            continue;
          t = new Spot(i+1, j);
          break;
        case 3:
          if (j==9)
            continue;
          t = new Spot(i, j+1);
          break;
        }
        if (b.validMove(f, t))
        {
          tmpM = new Move(b.getPiece(f), f, t);
View Full Code Here

Examples of net.sourceforge.java_stratego.stratego.Spot

      value *= -3;
   
    for (int i=0;i<10;i++)
    for (int j=0;j<10;j++)
    {
      Spot f = new Spot(i, j);
      Spot t = null;
      if (b.getPiece(f) == null)
        continue;
      if (b.getPiece(f).getColor() != turn)
        continue;
       
      for (int k=0;k<4;k++)
      {
        switch (k)
        {
        case 0:
          if (j==9)
            continue;
          t = new Spot(i, j+1);
          break;
        case 1:
          if (i==9)
            continue;
          t = new Spot(i+1, j);
          break;
        case 2:
          if (i==0)
            continue;
          t = new Spot(i-1, j);
          break;
        case 3:
          if (j==0)
            continue;
          t = new Spot(i, j-1);
          break;
        }
        if (b.validMove(f, t))
        {
          hasMove = true;
View Full Code Here

Examples of net.sourceforge.java_stratego.stratego.Spot

      for (int i=0;i<10;i++)
      for (int j=l_limit;j<u_limit;j++)
        if (board.getPiece(i, j) == null)
          for (int k=0;k<board.getTraySize();k++)
            if (getTrayPiece(k).getColor() == color)
              setupPlacePiece(getTrayPiece(k), new Spot(i, j));
    }
 
    if (board.getTraySize() == 0)
      status = Status.PLAYING;
  }
View Full Code Here

Examples of net.sourceforge.java_stratego.stratego.Spot

      {
        switch (Message.values()[type])
        {
        case MOVE:
          int x1, x2, y1, y2, rank;
          Spot from, to;
          Piece p;
          x1 = in.readInt();
          y1 = in.readInt();
          x2 = in.readInt();
          y2 = in.readInt();
          rank = in.readInt();
          if (x1 < 0)
          {
            from = Board.IN_TRAY;
            p = new Piece(0, 0, Rank.values()[rank]);
          }
          else
          {
            from = new Spot(x1, y1);
            p = engine.getBoardPiece(x1, y1);
          }
          if (x2 < 0)
            to = Board.IN_TRAY;
          else
            to = new Spot(x2, y2);

          game.engine.requestMove(new Move(p, from, to), player);
          break;
        case PLAY:
          game.engine.play(player);
View Full Code Here

Examples of net.sourceforge.java_stratego.stratego.Spot

          y = in.read();
       
        if (x<0||x>9||y<0||y>3)
          throw new Exception();
       
        board.move(new Move(board.getTrayPiece(0), EditorBoard.IN_TRAY, new Spot(x, y)));
      }
    }
    catch (IOException e)
    {
      JOptionPane.showMessageDialog(getJFrame(), "File Format Error: Unexpected end of file.",
View Full Code Here

Examples of org.dbpedia.spotlight.web.rest.output.Spot

            if (!result.isEmpty())
                filteredEntityCandidates.put(entry.getKey(), result);
        }

        for(SurfaceFormOccurrence sfOcc : filteredEntityCandidates.keySet()) {
            Spot spot = Spot.getInstance(sfOcc);
            List<Resource> resources = new LinkedList<Resource>();
            for(DBpediaResourceOccurrence occ : filteredEntityCandidates.get(sfOcc)) {
                Resource resource = Resource.getInstance(occ);
                resources.add(resource);
            }
            spot.setResources(resources);
            spots.add(spot);
        }
        annotation.setSpots(spots);
        return annotation;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.