Android Open Source - TileView Hot Spot Manager






From Project

Back to project page TileView.

License

The source code is released under:

MIT License

If you think the Android project TileView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.qozix.tileview.hotspots;
//ww  w  . j  av a  2 s.  c om
import android.graphics.Point;

import com.qozix.tileview.detail.DetailLevelEventListener;
import com.qozix.tileview.detail.DetailManager;

import java.util.ArrayList;

public class HotSpotManager implements DetailLevelEventListener {

  private double scale = 1;
  
  private ArrayList<HotSpotEventListener> listeners = new ArrayList<HotSpotEventListener>();
  private ArrayList<HotSpot> spots = new ArrayList<HotSpot>();
  
  public HotSpotManager( DetailManager detailManager ) {
    detailManager.addDetailLevelEventListener( this );
  }
  
  public void addHotSpot( HotSpot hotSpot ){
    spots.add( hotSpot );
  }
  
  public void removeHotSpot( HotSpot hotSpot ){
    spots.remove( hotSpot );
  }
  
  public void addHotSpotEventListener( HotSpotEventListener listener ) {
    listeners.add( listener );
  }
  
  public void removeHotSpotEventListener( HotSpotEventListener listener ) {
    listeners.remove( listener );
  }
  
  public void clear(){
    spots.clear();
  }
  
  // work from end of list - match the last one added (equivalant to z-index)
  private HotSpot getMatch( Point point ){
    Point scaledPoint = new Point();
    scaledPoint.x = (int) ( point.x / scale );
    scaledPoint.y = (int) ( point.y / scale );
    for(int i = spots.size() - 1; i >= 0; i--){
      HotSpot hotSpot = spots.get( i );
      if(hotSpot.contains( scaledPoint.x, scaledPoint.y )){
        return hotSpot;
      }
    }
    return null;
  }
  
  public void processHit( Point point ){
    // is there a match?
    HotSpot hotSpot = getMatch( point );
    if( hotSpot != null){
      HotSpotEventListener spotListener = hotSpot.getHotSpotEventListener();
      if( spotListener != null ) {
        spotListener.onHotSpotTap( hotSpot, point.x, point.y );
      }
      for( HotSpotEventListener listener : listeners ) {
        listener.onHotSpotTap( hotSpot, point.x, point.y );
      }
    }
  }

  @Override
  public void onDetailLevelChanged() {
    
  }

  @Override
  public void onDetailScaleChanged( double s ) {
    scale = s;
  }
}




Java Source Code List

com.qozix.animation.AnimationListener.java
com.qozix.animation.Animator.java
com.qozix.animation.TweenHandler.java
com.qozix.animation.TweenListener.java
com.qozix.animation.Tween.java
com.qozix.animation.easing.EasingEquation.java
com.qozix.animation.easing.Linear.java
com.qozix.animation.easing.Strong.java
com.qozix.layouts.AnchorLayout.java
com.qozix.layouts.FixedLayout.java
com.qozix.layouts.ScalingLayout.java
com.qozix.layouts.StaticLayout.java
com.qozix.layouts.TranslationLayout.java
com.qozix.layouts.ZoomPanLayout.java
com.qozix.os.AsyncTask.java
com.qozix.tileview.TileView.java
com.qozix.tileview.detail.DetailLevelEventListener.java
com.qozix.tileview.detail.DetailLevelPatternParserDefault.java
com.qozix.tileview.detail.DetailLevelPatternParser.java
com.qozix.tileview.detail.DetailLevelSet.java
com.qozix.tileview.detail.DetailLevelSetupListener.java
com.qozix.tileview.detail.DetailLevel.java
com.qozix.tileview.detail.DetailManager.java
com.qozix.tileview.geom.PositionManager.java
com.qozix.tileview.graphics.BitmapDecoderAssets.java
com.qozix.tileview.graphics.BitmapDecoderHttp.java
com.qozix.tileview.graphics.BitmapDecoder.java
com.qozix.tileview.hotspots.HotSpotEventListener.java
com.qozix.tileview.hotspots.HotSpotManager.java
com.qozix.tileview.hotspots.HotSpot.java
com.qozix.tileview.markers.CalloutManager.java
com.qozix.tileview.markers.MarkerEventListener.java
com.qozix.tileview.markers.MarkerManager.java
com.qozix.tileview.paths.DrawablePath.java
com.qozix.tileview.paths.PathHelper.java
com.qozix.tileview.paths.PathManager.java
com.qozix.tileview.samples.SampleManager.java
com.qozix.tileview.tiles.TileCache.java
com.qozix.tileview.tiles.TileManager.java
com.qozix.tileview.tiles.TileRenderHandler.java
com.qozix.tileview.tiles.TileRenderListener.java
com.qozix.tileview.tiles.TileRenderTask.java
com.qozix.tileview.tiles.TileTransitionListener.java
com.qozix.tileview.tiles.Tile.java
com.qozix.tileview.tiles.selector.TileSetSelectorByRange.java
com.qozix.tileview.tiles.selector.TileSetSelectorClosest.java
com.qozix.tileview.tiles.selector.TileSetSelectorMinimalUpScale.java
com.qozix.tileview.tiles.selector.TileSetSelector.java
com.qozix.utils.ViewCurator.java
com.qozix.widgets.Scroller.java