Package advanced.flickrMT

Examples of advanced.flickrMT.FlickrLoader


          flickrSecret = properties.getProperty("FlickrSecret", " ");
      } catch (Exception e) {
        System.err.println("Error while loading FlickrApiKey.txt file.");
      }
     
    final FlickrLoader flickrLoader = new FlickrLoader(p, flickrApiKey, flickrSecret, sp, 100);
        flickrLoader.setFotoLoadCount(3);
        flickrLoader.setUsePlacesForGeoSearch(usePlacesForGeoSearch);
       
        flickrLoader.addProgressFinishedListener(new IMTEventListener(){
      public void processMTEvent(MTEvent mtEvent) {
        System.out.println("Loading finished!");
       
        p.getCurrentScene().registerPreDrawAction(new IPreDrawAction(){
          public boolean isLoop() {
            return false;
          }

          public void processAction() {
            progressBar.setVisible(false);
            Photo[] photos = flickrLoader.getPhotos();
            for (int i = 0; i < photos.length; i++) {
              Photo foto = photos[i];
              String id = foto.getId();
              //System.out.println("Foto ID:" + id);
              boolean alreadyContained = false;
              Collection<Photo> vlaues = tagToPhoto.values();
              for (Iterator<Photo> iterator = vlaues.iterator(); iterator.hasNext();) {
                Photo photo = (Photo) iterator.next();
                if (photo.getId().equalsIgnoreCase(foto.getId())){
                  alreadyContained = true;
                }
              }
             
              if (!alreadyContained/*!tagToPhoto.containsValue(foto)*/){
                String fotoName = foto.getTitle();
                if (foto.hasGeoData()){
                  GeoData geo = foto.getGeoData();
                  float lat = geo.getLatitude();
                  float lon = geo.getLongitude();
                  System.out.println("\"" + fotoName + "\"" + " Has GeoData! -> Lat:" + lat + " Lon:" + lon + " PlaceID: " + foto.getPlaceId());

                  Point2f pointOnScreen   = map.locationPoint(new Location(lat, lon));
//                  System.out.println(" -> Point on Screen: " + pointOnScreen);

                  Vector3D vecOnScreen   = new Vector3D(0,0,0f);
//                  Vector3D vecOnScreen   = new Vector3D(pointOnScreen.x , pointOnScreen.y , 0.01f);
//                  Vector3D vecOnScreen   = new Vector3D(pointOnScreen.x -p.width/2 +128, pointOnScreen.y -p.height/2 +128, 0.01f);

                  //System.out.println("-> Creating tag at: " + vecOnScreen);
                  if pointOnScreen.x >= 0 && pointOnScreen.x <= p.width
                    &&  pointOnScreen.y >= 0 && pointOnScreen.y <= p.height
                  ){
                    final MTEllipse tagCircle = new MTEllipse(p, vecOnScreen, 15, 15, 30);
                    tagCircle.setPickable(true);
                    tagCircle.setFillColor(new MTColor(90, 205, 230, 200));
                    tagCircle.setDrawSmooth(true);
                    tagCircle.setStrokeWeight(2);
                    tagCircle.setStrokeColor(new MTColor(40, 130, 220, 255));
                    tagCircle.translate(new Vector3D(pointOnScreen.x, pointOnScreen.y , 0.0f));
                    tagCircle.transform(tagContainer.getGlobalInverseMatrix());
                    tagCircle.setName(id);
                   
                    tagToPhoto.put(tagCircle, foto);
                   
                    tagContainer.addChild(tagCircle);
                   
                    tagCircle.unregisterAllInputProcessors();
                    tagCircle.registerInputProcessor(new TapProcessor(p));
                    tagCircle.addGestureListener(TapProcessor.class, new IGestureEventListener(){
                      //@Override
                      public boolean processGestureEvent(MTGestureEvent g) {
                        if (g instanceof TapEvent) {
                          TapEvent ce = (TapEvent) g;
                          switch (ce.getTapID()) {
                          case TapEvent.BUTTON_DOWN:
                            IMTComponent3D e = ce.getTargetComponent();
                            Photo foto = tagToPhoto.get(e);
                            if (foto != null){
                              SinglePhotoLoader fotoLoader = new SinglePhotoLoader(foto, 50);
                              fotoLoader.start();
                             
                              //Disable and remove the fototag
                              tagCircle.setGestureAllowance(TapProcessor.class, false);
                             
                              p.getCurrentScene().registerPreDrawAction(new IPreDrawAction(){
                                public boolean isLoop() {
                                  return false;
                                }
                                public void processAction() {
//                                  fotoTagContainer.removeChild(tagCircle);
                                  tagToPhoto.remove(tagCircle);
                                  tagCircle.destroy();
                                }

                              });
                            }
                            break;
                          default:
                            break;
                          }
                        }
                        return true;
                      }
                    });
                  }//if point is on screen
                  else{
                    System.out.println("Foto not on screen: position:" + pointOnScreen +  " Title: "+ foto.getTitle() + " id:" + id);
                  }
              }else{
                System.out.println("Foto already loaded: "+ foto.getTitle() + " id:" + id);
              }
               
                /*
                ImageCard[] images = flickrLoader.getMtFotos();
                ImageCard image = images[i];
                if (image != null){

                  if (pointOnScreen.x >= 0 && pointOnScreen.x <= p.width
                   && pointOnScreen.y >= 0 && pointOnScreen.y <= p.height){

                    image.setUseDirectGL(true);
                    image.setDisplayCloseButton(true);

//                    image.translate(new Vector3D((float)(-image.getWidthLocal()/2f) , (float)(-image.getHeightLocal()/2f) , 0.0f));

                    image.translate(new Vector3D(pointOnScreen.x, pointOnScreen.y , 0.1f));

                    image.transform(
                        fotoTagContainer.getAbsoluteWorldToLocalMatrix()
                    );

//                    image.scale((float)(1f/map.sc), (float)(1f/map.sc), 1, image.getCenterPointGlobal(), TransformSpace.RELATIVE_TO_WORLD);

                    fotoContainer.addChild(image);

//                    Vector3D centerPoint = image.getCenterPointGlobal(); //TODO rename ..Local to ParentRelative
//                    float width = 15;
//                    image.scaleGlobal(1/image.getWidthGlobal(), 1/image.getWidthGlobal(), 1, centerPoint);
//                    image.scaleGlobal(width, width, 1, centerPoint);

//                    Vector3D centerPoint = image.getCenterPointLocal(); //TODO rename ..Local to ParentRelative
//                    float width = 15;
//                    image.scale(1/image.getWidthLocal(), 1/image.getWidthLocal(), 1, centerPoint, TransformSpace.RELATIVE_TO_PARENT);
//                    image.scale(width, width, 1, centerPoint, TransformSpace.RELATIVE_TO_PARENT);

//                    image.translate(new Vector3D(pointOnScreen.x , pointOnScreen.y , 0.01f));
//                    image.setPositionGlobal(new Vector3D(pointOnScreen.x , pointOnScreen.y , 0.01f));
                  }else{
                    System.out.println("Image '" + image.getName() + "' out of screen -> remove.");
                    image.destroy();
                  }
                }
                */
              }//if has geo
            }//for fotos
          }//prcessPreDrawAction()
        });//registerPreAction()
      }//ProcessMTEvent()
        });//addThreadFinishedListener()
        progressBar.setProgressInfoProvider(flickrLoader);
        progressBar.setVisible(true);
       
        //Run the thread
        flickrLoader.start();
  }
View Full Code Here

TOP

Related Classes of advanced.flickrMT.FlickrLoader

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.