List of usage examples for android.graphics Color GRAY
int GRAY
To view the source code for android.graphics Color GRAY.
Click Source Link
From source file:de.treichels.hott.ui.android.html.AndroidCurveImageGenerator.java
private Bitmap getBitmap(final Curve curve, final float scale, final boolean description) { final boolean pitchCurve = curve.getPoint()[0].getPosition() == 0; final float scale1 = scale * 0.75f; // smaller images on the android // platform// w w w .java2 s.c o m final Bitmap image = Bitmap.createBitmap((int) (10 + 200 * scale1), (int) (10 + 250 * scale1), Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(image); final Paint backgroundPaint = new Paint(); backgroundPaint.setColor(Color.WHITE); backgroundPaint.setStyle(Style.FILL); final Paint forgroundPaint = new Paint(); forgroundPaint.setColor(Color.BLACK); forgroundPaint.setStyle(Style.STROKE); forgroundPaint.setStrokeWidth(1.0f); forgroundPaint.setStrokeCap(Cap.BUTT); forgroundPaint.setStrokeJoin(Join.ROUND); forgroundPaint.setStrokeMiter(0.0f); final Paint curvePaint = new Paint(forgroundPaint); curvePaint.setFlags(Paint.ANTI_ALIAS_FLAG); curvePaint.setStrokeWidth(2.0f); final Paint pointPaint = new Paint(curvePaint); pointPaint.setStrokeWidth(5.0f); pointPaint.setStyle(Style.FILL_AND_STROKE); final Paint helpLinePaint = new Paint(forgroundPaint); helpLinePaint.setColor(Color.GRAY); helpLinePaint.setPathEffect(new DashPathEffect(new float[] { 5.0f, 5.0f }, 2.5f)); final Paint textPaint = new Paint(forgroundPaint); textPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD)); textPaint.setTextSize(12.0f); textPaint.setTextAlign(Align.CENTER); textPaint.setStyle(Style.FILL); canvas.drawRect(0, 0, 10 + 200 * scale1, 10 + 250 * scale1, backgroundPaint); canvas.drawRect(5, 5, 5 + 200 * scale1, 5 + 250 * scale1, forgroundPaint); canvas.drawLine(5, 5 + 25 * scale1, 5 + 200 * scale1, 5 + 25 * scale1, helpLinePaint); canvas.drawLine(5, 5 + 225 * scale1, 5 + 200 * scale1, 5 + 225 * scale1, helpLinePaint); if (!pitchCurve) { canvas.drawLine(5, 5 + 125 * scale1, 5 + 200 * scale1, 5 + 125 * scale1, helpLinePaint); canvas.drawLine(5 + 100 * scale1, 5, 5 + 100 * scale1, 5 + 250 * scale1, helpLinePaint); } if (curve.getPoint() != null) { int numPoints = 0; for (final CurvePoint p : curve.getPoint()) { if (p.isEnabled()) { numPoints++; } } final double[] xVals = new double[numPoints]; final double[] yVals = new double[numPoints]; int i = 0; for (final CurvePoint p : curve.getPoint()) { if (p.isEnabled()) { if (i == 0) { xVals[i] = pitchCurve ? 0 : -100; } else if (i == numPoints - 1) { xVals[i] = 100; } else { xVals[i] = p.getPosition(); } yVals[i] = p.getValue(); if (description) { float x0; float y0; if (pitchCurve) { x0 = (float) (5 + xVals[i] * 2 * scale1); y0 = (float) (5 + (225 - yVals[i] * 2) * scale1); } else { x0 = (float) (5 + (100 + xVals[i]) * scale1); y0 = (float) (5 + (125 - yVals[i]) * scale1); } canvas.drawPoint(x0, y0, pointPaint); if (y0 < 5 + 125 * scale1) { canvas.drawRect(x0 - 4, y0 + 5, x0 + 3, y0 + 18, backgroundPaint); canvas.drawText(Integer.toString(p.getNumber() + 1), x0 - 1, y0 + 16, textPaint); } else { canvas.drawRect(x0 - 4, y0 - 5, x0 + 3, y0 - 18, backgroundPaint); canvas.drawText(Integer.toString(p.getNumber() + 1), x0 - 1, y0 - 7, textPaint); } } i++; } } if (numPoints > 2 && curve.isSmoothing()) { final SplineInterpolator s = new SplineInterpolator(); final PolynomialSplineFunction function = s.interpolate(xVals, yVals); float x0 = 5; float y0; if (pitchCurve) { y0 = (float) (5 + (225 - yVals[0] * 2) * scale1); } else { y0 = (float) (5 + (125 - yVals[0]) * scale1); } while (x0 < 4 + 200 * scale1) { final float x1 = x0 + 1; float y1; if (pitchCurve) { y1 = (float) (5 + (225 - function.value((x1 - 5) / scale1 / 2) * 2) * scale1); } else { y1 = (float) (5 + (125 - function.value((x1 - 5) / scale1 - 100)) * scale1); } canvas.drawLine(x0, y0, x1, y1, curvePaint); x0 = x1; y0 = y1; } } else { for (i = 0; i < numPoints - 1; i++) { float x0, y0, x1, y1; if (pitchCurve) { x0 = (float) (5 + xVals[i] * 2 * scale1); y0 = (float) (5 + (225 - yVals[i] * 2) * scale1); x1 = (float) (5 + xVals[i + 1] * 2 * scale1); y1 = (float) (5 + (225 - yVals[i + 1] * 2) * scale1); } else { x0 = (float) (5 + (100 + xVals[i]) * scale1); y0 = (float) (5 + (125 - yVals[i]) * scale1); x1 = (float) (5 + (100 + xVals[i + 1]) * scale1); y1 = (float) (5 + (125 - yVals[i + 1]) * scale1); } canvas.drawLine(x0, y0, x1, y1, curvePaint); } } } return image; }
From source file:com.jjoe64.graphview_demos.fragments.SecondYAxis.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); GraphView graph = (GraphView) rootView.findViewById(R.id.graph); LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[] { new DataPoint(0, 1), new DataPoint(1, 5), new DataPoint(2, 3), new DataPoint(3, 2), new DataPoint(4, 6) }); graph.addSeries(series);/* w w w .jav a2 s. c o m*/ LineGraphSeries<DataPoint> series2 = new LineGraphSeries<DataPoint>(new DataPoint[] { new DataPoint(0, 30), new DataPoint(1, 30), new DataPoint(2, 60), new DataPoint(3, 20), new DataPoint(4, 50) }); graph.getGridLabelRenderer().setLabelFormatter( new StaticLabelsFormatter(graph, null, new String[] { "low", "middle", "high" })); // set second scale graph.getSecondScale().addSeries(series2); // the y bounds are always manual for second scale graph.getSecondScale().setMinY(0); graph.getSecondScale().setMaxY(100); series2.setColor(Color.RED); graph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(Color.RED); // legend series.setTitle("foo"); series2.setTitle("bar"); graph.getLegendRenderer().setVisible(true); graph.getLegendRenderer().setAlign(LegendRenderer.LegendAlign.TOP); graph.getViewport().setBackgroundColor(Color.GRAY); return rootView; }
From source file:com.cookbeans.boredapp.ui.fragment.SampleSlidingTabsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // BEGIN_INCLUDE (populate_tabs) /**/*from w w w . j a v a2 s . c o m*/ * Populate our tab list with tabs. Each item contains a title, indicator color and divider * color, which are used by {@link SlidingTabLayout}. */ mTabs.add(new SampleTabItem(SampleTabItem.POS_GANK, "?", // Title getResources().getColor(R.color.colorIndicator), // Indicator color // Color.WHITE, Color.GRAY, // Divider color getResources().getColor(R.color.colorPrimaryDark), getResources().getColor(R.color.colorPrimary), getResources().getColor(R.color.colorPrimaryDark))); mTabs.add(new SampleTabItem(SampleTabItem.POS_DANIU, "?", // Title getResources().getColor(R.color.colorIndicator), // Indicator color // Color.WHITE, Color.GRAY, // Divider color getResources().getColor(R.color.deepPurplePrimaryDark), getResources().getColor(R.color.deepPurplePrimary), getResources().getColor(R.color.deepPurplePrimaryDark))); mTabs.add(new SampleTabItem(SampleTabItem.POS_UNDIFINED_TOO, "?", // Title getResources().getColor(R.color.colorIndicator), // Indicator color // Color.WHITE, Color.GRAY, // Divider color getResources().getColor(R.color.pinkPrimaryDark), getResources().getColor(R.color.pinkPrimary), getResources().getColor(R.color.pinkPrimaryDark))); // END_INCLUDE (populate_tabs) }
From source file:com.simas.vc.editor.tree_view.AttributeTreeAdapter.java
private void selectView(final View view, final Object parentNode) { view.post(new Runnable() { @Override/*from w ww.j av a2s . co m*/ public void run() { mSelectedChildren.put(parentNode, view); view.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.DARKEN); } }); }
From source file:edu.cloud.iot.reception.ocr.ScanLicense.java
private void setUpCamera() { cameraView = new CameraSurfaceView(getApplicationContext()); cameraView.parent = this; cameraView.frontCameraRequired = true; // cameraView.setCameraDisplayOrientation(this,0);//Camera.CameraInfo.CAMERA_FACING_BACK); imageResult = new ImageView(getApplicationContext()); imageResult.setBackgroundColor(Color.GRAY); frameNew = (FrameLayout) findViewById(R.id.flCamera); snapPhoto = (Button) findViewById(R.id.bCapture); Log.v("FaceRecognitionActivity", "frameNew Value = " + frameNew); frameNew.addView(imageResult);/*from w ww.j a v a 2 s. c o m*/ frameNew.addView(cameraView); frameNew.bringChildToFront(cameraView); // asyncOCR.setParent(this); }
From source file:ch.kanti_baden.pu_marc_14b.traffictimewaste.SORT_TYPE.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_post_list, menu); // Disable create post button if user isn't logged in if (DatabaseLink.instance.isLoggedIn()) { MenuItem menuItem = menu.findItem(R.id.action_login); menuItem.setEnabled(false);//from w w w .j av a 2s. c om } else { MenuItem menuItem = menu.findItem(R.id.action_create); menuItem.setEnabled(false); Drawable icon = menuItem.getIcon(); icon.mutate().setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_IN); menuItem.setIcon(icon); } // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setOnSearchClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchView.setTranslationX(500f); searchView.setAlpha(0f); searchView.animate().translationX(0); searchView.animate().alpha(1f); } }); // Assumes current activity is the searchable activity searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); return true; }
From source file:ca.appvelopers.mcgillmobile.ui.walkthrough.WalkthroughAdapter.java
@Override public Object instantiateItem(ViewGroup collection, int position) { final Context context = collection.getContext(); View view;/*from w ww . j av a 2 s .c om*/ switch (position) { //Welcome case 0: view = View.inflate(context, R.layout.item_walkthrough_0, null); break; //Access Essentials case 1: view = View.inflate(context, R.layout.item_walkthrough_1, null); break; //Main Menu Explanation case 2: view = View.inflate(context, R.layout.item_walkthrough_2, null); break; // //Horizontal Schedule // case 3: // view = View.inflate(context, R.layout.item_walkthrough_3, null); // break; //Info case 3: view = View.inflate(context, R.layout.item_walkthrough_4, null); break; //Default HomepageManager / Faculty (first open only) case 4: view = View.inflate(context, R.layout.item_walkthrough_5, null); FormGenerator fg = FormGenerator.bind(context, (LinearLayout) view); //HomepageManager Prompt fg.text(R.string.walkthrough_homepage).gravity(Gravity.CENTER) .padding(context.getResources().getDimensionPixelOffset(R.dimen.padding_small)).build(); //HomepageManager fg.text(homepagePref.getTitleString()).leftIcon(R.drawable.ic_phone_android) .rightIcon(R.drawable.ic_chevron_right, Color.GRAY) .onClick(new TextViewFormItem.OnClickListener() { @Override public void onClick(final TextViewFormItem item) { DialogUtils.list(context, R.string.settings_homepage_title, new HomepageListAdapter(context) { @Override public void onHomepageSelected(@HomepageManager.Homepage int choice) { //Update it homepageManager.set(choice); item.view().setText(homepageManager.getTitleString()); analytics.sendEvent("Walkthrough", "HomepageManager", homepageManager.getString()); } }); } }).build(); //Faculty Prompt fg.text(R.string.walkthrough_faculty).gravity(Gravity.CENTER) .padding(context.getResources().getDimensionPixelOffset(R.dimen.padding_small)).build(); //Faculty fg.text(R.string.faculty_none).leftIcon(R.drawable.ic_mycourses) .rightIcon(R.drawable.ic_chevron_right, Color.GRAY) .onClick(new TextViewFormItem.OnClickListener() { @Override public void onClick(final TextViewFormItem item) { DialogUtils.list(context, R.string.faculty_title, new FacultyListAdapter(context, item.view().getText().toString()) { @Override public void onFacultySelected(String faculty) { //Update the view item.view().setText(faculty); //If the faculty is not empty, send the GA analytics.sendEvent("Walkthrough", "Faculty", faculty); } }); } }).build(); break; default: throw new IllegalStateException("Unknown position " + position + " in walkthrough"); } collection.addView(view); return view; }
From source file:com.nextgis.maplibui.formcontrol.AutoTextEdit.java
@Override public void init(JSONObject element, List<Field> fields, Bundle savedState, Cursor featureCursor, SharedPreferences preferences) throws JSONException { ControlHelper.setClearAction(this); JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY); mFieldName = attributes.getString(JSON_FIELD_NAME_KEY); mIsShowLast = ControlHelper.isSaveLastValue(attributes); mAllowSaveNewValue = attributes.optBoolean(JSON_ALLOW_NEW_VALUES); if (!ControlHelper.isEnabled(fields, mFieldName)) { setEnabled(false);/*from w w w . j a va2 s .c om*/ setTextColor(Color.GRAY); } String lastValue = null; if (ControlHelper.hasKey(savedState, mFieldName)) lastValue = savedState.getString(ControlHelper.getSavedStateKey(mFieldName)); else if (null != featureCursor) { int column = featureCursor.getColumnIndex(mFieldName); if (column >= 0) lastValue = featureCursor.getString(column); } else if (mIsShowLast) lastValue = preferences.getString(mFieldName, null); mAliasValueMap = new HashMap<>(); if (attributes.has(ConstantsUI.JSON_NGW_ID_KEY) && attributes.getLong(ConstantsUI.JSON_NGW_ID_KEY) != -1) { MapContentProviderHelper map = (MapContentProviderHelper) MapBase.getInstance(); if (null == map) throw new IllegalArgumentException("The map should extends MapContentProviderHelper or inherited"); String account = element.optString(SyncStateContract.Columns.ACCOUNT_NAME); long id = attributes.getLong(JSON_NGW_ID_KEY); for (int i = 0; i < map.getLayerCount(); i++) { if (map.getLayer(i) instanceof NGWLookupTable) { NGWLookupTable table = (NGWLookupTable) map.getLayer(i); if (table.getRemoteId() != id || !table.getAccountName().equals(account)) continue; for (Map.Entry<String, String> entry : table.getData().entrySet()) { mAliasValueMap.put(entry.getValue(), entry.getKey()); if (entry.getKey().equals(lastValue)) lastValue = entry.getValue(); } break; } } } else { JSONArray values = attributes.getJSONArray(JSON_VALUES_KEY); for (int j = 0; j < values.length(); j++) { JSONObject keyValue = values.getJSONObject(j); String value = keyValue.getString(JSON_VALUE_NAME_KEY); String alias = keyValue.getString(JSON_VALUE_ALIAS_KEY); mAliasValueMap.put(alias, value); if (value.equals(lastValue)) lastValue = alias; } } setText(lastValue); mAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_dropdown_item, new ArrayList<>(mAliasValueMap.keySet())); setAdapter(mAdapter); setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus && getText().length() == 0) { postDelayed(new Runnable() { @Override public void run() { showDropDown(); } }, 100); } } }); addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { if (charSequence.length() < 1) getOnFocusChangeListener().onFocusChange(AutoTextEdit.this, true); } @Override public void afterTextChanged(Editable editable) { } }); }
From source file:com.alex.view.loop.IndicatorView.java
public IndicatorView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // ?/* w w w .j av a 2s . com*/ TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.IndicatorView); normalBp = drawableToBitamp(ta.getDrawable(R.styleable.IndicatorView_normalDrawable)); selectBp = drawableToBitamp(ta.getDrawable(R.styleable.IndicatorView_selectDrawable)); mInterval = ta.getDimensionPixelOffset(R.styleable.IndicatorView_indicatorInterval, 6); normalColor = ta.getColor(R.styleable.IndicatorView_normalColor, Color.GRAY); selectColor = ta.getColor(R.styleable.IndicatorView_selectColor, Color.RED); mRadius = ta.getInteger(R.styleable.IndicatorView_indicatorRadius, 6); isCirculate = ta.getBoolean(R.styleable.IndicatorView_isCirculate, true); ta.recycle(); // ? init(); }
From source file:client.smrtms.com.smrtms_client.fragment.TabsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // BEGIN_INCLUDE (populate_tabs) /**//from w w w. j ava 2s .c o m * Populate our tab list with tabs. Each item contains a title, indicator color and divider * color, which are used by {@link SlidingTabLayout}. */ mTabs.add(new PagerItem(getString(R.string.tab_map), // Title Color.BLUE, // Indicator color Color.GRAY // Divider color )); mTabs.add(new PagerItem(getString(R.string.tab_contacts), // Title Color.YELLOW, // Indicator color Color.GRAY // Divider color )); mTabs.add(new PagerItem(getString(R.string.tab_events), // Title Color.GREEN, // Indicator color Color.GRAY // Divider color )); // END_INCLUDE (populate_tabs) }