@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // by jmpessoa --- fix for http get // ref. http://stackoverflow.com/questions/8706464/defaulthttpclient-to-androidhttpclient if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } // Log.i("jApp","01.Activity.onCreate"); controls = new Controls(); controls.activity = this; controls.appLayout = new RelativeLayout(this); controls.appLayout.getRootView().setBackgroundColor(0x00FFFFFF); controls.screenStyle = controls.jAppOnScreenStyle(); switch (controls.screenStyle) { case 1: this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; case 2: this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; default:; // Device Default , Rotation by Device } this.setContentView(controls.appLayout); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); // Event : Java -> Pascal // Log.i("jApp","02.Controls.jAppOnCreate"); controls.jAppOnCreate(this, controls.appLayout); }
@Override protected void dispatchDraw(Canvas canvas) { // DO YOUR DRAWING ON UNDER THIS VIEWS CHILDREN controls.pOnBeforeDispatchDraw( LAMWCommon.getPasObj(), canvas, 1); // event handle by pascal side super.dispatchDraw(canvas); // DO YOUR DRAWING ON TOP OF THIS VIEWS CHILDREN controls.pOnAfterDispatchDraw( LAMWCommon.getPasObj(), canvas, 1); // event handle by pascal side }
// http://stackoverflow.com/questions/15686555/display-back-button-on-action-bar @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // app icon in action bar clicked; go home controls.jAppOnBackPressed(); return true; default: String caption = item.getTitle().toString(); controls.jAppOnClickOptionMenuItem(item, item.getItemId(), caption, item.isChecked()); return true; // renabor } }
public static void refreshLayout() { int gw = frame.getContentPane().getWidth() - CONST.popupwidth; int gh = frame.getContentPane().getHeight() - CONST.menuHeight - CONST.controlsHeight; System.out.println("refreshLayout " + gw + " " + gh); layeredPane.setBounds(0, 0, frame.getContentPane().getWidth(), gh + CONST.menuHeight); menu.setBounds(0, 0, frame.getContentPane().getWidth(), CONST.menuHeight); player.graph.canvas.setLocation(0, CONST.menuHeight); player.graph.resizeCanvas(gw, gh); controls.panel.setBounds( 0, gh + CONST.menuHeight, frame.getContentPane().getWidth(), CONST.controlsHeight); informationPanel.scrollPanel.setBounds( gw - CONST.informationWidth, CONST.menuHeight, CONST.informationWidth, gh - CONST.zoomWindowHeight); zoomWindow.canvas.setBounds( gw - CONST.zoomWindowWidth, CONST.menuHeight + gh - CONST.zoomWindowHeight, CONST.zoomWindowWidth, CONST.zoomWindowHeight); popupInformation.setBounds(gw, CONST.menuHeight, CONST.popupwidth, gh - CONST.zoomWindowHeight); popupZoomWindow.setBounds( gw, CONST.menuHeight + gh - CONST.zoomWindowHeight, CONST.popupwidth, CONST.zoomWindowHeight); controls.refresh(); if (fitGraph) { player.graph.fitToScreen(); fitGraph = false; } gRepaint(); }
@Override public boolean onTouchEvent(MotionEvent event) { // LORDMAN 2013-08-16 if (enabled == false) { return false; } int actType = event.getAction() & MotionEvent.ACTION_MASK; switch (actType) { case MotionEvent.ACTION_DOWN: { btnState = 1; invalidate(); // Log.i("Java","jImageBtn Here"); break; } case MotionEvent.ACTION_MOVE: { break; } case MotionEvent.ACTION_UP: { btnState = 0; invalidate(); controls.pOnClick(PasObj, Const.Click_Default); break; } } return true; }
public synchronized void render(Canvas canvas) { if (canvas.getWidth() != surfaceWidth || canvas.getHeight() != surfaceHeight) { surfaceWidth = canvas.getWidth(); surfaceHeight = canvas.getHeight(); setWindowScale(); } /* while (surface == null) { try { wait(); } catch(InterruptedException e) {} } */ canvas.save(); canvas.scale(windowScale, windowScale, 0, 0); canvas.drawBitmap(screen, windowX / windowScale, windowY / windowScale, bilinearPaint); canvas.restore(); // HUD - caption, subtitles, buttons if (gameState == GAMESTATE_LEVEL) { moreButtonsAnim(); saveEffectRender(canvas); controls.render(canvas); activeFish.render(canvas, 800 - 96, 480 - 96, surfaceWidth, surfaceHeight); } // window caption renderCaption(canvas); // notifyAll(); }
/*by jmpessoa: TODO :Handles prepare menu item*/ @Override public boolean onPrepareOptionsMenu(Menu menu) { // super.onPrepareOptionsMenu(menu); boolean changeMenuItems = false; boolean continueChangingItem = true; changeMenuItems = controls.jAppOnPrepareOptionsMenu(menu, menu.size()); if (changeMenuItems) { for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); continueChangingItem = controls.jAppOnPrepareOptionsItem(menu, item, i); if (!continueChangingItem) break; } } return super.onPrepareOptionsMenu(menu); }
public void setWindowSize(int width, int height) { windowWidth = width; windowHeight = height; windowCaptionFrameCountdown = windowCaptionDelayFrames; setWindowScale(); controls.resizeToScreen(surfaceWidth, surfaceHeight); canvas.drawARGB(255, 0, 0, 0); }
public void preIntroSetup() { try { int bgWidth = env.bgImg.getWidth(env); int bgHeight = env.bgImg.getHeight(env); int[] bgPixels = new int[bgWidth * bgHeight]; for (int i = 0; i < bgPixels.length; i++) if (bgPixels[i] != 0) System.out.print(bgPixels[i]); overlay = new PImage(bgWidth, bgHeight); overlay.format = ARGB; overlay.pixels = bgPixels; runNum = 0; controls.setEnabled(false); /** * get into looping */ afterFirstStreaming = true; /** overview shut */ draw(); /*theCamera.moveToNow(new FVector(0.0f, 0.0f, 1000)); theCamera.lookAtNow(new FVector(0.0f, 1.0f, 0)); */ draw(); ortho(-1500, 800, -800, 800, 1000, 2000); loadPixels(); noStroke(); getOverviewShut(); afterOverviewShot = true; draw(); loop(); /** give the environment the hint to swop the surfaces */ env.addThem(); /** * intro */ theCamera.moveToNow(new FVector(-200.0f, 950.0f, 1000)); theCamera.lookAtNow(new FVector(-200.51917f, 851.8057f, 0)); theCamera.lookAtInter( new FVector(1341.8213f, 757.865f, 0), new Integer(4000), new Integer(3)); Object[] actionObjects = {new FVector(0, 0, -88), new Integer(2000), new Integer(0)}; theCamera.queueAction("lookAtInter", 4000, actionObjects); theCamera.moveToNow(new FVector(-500.51917f, 951.8057f, 200)); theCamera.moveToInter( new FVector(1341.8213f, 857.865f, 200), new Integer(4000), new Integer(3)); Object[] actionObjects2 = { new FVector(0, 800, Camera.maxCameraHeight), new Integer(2000), new Integer(1) }; theCamera.queueAction("moveToInter", 0, actionObjects2); Object[] actionObjects3 = {Boolean.valueOf(true)}; theCamera.queueAction("setControlsEnabled", 3500, actionObjects3); } catch (Exception e) { e.printStackTrace(); env.setErrorDisplay( "Das Applet konnte nicht gestartet werden. Eventuell ist dies ein Speicherproblem. Bitte stoppen sie alle anderen Java-Anwendungen. GGf. muss der Browser neu gestartet werden um den Cache zu leeren."); } }
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { char c = event.getDisplayLabel(); // boolean mute = controls.jAppOnKeyDown(c,keyCode,KeyEvent.keyCodeToString(keyCode)); //TODO // if (mute) return false; switch (keyCode) { case KeyEvent.KEYCODE_BACK: boolean mute = controls.jAppOnKeyDown(c, keyCode, KeyEvent.keyCodeToString(keyCode)); if (!mute) { // continue ... onBackPressed(); return true; } else { // exit! return false; // caution!! the back_key will not close the App, no more!! } case KeyEvent.KEYCODE_MENU: controls.jAppOnKeyDown(c, keyCode, KeyEvent.keyCodeToString(keyCode)); break; case KeyEvent.KEYCODE_SEARCH: controls.jAppOnKeyDown(c, keyCode, KeyEvent.keyCodeToString(keyCode)); break; case KeyEvent.KEYCODE_VOLUME_UP: // event.startTracking(); //TODO controls.jAppOnKeyDown(c, keyCode, KeyEvent.keyCodeToString(keyCode)); break; case KeyEvent.KEYCODE_VOLUME_DOWN: controls.jAppOnKeyDown(c, keyCode, KeyEvent.keyCodeToString(keyCode)); break; /*commented! need SDK API >= 18 [Android 4.3] to compile!*/ /* case KeyEvent.KEYCODE_BRIGHTNESS_DOWN: controls.jAppOnKeyDown(c,keyCode,KeyEvent.keyCodeToString(keyCode)); break; case KeyEvent.KEYCODE_BRIGHTNESS_UP: controls.jAppOnKeyDown(c,keyCode,KeyEvent.keyCodeToString(keyCode)); break; */ case KeyEvent.KEYCODE_HEADSETHOOK: controls.jAppOnKeyDown(c, keyCode, KeyEvent.keyCodeToString(keyCode)); break; // default: controls.jAppOnKeyDown(c,keyCode,KeyEvent.keyCodeToString(keyCode)); } return super.onKeyDown(keyCode, event); }
/** Global entrance/exit into/from detailview */ public void setTouring(boolean p_touring, Building selectedBuilding_p) { selectedBuilding = selectedBuilding_p; controls.setEnabled(!p_touring); SlideCase.setActive(!p_touring); touring = p_touring; ropeSlideIndex = 0; if (touring) { Environment.contentHolder.setBorder(new LineBorder(Environment.fh_CI_Color, 3)); hideSlideCases(); } else { theCamera.setInstantCircleView(Boolean.valueOf(false)); theCamera.setLastCircleViewBuilding(null); Object[] actionObjects = {}; theCamera.queueAction("resetBuildings", 1000, actionObjects); theCamera.guaranteeMinInteractiveCameraHeight(); Environment.contentHolder.setBorder(Environment.grayline); } }
@Override protected void onPause() { super.onPause(); controls.jAppOnPause(); }
public void mousePressed() { controls.mousePressed(); }
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); controls.jAppOnNewIntent(); }
@Override protected void onDestroy() { super.onDestroy(); controls.jAppOnDestroy(); }
public void keyPressed() { controls.keyPressed(); }
public void mouseReleased() { controls.mouseReleased(); }
/*by jmpessoa: Handles menu item selections*/ @Override public boolean onContextItemSelected(MenuItem item) { String caption = item.getTitle().toString(); controls.jAppOnClickContextMenuItem(item, item.getItemId(), caption, item.isChecked()); return false; }
@Override protected void onResume() { super.onResume(); controls.jAppOnResume(); }
FFNGApp() { screen = Bitmap.createBitmap(900, 900, Config.ARGB_8888); canvas = new Canvas(screen); captionPaint.setARGB(255, 255, 255, 255); captionPaint.setTextSize(30); // bottom left controls.addTouchArea( controls .new TouchArea(new Rect(48, 480 - 96, 48 + 96, 480), FFNGView.SDLK_DOWN, "gui/down.png")); controls.addTouchArea( controls .new TouchArea( new Rect(0, 480 - 2 * 96, 96, 480 - 96), FFNGView.SDLK_LEFT, "gui/left.png")); controls.addTouchArea( controls .new TouchArea( new Rect(96, 480 - 2 * 96, 2 * 96, 480 - 96), FFNGView.SDLK_RIGHT, "gui/right.png")); controls.addTouchArea( controls .new TouchArea( new Rect(48, 480 - 3 * 96, 48 + 96, 480 - 2 * 96), FFNGView.SDLK_UP, "gui/up.png")); // bottom right controls.addTouchArea( controls .new TouchArea( new Rect(800 - 96, 480 - 96, 800, 480), FFNGView.SDLK_SPACE, "gui/switch.png")); // top right controls.addTouchArea( controls .new TouchArea(new Rect(800 - 96, 0, 800, 96), FFNGView.MORE_BUTTONS, "gui/more.png")); controls.addTouchArea( moreGroup[0] = controls .new TouchArea( new Rect(800 - 2 * 96, -96, 800 - 96, 0), FFNGView.SDLK_BACKSPACE, "gui/restart.png")); controls.addTouchArea( moreGroup[1] = controls .new TouchArea( new Rect(800 - 3 * 96, -96, 800 - 2 * 96, 0), FFNGView.SDLK_ESCAPE, "gui/exit.png")); controls.addTouchArea( moreGroup[2] = controls .new TouchArea( new Rect(800 - 4 * 96, -96, 800 - 3 * 96, 0), FFNGView.SDLK_F10, "gui/options.png")); controls.addTouchArea( moreGroup[3] = controls .new TouchArea( new Rect(800 - 5 * 96, -96, 800 - 4 * 96, 0), FFNGView.SDLK_F3, "gui/load.png")); controls.addTouchArea( moreGroup[4] = controls .new TouchArea( new Rect(800 - 6 * 96, -96, 800 - 5 * 96, 0), FFNGView.SDLK_F2, "gui/save.png")); // top left controls.addTouchArea( controls.new TouchArea(new Rect(0, 0, 96, 96), FFNGView.SDLK_MINUS, "gui/undo.png")); controls.addTouchArea( controls.new TouchArea(new Rect(96, 0, 2 * 96, 96), FFNGView.SDLK_PLUS, "gui/redo.png")); controls.resizeToScreen(surfaceWidth, surfaceHeight); }
// Mouse and Key Envents processed in Controls public void mouseDragged() { controls.mouseDragged(); }
public void keyReleased() { controls.keyReleased(); }
@Override public void onBackPressed() { controls.jAppOnBackPressed(); }
@Override protected void onStop() { super.onStop(); controls.jAppOnStop(); }
public void mouseMoved() { controls.mouseMoved(); }
// by jmpessoa: option menu support @Override public boolean onCreateOptionsMenu(Menu menu) { controls.jAppOnCreateOptionsMenu(menu); return true; }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { controls.jAppOnActivityResult(requestCode, resultCode, data); }
public void draw() { if (!afterFirstStreaming) return; runNum++; if (afterOverviewShot) returnChanges = theCamera.apply(); // test world Objects with screen frustum if (returnChanges) { for (int i = 0; i < objectManager.worldObjects.size(); i++) { if (((ObjectOfInterest) (objectManager.worldObjects.elementAt(i))).selectable) ((Building) (objectManager.worldObjects.elementAt(i))).testIfOnScreen(); } } // process moving objects movingObjectsManager.process(); // draw time and weather conditions naturalFactor.putIntoEffect(); // korrdinatensystem groundPlane.draw(touring); clearZBuffer(); // houses.draw(); boxes.draw(); pushMatrix(); scale(buildingUniScale); // draw models for (int i = 0; i < objectManager.worldObjects.size(); i++) { if (((ObjectOfInterest) (objectManager.worldObjects.elementAt(i))).selectable) { ((Building) (objectManager.worldObjects.elementAt(i))) .draw(this, false /* Don't draw in gray old:touring*/); } else ((ObjectOfInterest) (objectManager.worldObjects.elementAt(i))).draw(this, touring); } popMatrix(); /** * ****************** AFTER INTRO * ************************************************************************************** */ if (afterIntro) { // if (theCamera.getPos() != null) Overview.setLookPoint(theCamera.getPos()); // locator.draw(); // // // draw moving objects // movingObjectsManager.draw(); // // if (drawDebugSpheres) { // sphereDetail(20); // for (int i = 0; i < objectManager.worldObjects.size(); i++) { // if (((ObjectOfInterest) (objectManager.worldObjects.elementAt(i))) . // selectable) // ((Building) (objectManager.worldObjects.elementAt(i))).debugDraw(this); // } // } // // fill(255, 255, 255, 255); // noStroke(); // // // sphere list drawing for testing // for (int i = 0; i < spheres.size(); i++) { // FVector pos = ((FVector) (spheres.elementAt(i))).cloneMe(); // fill(255, 100, 100, 255); // pushMatrix(); // translate(pos.getX(), pos.getY(), pos.getZ()); // sphere(10 + 5 * i); // popMatrix(); // } // // } // /** * ************************************************************************************* END * AFTER INTRO ************************** */ naturalFactor.applySurroundings(); if (selectedBuilding != null) { pushMatrix(); scale(buildingUniScale); selectedBuilding.draw(this, false); popMatrix(); } // clearZBuffer(); hint(DISABLE_DEPTH_TEST); /* * if (overviewImage != null) { for (int y = 0, y2 = 0; y < * (overviewImage.height * width); y += width, y2 += * overviewImage.width) { for (int x = width - overviewImage.width, * x2 = 0; x < width; x++, x2++) { //System.out.println("" + (x + y) + " " + * (x2+y2)); pixels[y+x] = 0xff000000 + color( (red(pixels[y+x]) + * red (overviewImage.pixels[y2+x2]))/2, (green(pixels[y+x]) + green * (overviewImage.pixels[y2+x2]))/2, (blue(pixels[y+x]) + * blue(overviewImage.pixels[y2+x2]))/2); } } } */ // 2D interface (buttons and sliders so far) camera(); // reset camera // lights(); fill(0, 20, 150, 20); stroke(255, 0, 0); noFill(); // render SlideCases renderSlideCases(mouseX, mouseY); if (touring) { if (preparingForTouring) { detailPreparingStep(); } else { paintTouringRope(); drawDetailBraces(); } } if (overlay != null) { image(overlay, 0, 250); } theCamera.drawFramerate(); // clean up and similar // ***************************************************** controls.reset(); env.repaintEnv(); // wait delay to allow processing of other system tasks try { delay(30); } catch (java.lang.IllegalMonitorStateException e) { // e.printStackTrace(); } noHint(DISABLE_DEPTH_TEST); }
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); controls.jAppOnRotate(newConfig.orientation); controls.jAppOnConfigurationChanged(); }
// by jmpessoa: context menu support - Context menu items do not support icons! @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); // Log.i("App.Java_onCreateContextMenu", "long_pressed!"); controls.jAppOnCreateContextMenu(menu); }