Example usage for android.graphics Region Region

List of usage examples for android.graphics Region Region

Introduction

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

Prototype

public Region() 

Source Link

Document

Create an empty region

Usage

From source file:Main.java

/**
 * Creates a simple region from the given path.
 *
 * @param path given path//from www .jav a2s .  c om
 * @return region object
 */
public static Region createRegionFromPath(Path path) {
    Region region = new Region();
    if (path != null) {
        RectF box = new RectF();
        path.computeBounds(box, true);
        region.setPath(path, new Region((int) box.left, (int) box.top, (int) box.right, (int) box.bottom));
    }
    return region;
}

From source file:jp.co.recruit_lifestyle.android.widget.ColoringLoadingView.java

public ColoringLoadingView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    initView();//  w  w  w  .j  a va 2  s  . c  o m

    mLoadingHandler = new Handler();
    mCharacterHandler = new Handler();
    mRectF = new RectF();
    mRegion = new Region();
    setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

From source file:com.roger.lineselectionwebview.LSWebView.java

/**
 * Setups up the web view./*from   w ww .j  a  va2s  .c  om*/
 * 
 * @param context
 */
@SuppressLint("SetJavaScriptEnabled")
protected void setup(Context context) {

    // On Touch Listener
    setOnLongClickListener(this);
    setOnTouchListener(this);

    // Webview setup
    getSettings().setJavaScriptEnabled(true);
    getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    getSettings().setPluginState(WebSettings.PluginState.ON);
    // getSettings().setBuiltInZoomControls(true);

    // Webview client.
    setWebViewClient(new WebViewClient() {
        // This is how it is supposed to work, so I'll leave it in, but this
        // doesn't get called on pinch
        // So for now I have to use deprecated getScale method.
        @Override
        public void onScaleChanged(WebView view, float oldScale, float newScale) {
            super.onScaleChanged(view, oldScale, newScale);
            mCurrentScale = newScale;
        }
    });

    // Zoom out fully
    // getSettings().setLoadWithOverviewMode(true);
    // getSettings().setUseWideViewPort(true);

    // Javascript interfaces
    mTextSelectionJSInterface = new TextSelectionJavascriptInterface(context, this);
    addJavascriptInterface(mTextSelectionJSInterface, mTextSelectionJSInterface.getInterfaceName());

    // Create the selection handles
    createSelectionLayer(context);

    // Set to the empty region
    Region region = new Region();
    region.setEmpty();
    mLastSelectedRegion = region;

    // Load up the android asset file
    // String filePath = "file:///android_asset/content.html";

    // Load the url
    // this.loadUrl(filePath);

}

From source file:org.androfarsh.widget.DragGridLayout.java

private Set<Node> findNodesUnder(Node dragNode, Set<Cell> hoveredCells) {
    if ((dragNode == null) || hoveredCells.isEmpty()) {
        return Collections.emptySet();
    }//from w  w w  .j ava2s.  c o m

    final Rect tmpRect = new Rect();
    final Region tmpRegion = new Region();
    for (Cell cell : hoveredCells) {
        tmpRegion.union(cell.rect);
    }

    Set<Node> nodes = new HashSet<Node>();
    int childCount = getChildCount();
    for (int i = 0; i < childCount; ++i) {
        View child = getChildAt(i);
        if ((child == mRootView) || (child == dragNode.view)) {
            continue;
        }

        requestCurrentRect(tmpRect, child);
        mTmpRegion.set(tmpRegion);
        mTmpRegion.op(tmpRect, Op.INTERSECT);

        if (!mTmpRegion.isEmpty()) {
            nodes.add(new Node(child, tmpRect));
        }
    }
    return nodes;
}