Example usage for android.graphics Rect toString

List of usage examples for android.graphics Rect toString

Introduction

In this page you can find the example usage for android.graphics Rect toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:com.android.switchaccess.TreeBuilderUtils.java

/**
 * Print a tree to a specified stream. This method is intended for debugging.
 *
 * @param tree The tree to print/*from w  ww  .ja  v a 2s . co m*/
 * @param printStream The stream to which to print
 * @param prefix Any prefix that should be prepended to each line.
 */
@SuppressWarnings("unused")
public static void printTree(OptionScanNode tree, PrintStream printStream, String prefix) {
    String treeClassName = tree.getClass().getSimpleName();
    if (tree instanceof AccessibilityNodeActionNode) {
        Iterator<Rect> rects = tree.getRectsForNodeHighlight().iterator();
        if (rects.hasNext()) {
            Rect rect = rects.next();
            printStream.println(prefix + treeClassName + " with rect: " + rect.toString());
        }
        return;
    }
    printStream.println(prefix + treeClassName);
    if (tree instanceof OptionScanSelectionNode) {
        OptionScanSelectionNode selectionNode = (OptionScanSelectionNode) tree;
        for (int i = 0; i < selectionNode.getChildCount(); ++i) {
            printTree(selectionNode.getChild(i), printStream, prefix + "-");
        }
    }
}

From source file:com.google.android.car.kitchensink.camera.CameraTestFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
    View v = inflater.inflate(R.layout.camera_test, container, false);

    int[] cameraList = mCarCameraManager.getCameraList();
    for (int camera : cameraList) {
        if (camera == CarCameraManager.CAR_CAMERA_TYPE_RVC) {
            mRvcCamera = mCarCameraManager.openCamera(1);
            break;
        }/*from  ww w  . j  ava  2 s .  c o  m*/
    }

    mTvCap = (TextView) v.findViewById(R.id.tvCap);
    mTvRvcCrop = (TextView) v.findViewById(R.id.tvRvcCrop);
    mTvRvcPos = (TextView) v.findViewById(R.id.tvRvcPos);
    mTvCameraState = (TextView) v.findViewById(R.id.tvCameraState);

    Button btn = (Button) v.findViewById(R.id.btnGetCap);
    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            try {
                int cap = mRvcCamera.getCapabilities();
                mTvCap.setText(String.valueOf(cap));
            } catch (CarNotConnectedException e) {
                Log.e(TAG, "Failed to get camera capabilities", e);
            }
        }
    });

    btn = (Button) v.findViewById(R.id.btnGetRvcCrop);
    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            try {
                Rect rect = mRvcCamera.getCameraCrop();
                if (rect != null) {
                    mTvRvcCrop.setText(rect.toString());
                } else {
                    mTvRvcCrop.setText("null");
                }
            } catch (CarNotConnectedException e) {
                Log.e(TAG, "Failed to get camera crop", e);
            }
        }
    });

    btn = (Button) v.findViewById(R.id.btnGetRvcPos);
    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            try {
                Rect rect = mRvcCamera.getCameraPosition();
                if (rect != null) {
                    mTvRvcPos.setText(String.valueOf(rect));
                } else {
                    mTvRvcPos.setText("null");
                }
            } catch (CarNotConnectedException e) {
                Log.e(TAG, "Failed to get camere position", e);
            }
        }
    });

    btn = (Button) v.findViewById(R.id.btnGetCameraState);
    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            try {
                CarCameraState state = mRvcCamera.getCameraState();
                if (state != null) {
                    mTvCameraState.setText(state.toString());
                } else {
                    mTvCameraState.setText("null");
                }
            } catch (CarNotConnectedException e) {
                Log.e(TAG, "Failed to get camere state", e);
            }
        }
    });

    btn = (Button) v.findViewById(R.id.btnSetRvcCrop);
    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Rect rect = new Rect(160, 240, 560, 480);
            try {
                mRvcCamera.setCameraCrop(rect);
            } catch (CarNotConnectedException e) {
                Log.e(TAG, "Failed to set camera crop", e);
            }
        }
    });

    btn = (Button) v.findViewById(R.id.btnSetRvcCrop2);
    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Rect rect = new Rect(0, 0, 720, 480);
            try {
                mRvcCamera.setCameraCrop(rect);
            } catch (CarNotConnectedException e) {
                Log.e(TAG, "Failed to set camera crop", e);
            }
        }
    });

    btn = (Button) v.findViewById(R.id.btnSetRvcPos);
    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Rect rect = new Rect(300, 0, 800, 480);
            try {
                mRvcCamera.setCameraPosition(rect);
            } catch (CarNotConnectedException e) {
                Log.e(TAG, "Failed to set camera position", e);
            }
        }
    });

    btn = (Button) v.findViewById(R.id.btnSetRvcPos2);
    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Rect rect = new Rect(500, 0, 800, 480);
            try {
                mRvcCamera.setCameraPosition(rect);
            } catch (CarNotConnectedException e) {
                Log.e(TAG, "Failed to set camera position", e);
            }
        }
    });

    btn = (Button) v.findViewById(R.id.btnSetRvcPos3);
    btn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Rect rect = new Rect(300, 0, 500, 300);
            try {
                mRvcCamera.setCameraPosition(rect);
            } catch (CarNotConnectedException e) {
                Log.e(TAG, "Failed to set camera position", e);
            }
        }
    });

    final ToggleButton toggleBtn = (ToggleButton) v.findViewById(R.id.btnRvcState);
    toggleBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            CarCameraState state = new CarCameraState(false, toggleBtn.isChecked());
            try {
                mRvcCamera.setCameraState(state);
            } catch (CarNotConnectedException e) {
                Log.e(TAG, "Failed to set camera state", e);
            }
        }
    });

    if (DBG) {
        Log.d(TAG, "Starting CameraTestFragment");
    }
    return v;
}

From source file:me.tipi.kiosk.ui.fragments.OCRFragment.java

@Override
public void onAutofocusStarted(Rect[] rects) {
    if (rects == null) {
        Log.i(TAG, "Autofocus started with focusing areas being null");
    } else {//  w w  w .  j av a  2 s . com
        Log.i(TAG, "Autofocus started");
        for (Rect rect : rects) {
            Log.d(TAG, "Focus area: " + rect.toString());
        }
    }
}

From source file:me.tipi.kiosk.ui.fragments.OCRFragment.java

@Override
public void onAutofocusStopped(Rect[] rects) {
    if (rects == null) {
        Log.i(TAG, "Autofocus stopped with focusing areas being null");
    } else {/*from   w  ww .  ja  v  a 2s . c  o m*/
        Log.i(TAG, "Autofocus stopped");
        for (Rect rect : rects) {
            Log.d(TAG, "Focus area: " + rect.toString());
        }
    }
}