本文整理汇总了Java中android.view.ScaleGestureDetector.getCurrentSpanX方法的典型用法代码示例。如果您正苦于以下问题:Java ScaleGestureDetector.getCurrentSpanX方法的具体用法?Java ScaleGestureDetector.getCurrentSpanX怎么用?Java ScaleGestureDetector.getCurrentSpanX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ScaleGestureDetector
的用法示例。
在下文中一共展示了ScaleGestureDetector.getCurrentSpanX方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean onScale(ScaleGestureDetector detector) {
RectF rect = mCropWindowHandler.getRect();
float x = detector.getFocusX();
float y = detector.getFocusY();
float dY = detector.getCurrentSpanY() / 2;
float dX = detector.getCurrentSpanX() / 2;
float newTop = y - dY;
float newLeft = x - dX;
float newRight = x + dX;
float newBottom = y + dY;
if (newLeft < newRight &&
newTop <= newBottom &&
newLeft >= 0 &&
newRight <= mCropWindowHandler.getMaxCropWidth() &&
newTop >= 0 &&
newBottom <= mCropWindowHandler.getMaxCropHeight()) {
rect.set(newLeft, newTop, newRight, newBottom);
mCropWindowHandler.setRect(rect);
invalidate();
}
return true;
}
示例2: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean onScale(ScaleGestureDetector detector) {
RectF rect = mCropWindowHandler.getRect();
float x = detector.getFocusX();
float y = detector.getFocusY();
float dY = detector.getCurrentSpanY() / 2;
float dX = detector.getCurrentSpanX() / 2;
float newTop = y - dY;
float newLeft = x - dX;
float newRight = x + dX;
float newBottom = y + dY;
if (newLeft < newRight
&& newTop <= newBottom
&& newLeft >= 0
&& newRight <= mCropWindowHandler.getMaxCropWidth()
&& newTop >= 0
&& newBottom <= mCropWindowHandler.getMaxCropHeight()) {
rect.set(newLeft, newTop, newRight, newBottom);
mCropWindowHandler.setRect(rect);
invalidate();
}
return true;
}
示例3: getCurrentSpanX
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
/**
* @see ScaleGestureDetector#getCurrentSpanX()
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static float getCurrentSpanX(ScaleGestureDetector scaleGestureDetector) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
return scaleGestureDetector.getCurrentSpanX();
} else {
return scaleGestureDetector.getCurrentSpan();
}
}
示例4: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector detector) {
if(source != null) {
// Zoom horizontal if focus in the main area or always if decoupled axis is deactivated:
if(!decoupledAxis || detector.getFocusX() > getGridSize()*1.5) {
float xScale = detector.getCurrentSpanX() / detector.getPreviousSpanX();
long frequencyFocus = virtualFrequency + (int) ((detector.getFocusX() / width - 0.5) * virtualSampleRate);
int maxSampleRate = demodulationEnabled ? (int) (source.getSampleRate() * 0.9) : source.getMaxSampleRate();
if(recordingEnabled)
maxSampleRate = source.getSampleRate();
virtualSampleRate = (int) Math.min(Math.max(virtualSampleRate / xScale, MIN_VIRTUAL_SAMPLERATE), maxSampleRate);
virtualFrequency = Math.min(Math.max(frequencyFocus + (long) ((virtualFrequency - frequencyFocus) / xScale),
source.getMinFrequency() - source.getSampleRate() / 2), source.getMaxFrequency() + source.getSampleRate() / 2);
// if we zoomed the channel selector out of the window, reset the channel selector:
if (demodulationEnabled && channelFrequency < virtualFrequency - virtualSampleRate / 2) {
channelFrequency = virtualFrequency - virtualSampleRate / 2;
rfControlInterface.updateChannelFrequency(channelFrequency);
}
if (demodulationEnabled && channelFrequency > virtualFrequency + virtualSampleRate / 2) {
channelFrequency = virtualFrequency + virtualSampleRate / 2;
rfControlInterface.updateChannelFrequency(channelFrequency);
}
}
// Zoom vertical if enabled and focus in the left grid area or if decoupled axis is deactivated:
if (verticalZoomEnabled && (!decoupledAxis || detector.getFocusX() <= getGridSize() * 1.5)) {
float yScale = detector.getCurrentSpanY() / detector.getPreviousSpanY();
float dBFocus = maxDB - (maxDB - minDB) * (detector.getFocusY() / getFftHeight());
float newMinDB = Math.min(Math.max(dBFocus - (dBFocus - minDB) / yScale, MIN_DB), MAX_DB - 10);
float newMaxDB = Math.min(Math.max(dBFocus - (dBFocus - maxDB) / yScale, newMinDB + 10), MAX_DB);
this.setDBScale(newMinDB, newMaxDB);
// adjust the squelch if it is outside the visible viewport right now:
if(squelch < minDB)
squelch = minDB;
if(squelch > maxDB)
squelch = maxDB;
}
// Automatically re-adjust the sample rate of the source if we zoom too far out or in
// (only if not recording or demodulating!)
if(!recordingEnabled && !demodulationEnabled) {
if (source.getSampleRate() < virtualSampleRate && virtualSampleRate < source.getMaxSampleRate())
source.setSampleRate(source.getNextHigherOptimalSampleRate(virtualSampleRate));
int nextLower = source.getNextLowerOptimalSampleRate(source.getSampleRate());
if ((virtualSampleRate < nextLower) && (source.getSampleRate() > nextLower)) {
source.setSampleRate(nextLower);
}
}
}
return true;
}