Example usage for android.view View LAYER_TYPE_SOFTWARE

List of usage examples for android.view View LAYER_TYPE_SOFTWARE

Introduction

In this page you can find the example usage for android.view View LAYER_TYPE_SOFTWARE.

Prototype

int LAYER_TYPE_SOFTWARE

To view the source code for android.view View LAYER_TYPE_SOFTWARE.

Click Source Link

Document

Indicates that the view has a software layer.

Usage

From source file:com.spoiledmilk.ibikecph.map.MapFragmentBase.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setHardwareAccelerationOff() {
    // Turn off hardware acceleration here, or in manifest
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        mapView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

From source file:com.kit.imagelib.imagelooker.ImagesLookerPhotoViewFragment.java

public View initWidget(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View contextView = inflater.inflate(R.layout.item_imageslooker_photoview, container, false);

    //        setContentView(R.layout.activity_imagelooker_main);

    mPhotoView = (PhotoView) contextView.findViewById(R.id.photoview);
    gifImageView = (GifView) contextView.findViewById(R.id.gifImageView);
    //        mPhotoView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    mPhotoView.setBackgroundColor(0);/*from  w w w .j  a v  a2 s  . com*/
    // The MAGIC happens here!
    //        mAttacher = new PhotoViewAttacher(mPhotoView);

    // Lets attach some listeners, not required though!
    //        mAttacher.setOnMatrixChangeListener(new MatrixChangeListener());
    //        mAttacher.setOnPhotoTapListener(new PhotoTapListener());
    //        mAttacher.setAdapterWidth(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mPhotoView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    rpb = (RoundProgressBar) contextView.findViewById(R.id.pb);

    //        LogUtils.printLog(ImagesLookerPhotoViewFragment.class, "rpb:" + rpb);
    //        Drawable bitmap = getResources().getDrawable(R.drawable.default_pic);
    //        mPhotoView.setImageDrawable(bitmap);

    // The MAGIC happens here!

    //        mAttacher.setScale(1f, 0, 0, true);

    imageView = mPhotoView;
    return contextView;
}

From source file:com.pursuer.reader.easyrss.WebpageItemViewCtrl.java

@SuppressLint("SetJavaScriptEnabled")
public WebpageItemViewCtrl(final DataMgr dataMgr, final Context context, final String uid,
        final boolean isMobilized) {
    super(dataMgr, R.layout.webpage_item, context);

    this.item = dataMgr.getItemByUid(uid, ITEM_PROJECTION);
    this.theme = new SettingTheme(dataMgr).getData();
    this.fontSize = new SettingFontSize(dataMgr).getData();
    // Disable hardware acceleration on Android 3.0-4.1 devices.
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1
            && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }/*from   w  w  w.j a va2 s . c  o m*/

    {
        mobilizedView = (WebView) view.findViewById(R.id.MobilizedContent);
        mobilizedView.setBackgroundColor(context.getResources().getColor(
                theme == SettingTheme.THEME_NORMAL ? R.color.NormalBackground : R.color.DarkBackground));
        mobilizedView.setFocusable(false);
        final WebSettings settings = mobilizedView.getSettings();
        settings.setDefaultTextEncodingName(HTTP.UTF_8);
        settings.setJavaScriptEnabled(false);
        settings.setDefaultFontSize(fontSize);
    }
    {
        originalView = (WebView) view.findViewById(R.id.OriginalContent);
        originalView.setFocusable(false);
        originalView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
        final WebSettings settings = originalView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setSupportZoom(true);
        settings.setBuiltInZoomControls(true);
        originalView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(final WebView webView, final String url) {
                view.findViewById(R.id.OriginalProgress).setVisibility(View.GONE);
            }

            @Override
            public void onPageStarted(final WebView webView, final String url, final Bitmap favicon) {
                if (!showMobilized) {
                    view.findViewById(R.id.OriginalProgress).setVisibility(View.VISIBLE);
                }
            }

            @Override
            public boolean shouldOverrideUrlLoading(final WebView webView, final String url) {
                webView.loadUrl(url);
                return false;
            }
        });
    }

    if (isMobilized) {
        showMobilizedPage();
    } else {
        showOriginalPage();
    }

    view.findViewById(R.id.BtnMobilzedPage).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View view) {
            showMobilizedPage();
        }
    });
    view.findViewById(R.id.BtnOriginalPage).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View view) {
            showOriginalPage();
        }
    });
    view.findViewById(R.id.BtnClose).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View view) {
            if (listener != null) {
                listener.onBackNeeded();
            }
        }
    });
}

