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);