@Override public boolean onTouch(View v, MotionEvent event) { Path temp = new Path(); float rx = event.getX(); float ry = event.getY(); mNodes = mGraph.getShortestPath( fromSpin.getSelectedItem().toString(), toSpin.getSelectedItem().toString()); // temp.rMoveTo(rx, ry); float x, y; String res = " "; for (int i = 0; i < mNodes.size(); i++) { x = (float) mNodes.get(i).getX(); y = (float) mNodes.get(i).getY(); res += mNodes.get(i).getLabel() + " "; if (i != 0) { temp.lineTo(x, y); } temp.moveTo(x, y); } Log.d("Path", res); myMap.setMap(temp, 2, rx, ry); return true; }
public void GenImageMap(MapGrid matrix, String date) { int[][] vtec = new int[MapGrid.getMaxRow()][MapGrid.getMaxColum()]; int[][] rms = new int[MapGrid.getMaxRow()][MapGrid.getMaxColum()]; ImageMap image = new ImageMap(); for (int i = 0; i < MapGrid.getMaxRow(); i++) { for (int j = 0; j < MapGrid.getMaxColum(); j++) { matrix.getGrid()[i][j].ToFile(); vtec[i][j] = matrix.getGrid()[i][j].getVtec(); rms[i][j] = matrix.getGrid()[i][j].getRms(); image.InsertValue(i, j, matrix.getGrid()[i][j].getVtec(), true); image.InsertValue(i, j, matrix.getGrid()[i][j].getRms(), false); } } historialvtec.add(vtec); historialrms.add(rms); image.GenImage(date); historialimages.add(image); }
void InitWXOGLGeom(String rid) { OGLR.InitGEOM(rid1, prod); if (!old_rid.equals(rid) || prod.equals("TZL") || prod.equals("TV0") || old_prod.equals("TZL") || old_prod.equals("TV0")) { OGLR.chunk_count = 0; OGLR.chunk_count_sti = 0; OGLR.hi_init = false; OGLR.tvs_init = false; OGLR.ConstructStateLines(); if (MyApplication.cod_lakes_default) OGLR.ConstructLakes(); else OGLR.DeconstructLakes(); if (MyApplication.county_default) OGLR.ConstructCounty(); else OGLR.DeconstructCounty(); if (MyApplication.cod_hw_default) OGLR.ConstructHWLines(); else OGLR.DeconstructHWLines(); if (MyApplication.cod_cities_default) OGLR.ConstructCities(); else OGLR.DeconstructCities(); old_rid = rid; } if (MyApplication.cod_warnings_default && !archive_mode) OGLR.ConstructWarningFFWLines(); else OGLR.DeconstructWarningFFWLines(); if (MyApplication.watmcd_default && !archive_mode) OGLR.ConstructWATMCDLines(); else OGLR.DeconstructWATMCDLines(); if (MyApplication.mpd_default && !archive_mode) OGLR.ConstructMPDLines(); else OGLR.DeconstructMPDLines(); if (MyApplication.cod_locdot_default) OGLR.ConstructLocationDot(loc_x_current, loc_y_current); else OGLR.DeconstructLocationDot(); img.setVisibility(View.GONE); mImageMap.setVisibility(View.GONE); glview.setVisibility(View.VISIBLE); glview.requestRender(); }
/** * Konstruktør. * * @param gameRenderer GameRendereren som eier objektet. * @param name Navnet til objektet. Blir default brukt som bildebasenavn */ GameObject(GameRenderer gameRenderer, String name, int objectX, int objectY) { dead = false; _name = name; _damage = 1; _age = 0; _xSpeed = _ySpeed = 0; x = objectX; y = objectY; _gameRenderer = gameRenderer; _movie = ImageMap.getInstance().getImage(name); if (_movie[0] == null) { Log.log("Couldn't find image for GameObject. Exiting."); System.exit(1); } width = _movie[0].getWidth(null); height = _movie[0].getHeight(null); }
@Override public boolean onMenuItemClick(MenuItem item) { if (in_ogl_anim) { in_ogl_anim = false; anim.setIcon(play_icon); if (item.getItemId() == R.id.action_a6) return true; } switch (item.getItemId()) { case R.id.action_share: if (anim_ran) { if (!prod.equals("2k")) animDrawable = UtilityUSImgWX.AnimationFromFiles(this, rid1, prod, frame_cnt_str); UtilityShare.ShareAnimGif( this, rid1 + " (" + MyApplication.preferences.getString("RID_LOC_" + rid1, "") + ") " + prod, animDrawable); } else { if (prod.equals("2k")) UtilityShare.ShareBitmap( this, rid1 + " (" + MyApplication.preferences.getString("RID_LOC_" + rid1, "") + ") " + prod, bitmap); else UtilityShare.ShareBitmap( this, rid1 + " (" + MyApplication.preferences.getString("RID_LOC_" + rid1, "") + ") " + prod, UtilityImg.LayerDrawableToBitmap( UtilityUSImgWX.LayeredImgFromFile(getApplicationContext(), rid1, prod, false))); } return true; case R.id.action_settings: Intent intent = new Intent(this, SettingsRadarActivity.class); startActivity(intent); return true; case R.id.action_n0q: prod = "N" + tilt + "Q"; setTitle(prod); tilt_option = true; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_n0u: prod = "N" + tilt + "U"; setTitle(prod); tilt_option = true; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_tv0: prod = "TV0"; setTitle(prod); tilt_option = false; rid_changed = true; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_tzl: prod = "TZL"; setTitle(prod); tilt_option = false; rid_changed = true; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_n0s: prod = "N" + tilt + "S"; setTitle(prod); tilt_option = false; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_net: prod = "EET"; setTitle(prod); tilt_option = false; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_DVL: prod = "DVL"; setTitle(prod); tilt_option = false; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_N0X: prod = "N" + tilt + "X"; setTitle(prod); tilt_option = true; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_N0C: prod = "N" + tilt + "C"; setTitle(prod); tilt_option = true; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_N0K: prod = "N" + tilt + "K"; setTitle(prod); tilt_option = true; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_H0C: prod = "H" + tilt + "C"; setTitle(prod); tilt_option = true; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_about: ShowRadarScanInfo(); return true; case R.id.action_vil: prod = "DVL"; setTitle(prod); tilt_option = false; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_dsp: prod = "DSP"; setTitle(prod); tilt_option = false; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_n0r: prod = "N0R"; setTitle(prod); tilt_option = false; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_n0v: prod = "N0V"; setTitle(prod); tilt_option = false; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_l2vel: prod = "L2VEL"; setTitle(prod); tilt_option = false; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_l2ref: prod = "L2REF"; setTitle(prod); tilt_option = false; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_tilt1: tilt = "0"; prod = prod.replaceAll("N[0-3]", "N" + tilt); setTitle(prod); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_tilt2: tilt = "1"; prod = prod.replaceAll("N[0-3]", "N" + tilt); setTitle(prod); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_tilt3: tilt = "2"; prod = prod.replaceAll("N[0-3]", "N" + tilt); setTitle(prod); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_tilt4: tilt = "3"; prod = prod.replaceAll("N[0-3]", "N" + tilt); setTitle(prod); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_a12: setTitle(prod); if (prod.equals("2k")) { new AnimateRadarMosaic().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "12", prod); } else { anim.setIcon(stop_icon); new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "12", prod); } return true; case R.id.action_a18: setTitle(prod); if (prod.equals("2k")) { new AnimateRadarMosaic().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "18", prod); } else { anim.setIcon(stop_icon); new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "18", prod); } return true; case R.id.action_a6: setTitle(prod); if (prod.equals("2k")) { new AnimateRadarMosaic().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "6", prod); } else { anim.setIcon(stop_icon); new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "6", prod); } return true; case R.id.action_a36: setTitle(prod); if (prod.equals("2k")) { new AnimateRadarMosaic().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "36", prod); } else { anim.setIcon(stop_icon); new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "36", prod); } return true; case R.id.action_a3: setTitle(prod); if (prod.equals("2k")) { new AnimateRadarMosaic().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "3", prod); } else { anim.setIcon(stop_icon); new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "3", prod); } return true; case R.id.action_zoomout: setTitle(state + " Radar"); if (zoom_level_radar == 0) { img_url = "http://climate.cod.edu/data/satellite/1km/" + onek + "/current/" + onek + ".rad.gif"; zoom_level_radar++; } else if (zoom_level_radar == 1) { img_url = "http://climate.cod.edu/data/satellite/2km/" + state + "/current/" + state + ".rad.gif"; zoom_level_radar++; } else if (zoom_level_radar == 2) { img_url = "http://climate.cod.edu/data/satellite/regional/" + sector + "/current/" + sector + ".rad.gif"; zoom_level_radar++; } else if (zoom_level_radar == 3) { img_url = "http://climate.cod.edu/data/satellite/regional/usa/current/usa.rad.gif"; zoom_level_radar = 0; } prod = "2k"; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_vis: setTitle(state + " Vis"); tilt_option = false; if (state.equals("HI") || state.equals("AK")) { zoom_level_vis = 3; } if (zoom_level_vis == 1) { img_url = "http://climate.cod.edu/data/satellite/1km/" + onek + "/current/" + onek + ".vis.gif"; zoom_level_vis++; } else if (zoom_level_vis == 2) { img_url = "http://climate.cod.edu/data/satellite/2km/" + state + "/current/" + state + ".vis.gif"; zoom_level_vis++; } else if (zoom_level_vis == 3) { img_url = "http://climate.cod.edu/data/satellite/regional/" + sector + "/current/" + sector + ".vis.gif"; zoom_level_vis++; } else if (zoom_level_vis == 4) { img_url = "http://climate.cod.edu/data/satellite/regional/usa/current/usa.vis.gif"; zoom_level_vis = 1; } prod = "2k"; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_ir: setTitle(state + " IR"); tilt_option = false; if (state.equals("HI") || state.equals("AK")) { zoom_level_ir = 2; } if (zoom_level_ir == 1) { img_url = "http://climate.cod.edu/data/satellite/2km/" + state + "/current/" + state + ".ir.gif"; zoom_level_ir++; } else if (zoom_level_ir == 2) { img_url = "http://climate.cod.edu/data/satellite/regional/" + sector + "/current/" + sector + ".ir.gif"; zoom_level_ir++; } else if (zoom_level_ir == 3) { img_url = "http://climate.cod.edu/data/satellite/regional/usa/current/usa.ir.gif"; zoom_level_ir = 1; } prod = "2k"; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_wv: setTitle(state + " WV"); tilt_option = false; if (state.equals("HI") || state.equals("AK")) { zoom_level_wv = 2; } if (zoom_level_wv == 1) { img_url = "http://climate.cod.edu/data/satellite/2km/" + state + "/current/" + state + ".wv.gif"; zoom_level_wv++; } else if (zoom_level_wv == 2) { img_url = "http://climate.cod.edu/data/satellite/regional/" + sector + "/current/" + sector + ".wv.gif"; zoom_level_wv++; } else if (zoom_level_wv == 3) { img_url = "http://climate.cod.edu/data/satellite/regional/usa/current/usa.wv.gif"; zoom_level_wv = 1; } prod = "2k"; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_NVW: prod = "2k"; img_url = "NVW"; setTitle("NVW"); img.resetZoom(); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_fav: ToggleFavorite(); return true; case R.id.action_CMH: rid1 = "CMH"; prod = "TZL"; setTitle(prod); RIDMapSwitch(rid1); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_CVG: rid1 = "CVG"; prod = "TZL"; setTitle(prod); RIDMapSwitch(rid1); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_DAL: rid1 = "DAL"; prod = "TZL"; setTitle(prod); RIDMapSwitch(rid1); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_DAY: rid1 = "DAY"; prod = "TZL"; setTitle(prod); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_EWR: rid1 = "EWR"; prod = "TZL"; RIDMapSwitch(rid1); setTitle(prod); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_FLL: rid1 = "FLL"; prod = "TZL"; RIDMapSwitch(rid1); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_IAD: rid1 = "IAD"; prod = "TZL"; RIDMapSwitch(rid1); setTitle(prod); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_IAH: rid1 = "IAH"; prod = "TZL"; RIDMapSwitch(rid1); setTitle(prod); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_MDW: rid1 = "MDW"; prod = "TZL"; RIDMapSwitch(rid1); setTitle(prod); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_PBI: rid1 = "PBI"; prod = "TZL"; setTitle(prod); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; case R.id.action_ridmap: LayoutParams params_iv = mImageMap.getLayoutParams(); params_iv.height = MyApplication.dm.heightPixels - toolbar.getHeight() - toolbar_bottom.getHeight() - getStatusBarHeight(); params_iv.width = MyApplication.dm.widthPixels; mImageMap.setLayoutParams(params_iv); if (!map_shown) { map_shown = true; glview.setVisibility(View.GONE); img.setVisibility(View.GONE); mImageMap.setVisibility(View.VISIBLE); ogl_in_view = false; mImageMap.addOnImageMapClickedHandler( new ImageMap.OnImageMapClickedHandler() { @Override public void onImageMapClicked(int id, ImageMap im2) { RIDMapSwitch(UtilityImageMap.MaptoRid(id)); } @Override public void onBubbleClicked(int id) {} }); } else { map_shown = false; mImageMap.setVisibility(View.GONE); img.setVisibility(View.GONE); glview.setVisibility(View.VISIBLE); ogl_in_view = true; } return true; default: return super.onOptionsItemSelected(item); } }
@Override public void onCreate(Bundle savedInstanceState) { setTheme(MyApplication.theme_int); super.onCreate(savedInstanceState); setContentView(R.layout.activity_uswxoglv2); loc_x_current = MyApplication.preferences.getString("LOC" + MyApplication.current_loc_fragment + "_X", ""); loc_y_current = MyApplication.preferences.getString("LOC" + MyApplication.current_loc_fragment + "_Y", ""); turl = getIntent().getStringArrayExtra(RID); // for L2 archive called from storm reports if (turl.length > 5) { url_str = turl[3]; loc_x_current = turl[4]; loc_y_current = turl[5]; archive_mode = true; } toolbar = (Toolbar) findViewById(R.id.toolbar_top); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_36px)); // toolbar.setNavigationIcon(android.R.drawable.); toolbar_bottom = (Toolbar) findViewById(R.id.toolbar_bottom); if (MyApplication.icons_even_spaced) UtilityToolbar.setupEvenlyDistributedToolbar(this, toolbar_bottom, R.menu.uswxoglradar); else toolbar_bottom.inflateMenu(R.menu.uswxoglradar); toolbar_bottom.setOnMenuItemClickListener(this); if (archive_mode) toolbar_bottom.setVisibility(View.GONE); Menu menu = toolbar_bottom.getMenu(); star_icon = R.drawable.star; star_outline_icon = R.drawable.star_outline; map_icon = R.drawable.map; star = menu.findItem(R.id.action_fav); map = menu.findItem(R.id.action_ridmap); map.setIcon(map_icon); tv0 = menu.findItem(R.id.action_tv0); tdwr = menu.findItem(R.id.action_tdwr); anim = menu.findItem(R.id.action_a6); tilt_menu = menu.findItem(R.id.action_tilt); // if ( ! MyApplication.loaded ) // MyApplication.Init(this); mImageMap = (ImageMap) findViewById(R.id.map); mImageMap.setVisibility(View.GONE); delay = UtilityImg.GetAnimInterval(); img = (TouchImageView2) findViewById(R.id.iv); img.setMaxZoom(max_zoom); prod = "N0Q"; glview = (WXGLSurfaceView) findViewById(R.id.glsurfaceview); InitGLVIEW(); ogl_in_view = true; rid1 = turl[0]; state = turl[1]; if (turl.length > 2) { prod = turl[2]; if (prod.equals("N0R")) { prod = "N0Q"; } } if (MyApplication.wxogl_remember_location && !archive_mode) { OGLR.setZoom(MyApplication.wxogl_zoom); glview.mScaleFactor = (MyApplication.wxogl_zoom); if (!MyApplication.wxogl_rid.equals("")) rid1 = MyApplication.wxogl_rid; prod = MyApplication.wxogl_prod; OGLR.mPositionX = MyApplication.wxogl_x; OGLR.mPositionY = MyApplication.wxogl_y; } setTitle(prod); rid_arr_loc = UtilityFavorites.SetupFavMenu(MyApplication.rid_fav, rid1, pref_token_location); spinner1 = (Spinner) findViewById(R.id.spinner1); dataAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, rid_arr_loc); dataAdapter.setDropDownViewResource(MyApplication.spinner_layout); spinner1.setAdapter(dataAdapter); spinner1.setOnItemSelectedListener(this); if (MyApplication.wxogl_radar_autorefresh) { // 180000 is 3 min mInterval = 60000 * MyApplication.preferences.getInt("RADAR_REFRESH_INTERVAL", 3); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mHandler = new Handler(); startRepeatingTask(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); // Init Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mButton = (FloatingActionButton) findViewById(R.id.startFab); mSeekbar = (SeekBar) findViewById(R.id.mySeekBar); myMap = (ImageMap) findViewById(R.id.mMap); myMap.setOnTouchListener(this); fromSpin = (Spinner) findViewById(R.id.spinnerFrom); toSpin = (Spinner) findViewById(R.id.spinnerTo); // Step Sensor sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); stepSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER); sensorManager.registerListener(this, stepSensor, SensorManager.SENSOR_DELAY_FASTEST); readGraph(); mButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (!started) { RobotControl.getInstance().setHeading(); mSeekbar.setEnabled(false); /** GRAPH CALCULATION Begin * */ RobotControl rc = RobotControl.getInstance(); mGraph.setNewOrigin(rc.getX(), rc.getY()); final String from = fromSpin.getSelectedItem().toString(); final String to = toSpin.getSelectedItem().toString(); mNodes = mGraph.getShortestPath(from, to); Log.d("SUPER LOG", mNodes.toString()); rc.driveAlong( mNodes, new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), "Success!", Toast.LENGTH_SHORT) .show(); fromSpin.setPrompt(to); mSeekbar.setEnabled(true); } }); // GRAPH PART END started = true; } } }); mSeekbar.setOnSeekBarChangeListener( new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { RobotControl.getInstance().rotateTo((float) progress); } @Override public void onStartTrackingTouch(SeekBar seekBar) {} @Override public void onStopTrackingTouch(SeekBar seekBar) {} }); }