List of usage examples for android.graphics Color HSVToColor
@ColorInt public static int HSVToColor(@IntRange(from = 0, to = 255) int alpha, @Size(3) float hsv[])
From source file:com.example.google.maps.flyover.MainActivity.java
private void setUpMap() { mMap.setIndoorEnabled(false);//from ww w .ja v a2 s .com // Disable gestures & controls since ideal results (pause Animator) is // not easy to show in a simplified example. mMap.getUiSettings().setAllGesturesEnabled(false); mMap.getUiSettings().setZoomControlsEnabled(false); // Create a marker to represent the user on the route. mMarker = mMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)).position(ROUTE[0])); // Create a polyline for the route. mMap.addPolyline( new PolylineOptions().add(ROUTE) .color(Color.HSVToColor(POLYLINE_ALPHA, new float[] { POLYLINE_HUE, POLYLINE_SATURATION, POLYLINE_VALUE })) .width(POLYLINE_WIDTH)); // Once the map is ready, zoom to the beginning of the route start the // animation. mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() { @Override public void onMapLoaded() { // Once the camera has moved to the beginning of the route, // start the animation. mMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition position) { mMap.setOnCameraChangeListener(null); animateRoute(); } }); // Animate the camera to the beginning of the route. float bearing = (float) SphericalUtil.computeHeading(ROUTE[0], ROUTE[1]); CameraPosition pos = new CameraPosition.Builder().target(ROUTE[0]).zoom(CAMERA_OBLIQUE_ZOOM) .tilt(CAMERA_OBLIQUE_TILT).bearing(bearing).build(); mMap.animateCamera(CameraUpdateFactory.newCameraPosition(pos)); } }); // Move the camera over the start position. CameraPosition pos = new CameraPosition.Builder().target(ROUTE[0]).zoom(CAMERA_OBLIQUE_ZOOM - 2).build(); mMap.moveCamera(CameraUpdateFactory.newCameraPosition(pos)); }
From source file:com.cyrilmottier.android.polaris2demo.PolygonDemoActivity.java
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (mMutablePolygon == null) { return;/*from w w w. j a v a 2s. c om*/ } if (seekBar == mColorBar) { mMutablePolygon.setFillColor( Color.HSVToColor(Color.alpha(mMutablePolygon.getFillColor()), new float[] { progress, 1, 1 })); } else if (seekBar == mAlphaBar) { int prevColor = mMutablePolygon.getFillColor(); mMutablePolygon.setFillColor( Color.argb(progress, Color.red(prevColor), Color.green(prevColor), Color.blue(prevColor))); } else if (seekBar == mWidthBar) { mMutablePolygon.setStrokeWidth(progress); } }
From source file:com.example.google.maps.dataviz.MainActivity.java
private void setUpMap() { mRoute = PolyUtil.decode(ROUTE);// w w w . j a va 2 s . c om // Create a polyline for the route. mMap.addPolyline( new PolylineOptions().addAll(mRoute) .color(Color.HSVToColor(POLYLINE_ALPHA, new float[] { POLYLINE_HUE, POLYLINE_SATURATION, POLYLINE_VALUE })) .width(POLYLINE_WIDTH)); mMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition position) { mMap.setOnCameraChangeListener(null); // Move the camera to show the entire route. LatLngBounds.Builder builder = LatLngBounds.builder(); for (LatLng coords : mRoute) { builder.include(coords); } mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 100)); mInitZoom = mMap.getCameraPosition().zoom; mInitPosition = mMap.getCameraPosition().target; } }); mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() { @Override public void onMapLoaded() { addDataToMap(); } }); }
From source file:de.quist.app.maps.example.CircleDemoActivity.java
@Override public void onMapReady(Map map) { mMap = map;/*from w w w.j a v a2s. c o m*/ // Override the default content description on the view, for accessibility mode. // Ideally this string would be localised. map.setContentDescription("Google Map with circles."); mColorBar.setOnSeekBarChangeListener(this); mAlphaBar.setOnSeekBarChangeListener(this); mWidthBar.setOnSeekBarChangeListener(this); mMap.setOnMarkerDragListener(this); mMap.setOnMapLongClickListener(this); mFillColor = Color.HSVToColor(mAlphaBar.getProgress(), new float[] { mColorBar.getProgress(), 1, 1 }); mStrokeColor = Color.BLACK; DraggableCircle circle = new DraggableCircle(SYDNEY, DEFAULT_RADIUS); mCircles.add(circle); // Move the map so that it is centered on the initial circle mMap.moveCamera(BuildConfig.MAP_BINDING.cameraUpdateFactory().newLatLngZoom(SYDNEY, 4.0f)); }
From source file:com.cyrilmottier.android.polaris2demo.CircleDemoActivity.java
private void setUpMap() { mColorBar.setOnSeekBarChangeListener(this); mAlphaBar.setOnSeekBarChangeListener(this); mWidthBar.setOnSeekBarChangeListener(this); mMap.setOnMarkerDragListener(this); mMap.setOnMapLongClickListener(this); mFillColor = Color.HSVToColor(mAlphaBar.getProgress(), new float[] { mColorBar.getProgress(), 1, 1 }); mStrokeColor = Color.BLACK;/* w w w .j a va 2 s.com*/ DraggableCircle circle = new DraggableCircle(SYDNEY, DEFAULT_RADIUS); mCircles.add(circle); // Move the map so that it is centered on the initial circle mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY, 4.0f)); }
From source file:de.vanita5.twittnuker.view.ColorPickerView.java
@Override public boolean onTouchEvent(final MotionEvent event) { boolean update = false; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mStartTouchPoint = new Point((int) event.getX(), (int) event.getY()); update = moveTrackersIfNeeded(event); break;/* ww w. jav a2 s. c om*/ case MotionEvent.ACTION_MOVE: update = moveTrackersIfNeeded(event); break; case MotionEvent.ACTION_UP: mStartTouchPoint = null; update = moveTrackersIfNeeded(event); break; } if (update) { if (mOnColorChangedListener != null) { final int color; if (mShowAlphaPanel) { color = Color.HSVToColor(mAlpha, new float[] { mHue, mSat, mVal }); } else { color = Color.HSVToColor(new float[] { mHue, mSat, mVal }); } mOnColorChangedListener.onColorChanged(color); } invalidate(); return true; } return super.onTouchEvent(event); }
From source file:com.cyrilmottier.android.polaris2demo.CircleDemoActivity.java
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (seekBar == mColorBar) { mFillColor = Color.HSVToColor(Color.alpha(mFillColor), new float[] { progress, 1, 1 }); } else if (seekBar == mAlphaBar) { mFillColor = Color.argb(progress, Color.red(mFillColor), Color.green(mFillColor), Color.blue(mFillColor)); }/*from w ww .j a va 2 s. c o m*/ for (DraggableCircle draggableCircle : mCircles) { draggableCircle.onStyleChange(); } }
From source file:com.dwdesign.tweetings.fragment.DMConversationFragment.java
@Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { if (mSendButton == null || s == null) return;// w ww .j ava 2s .c o m mSendButton.setEnabled(mValidator.isValidTweet(s.toString())); if (mTextCount != null) { final int acount = mValidator.getTweetLength(s.toString()); final float hue = acount < 140 ? acount >= 130 ? 5 * (140 - acount) : 50 : 0; final float[] hsv = new float[] { hue, 1.0f, 1.0f }; mTextCount.setTextColor(acount >= 130 ? Color.HSVToColor(0x80, hsv) : 0x80808080); mTextCount.setText(parseString(140 - acount)); } }
From source file:de.vanita5.twittnuker.view.ColorPickerView.java
@Override public boolean onTrackballEvent(final MotionEvent event) { final float x = event.getX(), y = event.getY(); boolean update = false; if (event.getAction() == MotionEvent.ACTION_MOVE) { switch (mLastTouchedPanel) { case PANEL_SAT_VAL: { float sat, val; sat = mSat + x / 50f;/*www. ja va2 s. c o m*/ val = mVal - y / 50f; if (sat < 0f) { sat = 0f; } else if (sat > 1f) { sat = 1f; } if (val < 0f) { val = 0f; } else if (val > 1f) { val = 1f; } mSat = sat; mVal = val; update = true; break; } case PANEL_HUE: { float hue = mHue - y * 10f; if (hue < 0f) { hue = 0f; } else if (hue > 360f) { hue = 360f; } mHue = hue; update = true; break; } case PANEL_ALPHA: { if (!mShowAlphaPanel || mAlphaRect == null) { update = false; } else { int alpha = (int) (mAlpha - x * 10); if (alpha < 0) { alpha = 0; } else if (alpha > 0xff) { alpha = 0xff; } mAlpha = alpha; update = true; } break; } } } if (update) { final int color; if (mShowAlphaPanel) { color = Color.HSVToColor(mAlpha, new float[] { mHue, mSat, mVal }); } else { color = Color.HSVToColor(new float[] { mHue, mSat, mVal }); } if (mOnColorChangedListener != null) { mOnColorChangedListener.onColorChanged(color); } invalidate(); return true; } return super.onTrackballEvent(event); }
From source file:org.mariotaku.twidere.fragment.DirectMessagesConversationFragment.java
private void updateTextCount() { if (mTextCount != null) { final String text = mEditText != null ? parseString(mEditText.getText()) : null; final int count = mValidator.getTweetLength(text); final float hue = count < Validator.MAX_TWEET_LENGTH ? count >= Validator.MAX_TWEET_LENGTH - 10 ? 5 * (Validator.MAX_TWEET_LENGTH - count) : 50 : 0;// www . j av a 2 s .co m final float[] hsv = new float[] { hue, 1.0f, 1.0f }; mTextCount.setTextColor( count >= Validator.MAX_TWEET_LENGTH - 10 ? Color.HSVToColor(0x80, hsv) : 0x80808080); mTextCount.setText(parseString(Validator.MAX_TWEET_LENGTH - count)); } }