From source file:com.facebook.keyframes.sample.MainActivity.java

private void setKFImage(KFImage kfImage) {
    clearImage();/*from w ww .  ja  v a  2  s . c om*/
    mKfImage = kfImage;

    final Drawable logoDrawable = getResources().getDrawable(R.drawable.keyframes_launcher);
    if (logoDrawable != null) {
        logoDrawable.setBounds(0, 0, 80, 80);
        mKeyFramesDrawable = new KeyframesDrawableBuilder().withImage(mKfImage).withMaxFrameRate(60)
                .withExperimentalFeatures()
                .withParticleFeatureConfigs(Pair.create("keyframes", Pair.create(logoDrawable, new Matrix())))
                .build();
    }
    mKeyFramesDrawable.startAnimation();

    final ImageView imageView = (ImageView) findViewById(R.id.sample_image_view);
    imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    imageView.setImageDrawable(mKeyFramesDrawable);
}

From source file:com.android.madpausa.cardnotificationviewer.CardElementHolder.java

private void resetHolder() {
    cancel = false;/*from   w  w w .  j a va  2  s.c o  m*/
    root.setTranslationX(0);
    root.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    root.setAlpha(1);
    root.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

From source file:eu.janmuller.android.simplecropimage.CropImage.java

@Override
public void onCreate(Bundle icicle) {

    super.onCreate(icicle);
    mContentResolver = getContentResolver();

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.cropimage);/*  ww  w  .  j  av a  2  s .com*/

    mImageView = (CropImageView) findViewById(R.id.image);

    showStorageToast(this);

    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {

        if (extras.getString(CIRCLE_CROP) != null) {

            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
                mImageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }

            mCircleCrop = true;
            mAspectX = 1;
            mAspectY = 1;
        }

        mImagePath = extras.getString(IMAGE_FILE);

        if (mImagePath == null) {
            mSaveUri = extras.getParcelable(IMAGE_PATH);
        } else {
            mSaveUri = getImageUri(mImagePath);
        }

        mBitmap = getBitmap(mSaveUri);

        if (extras.containsKey(ASPECT_X) && extras.get(ASPECT_X) instanceof Integer) {

            mAspectX = extras.getInt(ASPECT_X);
        } else {

            throw new IllegalArgumentException("aspect_x must be integer");
        }
        if (extras.containsKey(ASPECT_Y) && extras.get(ASPECT_Y) instanceof Integer) {

            mAspectY = extras.getInt(ASPECT_Y);
        } else {

            throw new IllegalArgumentException("aspect_y must be integer");
        }
        mOutputX = extras.getInt(OUTPUT_X);
        mOutputY = extras.getInt(OUTPUT_Y);
        mScale = extras.getBoolean(SCALE, true);
        mScaleUp = extras.getBoolean(SCALE_UP_IF_NEEDED, true);
    }

    if (mBitmap == null) {

        Log.d(TAG, "finish!!!");
        finish();
        return;
    }

    // Make UI fullscreen.
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    findViewById(R.id.discard).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            setResult(RESULT_CANCELED);
            finish();
        }
    });

    findViewById(R.id.save).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            try {
                onSaveClicked();
            } catch (Exception e) {
                finish();
            }
        }
    });
    /*findViewById(R.id.rotateLeft).setOnClickListener(
        new View.OnClickListener() {
            public void onClick(View v) {
            
                mBitmap = Util.rotateImage(mBitmap, -90);
                RotateBitmap rotateBitmap = new RotateBitmap(mBitmap);
                mImageView.setImageRotateBitmapResetBase(rotateBitmap, true);
                mRunFaceDetection.run();
            }
        });*/

    /*findViewById(R.id.rotateRight).setOnClickListener(
        new View.OnClickListener() {
            public void onClick(View v) {
            
                mBitmap = Util.rotateImage(mBitmap, 90);
                RotateBitmap rotateBitmap = new RotateBitmap(mBitmap);
                mImageView.setImageRotateBitmapResetBase(rotateBitmap, true);
                mRunFaceDetection.run();
            }
        });*/
    startFaceDetection();
}

