public void draw(Graphics2D g2) { g2.setColor(new Color(33, 104, 96)); g2.fill(new Rectangle2D.Double(0, 0, Window.WIDTH, Window.HEIGHT)); bigPkm(selected == 0, g2, character.currentPokemon()[0]); for (int i = 1; i < 6; i++) { smallPkm(selected == i, g2, character.currentPokemon()[i], i - 1); } if (hasCancel) cancelButton( selected == totalButtons - 1, g2, Window.WIDTH - WIDTH3 - 20, Window.HEIGHT - HEIGHT3 - 20); if (switching) switchingTxt.draw(g2); else txt.draw(g2); if (menu != null) { menu.draw(g2); if (menu.result() != null) { if (menu.result().equals("Switch")) { if (inBattle) { switchIndex = selected; over = true; } else { switchIndex = selected; switching = true; } } menu = null; } } }
@Test public void testSetSpecial() { Menu m = new Menu(name, description); assertTrue(m.addItem(i1)); assertTrue(m.setSpecial(i1)); assertTrue(m.getSpecial().equals(i1)); }
/** * Method declaration * * @param s */ private void addToRecent(String s) { for (int i = 0; i < iMaxRecent; i++) { if (s.equals(sRecent[i])) { return; } } if (sRecent[iRecent] != null) { mRecent.remove(iRecent); } sRecent[iRecent] = s; if (s.length() > 43) { s = s.substring(0, 40) + "..."; } MenuItem item = new MenuItem(s); item.setActionCommand("#" + iRecent); item.addActionListener(this); mRecent.insert(item, iRecent); iRecent = (iRecent + 1) % iMaxRecent; }
public boolean onPrepareOptionsMenu(Menu menu) { MenuItem startItem = menu.findItem(START_LIVE_DATA); MenuItem stopItem = menu.findItem(STOP_LIVE_DATA); MenuItem settingsItem = menu.findItem(SETTINGS); MenuItem commandItem = menu.findItem(COMMAND_ACTIVITY); // validate if preRequisites are satisfied. if (preRequisites) { if (mServiceConnection.isRunning()) { startItem.setEnabled(false); stopItem.setEnabled(true); settingsItem.setEnabled(false); commandItem.setEnabled(false); } else { stopItem.setEnabled(false); startItem.setEnabled(true); settingsItem.setEnabled(true); commandItem.setEnabled(false); } } else { startItem.setEnabled(false); stopItem.setEnabled(false); settingsItem.setEnabled(false); commandItem.setEnabled(false); } return true; }
/* * Handle events common to all views. * Returns false if no action was taken. */ protected final void keyPressed(int keyCode) { if (modal != null) { if (modal.keyPressed(keyCode, this)) { if ((modal == menu) && (menu.execute())) { menuAction(menu.getAction()); } modal = modal.parentModal; } this.repaint(); System.out.println("repaint"); return; } switch (keyCode) { case -7: case KEY_POUND: modal = menu; this.repaint(); return; case -6: case KEY_STAR: case KEY_NUM0: // Convenience key when developing viewNavigator.ShowNext(); return; } keyPressedView(keyCode); // Let the current view handle this keypress }
@Test public void testAddItemDuplicate() { Menu m = new Menu(name, description); assertTrue(m.addItem(i1)); assertFalse(m.addItem(i1)); assertTrue(m.addItem(i2)); }
public SplashDemo() throws NullPointerException, IllegalStateException, IOException { super("SplashScreen demo"); setSize(300, 200); setLayout(new BorderLayout()); Menu m1 = new Menu("File"); MenuItem mi1 = new MenuItem("Exit"); m1.add(mi1); mi1.addActionListener(this); this.addWindowListener(closeWindow); MenuBar mb = new MenuBar(); setMenuBar(mb); mb.add(m1); final SplashScreen splash = SplashScreen.getSplashScreen(); if (splash == null) { System.out.println("SplashScreen.getSplashScreen() returned null"); return; } Graphics2D g = splash.createGraphics(); if (g == null) { System.out.println("g is null"); return; } for (int i = 0; i < 100; i++) { renderSplashFrame(g, i); splash.update(); try { Thread.sleep(90); } catch (InterruptedException e) { } } splash.close(); setVisible(true); toFront(); }
/** * Shows "call via" menu allowing user to selected from multiple providers. * * @param context the android context * @param v the View that will contain the popup menu. * @param destination target callee name. */ private static void showCallViaMenu(final Context context, View v, final String destination) { PopupMenu popup = new PopupMenu(context, v); Menu menu = popup.getMenu(); Iterator<ProtocolProviderService> registeredProviders = AccountUtils.getRegisteredProviders().iterator(); while (registeredProviders.hasNext()) { final ProtocolProviderService provider = registeredProviders.next(); String accountAddress = provider.getAccountID().getAccountAddress(); MenuItem menuItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, accountAddress); menuItem.setOnMenuItemClickListener( new MenuItem.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { createCall(context, destination, provider); return false; } }); } popup.show(); }
/** * Gives us the choice between setPower(), or setSpeed(). It allowed us to test which one we * should use. */ public static void test() { /* * First, get the values from the user by displaying the instructions on * the screen. If the user agrees with the parameters set in the menu, * proceed to the launching. If not, display the menu again. */ while (!mainMenu.summarizeLauncher()) { if (mainMenu.display()) { launcherPower = mainMenu.askForPower(); } else { launcherSpeed = mainMenu.askForSpeed(); } launcherDelay = mainMenu.askForDelay(); } LCD.clearDisplay(); LCD.drawString(" Shooting ", 0, 0); if (launcherPower != -1) { launcher.chainFireAtPower(launcherPower, launcherDelay); } else { launcher.chainFireAtSpeed(launcherSpeed, launcherDelay); } LCD.clearDisplay(); }
public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, START_LIVE_DATA, 0, "Start Live Data"); menu.add(0, COMMAND_ACTIVITY, 0, "Run Command"); menu.add(0, STOP_LIVE_DATA, 0, "Stop"); menu.add(0, SETTINGS, 0, "Settings"); return true; }
public static void main(String[] agrs) { // create new instance of Menu class Menu m = new Menu(); // call menu method of object m, an instance of the Menu class m.menu(); }
public void fillMenuOptions(Menu menu, int instance) { boolean haveContext = false; boolean hasMiniMenu = false; if ((instance == Menu.INSTANCE_CONTEXT) || (pushMiniMenu)) { for (int i = 0; i < m_MiniMenuItems.size(); ++i) { MenuItem item = (MenuItem) m_MiniMenuItems.elementAt(i); if (item != null) { menu.add(item); hasMiniMenu = true; } } } if (!hasMiniMenu) { for (int i = 0; i < m_contextMenuItems.size(); ++i) { MenuItem item = (MenuItem) m_contextMenuItems.elementAt(i); if (item != null) { menu.add(item); haveContext = true; } } } if (((!haveContext) && (!hasMiniMenu))) { for (int i = 0; i < m_menuItems.size(); ++i) { menu.add((MenuItem) m_menuItems.elementAt(i)); } } }
/** * Closes currently opened menu (if any). Used by framework and typically there is no need to call * this manually */ public void closeMenu() { if (currentMenu != null) { currentMenu.deselectButton(); currentMenu.remove(); currentMenu = null; } }
// // Initialize the GUI (application and applet) // public void initialize(String[] args) { // Initialize the window, menubar, etc. super.initialize(args); exampleFrame.setTitle("Java 3D Light Scoping Example"); // // Add a menubar menu to change node parameters // Use bounding leaf // Menu m = new Menu("DirectionalLights"); light1OnOffMenu = new CheckboxMenuItem("Red light with sphere set 1 scope", light1OnOff); light1OnOffMenu.addItemListener(this); m.add(light1OnOffMenu); light2OnOffMenu = new CheckboxMenuItem("Blue light with sphere set 2 scope", light2OnOff); light2OnOffMenu.addItemListener(this); m.add(light2OnOffMenu); light3OnOffMenu = new CheckboxMenuItem("White light with universal scope", light3OnOff); light3OnOffMenu.addItemListener(this); m.add(light3OnOffMenu); exampleMenuBar.add(m); }
private void jButton4ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: this.setVisible(false); Menu mn = new Menu(); mn.setVisible(true); } // GEN-LAST:event_jButton4ActionPerformed
@Test public void testFilterAspectsInNavBar() { GIVEN("Sam-+->Bob as Work"); Relation.forUser(Users.Pod2.sam).toUser(Users.Pod2.bob, WORK).doNotLogOut().ensure(); GIVEN("Work aspect post from Sam is added after setup relation"); Menu.openStream(); Feed.ensureNoPost(Users.Pod2.sam, Phrases.POST_FOR_WORK); Feed.addAspectPost(WORK, Phrases.POST_FOR_WORK); GIVEN("Bob-+->Sam as Friends "); Relation.forUser(Users.Pod2.bob).toUser(Users.Pod2.sam, FRIENDS).doNotLogOut().ensure(); GIVEN("Friends and Family aspects post from Bob are added after setup relation"); Menu.openStream(); Feed.ensureNoPost(Users.Pod2.bob, Phrases.POST_FOR_FRIENDS); Feed.addAspectPost(FRIENDS, Phrases.POST_FOR_FRIENDS); Feed.ensureNoPost(Users.Pod2.bob, Phrases.POST_FOR_FAMILY); Feed.addAspectPost(FAMILY, Phrases.POST_FOR_FAMILY); WHEN("In NavBar aspects list all aspects is deselected"); NavBar.openMyAspects(); Aspects.toggleAll(); Aspects.assertToggleAllText("Select all"); THEN("All posts in all aspects is shown"); Feed.assertPost(Users.Pod2.sam, Phrases.POST_FOR_WORK); Feed.assertPost(Users.Pod2.bob, Phrases.POST_FOR_FRIENDS); Feed.assertPost(Users.Pod2.bob, Phrases.POST_FOR_FAMILY); WHEN("In NavBar aspects list some aspects is selected"); Aspects.toggleAspect(ACQUAINTANCES); Aspects.toggleAspect(FRIENDS); THEN("Author's posts limited in these aspects is shown"); AND("posts of users linked in these aspects is shown"); Feed.assertPost(Users.Pod2.sam, Phrases.POST_FOR_WORK); Feed.assertPost(Users.Pod2.bob, Phrases.POST_FOR_FRIENDS); Feed.assertNoPost(Users.Pod2.bob, Phrases.POST_FOR_FAMILY); WHEN("In NavBar aspects list some aspect is deselected"); Aspects.toggleAspect(FRIENDS); THEN("Author's posts limited in this aspect is not shown"); AND("posts of users linked in this aspect is not shown"); Feed.assertNoPost(Users.Pod2.sam, Phrases.POST_FOR_WORK); Feed.assertNoPost(Users.Pod2.bob, Phrases.POST_FOR_FRIENDS); Feed.assertNoPost(Users.Pod2.bob, Phrases.POST_FOR_FAMILY); WHEN("In NavBar aspects list all aspects is selected"); Aspects.toggleAll(); Aspects.assertToggleAllText("Deselect all"); THEN("All posts in all aspects is shown"); Feed.assertPost(Users.Pod2.sam, Phrases.POST_FOR_WORK); Feed.assertPost(Users.Pod2.bob, Phrases.POST_FOR_FRIENDS); Feed.assertPost(Users.Pod2.bob, Phrases.POST_FOR_FAMILY); }
@Test public void testSetGetName() { Menu testMenu = new Menu(12345); testMenu.setName("Denny's Menu"); assertEquals("Denny's Menu", testMenu.getName()); }
public void update(String id, String title, MenuVisibility visibility, String link, int order) { Menu menu = this.read(id); if (StringUtils.hasText(title)) menu.setTitle(title); if (StringUtils.hasText(link)) menu.setTitle(link); if (visibility != null) menu.setVisibility(visibility); if (order > 0) menu.setOrder(order); this.menuRepository.save(menu); }
public void printMenu() { Iterator menuIterator = menus.iterator(); while (menuIterator.hasNext()) { Menu menu = (Menu) menuIterator.next(); printMenu(menu.createIterator()); System.out.println(); } }
public void mousePressed() { if (!menu.startPressed()) { menu.mPressed(mouseX, mouseY); } else { levels.mPressed(mouseX, mouseY); } }
/** {@inheritDoc} */ @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.editor, menu); mSaveAction = menu.findItem(R.id.mnu_save); mWordWrapAction = menu.findItem(R.id.mnu_word_wrap); return super.onCreateOptionsMenu(menu); }
@Test public void testSetGetEvent() { Menu testMenu = new Menu(67890); testMenu.setEvent("Easter Dinner"); assertEquals("Easter Dinner", testMenu.getEvent()); }
@Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.getWheelRotation() > 0) { menu.setReleased(0); } else { menu.setReleased(1); } }
private void paintMenu(Graphics2D g2d) { if (showMenu == true) { if (c.getPoints() > c.getHighscore().getLowestPointsInTable() && c.getLifes() == 0) { menu.setState(4); } menu.draw(g2d); } }
/* * Finds menu in Menu enum with specified index */ private Menu calcMenuFromId(int i) { for (Menu m : Menu.values()) { if (m.ordinal() == i) { return m; } } return Menu.NONE; }
private static void initMenu() { // 系统管理模块 Menu menu = new Menu("10", "系统管理"); List<SubMenu> subMenus = new ArrayList<>(); subMenus.add(new SubMenu("1001", "后台用户管理", "/system/user", "10")); subMenus.add(new SubMenu("1002", "角色管理", "/system/role", "10")); menu.setChildMenuList(subMenus); menuList.add(menu); }
public void printMenu() { Iterator pancakeIterator = pancakeHouseMenu.createIterator(); Iterator dinerIterator = dinerMenu.createIterator(); System.out.println("MENU\n----\nBREAKFAST"); printMenu(pancakeIterator); System.out.println("\nLUNCH"); printMenu(dinerIterator); }
@Test public void testRemoveItem() { Menu m = new Menu(name, description); assertTrue(m.addItem(i1)); assertTrue(m.addItem(i2)); assertTrue(m.removeItem(i1)); assertTrue(m.removeItem(i2)); }
public void dispose() { for (Menu menu : activeMenus) { menu.dispose(); } activeMenus.clear(); universe.dispose(); shader.dispose(); model.dispose(); }
public static void main(String[] args) throws IOException { int choice; PrintWriter pw = new PrintWriter(new FileWriter("csis.txt")); Decimal dec = new Decimal(pw); Binary bin = new Binary(pw); Hexadecimal hex = new Hexadecimal(pw); Menu menu = new Menu(pw); do { menu.display(); choice = menu.getSelection(); switch (choice) { case 1: dec.decToBin(); break; case 2: dec.decToHex(); break; case 3: bin.binToDec(); break; case 4: bin.binToHex(); break; case 5: hex.hexToDec(); break; case 6: hex.hexToBin(); break; } } while (choice != 7); pw.close(); }