Skip to content

Commit

Permalink
minor bug fixes; formatting
Browse files Browse the repository at this point in the history
fixed smoothScaleTo bug courtesy @corsc; fixed onLayout fast-fail that
was preventing dynamic markers from qualifying for MarkerTapEvents
courtesy @skaor; updated formatting and convention to match existing
pattern
  • Loading branch information
moagrius committed Oct 10, 2013
1 parent be9314d commit c3dfc9b
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 121 deletions.
1 change: 1 addition & 0 deletions src/com/qozix/layouts/ZoomPanLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void onTweenProgress( double progress, double eased ) {
}
@Override
public void onTweenStart() {
saveHistoricalScale();
isTweening = true;
for ( ZoomPanListener listener : zoomPanListeners ) {
listener.onZoomStart( scale );
Expand Down
29 changes: 17 additions & 12 deletions src/com/qozix/tileview/TileView.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,23 @@ public void setDownsampleDecoder( BitmapDecoder decoder ) {
sampleManager.setDecoder( decoder );
}

/**

This comment has been minimized.

Copy link
@corsc

corsc Oct 11, 2013

Collaborator

Sorry it looks like my formatting was wrong. I use a different style so I think I set my eclipse formatter to the wrong settings for your style. Do you use eclipse? if so, do you think you could export and send me your settings? save us some trouble for next time?

This comment has been minimized.

Copy link
@moagrius

moagrius Oct 11, 2013

Author Owner

no problem at all. yep, i use eclipse (although I hear they're pushing Android Studio for IntelliJ)... should i just send to the email address listed on your profile?

* Get the {@link TileSetSelector} implementation currently used to select tile sets.
* @return TileSetSelector implementation currently in use.
*/
public TileSetSelector getTileSetSelector() {
return detailManager.getTileSetSelector();
}

/**
* Set the tile selection method, defaults to {@link TileSetSelectorMinimalUpScale}
* Implement the {@link TileSetSelector} interface to customize how tile sets are selected.
* @param selector (TileSetSelector) implementation that handles tile set selection as scale is changed.
*/
public void setTileSetSelector(TileSetSelector selector) {
detailManager.setTileSetSelector(selector);
}

/**
* Defines whether tile bitmaps should be rendered using an AlphaAnimation
* @param enabled (boolean) true if the TileView should render tiles with fade transitions
Expand Down Expand Up @@ -1149,16 +1166,4 @@ public void onRenderComplete() {

}

public TileSetSelector getTileSetSelector() {
return this.detailManager.getTileSetSelector();
}

/**
* Set the tile selection method, defaults to {@link TileSetSelectorMinimalUpScale}
*
* @param selector
*/
public void setTileSetSelector(TileSetSelector selector) {
this.detailManager.setTileSetSelector(selector);
}
}
16 changes: 7 additions & 9 deletions src/com/qozix/tileview/detail/DetailLevelSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DetailLevelSet extends LinkedList<DetailLevel> {
private static final long serialVersionUID = -1742428277010988084L;

private TileSetSelector tileSetSelector = new TileSetSelectorMinimalUpScale();

public void addDetailLevel( DetailLevel detailLevel ) {
// ensure uniqueness
if ( contains( detailLevel ) ) {
Expand All @@ -33,21 +33,19 @@ public void addDetailLevel( DetailLevel detailLevel ) {
}

public DetailLevel find( double scale ) {
return this.tileSetSelector.find(scale, this);
return tileSetSelector.find( scale, this );
}

public TileSetSelector getTileSetSelector() {
return this.tileSetSelector;
return tileSetSelector;
}

/**
* Set the tile selection method, defaults to {@link TileSetSelectorMinimalUpScale}
*
* @param selector
* @param selector (TileSetSelector)
*/
public void setTileSetSelector(TileSetSelector selector) {
this.tileSetSelector = selector;
public void setTileSetSelector( TileSetSelector selector ) {
tileSetSelector = selector;
}

}

}
3 changes: 0 additions & 3 deletions src/com/qozix/tileview/markers/MarkerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ public void processHit ( Point point ) {
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout( changed, l, t, r, b );
if(!changed){
return;
}
for (int i = getChildCount() - 1; i >= 0; i--) {
View child = getChildAt(i);
if (child.getVisibility() != GONE) {
Expand Down
60 changes: 29 additions & 31 deletions src/com/qozix/tileview/tiles/selector/TileSetSelectorByRange.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,44 @@
import java.util.ArrayList;
import java.util.List;

import android.util.Log;

import com.qozix.tileview.detail.DetailLevel;
import com.qozix.tileview.detail.DetailLevelSet;

public class TileSetSelectorByRange implements TileSetSelector {

private List<Double> switchPoint = new ArrayList<Double>();
private List<Double> switchPoint = new ArrayList<Double>();

@Override
public DetailLevel find(double scale, DetailLevelSet levels) {
int totalLevels = levels.size();
int totalSwitches = this.switchPoint.size();

// fast-fail
if (totalLevels == 0) {
return null;
}
@Override
public DetailLevel find( double scale, DetailLevelSet levels ) {
int totalLevels = levels.size();
int totalSwitches = switchPoint.size();

// sanity check the switchPoints with the levels
// switchPoints should be 1 less then the total levels
if (totalLevels != (totalSwitches + 1)) {
return null;
}
// fast-fail
if ( totalLevels == 0 ) {
return null;
}

// loop through and find a set where this scale fits
for (int index = 0; index < totalSwitches; index++) {
double thisSwitchPoint = this.switchPoint.get(index);
// sanity check the switchPoints with the levels
// switchPoints should be 1 less then the total levels
if ( totalLevels != ( totalSwitches + 1 ) ) {
return null;
}

// when we exceed the scale we take the previous
if (scale < thisSwitchPoint) {
return levels.get(index);
}
}
// loop through and find a set where this scale fits
for ( int index = 0; index < totalSwitches; index++ ) {
double thisSwitchPoint = this.switchPoint.get( index );

// take the last
return levels.get(totalLevels - 1);
}
// when we exceed the scale we take the previous
if ( scale < thisSwitchPoint ) {
return levels.get( index );
}
}

public void add(final double value) {
this.switchPoint.add(value);
}
// take the last
return levels.get( totalLevels - 1 );
}

public void add( final double value ) {
switchPoint.add( value );
}
}
67 changes: 31 additions & 36 deletions src/com/qozix/tileview/tiles/selector/TileSetSelectorClosest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,37 @@
import com.qozix.tileview.detail.DetailLevel;
import com.qozix.tileview.detail.DetailLevelSet;

public class TileSetSelectorClosest implements
TileSetSelector {

@Override
public DetailLevel find(double scale, DetailLevelSet levels) {
// fast-fail
if (levels.size() == 0) {
return null;
}
public class TileSetSelectorClosest implements TileSetSelector {

@Override
public DetailLevel find( double scale, DetailLevelSet levels ) {
// fast-fail
if ( levels.size() == 0 ) {
return null;
}

// default to first item
DetailLevel match = null;
double diffToMatch = 0d;

// default to first item
DetailLevel match = null;
double diffToMatch = 0d;

// loop through and find the "closest"
for (final DetailLevel thisLevel : levels)
{
if (match == null)
{
// default to the first value found
match = thisLevel;
diffToMatch = Math.abs(scale - match.getScale());
continue;
}

// calculate the diff from current level to requested scale
final double diffToCurrent = Math.abs(scale - thisLevel.getScale());
if (diffToCurrent < diffToMatch)
{
match = thisLevel;
diffToMatch = diffToCurrent;
}
}


return match;
}
// loop through and find the "closest"
for ( final DetailLevel thisLevel : levels ) {
if ( match == null ) {
// default to the first value found
match = thisLevel;
diffToMatch = Math.abs( scale - match.getScale() );
continue;
}

// calculate the diff from current level to requested scale
final double diffToCurrent = Math.abs( scale - thisLevel.getScale() );
if ( diffToCurrent < diffToMatch ) {
match = thisLevel;
diffToMatch = diffToCurrent;
}
}

return match;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,39 @@
import com.qozix.tileview.detail.DetailLevel;
import com.qozix.tileview.detail.DetailLevelSet;

public class TileSetSelectorMinimalUpScale implements
TileSetSelector {
public class TileSetSelectorMinimalUpScale implements TileSetSelector {

@Override
public DetailLevel find(double scale, DetailLevelSet levels) {
// fast-fail
if (levels.size() == 0) {
return null;
}

// set to null initially, but should never fail to populate
DetailLevel match = null;
// start at the last index
int index = levels.size() - 1;
// loop from largest to smallest
for (int i = index; i >= 0; i--) {
// store the iteration level in the return product for now
match = levels.get(i);
// if the iteration scale is less than the desired scale...
if (match.getScale() < scale) {
// and there's a level registered with a larger scale
if (i < index) {
// ... try to get the next largest
match = levels.get(i + 1);
// if we're at the largest level and can't go up one, then
// we've got our best-case
@Override
public DetailLevel find( double scale, DetailLevelSet levels ) {
// fast-fail
if ( levels.size() == 0 ) {
return null;
}
// if there's just one level, that's our best-case
if( levels.size() == 1 ) {
return levels.get( 0 );
}
// set to null initially, but should never fail to populate
DetailLevel match = null;
// start at the last index
int index = levels.size() - 1;
// loop from largest to smallest
for ( int i = index; i >= 0; i-- ) {
// store the iteration level in the return product for now
match = levels.get( i );
// if the iteration scale is less than the desired scale...
if ( match.getScale() < scale ) {
// and there's a level registered with a larger scale
if ( i < index ) {
// ... try to get the next largest
match = levels.get( i + 1 );
// if we're at the largest level and can't go up one, then we've got our best-case
}
// we've got a match, all done
break;
}
}
// we've got a match, all done
break;
}
return match;
}
return match;
}

}

0 comments on commit c3dfc9b

Please sign in to comment.