From source file:com.pursuer.reader.easyrss.VerticalSingleItemView.java

@SuppressLint({ "NewApi", "SimpleDateFormat" })
public VerticalSingleItemView(final DataMgr dataMgr, final Context context, final String uid, final View menu,
        final VerticalItemViewCtrl itemViewCtrl) {
    this.dataMgr = dataMgr;
    this.context = context;
    this.item = dataMgr.getItemByUid(uid, ITEM_PROJECTION);
    this.fontSize = new SettingFontSize(dataMgr).getData();
    this.theme = new SettingTheme(dataMgr).getData();
    this.showTop = false;
    this.showBottom = false;
    this.menu = menu;
    this.itemViewCtrl = itemViewCtrl;
    this.imageClickTime = 0;

    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.view = inflater.inflate(R.layout.single_item_view, null);
    // Disable hardware acceleration on Android 3.0-4.1 devices.
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1
            && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }/* ww  w. j  a va 2  s .c o m*/

    lastItemView = view.findViewById(R.id.LastItemView);
    nextItemView = view.findViewById(R.id.NextItemView);
    itemScrollView = (OverScrollView) view.findViewById(R.id.ItemScrollView);
    itemScrollView.setTopScrollView(lastItemView);
    itemScrollView.setBottomScrollView(nextItemView);
    itemScrollView.setOnScrollChangeListener(this);
    itemScrollView.setOnTouchListener(this);

    final View btnShowOriginal = view.findViewById(R.id.BtnShowOriginal);
    btnShowOriginal.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(final View view, final MotionEvent event) {
            boolean ret = false;
            final TextView txt = (TextView) view.findViewById(R.id.BtnText);
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                txt.setTextColor(0xFF787878);
                ret = true;
                break;
            case MotionEvent.ACTION_MOVE:
                ret = true;
                break;
            case MotionEvent.ACTION_CANCEL:
                txt.setTextColor(0xBB787878);
                ret = false;
                break;
            case MotionEvent.ACTION_UP:
                txt.setTextColor(0xBB787878);
                final SettingBrowserChoice setting = new SettingBrowserChoice(dataMgr);
                if (setting.getData() == SettingBrowserChoice.BROWSER_CHOICE_EXTERNAL) {
                    final Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent.setData(Uri.parse(item.getHref()));
                    context.startActivity(intent);
                } else if (VerticalSingleItemView.this.listener != null) {
                    VerticalSingleItemView.this.listener.showWebsitePage(item.getUid(), false);
                }
                break;
            default:
            }
            return ret;
        }
    });

    final View btnShowMobilized = view.findViewById(R.id.BtnShowMobilized);
    btnShowMobilized.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(final View view, final MotionEvent event) {
            boolean ret = false;
            final TextView txt = (TextView) view.findViewById(R.id.BtnText);
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                txt.setTextColor(0xFF787878);
                ret = true;
                break;
            case MotionEvent.ACTION_MOVE:
                ret = true;
                break;
            case MotionEvent.ACTION_CANCEL:
                txt.setTextColor(0xBB787878);
                ret = false;
                break;
            case MotionEvent.ACTION_UP:
                txt.setTextColor(0xBB787878);
                if (VerticalSingleItemView.this.listener != null) {
                    VerticalSingleItemView.this.listener.showWebsitePage(item.getUid(), true);
                }
                ret = true;
                break;
            default:
            }
            return ret;
        }
    });

    {
        final ListItemItem lastItem = itemViewCtrl.getLastItem(item.getUid());
        final TextView txt = (TextView) lastItemView.findViewById(R.id.LastItemTitle);
        txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize);
        if (lastItem == null) {
            lastUid = null;
            menu.findViewById(R.id.BtnPrevious).setEnabled(false);
            final ImageView img = (ImageView) lastItemView.findViewById(R.id.LastItemArrow);
            img.setImageResource(R.drawable.no_more_circle);
            txt.setText(R.string.TxtNoPreviousItem);
        } else {
            lastUid = lastItem.getId();
            final View btnLast = menu.findViewById(R.id.BtnPrevious);
            btnLast.setEnabled(true);
            btnLast.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(final View view) {
                    if (listener != null) {
                        listener.showLastItem();
                    }
                }
            });
            txt.setText(lastItem.getTitle());
        }
    }

    {
        final ListItemItem nextItem = itemViewCtrl.getNextItem(item.getUid());
        final TextView txt = (TextView) nextItemView.findViewById(R.id.NextItemTitle);
        txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize);
        if (nextItem == null) {
            nextUid = null;
            menu.findViewById(R.id.BtnNext).setEnabled(false);
            final ImageView img = (ImageView) nextItemView.findViewById(R.id.NextItemArrow);
            img.setImageResource(R.drawable.no_more_circle);
            txt.setText(R.string.TxtNoNextItem);
        } else {
            nextUid = nextItem.getId();
            final View btnNext = menu.findViewById(R.id.BtnNext);
            btnNext.setEnabled(true);
            btnNext.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(final View view) {
                    if (listener != null) {
                        listener.showNextItem();
                    }
                }
            });
            txt.setText(nextItem.getTitle());
        }
    }

    final TextView title = (TextView) view.findViewById(R.id.ItemTitle);
    title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize * 4 / 3);
    title.setText(item.getTitle());
    final TextView info = (TextView) view.findViewById(R.id.ItemInfo);
    info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize * 4 / 5);
    final StringBuilder infoText = new StringBuilder();
    final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    sdf.setTimeZone(TimeZone.getDefault());
    infoText.append(sdf.format(Utils.timestampToDate(item.getTimestamp())));
    if (item.getAuthor() != null && item.getAuthor().length() > 0) {
        infoText.append(" | By ");
        infoText.append(item.getAuthor());
    }
    if (item.getSourceTitle() != null && item.getSourceTitle().length() > 0) {
        infoText.append(" (");
        infoText.append(item.getSourceTitle());
        infoText.append(")");
    }
    info.setText(infoText);

    webView = (WebView) view.findViewById(R.id.webView);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setBackgroundColor(context.getResources()
            .getColor(theme == SettingTheme.THEME_NORMAL ? R.color.NormalBackground : R.color.DarkBackground));
    webView.setFocusable(false);
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
            if (VerticalSingleItemView.this.imageClickTime > System.currentTimeMillis() - 1000) {
                return true;
            }
            final Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setData(Uri.parse(url));
            context.startActivity(intent);
            return true;
        }
    });
    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public boolean onJsAlert(final WebView view, final String url, final String message,
                final JsResult result) {
            if (VerticalSingleItemView.this.listener != null) {
                if (message.endsWith(".erss")) {
                    VerticalSingleItemView.this.listener
                            .onImageViewRequired(item.getStoragePath() + "/" + message);
                } else {
                    VerticalSingleItemView.this.listener.onImageViewRequired(message);
                }
            }
            VerticalSingleItemView.this.imageClickTime = System.currentTimeMillis();
            result.cancel();
            return true;
        }
    });

    updateButtonStar();
    updateButtonSharing();
    updateButtonOpenLink();

    if (!item.getState().isRead()) {
        dataMgr.markItemAsReadWithTransactionByUid(uid);
        NetworkMgr.getInstance().startImmediateItemStateSyncing();
    }
}

