List of usage examples for android.graphics Color rgb
@ColorInt public static int rgb(float red, float green, float blue)
From source file:org.rm3l.ddwrt.tiles.status.wan.WANMonthlyTrafficTile.java
private Intent renderTraffDateForMonth(@NotNull final String monthFormatted) { Log.d(LOG_TAG, "renderTraffDateForMonth: " + monthFormatted); if (traffData == null) { return null; }//from ww w . j ava 2 s. c o m final ImmutableMap<Integer, ArrayList<Double>> row = traffData.row(monthFormatted); if (row == null) { return null; } final SortedMap<Integer, ArrayList<Double>> dailyTraffMap = new TreeMap<>(row); if (dailyTraffMap.isEmpty()) { return null; } Log.d(LOG_TAG, "renderTraffDateForMonth: " + monthFormatted + " / dailyTraffMap=" + dailyTraffMap); final int size = dailyTraffMap.size(); final int[] days = new int[size]; final double[] inData = new double[size]; final double[] outData = new double[size]; int i = 0; for (final Map.Entry<Integer, ArrayList<Double>> dailyTraffMapEntry : dailyTraffMap.entrySet()) { final ArrayList<Double> dailyTraffMapEntryValue = dailyTraffMapEntry.getValue(); if (dailyTraffMapEntryValue == null || dailyTraffMapEntryValue.size() < 2) { continue; } final Double in = dailyTraffMapEntryValue.get(0); final Double out = dailyTraffMapEntryValue.get(1); if (in == null || out == null) { continue; } days[i] = dailyTraffMapEntry.getKey(); inData[i] = in; outData[i] = out; i++; } // Creating an XYSeries for Inbound final XYSeries inboundSeries = new XYSeries("Inbound"); // Creating an XYSeries for Outbound final XYSeries outboundSeries = new XYSeries("Outbound"); // Adding data to In and Out Series for (int j = 0; j < i; j++) { inboundSeries.add(j, inData[j]); outboundSeries.add(j, outData[j]); } // Creating a dataset to hold each series final XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); // Adding inbound Series to the dataset dataset.addSeries(inboundSeries); // Adding outbound Series to dataset dataset.addSeries(outboundSeries); // Creating XYSeriesRenderer to customize inboundSeries final XYSeriesRenderer inboundRenderer = new XYSeriesRenderer(); inboundRenderer.setColor(Color.rgb(130, 130, 230)); inboundRenderer.setFillPoints(true); inboundRenderer.setLineWidth(2); inboundRenderer.setDisplayChartValues(true); // Creating XYSeriesRenderer to customize outboundSeries final XYSeriesRenderer outboundRenderer = new XYSeriesRenderer(); outboundRenderer.setColor(Color.rgb(220, 80, 80)); outboundRenderer.setFillPoints(true); outboundRenderer.setLineWidth(2); outboundRenderer.setDisplayChartValues(true); // Creating a XYMultipleSeriesRenderer to customize the whole chart final XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer(); multiRenderer.setXLabels(i); multiRenderer.setChartTitle("Traffic Data for '" + monthFormatted + "'"); multiRenderer.setXTitle("Days"); multiRenderer.setYTitle("Traffic (MB)"); multiRenderer.setZoomButtonsVisible(true); for (int k = 0; k < i; k++) { multiRenderer.addXTextLabel(k, String.valueOf(days[k])); } // for(int k = 0; k < days.length; k++) { // multiRenderer.addXTextLabel(k, String.valueOf(k)); // } // Adding inboundRenderer and outboundRenderer to multipleRenderer // Note: The order of adding dataseries to dataset and renderers to multipleRenderer // should be same multiRenderer.addSeriesRenderer(inboundRenderer); multiRenderer.addSeriesRenderer(outboundRenderer); return ChartFactory.getBarChartIntent(this.mParentFragmentActivity, dataset, multiRenderer, BarChart.Type.DEFAULT); }
From source file:org.mozilla.gecko.gfx.GeckoSoftwareLayerClient.java
private static int parseColorFromGecko(String string) { if (sColorPattern == null) { sColorPattern = Pattern.compile("rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)"); }/* w w w . j a v a 2s . c om*/ Matcher matcher = sColorPattern.matcher(string); if (!matcher.matches()) { return Color.WHITE; } int r = Integer.parseInt(matcher.group(1)); int g = Integer.parseInt(matcher.group(2)); int b = Integer.parseInt(matcher.group(3)); return Color.rgb(r, g, b); }
From source file:net.line2soft.preambul.views.SlippyMapActivity.java
/** * Displays excursions/*ww w . j a v a 2 s . co m*/ * @param id The ID of the excursion to display (Values: -1 to hide all excursions, 0 to show all excursions, >=1 to show one specific excursion) */ public void displayExcursion(int id) { try { overlayPaths.clear(); removeMarker("NAV"); //Hide all excursions if (id == -1) { hideNavigationInstruction(); } //Display one excursion else if (id > 0) { Paint color = createPaint(getResources().getColor(R.color.Green)); OverlayWay path = MapController.getInstance(this).getCurrentLocation().getExcursions(this).get(id) .getPath(); path.setPaint(color, null); overlayPaths.addWay(new OverlayWayText(path, null)); showNavigationInstruction(id); } //Display all excursions else { //Init colors Paint[] colors = new Paint[30]; colors[0] = createPaint(getResources().getColor(R.color.GreenYellow)); colors[1] = createPaint(getResources().getColor(R.color.Orange)); colors[2] = createPaint(getResources().getColor(R.color.Blue)); colors[3] = createPaint(getResources().getColor(R.color.DarkRed)); colors[4] = createPaint(getResources().getColor(R.color.Purple)); colors[5] = createPaint(getResources().getColor(R.color.Pink)); colors[6] = createPaint(getResources().getColor(R.color.Black)); colors[7] = createPaint(getResources().getColor(R.color.Indigo)); colors[8] = createPaint(getResources().getColor(R.color.Gold)); colors[9] = createPaint(getResources().getColor(R.color.DarkOrange)); colors[10] = createPaint(getResources().getColor(R.color.Violet)); colors[11] = createPaint(getResources().getColor(R.color.Brown)); colors[12] = createPaint(getResources().getColor(R.color.PowderBlue)); colors[13] = createPaint(getResources().getColor(R.color.Cyan)); colors[14] = createPaint(getResources().getColor(R.color.DarkGreen)); colors[15] = createPaint(getResources().getColor(R.color.DarkSalmon)); colors[16] = createPaint(getResources().getColor(R.color.DarkViolet)); colors[17] = createPaint(getResources().getColor(R.color.DarkGoldenrod)); colors[18] = createPaint(getResources().getColor(R.color.Thistle)); colors[19] = createPaint(getResources().getColor(R.color.DarkTurquoise)); colors[20] = createPaint(getResources().getColor(R.color.FireBrick)); colors[21] = createPaint(getResources().getColor(R.color.Aquamarine)); colors[22] = createPaint(getResources().getColor(R.color.Aqua)); colors[23] = createPaint(getResources().getColor(R.color.BurlyWood)); colors[24] = createPaint(getResources().getColor(R.color.Crimson)); colors[25] = createPaint(getResources().getColor(R.color.DeepPink)); colors[26] = createPaint(getResources().getColor(R.color.Gainsboro)); colors[27] = createPaint(getResources().getColor(R.color.Moccasin)); colors[28] = createPaint(getResources().getColor(R.color.Tomato)); colors[29] = createPaint(getResources().getColor(R.color.SlateBlue)); HashMap<Integer, Excursion> exc = MapController.getInstance(this).getCurrentLocation() .getExcursions(this); int addedPaths = 0; for (int i : exc.keySet()) { OverlayWay path = MapController.getInstance(this).getCurrentLocation().getExcursions(this) .get(i).getPath(); if (addedPaths < colors.length) { path.setPaint(colors[addedPaths], null); } else { //generate random color int red = (int) (Math.random() * 255); int green = (int) (Math.random() * 255); int blue = (int) (Math.random() * 255); int color = Color.rgb(red, green, blue); //set paint path.setPaint(createPaint(color), null); } overlayPaths.addWay(new OverlayWayText(path, MapController.getInstance(this) .getCurrentLocation().getExcursions(this).get(i).getName())); addedPaths++; } hideNavigationInstruction(); } } catch (Exception e) { displayInfo(getString(R.string.message_map_cant_load_overlays)); e.printStackTrace(); hideNavigationInstruction(); } }
From source file:com.aujur.ebookreader.Configuration.java
public int getLinkColor() { return getProfileSetting(KEY_LINK, Color.BLUE, Color.rgb(255, 165, 0)); }
From source file:net.gsantner.opoc.util.ContextUtils.java
/** * Draw text in the center of the given {@link DrawableRes} * This may be useful for e.g. badge counts *//*from w w w. j a v a2s . co m*/ public Bitmap drawTextOnDrawable(@DrawableRes int drawableRes, String text, int textSize) { Resources resources = _context.getResources(); float scale = resources.getDisplayMetrics().density; Bitmap bitmap = drawableToBitmap(drawableRes); bitmap = bitmap.copy(bitmap.getConfig(), true); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.rgb(61, 61, 61)); paint.setTextSize((int) (textSize * scale)); paint.setShadowLayer(1f, 0f, 1f, Color.WHITE); Rect bounds = new Rect(); paint.getTextBounds(text, 0, text.length(), bounds); int x = (bitmap.getWidth() - bounds.width()) / 2; int y = (bitmap.getHeight() + bounds.height()) / 2; canvas.drawText(text, x, y, paint); return bitmap; }
From source file:cz.tomsuch.lampicka.activities.LampActivity.java
/** * Parses response from lamp, setting remote settings to local UI controls * *///from w w w. j av a 2 s .co m private void applyLampSettings(String substring) { String[] parts = substring.split(":"); if (parts == null || parts.length != 6) return; int counter = 0; int red = 0, green = 0, blue = 0; int currentEffect = 0, currentBacklightEffect = 0, currentColorIntensity = 0; for (String part : parts) { int value = Integer.parseInt(part); switch (counter) { case 0: red = value; break; case 1: green = value; break; case 2: blue = value; break; case 3: currentBacklightEffect = value; break; case 4: currentEffect = value; break; case 5: currentColorIntensity = value; break; } counter++; } this.lamp_color_intensity.setProgressAndThumb(currentColorIntensity); this.colorPicker.setColor(Color.rgb(red, green, blue)); this.currentEffect = BluetoothLampEffect.getEffectRawNo(currentEffect); this.currentBacklightEffect = BluetoothLampBacklightMode.getEffectRawNo(currentBacklightEffect); this.lamp_effects_select.setText(this.currentEffect.getName()); this.lamp_backlight_select.setText(this.currentBacklightEffect.getName()); }
From source file:org.mixare.DataView.java
public void draw(PaintScreen dw) { // ? ?? ? ?? ? mixContext.getRM(cam.transform);/*from w w w.jav a 2 s . co m*/ // ? ? ?? curFix = mixContext.getCurrentLocation(); int po = mixContext.getPosition(); String searchtitle = mixContext.title; double searchlat = mixContext.lat; double searchlon = mixContext.lon; // ? ?? ? ?? state.calcPitchBearing(cam.transform); // Load Layer // ? ? ? ??, ?? ? if (state.nextLStatus == MixState.NOT_STARTED && !frozen) { // Log.i("check", String.valueOf(po)); // ?? URL ? ?? if (mixContext.getStartUrl().length() > 0) { // ? ? ?? switch (po) { case 1: requestData(mixContext.getStartUrl(), DATAFORMAT.CONVENIENCE, DATASOURCE.CONVENIENCE); isLauncherStarted = true; break; // ? ? ? case 2: requestData(mixContext.getStartUrl(), DATAFORMAT.CAFE, DATASOURCE.CAFE); isLauncherStarted = true; break; case 3: requestData(mixContext.getStartUrl(), DATAFORMAT.BANK, DATASOURCE.BANK); isLauncherStarted = true; break; case 4: requestData(mixContext.getStartUrl(), DATAFORMAT.PCCAFE, DATASOURCE.PCCAFE); isLauncherStarted = true; break; case 5: requestData(mixContext.getStartUrl(), DATAFORMAT.HOSPITAL, DATASOURCE.HOSPITAL); isLauncherStarted = true; break; case 6: requestData(mixContext.getStartUrl(), DATAFORMAT.PHARMACY, DATASOURCE.PHARMACY); isLauncherStarted = true; break; case 7: requestData(mixContext.getStartUrl(), DATAFORMAT.HOTEL, DATASOURCE.HOTEL); isLauncherStarted = true; break; case 8: requestData(mixContext.getStartUrl(), DATAFORMAT.SEARCH, DATASOURCE.SEARCH); isLauncherStarted = true; Toast.makeText(mixContext, "data view default", Toast.LENGTH_SHORT).show(); break; default: Toast.makeText(mixContext, "data view default", Toast.LENGTH_SHORT).show(); break; // if (!mixContext.isDataSourceSelected(DataSource.DATASOURCE.CAFE)) { // mixContext.toogleDataSource(DataSource.DATASOURCE.CAFE); } } // URL ? ? ? ? else { // ? ?, ?, ? ? ? double lat = curFix.getLatitude(), lon = curFix.getLongitude(), alt = curFix.getAltitude(); if (po == 1) { if (mixContext.isDataSourceSelected(DataSource.DATASOURCE.CONVENIENCE)) { requestData( DataSource.createRequestURL(DataSource.DATASOURCE.CONVENIENCE, lat, lon, alt, radius, Locale.getDefault().getLanguage(), searchlat, searchlon), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.CONVENIENCE), DataSource.DATASOURCE.CONVENIENCE); } } else if (po == 2) { if (mixContext.isDataSourceSelected(DataSource.DATASOURCE.CAFE)) { requestData( DataSource.createRequestURL(DataSource.DATASOURCE.CAFE, lat, lon, alt, radius, Locale.getDefault().getLanguage(), searchlat, searchlon), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.CAFE), DataSource.DATASOURCE.CAFE); } } else if (po == 3) { if (mixContext.isDataSourceSelected(DataSource.DATASOURCE.BANK)) { requestData( DataSource.createRequestURL(DataSource.DATASOURCE.BANK, lat, lon, alt, radius, Locale.getDefault().getLanguage(), searchlat, searchlon), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.BANK), DataSource.DATASOURCE.BANK); } } else if (po == 4) { if (mixContext.isDataSourceSelected(DataSource.DATASOURCE.PCCAFE)) { requestData( DataSource.createRequestURL(DataSource.DATASOURCE.PCCAFE, lat, lon, alt, radius, Locale.getDefault().getLanguage(), searchlat, searchlon), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.PCCAFE), DataSource.DATASOURCE.PCCAFE); } } else if (po == 5) { if (mixContext.isDataSourceSelected(DataSource.DATASOURCE.HOSPITAL)) { requestData( DataSource.createRequestURL(DataSource.DATASOURCE.HOSPITAL, lat, lon, alt, radius, Locale.getDefault().getLanguage(), searchlat, searchlon), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.HOSPITAL), DataSource.DATASOURCE.HOSPITAL); } } else if (po == 6) { if (mixContext.isDataSourceSelected(DataSource.DATASOURCE.PHARMACY)) { requestData( DataSource.createRequestURL(DataSource.DATASOURCE.PHARMACY, lat, lon, alt, radius, Locale.getDefault().getLanguage(), searchlat, searchlon), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.PHARMACY), DataSource.DATASOURCE.PHARMACY); } } else if (po == 7) { if (mixContext.isDataSourceSelected(DataSource.DATASOURCE.HOTEL)) { requestData( DataSource.createRequestURL(DataSource.DATASOURCE.HOTEL, lat, lon, alt, radius, Locale.getDefault().getLanguage(), searchlat, searchlon), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.HOTEL), DataSource.DATASOURCE.HOTEL); } } else if (po == 8) { requestData( DataSource.createRequestURL(DataSource.DATASOURCE.SEARCH, lat, lon, alt, radius, Locale.getDefault().getLanguage(), searchlat, searchlon), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.SEARCH), DataSource.DATASOURCE.SEARCH); // Intent intent = new Intent(); // ArrayList<String> items = intent.getStringArrayExtra("data"); } /*switch(po) { case 1: if(mixContext.isDataSourceSelected(DataSource.DATASOURCE.CONVENIENCE)){ requestData(DataSource.createRequestURL(DataSource.DATASOURCE.CONVENIENCE, lat, lon, alt, radius, Locale.getDefault().getLanguage()), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.CONVENIENCE),DataSource.DATASOURCE.CONVENIENCE);} break; case 2: if(mixContext.isDataSourceSelected(DataSource.DATASOURCE.CAFE)){ requestData(DataSource.createRequestURL(DataSource.DATASOURCE.CAFE, lat, lon, alt, radius, Locale.getDefault().getLanguage()), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.CAFE),DataSource.DATASOURCE.CAFE);} break; case 3: if(mixContext.isDataSourceSelected(DataSource.DATASOURCE.BANK)){ requestData(DataSource.createRequestURL(DataSource.DATASOURCE.BANK, lat, lon, alt, radius, Locale.getDefault().getLanguage()), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.BANK),DataSource.DATASOURCE.BANK);} break; case 4: if(mixContext.isDataSourceSelected(DataSource.DATASOURCE.PCCAFE)){ requestData(DataSource.createRequestURL(DataSource.DATASOURCE.PCCAFE, lat, lon, alt, radius, Locale.getDefault().getLanguage()), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.PCCAFE),DataSource.DATASOURCE.PCCAFE);} break; case 5: if(mixContext.isDataSourceSelected(DataSource.DATASOURCE.HOSPITAL)){ requestData(DataSource.createRequestURL(DataSource.DATASOURCE.HOSPITAL, lat, lon, alt, radius, Locale.getDefault().getLanguage()), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.HOSPITAL),DataSource.DATASOURCE.HOSPITAL);} break; case 6: if(mixContext.isDataSourceSelected(DataSource.DATASOURCE.PHARMACY)){ requestData(DataSource.createRequestURL(DataSource.DATASOURCE.PHARMACY, lat, lon, alt, radius, Locale.getDefault().getLanguage()), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.PHARMACY),DataSource.DATASOURCE.PHARMACY);} break; case 7: if(mixContext.isDataSourceSelected(DataSource.DATASOURCE.HOTEL)){ requestData(DataSource.createRequestURL(DataSource.DATASOURCE.HOTEL, lat, lon, alt, radius, Locale.getDefault().getLanguage()), DataSource.dataFormatFromDataSource(DataSource.DATASOURCE.HOTEL),DataSource.DATASOURCE.HOTEL);} break; }*/ // ??? ?? ?? ? /* for(DataSource.DATASOURCE source: DataSource.DATASOURCE.values()) { // ?? ?? ?? ? Log.i("check", String.valueOf(cnt++));f requestData(DataSource.createRequestURL(source,lat,lon,alt,radius,Locale.getDefault().getLanguage()),DataSource.dataFormatFromDataSource(source),source); // Debug notification // Toast.makeText(mixContext, "Downloading from "+ source, Toast.LENGTH_SHORT).show(); } }*/ } // ? ? ? ?? ? if (state.nextLStatus == MixState.NOT_STARTED) state.nextLStatus = MixState.DONE; // ? ? ? } //TODO: //state.downloadId = mixContext.getDownloader().submitJob(request); else if (state.nextLStatus == MixState.PROCESSING) { // ? ?? // ? ? ? DownloadManager dm = mixContext.getDownloader(); DownloadResult dRes; // // ?? ?? ? while ((dRes = dm.getNextResult()) != null) { // ? ? ?? ? 1 ?? if (dRes.error && retry < 2) { retry++; // ? ? mixContext.getDownloader().submitJob(dRes.errorRequest); // ? ?? Toast.makeText(mixContext, mixContext.getResources().getString(R.string.download_error) + " " + dRes.errorRequest.url, Toast.LENGTH_SHORT).show(); } // ? if (!dRes.error) { //jLayer = (DataHandler) dRes.obj; // ?? ? Log.i(MixView.TAG, "Adding Markers"); dataHandler.addMarkers(dRes.getMarkers()); dataHandler.onLocationChanged(curFix); // // ?? ?? Toast.makeText(mixContext, mixContext.getResources().getString(R.string.download_received) + " " + dRes.source, Toast.LENGTH_SHORT).show(); } } if (dm.isDone()) { // ?? ? ?? retry = 0; // ? state.nextLStatus = MixState.DONE; // ? ? } } /* ?? */ dataHandler.updateActivationStatus(mixContext); // ? // ??? ? ? for (int i = dataHandler.getMarkerCount() - 1; i >= 0; i--) { Marker ma = dataHandler.getMarker(i); //if (ma.isActive() && (ma.getDistance() / 1000f < radius || ma instanceof NavigationMarker || ma instanceof SocialMarker)) { // ? ? ? ? if (ma.isActive() && (ma.getDistance() / 1000f < radius)) { // ? ? , ? // , ? ?? // ? ? ?? //if (!frozen) // ma.update(curFix); if (!frozen) ma.calcPaint(cam, addX, addY); ma.draw(dw); } } /* ?? */ String dirTxt = ""; // ? ? int bearing = (int) state.getCurBearing(); // ? ?? ?? int range = (int) (state.getCurBearing() / (360f / 16f)); // //TODO: XML ? ? ? ? // ? ? ? ? if (range == 15 || range == 0) dirTxt = "N"; else if (range == 1 || range == 2) dirTxt = "NE"; else if (range == 3 || range == 4) dirTxt = "E"; else if (range == 5 || range == 6) dirTxt = "SE"; else if (range == 7 || range == 8) dirTxt = "S"; else if (range == 9 || range == 10) dirTxt = "SW"; else if (range == 11 || range == 12) dirTxt = "W"; else if (range == 13 || range == 14) dirTxt = "NW"; // ??? ?? radarPoints.view = this; // ? ?? dw.paintObj(radarPoints, rx, ry, -state.getCurBearing(), 1); dw.setFill(false); dw.setColor(Color.argb(150, 0, 0, 220)); dw.paintLine(lrl.x, lrl.y, rx + RadarPoints.RADIUS, ry + RadarPoints.RADIUS); dw.paintLine(rrl.x, rrl.y, rx + RadarPoints.RADIUS, ry + RadarPoints.RADIUS); dw.setColor(Color.rgb(255, 255, 255)); dw.setFontSize(12); // ??? ? ? radarText(dw, MixUtils.formatDist(radius * 1000), rx + RadarPoints.RADIUS, ry + RadarPoints.RADIUS * 2 - 10, false); radarText(dw, "" + bearing + ((char) 176) + " " + dirTxt, rx + RadarPoints.RADIUS, ry - 5, true); /* ? UI ? */ UIEvent evt = null; synchronized (uiEvents) { if (uiEvents.size() > 0) { evt = uiEvents.get(0); uiEvents.remove(0); } } // ?? if (evt != null) { switch (evt.type) { case UIEvent.KEY: handleKeyEvent((KeyEvent) evt); break; case UIEvent.CLICK: handleClickEvent((ClickEvent) evt); break; } } state.nextLStatus = MixState.PROCESSING; // ? ? }
From source file:es.upv.riromu.arbre.main.MainActivity.java
/***************************************************************/ @Override//from www.j a va 2 s .c o m protected void onActivityResult(int requestCode, int resultCode, Intent returnedIntent) { super.onActivityResult(requestCode, resultCode, returnedIntent); switch (requestCode) { case PICK_IMAGE: if (resultCode == RESULT_OK) { resetVisibility(PICK_IMAGE); try { state[PICK_IMAGE] = true; state[CROP_IMAGE] = false; state[TREAT_IMAGE] = false; captura = String.valueOf(System.currentTimeMillis() / 1000L); ImageView imv = (ImageView) findViewById(R.id.image_intro); image_uri = returnedIntent.getData(); InputStream is = getContentResolver().openInputStream(returnedIntent.getData()); imv.setImageBitmap(BitmapFactory.decodeStream(is)); is.close(); RangeSeekBar<Integer> seekBar = (RangeSeekBar<Integer>) findViewById(R.id.rangeseekbar); seekBar.setVisibility(View.GONE); } catch (IOException e) { Log.e(TAG, "Error reading from gallery" + e.getMessage()); } catch (Exception e) { Log.e(TAG, "Error reading from gallery" + e.getMessage()); } } break; case CAPTURE_IMAGE: try { if (resultCode == RESULT_OK) { resetVisibility(CAPTURE_IMAGE); captura = String.valueOf(System.currentTimeMillis() / 1000L); state[PICK_IMAGE] = false; state[CROP_IMAGE] = false; state[TREAT_IMAGE] = false; TextView imc = (TextView) findViewById(R.id.textView); imc.setBackgroundColor(Color.rgb(255, 255, 255)); RangeSeekBar<Integer> seekBar = (RangeSeekBar<Integer>) findViewById(R.id.rangeseekbar); seekBar.setVisibility(View.GONE); if (returnedIntent != null) { setPic(); Bundle extras = returnedIntent.getExtras(); setSelectedImage(returnedIntent.getData()); } else { ImageView imv = (ImageView) findViewById(R.id.image_intro); image = Util.decodeSampledBitmapFromUri(image_uri, MAX_SIZE, MAX_SIZE, this); imv.setImageBitmap(image); gpstracker = new GPSTracking(this); if (gpstracker.canGetLocation()) { latitude = String.valueOf(gpstracker.getLatitude()); longitude = String.valueOf(gpstracker.getLongitude()); } else { gpstracker.showSettingsAlert(); } } } } catch (Exception e) { Log.e(TAG, "Error " + e.getMessage()); } break; case CROP_IMAGE: try { if (resultCode == RESULT_OK) { state[CROP_IMAGE] = true; state[TREAT_IMAGE] = false; RangeSeekBar<Integer> seekBar = (RangeSeekBar<Integer>) findViewById(R.id.rangeseekbar); seekBar.setVisibility(View.VISIBLE); ImageTreatment imt = null; Bundle extras = returnedIntent.getExtras(); if (extras != null) { croppedimage_uri = Uri.parse(extras.getString(RETURN_DATA)); // croppedimage=extras.getParcelable(RETURN_DATA_AS_BITMAP); if (croppedimage_uri != null) { InputStream is = getContentResolver().openInputStream(croppedimage_uri); croppedimage = BitmapFactory.decodeStream(is); is.close(); } else { image = BitmapFactory.decodeResource(getResources(), R.drawable.platanus_hispanica); } ImageView imv = (ImageView) findViewById(R.id.image_intro); imv.setImageBitmap(croppedimage); colours[COLOUR_R] = (int) imt.getRedColor(); colours[COLOUR_B] = (int) imt.getBlueColor(); colours[COLOUR_G] = (int) imt.getGreenColor(); } } } catch (OutOfMemoryError e) { Log.e(TAG, "Error " + e.getMessage()); } catch (IOException e) { Log.e(TAG, "Error " + e.getMessage()); } catch (Exception e) { Log.e(TAG, "Error " + e.getMessage()); } } }
From source file:org.protocoderrunner.apprunner.api.PUI.java
@ProtocoderScript @APIMethod(description = "Changes the background color using RGB", example = "") @APIParam(params = { "r", "g", "b" }) public void setBackgroundColor(int red, int green, int blue) { initializeLayout();//from ww w. j a va2s. c o m holderLayout.setBackgroundColor(Color.rgb(red, green, blue)); }
From source file:com.mjhram.geodata.GpsMainActivity.java
public Bitmap drawMultilineTextToBitmap(Context gContext, Bitmap bitmap, String gText) { // prepare canvas Resources resources = gContext.getResources(); float scale = resources.getDisplayMetrics().density; //Bitmap bitmap = BitmapFactory.decodeResource(resources, gResId); android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig(); // set default bitmap config if none if (bitmapConfig == null) { bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888; }//from w w w. ja v a 2 s . co m // resource bitmaps are imutable, // so we need to convert it to mutable one bitmap = bitmap.copy(bitmapConfig, true); Canvas canvas = new Canvas(bitmap); // new antialiased Paint TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG); // text color - #3D3D3D paint.setColor(Color.rgb(61, 61, 61)); // text size in pixels paint.setTextSize((int) (20 * scale)); // text shadow paint.setShadowLayer(1f, 0f, 1f, Color.WHITE); //canvas.drawText("This is", 100, 100, paint); //canvas.drawText("multi-line", 100, 150, paint); //canvas.drawText("text", 100, 200, paint); // set text width to canvas width minus 16dp padding int textWidth = canvas.getWidth() - (int) (16 * scale); // init StaticLayout for text StaticLayout textLayout = new StaticLayout(gText, paint, textWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false); // get height of multiline text int textHeight = textLayout.getHeight(); // get position of text's top left corner float x = (bitmap.getWidth() - textWidth) / 2; float y = bitmap.getHeight() - textHeight; // draw text to the Canvas center canvas.save(); canvas.translate(x, y); textLayout.draw(canvas); canvas.restore(); return bitmap; }