List of usage examples for android.graphics Color WHITE
int WHITE
To view the source code for android.graphics Color WHITE.
Click Source Link
From source file:net.networksaremadeofstring.rhybudd.RhybuddDock.java
private void drawGaugeNeedle(Canvas canvas, int count, int Scale) { canvas.save(Canvas.MATRIX_SAVE_FLAG); float divisor = 360.0f / Scale; canvas.rotate((float) (divisor * count), 100, 100); //Inside//from www.ja v a 2 s . c o m Paint needleInsidePaint = new Paint(); needleInsidePaint.setStyle(Paint.Style.FILL_AND_STROKE); needleInsidePaint.setColor(Color.WHITE); needleInsidePaint.setStrokeWidth(4); needleInsidePaint.setAntiAlias(true); Paint needleEdgePaint = new Paint(); needleEdgePaint.setStyle(Paint.Style.STROKE); needleEdgePaint.setColor(Color.DKGRAY); needleEdgePaint.setStrokeWidth(0.5f); needleEdgePaint.setAntiAlias(true); canvas.drawOval(new RectF(95, 95, 105, 105), needleInsidePaint); canvas.drawOval(new RectF(95, 96, 105, 105), needleEdgePaint); Path needleInside = new Path(); needleInside.moveTo(98, 98); needleInside.lineTo(100, 20); needleInside.lineTo(102, 102); canvas.drawPath(needleInside, needleInsidePaint); Path needleEdge = new Path(); needleInside.moveTo(99, 99); needleInside.lineTo(99, 19); needleInside.lineTo(103, 103); canvas.drawPath(needleEdge, needleEdgePaint); canvas.restore(); }
From source file:com.dynamixsoftware.printingsample.IntentApiFragment.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.check_premium: new AlertDialog.Builder(requireContext()).setTitle(R.string.check_premium) .setMessage("" + intentApi.checkPremium()).setPositiveButton(R.string.ok, null).show(); break;/*from w ww . j a v a2 s .co m*/ case R.id.activate_online: final Context appContext = requireContext().getApplicationContext(); intentApi.setLicense("YOUR_ACTIVATION_KEY", new ISetLicenseCallback.Stub() { @Override public void start() { toastInMainThread(appContext, "activate start"); } @Override public void serverCheck() { toastInMainThread(appContext, "activate check server"); } @Override public void finish(final Result arg0) { toastInMainThread(appContext, "activate finish " + (arg0 == Result.OK ? "ok" : "error")); } }); break; case R.id.setup_printer: intentApi.setupCurrentPrinter(); break; case R.id.change_options: intentApi.changePrinterOptions(); break; case R.id.get_current_printer: try { IPrinterInfo printer = intentApi.getCurrentPrinter(); Toast.makeText(requireContext().getApplicationContext(), "current printer " + (printer != null ? printer.getName() : "null"), Toast.LENGTH_LONG) .show(); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.print_image: intentApi.print(Uri.parse("file://" + FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG)), "image/png", "from printing sample"); break; case R.id.print_file: intentApi.print(Uri.parse("file://" + FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_DOC)), "application/msword", "from printing sample"); break; case R.id.show_file_preview: intentApi.showFilePreview( Uri.parse("file://" + FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_DOC)), "application/msword", 0); break; case R.id.print_with_your_rendering: try { IDocument.Stub document = new IDocument.Stub() { private int thumbnailWidth; private int thumbnailHeight; @Override public Bitmap renderPageFragment(int arg0, Rect fragment) throws RemoteException { IPrinterInfo printer = intentApi.getCurrentPrinter(); if (printer != null) { Bitmap bitmap = Bitmap.createBitmap(fragment.width(), fragment.height(), Bitmap.Config.ARGB_8888); for (int i = 0; i < 3; i++) try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; options.inDither = false; if (i > 0) { options.inSampleSize = 1 << i; } Bitmap imageBMP = BitmapFactory.decodeStream( new FileInputStream( FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG)), null, options); Paint p = new Paint(); int imageWidth = 0; int imageHeight = 0; if (imageBMP != null) { imageWidth = imageBMP.getWidth(); imageHeight = imageBMP.getHeight(); } int xDpi = printer.getPrinterContext().getHResolution(); int yDpi = printer.getPrinterContext().getVResolution(); // in dots int paperWidth = printer.getPrinterContext().getPaperWidth() * xDpi / 72; int paperHeight = printer.getPrinterContext().getPaperHeight() * yDpi / 72; float aspectH = (float) imageHeight / (float) paperHeight; float aspectW = (float) imageWidth / (float) paperWidth; aspectH = aspectH > 1 ? 1 / aspectH : aspectH; aspectW = aspectW > 1 ? 1 / aspectW : aspectW; RectF dst = new RectF(0, 0, fragment.width() * aspectW, fragment.height() * aspectH); float sLeft = 0; float sTop = fragment.top * aspectH; float sRight = imageWidth; float sBottom = fragment.top * aspectH + fragment.bottom * aspectH; RectF source = new RectF(sLeft, sTop, sRight, sBottom); Canvas canvas = new Canvas(bitmap); canvas.drawColor(Color.WHITE); // move image to actual printing area dst.offsetTo(dst.left - fragment.left, dst.top - fragment.top); Matrix matrix = new Matrix(); matrix.setRectToRect(source, dst, Matrix.ScaleToFit.FILL); canvas.drawBitmap(imageBMP, matrix, p); break; } catch (IOException ex) { ex.printStackTrace(); break; } catch (OutOfMemoryError ex) { if (bitmap != null) { bitmap.recycle(); bitmap = null; } continue; } return bitmap; } else { return null; } } @Override public void initDeviceContext(IPrinterContext printerContext, int thumbnailWidth, int thumbnailHeight) { this.thumbnailWidth = thumbnailWidth; this.thumbnailHeight = thumbnailHeight; } @Override public int getTotalPages() { return 1; } @Override public String getDescription() { return "PrintHand test page"; } @Override public Bitmap getPageThumbnail(int arg0) throws RemoteException { Bitmap bitmap = Bitmap.createBitmap(thumbnailWidth, thumbnailHeight, Bitmap.Config.ARGB_8888); for (int i = 0; i < 3; i++) try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; options.inDither = false; if (i > 0) { options.inSampleSize = 1 << i; } Bitmap imageBMP = BitmapFactory.decodeStream( new FileInputStream( FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG)), null, options); Paint p = new Paint(); int imageWidth = 0; int imageHeight = 0; if (imageBMP != null) { imageWidth = imageBMP.getWidth(); imageHeight = imageBMP.getHeight(); } // default int paperWidth = 2481; int paperHeight = 3507; IPrinterInfo printer = intentApi.getCurrentPrinter(); if (printer != null) { int xDpi = printer.getPrinterContext().getHResolution(); int yDpi = printer.getPrinterContext().getVResolution(); // in dots paperWidth = printer.getPrinterContext().getPaperWidth() * xDpi / 72; paperHeight = printer.getPrinterContext().getPaperHeight() * yDpi / 72; } float aspectW = (float) imageWidth / (float) paperWidth; float aspectH = (float) imageHeight / (float) paperHeight; RectF dst = new RectF(0, 0, thumbnailWidth * aspectW, thumbnailHeight * aspectH); float sLeft = 0; float sTop = 0; float sRight = imageWidth; float sBottom = imageHeight; RectF source = new RectF(sLeft, sTop, sRight, sBottom); Canvas canvas = new Canvas(bitmap); canvas.drawColor(Color.WHITE); Matrix matrix = new Matrix(); matrix.setRectToRect(source, dst, Matrix.ScaleToFit.FILL); canvas.drawBitmap(imageBMP, matrix, p); break; } catch (IOException ex) { ex.printStackTrace(); break; } catch (OutOfMemoryError ex) { if (bitmap != null) { bitmap.recycle(); bitmap = null; } continue; } return bitmap; } }; intentApi.print(document); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.print_with_your_rendering_without_ui: try { IJob.Stub job = new IJob.Stub() { @Override public Bitmap renderPageFragment(int num, Rect fragment) throws RemoteException { IPrinterInfo printer = intentApi.getCurrentPrinter(); if (printer != null) { Bitmap bitmap = Bitmap.createBitmap(fragment.width(), fragment.height(), Bitmap.Config.ARGB_8888); for (int i = 0; i < 3; i++) try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; options.inDither = false; if (i > 0) { options.inSampleSize = 1 << i; } Bitmap imageBMP = BitmapFactory.decodeStream( new FileInputStream( FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG)), null, options); Paint p = new Paint(); int imageWidth = 0; int imageHeight = 0; if (imageBMP != null) { imageWidth = imageBMP.getWidth(); imageHeight = imageBMP.getHeight(); } int xDpi = printer.getPrinterContext().getHResolution(); int yDpi = printer.getPrinterContext().getVResolution(); // in dots int paperWidth = printer.getPrinterContext().getPaperWidth() * xDpi / 72; int paperHeight = printer.getPrinterContext().getPaperHeight() * yDpi / 72; float aspectH = (float) imageHeight / (float) paperHeight; float aspectW = (float) imageWidth / (float) paperWidth; RectF dst = new RectF(0, 0, fragment.width() * aspectW, fragment.height() * aspectH); float sLeft = 0; float sTop = fragment.top * aspectH; float sRight = imageWidth; float sBottom = fragment.top * aspectH + fragment.bottom * aspectH; RectF source = new RectF(sLeft, sTop, sRight, sBottom); Canvas canvas = new Canvas(bitmap); canvas.drawColor(Color.WHITE); // move image to actual printing area dst.offsetTo(dst.left - fragment.left, dst.top - fragment.top); Matrix matrix = new Matrix(); matrix.setRectToRect(source, dst, Matrix.ScaleToFit.FILL); canvas.drawBitmap(imageBMP, matrix, p); break; } catch (IOException ex) { ex.printStackTrace(); break; } catch (OutOfMemoryError ex) { if (bitmap != null) { bitmap.recycle(); bitmap = null; } continue; } return bitmap; } else { return null; } } @Override public int getTotalPages() { return 1; } }; intentApi.print(job, 1); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.print_image_with_print_hand_rendering_without_ui: try { intentApi.print("PrintingSample", "image/png", Uri.parse("file://" + FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG))); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.change_image_options: try { List<PrintHandOption> imageOptions = intentApi.getImagesOptions(); changeRandomOption(imageOptions); intentApi.setImagesOptions(imageOptions); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.print_file_with_print_hand_rendering_without_ui: try { intentApi.print("PrintingSample", "application/ms-word", Uri.parse("file://" + FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_DOC))); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.print_protected_file_with_print_hand_rendering_without_ui: try { intentApi.print("PrintingSample", "application/pdf", Uri.parse("file://" + FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PDF))); } catch (RemoteException e) { e.printStackTrace(); } break; case R.id.change_files_options: try { List<PrintHandOption> fileOptions = intentApi.getFilesOptions(); changeRandomOption(fileOptions); intentApi.setFilesOptions(fileOptions); } catch (RemoteException e) { e.printStackTrace(); } break; } }
From source file:com.dmitrymalkovich.android.githubanalytics.traffic.TrafficFragment.java
@SuppressWarnings("deprecation") private void chartStyling(LineChart chart) { chart.setTouchEnabled(false);/*from w w w . j av a 2 s. com*/ chart.setDescription(""); chart.setAutoScaleMinMaxEnabled(false); chart.setNoDataTextColor( SettingsActivity.ThemePreferenceFragment.isLight(getContext()) ? Color.BLACK : Color.WHITE); YAxis axisRight = chart.getAxisRight(); axisRight.setEnabled(false); chart.getLegend().setEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { chart.setNestedScrollingEnabled(false); } XAxis xAxis = chart.getXAxis(); chartXAxisStyling(xAxis); YAxis yAxis = chart.getAxisLeft(); chartYAxisStyling(yAxis); }
From source file:eu.sathra.SathraActivity.java
/** * Hides or shows FPS counter in the top left of the screen. * /*from w w w .j a va 2 s . c o m*/ * @param show * If true, FPS counter will be shown */ public void showFPS(boolean show) { if (mFPSCounterView == null) { mFPSCounterView = new TextView(this); mFPSCounterView.setTextSize(FPS_VIEW_TEXT_SIZE); mFPSCounterView.setTextColor(Color.WHITE); ((ViewGroup) findViewById(android.R.id.content)).addView(mFPSCounterView); } if (show) mFPSCounterView.post(mFPSCounterUpdater); mFPSCounterView.setVisibility(show ? View.VISIBLE : View.INVISIBLE); }
From source file:com.paic.zhifu.wallet.activity.modules.creditpayment.RealNameSignUpApplyActivity.java
private void enableApplyBtn() { signUpApplyBtn.setEnabled(true); signUpApplyBtn.setBackgroundResource(R.drawable.normal_btn); signUpApplyBtn.setTextColor(Color.WHITE); }
From source file:com.coinblesk.client.utils.UIUtils.java
private static SpannableString coinFiatSpannable(Context context, String amountFirst, String codeFirst, String amountSecond, String codeSecond, float secondaryRelativeSize) { if (amountFirst == null) amountFirst = ""; if (codeFirst == null) codeFirst = ""; if (amountSecond == null) amountSecond = ""; if (codeSecond == null) codeSecond = ""; StringBuffer resultBuffer = new StringBuffer(); resultBuffer.append(amountFirst).append(" "); int lenFirstAmount = resultBuffer.length(); resultBuffer.append(codeFirst);/*from w ww.j ava 2s. com*/ int lenFirstCode = resultBuffer.length(); resultBuffer.append(" ").append(amountSecond).append(" ").append(codeSecond); int lenSecond = resultBuffer.length(); SpannableString formattedString = new SpannableString(resultBuffer); formattedString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, lenFirstAmount, 0); formattedString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.colorAccent)), lenFirstAmount, lenFirstCode, 0); formattedString.setSpan(new RelativeSizeSpan(secondaryRelativeSize), lenFirstAmount, lenFirstCode, 0); formattedString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.main_color_400)), lenFirstCode, lenSecond, 0); formattedString.setSpan(new RelativeSizeSpan(secondaryRelativeSize), lenFirstCode, lenSecond, 0); return formattedString; }
From source file:com.hypodiabetic.happ.MainActivity.java
public void checkInsulinAppIntegration(View view) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.getInstace()); Date now = new Date(); Profile p = new Profile(now, MainActivity.getInstace()); //Local device based Integrations String insulin_Integration_App = prefs.getString("insulin_integration", ""); //Insulin Integration App, try and connect if (!insulin_Integration_App.equals("")) { final InsulinIntegrationApp insulinIntegrationApp = new InsulinIntegrationApp(MainActivity.getInstace(), insulin_Integration_App, "TEST"); insulinIntegrationApp.connectInsulinTreatmentApp(); insulinIntegrationApp_status.setText("Connecting..."); insulinIntegrationApp_icon.setBackground(clockWhite); insulinIntegrationApp_icon.setColorFilter(Color.WHITE); //listens out for connection insulinIntegrationAppUpdate = new BroadcastReceiver() { @Override/* w ww.jav a 2 s.c om*/ public void onReceive(Context context, Intent intent) { insulinIntegrationApp_status.setText(intent.getStringExtra("MSG")); insulinIntegrationApp_icon.setBackground(tickWhite); insulinIntegrationApp.sendTest(); LocalBroadcastManager.getInstance(MainActivity.getInstace()) .unregisterReceiver(insulinIntegrationAppUpdate); } }; LocalBroadcastManager.getInstance(MainActivity.getInstace()) .registerReceiver(insulinIntegrationAppUpdate, new IntentFilter("INSULIN_INTEGRATION_TEST")); } else { insulinIntegrationApp_status.setText("No app selected or not in Closed Loop"); insulinIntegrationApp_icon.setBackgroundResource(R.drawable.alert_circle); } }
From source file:com.am.pagergradienttab.view.PagerGradientTabStrip.java
/** * /*from w ww . ja v a 2 s. com*/ * * @param canvas */ private void drawTag(Canvas canvas) { // TODO if (mTagAdapter != null) { canvas.save(); float canvasOffset = 0; int x = getPaddingLeft(); int y = getPaddingTop(); float textTop = 0; mTextPaint.setColor(Color.WHITE); mTextPaint.setTextAlign(Align.LEFT); for (int position = 0; position < tabs.size(); position++) { canvas.translate(canvasOffset, 0); canvasOffset = itemWidth + intervalWidth; canvas.save(); if (mTagAdapter.isEnable(position)) { int textWidth; int textHeight; mTextPaint.setTextSize(mTagAdapter.getTextSize(position)); String tag = mTagAdapter.getTag(position) == null ? "" : mTagAdapter.getTag(position); textWidth = (int) Math.ceil(mTextPaint.measureText(tag)); FontMetrics fontMetrics = mTextPaint.getFontMetrics(); textHeight = (int) Math.ceil(fontMetrics.descent - fontMetrics.ascent); textTop = textHeight - (-fontMetrics.ascent - fontMetrics.descent + (fontMetrics.bottom - fontMetrics.descent) * density); textHeight += textTop; if ("".equals(tag)) { textHeight = 0; } final Drawable drawable = mTagAdapter.getBackground(position); int drawableWidth = drawable == null ? 0 : drawable.getMinimumWidth(); int drawableHeight = drawable == null ? 0 : drawable.getMinimumHeight(); float offsetX = Math.max(textWidth + mTagAdapter.getPaddingLeft(position) + mTagAdapter.getPaddingRight(position), drawableWidth); float offsetTextX = (offsetX - (textWidth + mTagAdapter.getPaddingLeft(position) + mTagAdapter.getPaddingRight(position))) * 0.5f; float offsetY = Math.max(textHeight + mTagAdapter.getPaddingBottom(position) + mTagAdapter.getPaddingTop(position), drawableHeight); float offsetTextY = (offsetY - (textHeight + mTagAdapter.getPaddingBottom(position) + mTagAdapter.getPaddingTop(position))) * 0.5f; mTextPaint.setTextSize(showTextScale ? textSize * (1 + magnification) : textSize); float myTextWidth = mTextPaint.measureText(tabs.get(position)); TagAlign ta = mTagAdapter.getTagAlign(position); switch (ta) { default: case LEFTTOP: canvas.translate(mTagAdapter.getMarginLeft(position), mTagAdapter.getMarginTop(position)); break; case LEFTCENTER: canvas.translate(mTagAdapter.getMarginLeft(position), (getHeight() - underLineHeight - offsetY) / 2); break; case LEFTBOTTOM: canvas.translate(mTagAdapter.getMarginLeft(position), getHeight() - offsetY - underLineHeight - mTagAdapter.getMarginBottom(position)); break; case RIGHTTOP: canvas.translate(itemWidth - offsetX - mTagAdapter.getMarginRight(position), mTagAdapter.getMarginTop(position)); break; case RIGHTCENTER: canvas.translate(itemWidth - offsetX - mTagAdapter.getMarginRight(position), (getHeight() - underLineHeight - offsetY) / 2); break; case RIGHTBOTTOM: canvas.translate(itemWidth - offsetX - mTagAdapter.getMarginRight(position), getHeight() - offsetY - underLineHeight - mTagAdapter.getMarginBottom(position)); break; case LEFTTOPTEXT: canvas.translate( (itemWidth - myTextWidth) / 2 - offsetX - mTagAdapter.getMarginRight(position), mTagAdapter.getMarginTop(position)); break; case LEFTCENTERTEXT: canvas.translate( (itemWidth - myTextWidth) / 2 - offsetX - mTagAdapter.getMarginRight(position), (getHeight() - underLineHeight - offsetY) / 2); break; case LEFTBOTTOMTEXT: canvas.translate( (itemWidth - myTextWidth) / 2 - offsetX - mTagAdapter.getMarginRight(position), getHeight() - offsetY - underLineHeight - mTagAdapter.getMarginBottom(position)); break; case RIGHTTOPTEXT: canvas.translate((itemWidth + myTextWidth) / 2 + mTagAdapter.getMarginLeft(position), mTagAdapter.getMarginTop(position)); break; case RIGHTCENTERTEXT: canvas.translate((itemWidth + myTextWidth) / 2 + mTagAdapter.getMarginLeft(position), (getHeight() - underLineHeight - offsetY) / 2); break; case RIGHTBOTTOMTEXT: canvas.translate((itemWidth + myTextWidth) / 2 + mTagAdapter.getMarginLeft(position), getHeight() - offsetY - underLineHeight - mTagAdapter.getMarginBottom(position)); break; } mTextPaint.setTextSize(mTagAdapter.getTextSize(position)); if (drawable != null) { drawable.setBounds(x, y, (int) (x + offsetX), (int) (y + offsetY)); drawable.draw(canvas); } canvas.drawText(tag, x + offsetTextX + mTagAdapter.getPaddingLeft(position), y + offsetY - textTop - offsetTextY - mTagAdapter.getPaddingTop(position), mTextPaint); } canvas.restore(); } canvas.restore(); } }
From source file:com.color.kid.kidpaint.activity.OptionsActivity.java
protected void initialiseNewBitmap(Drawable drawable) { Display display = getWindowManager().getDefaultDisplay(); float width = display.getWidth(); float height = display.getHeight(); Bitmap bitmap = Bitmap.createBitmap((int) width + 200, (int) height, Bitmap.Config.ARGB_8888); bitmap.eraseColor(Color.WHITE); PaintroidApplication.drawingSurface// w w w . j a va2s . c om .resetBitmap(Util.overlay(bitmap, Util.drawableToBitmap(drawable, this))); PaintroidApplication.perspective.resetScaleAndTranslation(); mCurrentTool = new DrawTool(this, ToolType.BRUSH); PaintroidApplication.currentTool = mCurrentTool; PaintroidApplication.currentTool.resetInternalState(Tool.StateChange.NEW_IMAGE_LOADED); PaintroidApplication.isPlainImage = true; PaintroidApplication.isSaved = false; PaintroidApplication.savedPictureUri = null; }
From source file:co.dilaver.quoter.activities.ShareActivity.java
private int getContrastColor(int color) { double y = (299 * Color.red(color) + 587 * Color.green(color) + 114 * Color.blue(color)) / 1000; return y >= 128 ? Color.BLACK : Color.WHITE; }