From source file:eu.hydrologis.geopaparazzi.chart.ProfileChartActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.profilechart);

    int backgroundColor = getResources().getColor(R.color.main_background);
    int decorationsColor = getResources().getColor(R.color.main_decorations_dark);
    int textColor = getResources().getColor(R.color.main_text_color_neutral);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        try {/* www .  ja va2s .co m*/
            long logid = extras.getLong(Constants.ID);

            line = DaoGpsLog.getGpslogAsLine(logid, -1);

        } catch (IOException e) {
            GPLog.error(this, e.getLocalizedMessage(), e);
            e.printStackTrace();
        }

    } else {
        Toast.makeText(this, R.string.an_error_occurred_while_creating_the_chart_, Toast.LENGTH_LONG).show();
    }

    final float f26 = PixelUtils.dpToPix(26);
    final float f10 = PixelUtils.dpToPix(10);
    final SizeMetrics sm = new SizeMetrics(0, SizeLayoutType.FILL, 0, SizeLayoutType.FILL);

    xyPlotSpeed = (XYPlot) findViewById(R.id.speed_plot);
    xyPlotElev = (XYPlot) findViewById(R.id.elevation_plot);
    xyPlotSpeed.setOnTouchListener(this);

    infoTextView = (TextView) findViewById(R.id.info_text);
    Button resetButton = (Button) findViewById(R.id.reset_chart_button);
    resetButton.setOnClickListener(this);

    drawerLayout = (DrawerLayout) findViewById(R.id.container_drawer);

    // Disable Hardware Acceleration on the xyPlot view object.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        xyPlotSpeed.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        xyPlotElev.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    /*
     * Setup the Plots
     */
    xyPlotSpeed.setPlotMargins(0, 0, 0, 0);
    xyPlotElev.setPlotMargins(0, 0, 0, 0);

    xyPlotSpeed.setPlotPadding(0, 0, 0, 0);
    xyPlotElev.setPlotPadding(0, 0, 0, 0);

    xyPlotElev.getDomainLabelWidget().setVisible(false);
    xyPlotElev.getRangeLabelWidget().setVisible(false);
    xyPlotElev.getTitleWidget().setVisible(false);

    xyPlotElev.setBorderPaint(null);
    xyPlotElev.setBackgroundPaint(null);

    /* 
     * Setup the Graph Widgets
     */
    XYGraphWidget graphWidgetSpeed = xyPlotSpeed.getGraphWidget();
    XYGraphWidget graphWidgetElev = xyPlotElev.getGraphWidget();

    graphWidgetSpeed.setSize(sm);
    graphWidgetElev.setSize(sm);

    graphWidgetSpeed.setMargins(0, 0, 0, 0);
    graphWidgetElev.setMargins(0, 0, 0, 0);

    graphWidgetSpeed.setPadding(f26, f10, f26, f26);
    graphWidgetElev.setPadding(f26, f10, f26, f26);

    graphWidgetSpeed.setRangeAxisPosition(true, false, 4, "10");
    graphWidgetElev.setRangeAxisPosition(false, false, 4, "10");

    graphWidgetSpeed.setRangeLabelVerticalOffset(-3);
    graphWidgetElev.setRangeLabelVerticalOffset(-3);

    graphWidgetSpeed.setRangeOriginLabelPaint(null);
    graphWidgetElev.setRangeOriginLabelPaint(null);

    graphWidgetSpeed.setRangeLabelWidth(0);
    graphWidgetElev.setRangeLabelWidth(0);

    graphWidgetSpeed.setDomainLabelWidth(0);
    graphWidgetElev.setDomainLabelWidth(0);

    graphWidgetElev.setBackgroundPaint(null);
    graphWidgetElev.setDomainLabelPaint(null);
    graphWidgetElev.setGridBackgroundPaint(null);
    graphWidgetElev.setDomainOriginLabelPaint(null);
    graphWidgetElev.setRangeOriginLinePaint(null);
    graphWidgetElev.setDomainGridLinePaint(null);
    graphWidgetElev.setRangeGridLinePaint(null);

    graphWidgetSpeed.getBackgroundPaint().setColor(backgroundColor);
    graphWidgetSpeed.getGridBackgroundPaint().setColor(backgroundColor);

    graphWidgetSpeed.getRangeOriginLinePaint().setColor(decorationsColor);
    graphWidgetSpeed.getRangeOriginLinePaint().setStrokeWidth(3f);
    graphWidgetSpeed.getDomainOriginLinePaint().setColor(decorationsColor);
    graphWidgetSpeed.getDomainOriginLinePaint().setStrokeWidth(3f);

    graphWidgetSpeed.getRangeGridLinePaint().setColor(decorationsColor);
    graphWidgetSpeed.getRangeGridLinePaint().setStrokeWidth(1f);
    graphWidgetSpeed.getDomainGridLinePaint().setColor(decorationsColor);
    graphWidgetSpeed.getDomainGridLinePaint().setStrokeWidth(1f);

    graphWidgetSpeed.getRangeLabelPaint().setColor(textColor);
    graphWidgetSpeed.getDomainLabelPaint().setColor(textColor);
    graphWidgetSpeed.getDomainOriginLabelPaint().setColor(textColor);
    Paint rangeOriginLabelPaint = graphWidgetSpeed.getRangeOriginLabelPaint();
    if (rangeOriginLabelPaint == null) {
        rangeOriginLabelPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        rangeOriginLabelPaint.setStyle(Paint.Style.STROKE);
        graphWidgetSpeed.setRangeOriginLabelPaint(rangeOriginLabelPaint);
    }
    rangeOriginLabelPaint.setColor(textColor);

    graphWidgetSpeed.getRangeLabelPaint().setTextSize(PixelUtils.dpToPix(8));
    graphWidgetElev.getRangeLabelPaint().setTextSize(PixelUtils.dpToPix(8));

    graphWidgetSpeed.getDomainOriginLabelPaint().setTextSize(PixelUtils.dpToPix(8));
    graphWidgetSpeed.getDomainLabelPaint().setTextSize(PixelUtils.dpToPix(8));

    float textSize = graphWidgetSpeed.getRangeLabelPaint().getTextSize();
    graphWidgetSpeed.setRangeLabelVerticalOffset((textSize / 2) * -1);
    graphWidgetElev.setRangeLabelVerticalOffset(graphWidgetSpeed.getRangeLabelVerticalOffset());

    /*
     * Position the Graph Widgets in the Centre
     */
    graphWidgetSpeed.position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0, YLayoutStyle.ABSOLUTE_FROM_CENTER,
            AnchorPosition.CENTER);
    graphWidgetElev.position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0, YLayoutStyle.ABSOLUTE_FROM_CENTER,
            AnchorPosition.CENTER);

    /* 
     * Position the Label Widgets
     */
    xyPlotSpeed.getDomainLabelWidget().setWidth(100);
    xyPlotSpeed.getRangeLabelWidget().setWidth(100);
    xyPlotSpeed.getDomainLabelWidget().position(0, XLayoutStyle.RELATIVE_TO_CENTER, 1,
            YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.BOTTOM_MIDDLE);
    xyPlotSpeed.getRangeLabelWidget().position(1, XLayoutStyle.ABSOLUTE_FROM_LEFT, -20,
            YLayoutStyle.ABSOLUTE_FROM_CENTER, AnchorPosition.LEFT_BOTTOM);

    /*
     *  Setup and Position the speed Legend
     */
    XYLegendWidget legendWidgetSpeed = xyPlotSpeed.getLegendWidget();
    legendWidgetSpeed.setSize(new SizeMetrics(100, SizeLayoutType.ABSOLUTE, 200, SizeLayoutType.ABSOLUTE));
    legendWidgetSpeed.setPadding(1, 1, 1, 1);
    legendWidgetSpeed.setTableModel(new DynamicTableModel(1, 3));
    legendWidgetSpeed.setIconSizeMetrics(new SizeMetrics(PixelUtils.dpToPix(10), SizeLayoutType.ABSOLUTE,
            PixelUtils.dpToPix(10), SizeLayoutType.ABSOLUTE));
    legendWidgetSpeed.getTextPaint().setColor(textColor);
    legendWidgetSpeed.getTextPaint().setTextSize(PixelUtils.dpToPix(9));
    legendWidgetSpeed.position(PixelUtils.dpToPix(30), XLayoutStyle.ABSOLUTE_FROM_LEFT, f10 + 2,
            YLayoutStyle.ABSOLUTE_FROM_TOP, AnchorPosition.LEFT_TOP);

    /*
     *  Setup and Position the elev Legend
     */
    XYLegendWidget legendWidgetElev = xyPlotElev.getLegendWidget();
    legendWidgetElev.setSize(new SizeMetrics(100, SizeLayoutType.ABSOLUTE, 200, SizeLayoutType.ABSOLUTE));
    legendWidgetElev.setPadding(1, 1, 1, 1);
    legendWidgetElev.setTableModel(new DynamicTableModel(1, 3));
    legendWidgetElev.setIconSizeMetrics(new SizeMetrics(PixelUtils.dpToPix(10), SizeLayoutType.ABSOLUTE,
            PixelUtils.dpToPix(10), SizeLayoutType.ABSOLUTE));
    //        legendWidgetElev.getTextPaint().setColor(textColor);
    legendWidgetElev.getTextPaint().setTextSize(PixelUtils.dpToPix(9));
    legendWidgetElev.getTextPaint().setTextAlign(Align.RIGHT);
    legendWidgetElev.setMarginLeft(185);
    legendWidgetElev.position(PixelUtils.dpToPix(30), XLayoutStyle.ABSOLUTE_FROM_RIGHT, f10 + 2,
            YLayoutStyle.ABSOLUTE_FROM_TOP, AnchorPosition.RIGHT_TOP);

    // Setup the formatters
    int rgbSpeedLine = Color.rgb(0, 200, 0);
    int rgbSpeedPoints = Color.rgb(0, 100, 0);
    int rgbElevLine = Color.rgb(0, 0, 200);
    int rgbElevPoints = Color.rgb(0, 0, 100);

    seriesSpeedFormat = new LineAndPointFormatter(rgbSpeedLine, rgbSpeedPoints, null, null);
    seriesElevFormat = new LineAndPointFormatter(rgbElevLine, rgbElevPoints, null, null);

}

