public Font GetFont(String opt1, String opt2, Font previous) { Font newfont = previous; int actual = -1; int pstyle = previous.getStyle(); int psize = previous.getHeight(); FontFamily fontFamily[] = FontFamily.getFontFamilies(); for (int x = 0; x < fontFamily.length; x++) { if (fontFamily[x].getName().equalsIgnoreCase(opt1)) { actual = x; break; } } if (actual == -1) { for (int x = 0; x < fontFamily.length; x++) { if (fontFamily[x].getName().equalsIgnoreCase(opt2)) { actual = x; break; } } } if (actual == -1) { newfont = Font.getDefault().derive(pstyle, psize); } else { newfont = fontFamily[actual].getFont(pstyle, psize); } return newfont; }
/** * Constructor. * * @param text The text to be displayed on the button * @param style Combination of field style bits to specify display attributes */ public BOC(String dboc, String iboc, String tboc) { super(Field.NON_FOCUSABLE); try { _width = Display.getWidth(); switch (_width) { case 480: f2 = 20; dbmp = Bitmap.getBitmapResource("bocdom480.jpg"); ibmp = Bitmap.getBitmapResource("bocinter480.jpg"); tbmp = Bitmap.getBitmapResource("boctotal480.jpg"); _height = 60; break; case 360: f2 = 19; dbmp = Bitmap.getBitmapResource("bocdom360.png"); ibmp = Bitmap.getBitmapResource("bocinter360.png"); tbmp = Bitmap.getBitmapResource("boctotal360.png"); _height = 60; break; default: f2 = 17; dbmp = Bitmap.getBitmapResource("bocdom320.png"); ibmp = Bitmap.getBitmapResource("bocinter320.png"); tbmp = Bitmap.getBitmapResource("boctotal320.png"); _height = 60; break; } _dboc = dboc; _iboc = iboc; _tboc = tboc; FontFamily ff1 = FontFamily.forName("BBAlpha Serif"); font = ff1.getFont(Font.PLAIN, f2); } catch (Exception ex) { System.out.println(ex.getMessage()); } }
public class Layout extends UserInterface { UiApplication theApp; Strings strings; FontFamily fontFamily[] = FontFamily.getFontFamilies(); Background bkg_splash = null; Background bkg_main = null; Bitmap splash = null; Bitmap main = null; Bitmap btn = null; String logo = "img/logo.png"; String button = "img/button_notext1_off.png"; String button_on = "img/button_notext1_on.png"; String friends = "img/button_notext2_off.png"; String friends_on = "img/button_notext2_on.png"; String defSplash = "img/splash_360x480.png"; String blank = "img/blank.png"; public Layout(CMainScreen c) { super(c); UiApplication ui = UiApplication.getUiApplication(); theApp = (UiApplication) ui; strings = new Strings(); setUpAssets(); } public void setUpAssets() { int w = Display.getWidth(); int h = Display.getHeight(); String res = w + "x" + h; System.out.println("res__________" + res); splash = Bitmap.getBitmapResource("img/splash_" + res + ".png"); main = Bitmap.getBitmapResource("img/bkg_main.jpg"); btn = Bitmap.getBitmapResource(button); if (splash == null) { splash = Bitmap.getBitmapResource(defSplash); } bkg_splash = BackgroundFactory.createBitmapBackground(splash); bkg_main = BackgroundFactory.createBitmapBackground(main); } public Manager splashScreen(Manager parent) { VerticalFieldManager fm_MainHolder = new VerticalFieldManager( Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT | Manager.NO_VERTICAL_SCROLL) { public int getPreferredWidth() { return Display.getWidth(); } public int getPreferredHeight() { return Display.getHeight(); } protected void sublayout(int width, int height) { width = getPreferredWidth(); height = getPreferredHeight(); super.sublayout(width, height); super.setExtent(width, height); } }; Background back = bkg_splash; fm_MainHolder.setBackground(back); parent.add(fm_MainHolder); return fm_MainHolder; } public Manager mainScreen(Manager parent) { CInterface ci = new CInterface(); final int columnHeight0 = (int) ((Display.getHeight() / 2)); final int columnHeight1 = (int) (Display.getHeight() / 2); final int btnw = (int) ((float) Display.getWidth() * .75); final EncodedImage buttonoff = ci.getScaledImage(EncodedImage.getEncodedImageResource(button), btnw); final EncodedImage buttonon = ci.getScaledImage(EncodedImage.getEncodedImageResource(button_on), btnw); final EncodedImage friendsoff = ci.getScaledImage(EncodedImage.getEncodedImageResource(friends), btnw); final EncodedImage friendson = ci.getScaledImage(EncodedImage.getEncodedImageResource(friends_on), btnw); int imagew = (int) ((float) Display.getWidth() * .75); Bitmap blankbmp = Bitmap.getBitmapResource(blank); VerticalFieldManager fm_MainHolder = new VerticalFieldManager( Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT | Manager.NO_HORIZONTAL_SCROLL | Manager.NO_VERTICAL_SCROLL) { public int getPreferredWidth() { return Display.getWidth(); } public int getPreferredHeight() { return Display.getHeight(); } protected void sublayout(int width, int height) { width = getPreferredWidth(); height = getPreferredHeight(); super.sublayout(width, height); super.setExtent(width, height); } }; Background back = bkg_main; fm_MainHolder.setBackground(back); // MAIN LOGO HorizontalFieldManager lgo = new HorizontalFieldManager( Manager.NO_VERTICAL_SCROLL | Manager.NO_HORIZONTAL_SCROLL | Manager.FIELD_HCENTER | Manager.FIELD_VCENTER | Manager.USE_ALL_WIDTH) { public int getPreferredHeight() { return columnHeight0; } protected void sublayout(int width, int height) { width = super.getPreferredWidth(); height = getPreferredHeight(); super.sublayout(width, height); super.setExtent(width, height); } }; BitmapField img = ci.WriteSimpleImage( lgo, logo, BitmapField.FIELD_VCENTER | BitmapField.FIELD_HCENTER, imagew, ""); fm_MainHolder.add(lgo); // BUTTON HOLDER VerticalFieldManager vfmButton = new VerticalFieldManager( Manager.FIELD_HCENTER | Manager.FIELD_VCENTER | Manager.USE_ALL_WIDTH) { public int getPreferredHeight() { return columnHeight1; } public int getPreferredWidth() { return Display.getWidth(); } protected void sublayout(int width, int height) { width = getPreferredWidth(); height = getPreferredHeight(); super.sublayout(width, height); super.setExtent(width, height); } }; final BitmapField bmFieldSpan = new BitmapField(blankbmp, BitmapField.NON_FOCUSABLE); CustomButtonField cbfFriends = new CustomButtonField( btnw, strings.getString("invite_friends"), friendsoff.getBitmap(), friendson.getBitmap(), Field.FOCUSABLE | Field.FIELD_HCENTER | Field.FIELD_VCENTER) { protected boolean navigationClick(int status, int time) { c.action_callback("web_friends", "", ""); return true; } }; CustomButtonField cbfButton = new CustomButtonField( btnw, strings.getString("read_qr"), buttonoff.getBitmap(), buttonon.getBitmap(), Field.FOCUSABLE | Field.FIELD_HCENTER | Field.FIELD_VCENTER) { protected boolean navigationClick(int status, int time) { c.action_callback("qr_start", "", ""); return true; } }; vfmButton.add(cbfButton); vfmButton.add(bmFieldSpan); vfmButton.add(cbfFriends); fm_MainHolder.add(vfmButton); parent.add(fm_MainHolder); return fm_MainHolder; } public void construct_makescrollable_attache(Manager parent) { parent.add(new NullField(NullField.FOCUSABLE)); } }
public PickScreen(int voteType) { super(); this.voteType = voteType; VerticalFieldManager vertFieldManager = new VerticalFieldManager( VerticalFieldManager.USE_ALL_WIDTH | VerticalFieldManager.VERTICAL_SCROLLBAR) { // Override the paint method to draw the background image. public void paint(Graphics graphics) { graphics.setColor(Color.BLACK); graphics.fillRect(0, 0, this.getWidth(), this.getHeight()); super.paint(graphics); } }; ; try { // set up the smaller list font ff1 = FontFamily.forName("Verdana"); font2 = ff1.getFont(Font.BOLD, 20); } catch (final ClassNotFoundException cnfe) { } Vector contList = GameData.getCurrentGame().getActiveContestants(); Contestant[] contArray = new Contestant[contList.size()]; contList.copyInto(contArray); ocfActiveContestant = new ObjectChoiceField(" Cast your " + voteType + " vote: ", contArray); User user = GameData.getCurrentGame().getCurrentUser(); if (voteType == T_WEEKLY && user.getWeeklyPick() != null) { ocfActiveContestant.setSelectedIndex(user.getWeeklyPick()); } else if (voteType == T_ULTIMATE && user.getUltimatePick() != null) { ocfActiveContestant.setSelectedIndex(user.getUltimatePick()); } list = new RichList(vertFieldManager, true, 3, 0); // get all contestants for list contList = GameData.getCurrentGame().getAllContestants(); for (int i = 0; i < contList.size(); i++) { Contestant cont = (Contestant) contList.elementAt(i); /* list contains labels so that the text colour can change */ lblContName = new LabelField(cont.getFirstName() + " " + cont.getLastName(), LabelField.ELLIPSIS) { public void paint(Graphics g) { g.setColor(Color.WHITE); super.paint(g); } }; lblContName.setFont(font2); labelContTribe = new LabelField(cont.getTribe(), LabelField.ELLIPSIS) { public void paint(Graphics g) { g.setColor(Color.WHITE); super.paint(g); } }; lblContName.setFont(font2); String tempString = ""; if (cont.isCastOff()) tempString = "Castoff"; else tempString = "Active"; labelTempStatus = new LabelField(tempString, LabelField.ELLIPSIS) { public void paint(Graphics g) { g.setColor(Color.WHITE); super.paint(g); } }; lblContName.setFont(font2); Bitmap imgContestant = getImage(cont.getPicture()); list.add(new Object[] {imgContestant, lblContName, labelContTribe, labelTempStatus}); } HorizontalFieldManager horFieldManager = new HorizontalFieldManager( HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.FIELD_HCENTER) { // Override the paint method to draw the background image. public void paint(Graphics graphics) { graphics.setColor(Color.GREEN); graphics.fillRect(0, 0, this.getWidth(), this.getHeight()); super.paint(graphics); } }; ; String voted = "Vote"; user = GameData.getCurrentGame().getCurrentUser(); System.out.println(user.getWeeklyPick() + " " + this.voteType); if ((this.voteType == T_WEEKLY && user.getWeeklyPick() != null) || (this.voteType == T_ULTIMATE && user.getUltimatePick() != null)) voted = "Revote"; btnVoted = new ButtonField(voted); btnVoted.setChangeListener(this); horFieldManager.add(btnVoted); horFieldManager.add(ocfActiveContestant); horFieldManager.setFont(font2); this.setTitle(horFieldManager); this.add(vertFieldManager); this.setStatus(Common.getToolbar("Log Out")); vertFieldManager.setFocus(); // THIS NEEDS TO BE HERE. APP CRASHES WITHOUT IT }
public CambiarPuntosMap() { if (Display.getWidth() == 320) { getMainManager() .setBackground( BackgroundFactory.createBitmapBackground( Bitmap.getBitmapResource("background_320.png"))); tFuente = 17; tFuente2 = 20; veinticinco = 10; veinte = 10; trecientoscuarentaysiete = 170; setenta = 35; hr = Bitmap.getBitmapResource("hr_line_3.png"); leftHr = 10; btnMapa = Bitmap.getBitmapResource("btnMapa_320.png"); btnMapa1 = Bitmap.getBitmapResource("btnMapa1_320.png"); btnAgregarMapa = Bitmap.getBitmapResource("btnAgregarMapa_320.png"); btnAgregarMapa1 = Bitmap.getBitmapResource("btnAgregarMapa1_320.png"); } if (Display.getWidth() == 360) { getMainManager() .setBackground( BackgroundFactory.createBitmapBackground( Bitmap.getBitmapResource("background_360.png"))); tFuente = 20; tFuente2 = 23; veinticinco = 10; veinte = 10; trecientoscuarentaysiete = 403; setenta = 35; hr = Bitmap.getBitmapResource("hr_line_3.png"); leftHr = 30; btnMapa = Bitmap.getBitmapResource("btnMapa_320.png"); btnMapa1 = Bitmap.getBitmapResource("btnMapa1_320.png"); btnAgregarMapa = Bitmap.getBitmapResource("btnAgregarMapa_320.png"); btnAgregarMapa1 = Bitmap.getBitmapResource("btnAgregarMapa1_320.png"); } if (Display.getWidth() == 480) { getMainManager() .setBackground( BackgroundFactory.createBitmapBackground( Bitmap.getBitmapResource("background_480.png"))); tFuente = 20; tFuente2 = 23; veinticinco = 10; veinte = 10; trecientoscuarentaysiete = 291; setenta = 35; hr = Bitmap.getBitmapResource("hr_line.png"); leftHr = 0; btnMapa = Bitmap.getBitmapResource("btnMapa_320.png"); btnMapa1 = Bitmap.getBitmapResource("btnMapa1_320.png"); btnAgregarMapa = Bitmap.getBitmapResource("btnAgregarMapa_320.png"); btnAgregarMapa1 = Bitmap.getBitmapResource("btnAgregarMapa1_320.png"); } if (Display.getWidth() == 640) { getMainManager() .setBackground( BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("background.png"))); tFuente = 35; tFuente2 = 40; } try { FontFamily ffFont1 = FontFamily.forName("Arial"); fLite = ffFont1.getFont(Font.SANS_SERIF_STYLE, tFuente); fTitle = ffFont1.getFont(Font.SANS_SERIF_STYLE, tFuente2); // hr = Bitmap.getBitmapResource("hr_line.png"); // getMainManager().setBackground(BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("background.png"))); VerticalFieldManager logoHfm = new VerticalFieldManager(VerticalFieldManager.FIELD_HCENTER); logoHfm.setBackground( BackgroundFactory.createLinearGradientBackground(0xe68241, 0xe68241, 0xd16f2f, 0xd16f2f)); logoHfm.setMargin(0, 0, 0, 0); ColorRichText emailCrt = new ColorRichText( Strings.CHANGECONFIG, 0xffffff, RichTextField.FIELD_HCENTER | RichTextField.TEXT_ALIGN_HCENTER); emailCrt.setFont(fTitle); emailCrt.setMargin(veinticinco, 0, veinticinco, 0); logoHfm.add(emailCrt); VerticalField footerLogoHfm = new VerticalField(Display.getWidth(), veinte, VerticalFieldManager.FIELD_HCENTER); footerLogoHfm.setBackground( BackgroundFactory.createLinearGradientBackground(0x9cbe4f, 0x7a9b3c, 0x7a9b3c, 0x9cbe4f)); ColorRichText introCrt = new ColorRichText( "Elige tus puntos favoritos", 0xffffff, RichTextField.FIELD_HCENTER | RichTextField.TEXT_ALIGN_HCENTER); introCrt.setFont(fTitle); introCrt.setMargin(25, 0, 25, 0); footerLogoHfm.add(introCrt); logoHfm.add(footerLogoHfm); add(logoHfm); VerticalField allContentFiltro = new VerticalField( Display.getWidth(), trecientoscuarentaysiete, HorizontalField.FIELD_HCENTER | VerticalField.VERTICAL_SCROLL | VerticalField.VERTICAL_SCROLLBAR); Object[] municipioO = new Object[] {"one", "two", "three"}; ObjectChoiceField municipioOcf = new FullWidthChoiceField(); municipioOcf.setChoices(municipioO); municipioOcf.setMargin(0, 70, 0, 70); VerticalFieldManager municipioVfm = new VerticalFieldManager( VerticalFieldManager.FIELD_HCENTER | HorizontalFieldManager.FIELD_HCENTER); LabelField municipioLf = new LabelField("Municipio", LabelField.FIELD_HCENTER); municipioLf.setFont(fLite); municipioLf.setMargin(15, 0, 5, 0); municipioVfm.add(municipioLf); // |/ DrawStyle.HCENTER)); municipioVfm.add(municipioOcf); hrBf = new BitmapField(hr); hrBf.setMargin(20, 0, 0, leftHr); municipioVfm.add(hrBf); allContentFiltro.add(municipioVfm); /**/ Object[] establecimientoO = new Object[] {"one", "two", "three"}; ObjectChoiceField establecimientoOcf = new FullWidthChoiceField(); establecimientoOcf.setChoices(establecimientoO); establecimientoOcf.setMargin(0, 70, 0, 70); VerticalFieldManager establecimientoVfm = new VerticalFieldManager( VerticalFieldManager.FIELD_HCENTER | HorizontalFieldManager.FIELD_HCENTER); LabelField establecimientoLf = new LabelField("Establecimiento", LabelField.FIELD_HCENTER); establecimientoLf.setFont(fLite); establecimientoLf.setMargin(15, 0, 5, 0); establecimientoVfm.add(establecimientoLf); // |/ DrawStyle.HCENTER)); establecimientoVfm.add(establecimientoOcf); hrBf = new BitmapField(hr); hrBf.setMargin(20, 0, 0, leftHr); establecimientoVfm.add(hrBf); allContentFiltro.add(establecimientoVfm); HorizontalFieldManager botonesHfc = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER); // botonesHfc.setMargin(0, 50, 0, 0); BitmapButtonField btnMapaUser = new BitmapButtonField(btnMapa, btnMapa1, Field.FIELD_HCENTER); btnMapaUser.setChangeListener( new FieldChangeListener() { public void fieldChanged(Field field, int context) { UiApplication.getUiApplication().pushScreen(new ListaEstablecimiebtosMap()); } }); btnMapaUser.setMargin(20, 10, 0, 0); BitmapButtonField btnAgregarMapaUser = new BitmapButtonField(btnAgregarMapa, btnAgregarMapa1, Field.FIELD_HCENTER); btnAgregarMapaUser.setChangeListener( new FieldChangeListener() { public void fieldChanged(Field field, int context) { UiApplication.getUiApplication().pushScreen(new ListaEstablecimiebtosMap()); } }); btnAgregarMapaUser.setMargin(20, 10, 0, 0); botonesHfc.add(btnMapaUser); botonesHfc.add(btnAgregarMapaUser); allContentFiltro.add(botonesHfc); add(allContentFiltro); } catch (Exception e) { // TODO: handle exception System.out.println(e.getMessage()); add(new RichTextField(e.getMessage())); } }
CitationScreen6(Citation _c) { c = _c; String cNumberString = Integer.toString(c.Number); /* CustomLabelField lf = new CustomLabelField("OREGON UNIFORM CITATION: #" + cNumberString, LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH); lf.setBackgroundColor(0x00194E84); lf.setTextColor(0x00ffffff); FontFamily fontFamily0[] = FontFamily.getFontFamilies(); Font font = fontFamily0[1].getFont(FontFamily.CBTF_FONT, 14); lf.setFont(font); add(lf); */ LabelField lf0 = new LabelField( "OREGON UNIFORM CITATION: #" + cNumberString, LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER) { protected void paintBackground(net.rim.device.api.ui.Graphics g) { g.clear(); g.getColor(); g.setColor(Color.GREEN); g.fillRect(0, 0, Display.getWidth(), Display.getHeight()); g.setColor(Color.WHITE); } }; FontFamily fontFamily0[] = FontFamily.getFontFamilies(); Font font0 = fontFamily0[1].getFont(FontFamily.CBTF_FONT, 14); lf0.setFont(font0); setTitle(lf0); add(new SeparatorField()); /* CustomLabelField lf1 = new CustomLabelField("************* INCIDENT ATTRIBUTES **************", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH); lf1.setBackgroundColor(Color.LIGHTGREY); lf1.setTextColor(Color.BLUE); FontFamily fontFamily[] = FontFamily.getFontFamilies(); Font font1 = fontFamily[1].getFont(FontFamily.CBTF_FONT, 14); lf1.setFont(font1); add(lf1); */ LabelField lf3 = new LabelField( "********* INCIDENT ATTRIBUTES **********", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER) { protected void paintBackground(net.rim.device.api.ui.Graphics g) { g.clear(); g.getColor(); g.setColor(Color.GREEN); g.fillRect(0, 0, Display.getWidth(), Display.getHeight()); g.setColor(Color.WHITE); } }; FontFamily fontFamily3[] = FontFamily.getFontFamilies(); Font font3 = fontFamily3[1].getFont(FontFamily.CBTF_FONT, 14); lf3.setFont(font0); add(lf3); add(new SeparatorField()); // -------------- // CheckboxField field_accident = new CheckboxField("Accident", false); add(field_accident); // CheckboxField field_radar = new CheckboxField("Radar", false); add(field_radar); // CheckboxField field_jail_booking = new CheckboxField("Jail Booking", false); add(field_jail_booking); // CheckboxField field_paced = new CheckboxField("Paced", false); add(field_paced); // CheckboxField field_school_zone = new CheckboxField("School Zone", false); add(field_school_zone); // CheckboxField field_alcohol = new CheckboxField("Alcohol", false); add(field_alcohol); add(new SeparatorField()); // EditField field_vbfi = new EditField("VBFI: ", ""); add(field_vbfi); // ObjectChoiceField String choicestrs1[] = { "5MPH", "10MPH", "15MPH", "20MPH", "25MPH", "30MPH", "35MPH", "40MPH", "45MPH", "50MPH", "55MPH", "60MPH", "65MPH", "70MPH", "75MPH", "80MPH" }; field_speed_limit = new ObjectChoiceField("Speed Limit: ", choicestrs1, 0); add(field_speed_limit); // EditField field_alleged_speed = new EditField("Alleged Speed: ", ""); add(field_alleged_speed); add(new SeparatorField()); // ButtonField row - set all buttons at the bottom row of the form HorizontalFieldManager navButtonManager = new HorizontalFieldManager(); // ButtonField ButtonField btn_prev; btn_prev = new ButtonField("Prev", ButtonField.CONSUME_CLICK); btn_prev.setChangeListener(new ButtonListener6(this, c)); navButtonManager.add(btn_prev); ButtonField btn_next; btn_next = new ButtonField("Next", ButtonField.CONSUME_CLICK); btn_next.setChangeListener(new ButtonListener6(this, c)); navButtonManager.add(btn_next); add(navButtonManager); add(new SeparatorField()); addMenuItem(saveItem6); addMenuItem(getItem6); restoreUIFieldsFromCitation(); }