Search in sources :

Example 1 with OnTouchImageViewListener

use of com.ortiz.touch.TouchImageView.OnTouchImageViewListener in project TouchImageView by MikeOrtiz.

the class SingleTouchImageViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_single_touchimageview);
    //
    // DecimalFormat rounds to 2 decimal places.
    //
    df = new DecimalFormat("#.##");
    scrollPositionTextView = (TextView) findViewById(R.id.scroll_position);
    zoomedRectTextView = (TextView) findViewById(R.id.zoomed_rect);
    currentZoomTextView = (TextView) findViewById(R.id.current_zoom);
    image = (TouchImageView) findViewById(R.id.img);
    //
    // Set the OnTouchImageViewListener which updates edit texts
    // with zoom and scroll diagnostics.
    //
    image.setOnTouchImageViewListener(new OnTouchImageViewListener() {

        @Override
        public void onMove() {
            PointF point = image.getScrollPosition();
            RectF rect = image.getZoomedRect();
            float currentZoom = image.getCurrentZoom();
            boolean isZoomed = image.isZoomed();
            scrollPositionTextView.setText("x: " + df.format(point.x) + " y: " + df.format(point.y));
            zoomedRectTextView.setText("left: " + df.format(rect.left) + " top: " + df.format(rect.top) + "\nright: " + df.format(rect.right) + " bottom: " + df.format(rect.bottom));
            currentZoomTextView.setText("getCurrentZoom(): " + currentZoom + " isZoomed(): " + isZoomed);
        }
    });
}
Also used : RectF(android.graphics.RectF) OnTouchImageViewListener(com.ortiz.touch.TouchImageView.OnTouchImageViewListener) DecimalFormat(java.text.DecimalFormat) PointF(android.graphics.PointF)

Example 2 with OnTouchImageViewListener

use of com.ortiz.touch.TouchImageView.OnTouchImageViewListener in project TouchImageView by MikeOrtiz.

the class MirroringExampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mirroring_example);
    topImage = (TouchImageView) findViewById(R.id.topImage);
    bottomImage = (TouchImageView) findViewById(R.id.bottomImage);
    //
    // Each image has an OnTouchImageViewListener which uses its own TouchImageView
    // to set the other TIV with the same zoom variables.
    //
    topImage.setOnTouchImageViewListener(new OnTouchImageViewListener() {

        @Override
        public void onMove() {
            bottomImage.setZoom(topImage);
        }
    });
    bottomImage.setOnTouchImageViewListener(new OnTouchImageViewListener() {

        @Override
        public void onMove() {
            topImage.setZoom(bottomImage);
        }
    });
}
Also used : OnTouchImageViewListener(com.ortiz.touch.TouchImageView.OnTouchImageViewListener)

Aggregations

OnTouchImageViewListener (com.ortiz.touch.TouchImageView.OnTouchImageViewListener)2 PointF (android.graphics.PointF)1 RectF (android.graphics.RectF)1 DecimalFormat (java.text.DecimalFormat)1