From source file:com.vinaysshenoy.okulus.OkulusImageView.java

/**
 * @param context//from   w  w  w  . j  a  v a 2 s  . com
 * @param attrs
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
private void init(Context context, AttributeSet attrs) {

    mViewRect = new Rect();
    mCornerRadius = dpToPx(DEFAULT_CORNER_RADIUS);
    float borderWidthInDips = DEFAULT_BORDER_WIDTH;
    mBorderColor = DEFAULT_BORDER_COLOR;
    mFullCircle = DEFAULT_FULL_CIRCLE;
    float shadowWidthInDips = DEFAULT_SHADOW_WIDTH;
    mShadowColor = DEFAULT_SHADOW_COLOR;
    mShadowRadius = DEFAULT_SHADOW_RADIUS;
    mTouchSelectorColor = DEFAULT_TOUCH_SELECTOR_COLOR;
    mTouchSelectorEnabled = DEFAULT_TOUCH_SELECTOR_ENABLED;

    if (attrs != null) {

        TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.OkulusImageView);
        mCornerRadius = styledAttrs.getDimension(R.styleable.OkulusImageView_cornerRadius, mCornerRadius);
        mBorderColor = styledAttrs.getColor(R.styleable.OkulusImageView_borderColor, mBorderColor);
        mFullCircle = styledAttrs.getBoolean(R.styleable.OkulusImageView_fullCircle, mFullCircle);
        mShadowColor = styledAttrs.getColor(R.styleable.OkulusImageView_shadowColor, mShadowColor);
        mShadowRadius = styledAttrs.getFloat(R.styleable.OkulusImageView_shadowRadius, mShadowRadius);
        mTouchSelectorColor = styledAttrs.getColor(R.styleable.OkulusImageView_touchSelectorColor,
                mTouchSelectorColor);
        mTouchSelectorEnabled = styledAttrs.getBoolean(R.styleable.OkulusImageView_touchSelectorEnabled,
                mTouchSelectorEnabled);

        float dimension = styledAttrs.getDimension(R.styleable.OkulusImageView_borderWidth, borderWidthInDips);
        borderWidthInDips = pxToDp(dimension);
        dimension = styledAttrs.getDimension(R.styleable.OkulusImageView_shadowWidth, shadowWidthInDips);
        shadowWidthInDips = pxToDp(dimension);

        styledAttrs.recycle();
    }

    clampBorderAndShadowWidths(borderWidthInDips, shadowWidthInDips);
    mBorderWidth = dpToPx(borderWidthInDips);
    mShadowWidth = dpToPx(shadowWidthInDips);

    if (mShadowWidth > 0f) {

        if (Build.VERSION.SDK_INT >= 14) {
            /* We need to set layer type for shadows to work
             * on ICS and above
             */
            setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }
    }
    setOkulusDrawable(null);

}

From source file:android.support.design.widget.FloatingActionButtonIcs.java

private void updateFromViewRotation() {
    if (Build.VERSION.SDK_INT == 19) {
        // KitKat seems to have an issue with views which are rotated with angles which are
        // not divisible by 90. Worked around by moving to software rendering in these cases.
        if ((mRotation % 90) != 0) {
            if (mView.getLayerType() != View.LAYER_TYPE_SOFTWARE) {
                mView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }/*from ww w . ja va 2  s . com*/
        } else {
            if (mView.getLayerType() != View.LAYER_TYPE_NONE) {
                mView.setLayerType(View.LAYER_TYPE_NONE, null);
            }
        }
    }

    // Offset any View rotation
    if (mShadowDrawable != null) {
        mShadowDrawable.setRotation(-mRotation);
    }
    if (mBorderDrawable != null) {
        mBorderDrawable.setRotation(-mRotation);
    }
}