Java Code Examples for com.codename1.io.Log#p()
The following examples show how to use
com.codename1.io.Log#p() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Dialog.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
/** * The default version of show modal shows the dialog occupying the center portion * of the screen. */ private void showImpl(boolean reverse) { if(modal && Display.isInitialized() && Display.getInstance().isMinimized()){ Log.p("Modal dialogs cannot be displayed on a minimized app"); return; } // this behavior allows a use case where dialogs of various sizes are layered // one on top of the other setDisposed(false); if(top > -1) { show(top, bottom, left, right, includeTitle, modal); } else { if(modal) { if(getDialogPosition() == null) { super.showModal(reverse); } else { showPacked(getDialogPosition(), true); } } else { showModeless(); } } }
Example 2
Source File: LayeredLayout.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public Inset changeUnitsTo(byte unit, Rectangle refBox) { if (unit != this.unit) { if (unit == UNIT_PIXELS) { setPixels(getCurrentValuePx()); } else if (unit == UNIT_DIPS) { setDips(getCurrentValueMM()); } else if (unit == UNIT_PERCENT) { try { setPercent(getCurrentValuePx() * 100f / (isVertical()?refBox.getHeight() : refBox.getWidth())); } catch (IllegalArgumentException ex) { Log.p(ex.getMessage()); setPercent(100f); } } else if (unit == UNIT_BASELINE) { if (side != Component.TOP) { throw new IllegalArgumentException("Baseline unit only allowed on top inset"); } getOppositeInset().changeUnitsTo(UNIT_AUTO, refBox); unit(unit); } else { unit(unit); } } return this; }
Example 3
Source File: PickerTest3071.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public void start() { if(current != null){ current.show(); return; } Form hi110 = new Form("Welcome"); Picker p2=new Picker(); p2.setType(Display.PICKER_TYPE_DATE_AND_TIME); Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 2020); cal.set(Calendar.HOUR_OF_DAY, 22); cal.set(Calendar.MINUTE, 30); cal.set(Calendar.MONTH, 3); cal.set(Calendar.DATE, 3); Log.p(cal.getTime().toString()); p2.setDate(cal.getTime()); hi110.add(p2); hi110.show(); }
Example 4
Source File: CSSBorder.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
Image image() { if (image == null) { image = res.getImage(imageName); if (image == null) { try { image = EncodedImage.create("/"+imageName); } catch (IOException ex) { Log.p("Failed to load image named "+imageName+" for CSSBorder"); throw new IllegalStateException("Failed to load image "+imageName); } } } return image; }
Example 5
Source File: CameraKitTest2867.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
public void stop() { if(ck.isStarted()) { Log.p("stopping camera", Log.INFO); ck.stop(); } current = getCurrentForm(); if(current instanceof Dialog) { ((Dialog)current).dispose(); current = getCurrentForm(); } }
Example 6
Source File: UIManager.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
private Style getComponentStyleImpl(String id, boolean selected, String prefix) { try { Style style = null; if (id == null || id.length() == 0) { //if no id return the default style id = ""; } else { id = id + "."; } if (selected) { style = (Style) selectedStyles.get(id); if (style == null) { style = createStyle(id, prefix, true); selectedStyles.put(id, style); } } else { if (prefix.length() == 0) { style = (Style) styles.get(id); if (style == null) { style = createStyle(id, prefix, false); styles.put(id, style); } } else { return createStyle(id, prefix, false); } } return new Style(style); } catch(Throwable err) { // fail gracefully for an illegal style, this is useful for the resource editor Log.p("Error creating style " + id + " selected: " + selected + " prefix: " + prefix); Log.e(err); return new Style(defaultStyle); } }
Example 7
Source File: GeoVizDemo.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
/** * Recalculate the map and chart preferred sizes when the viewport is changed. */ private void updateComponentSizes(){ current.removeComponent(geoVizComponent); current.removeComponent(densityChart); if (Display.getInstance().isPortrait()){ Log.p("In portrait"); current.addComponent(BorderLayout.CENTER, geoVizComponent); current.addComponent(BorderLayout.SOUTH, densityChart); geoVizComponent.setPreferredSize(new Dimension( Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight()/2 )); densityChart.setPreferredSize(new Dimension( Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight()/2 )); } else { current.addComponent(BorderLayout.EAST, geoVizComponent); current.addComponent(BorderLayout.CENTER, densityChart); geoVizComponent.setPreferredSize(new Dimension( Display.getInstance().getDisplayWidth()/2, Display.getInstance().getDisplayHeight() )); densityChart.setPreferredSize(new Dimension( Display.getInstance().getDisplayWidth()/2, Display.getInstance().getDisplayHeight() )); } }
Example 8
Source File: SEBrowserComponent.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
private void executeImpl(String js) { try { web.getEngine().executeScript(js); } catch (Throwable t) { Log.p("Javascript exception occurred while running expression: "+js); throw t; } }
Example 9
Source File: SQLMap.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
private void execute(String stmt) throws IOException { if(verbose) { Log.p(stmt); } db.execute(stmt); }
Example 10
Source File: Label.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
void initAutoResize() { if(autoSizeMode) { Style s = getUnselectedStyle(); int p = s.getHorizontalPadding(); int w = getWidth(); if(w > p + 10) { if(originalFont == null) { originalFont = s.getFont(); } else { if(w == widthAtLastCheck) { return; } } Font currentFont = getUnselectedStyle().getFont(); float fontSize = currentFont.getPixelSize(); if(fontSize < 1) { Log.p("Autosize disabled probably because component wasn't using native fonts for UIID: " + getUIID()); autoSizeMode = false; return; } widthAtLastCheck = w; autoSizeMode = false; int currentWidth = calcPreferredSize().getWidth(); int maxSizePixel = Display.getInstance().convertToPixels(maxAutoSize); while(currentWidth < w) { fontSize++; if(fontSize >= maxSizePixel) { fontSize = maxSizePixel; currentFont = currentFont.derive(maxSizePixel, currentFont.getStyle()); getAllStyles().setFont(currentFont); currentWidth = calcPreferredSize().getWidth(); break; } currentFont = currentFont.derive(fontSize, currentFont.getStyle()); getAllStyles().setFont(currentFont); currentWidth = calcPreferredSize().getWidth(); } int minSizePixel = Display.getInstance().convertToPixels(minAutoSize); while(currentWidth > w) { fontSize--; if(fontSize <= minSizePixel) { fontSize = minSizePixel; currentFont = currentFont.derive(minSizePixel, currentFont.getStyle()); getAllStyles().setFont(currentFont); currentWidth = calcPreferredSize().getWidth(); break; } currentFont = currentFont.derive(fontSize, currentFont.getStyle()); getAllStyles().setFont(currentFont); currentWidth = calcPreferredSize().getWidth(); } autoSizeMode = true; } } }
Example 11
Source File: SQLMap.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
private void execute(String stmt, Object[] args) throws IOException { if(verbose) { Log.p(stmt); } db.execute(stmt, args); }
Example 12
Source File: IOSVirtualKeyboard.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
@Override public void setInputType(int inputType) { Log.p("setInputType not supported on this keyboard"); }
Example 13
Source File: FacebookImpl.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
@Override public void inviteFriends(String appLinkUrl, String previewImageUrl, Callback cb) { Log.p("The facebook SDK no longer supports app invites. https://developers.facebook.com/blog/post/2017/11/07/changes-developer-offerings/"); }
Example 14
Source File: LookAndFeel.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
private void initCommandBehaviorConstant(String c, boolean complete) { if(c != null) { if(c.equalsIgnoreCase("SoftKey")) { Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_SOFTKEY); return; } if(c.equalsIgnoreCase("Touch")) { Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_TOUCH_MENU); return; } if(c.equalsIgnoreCase("Bar")) { Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_BUTTON_BAR); return; } if(c.equalsIgnoreCase("Title")) { Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK); return; } if(c.equalsIgnoreCase("Right")) { Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_RIGHT); return; } if(c.equalsIgnoreCase("Native")) { Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_NATIVE); return; } if(c.equalsIgnoreCase("ICS")) { Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_ICS); return; } if(c.equalsIgnoreCase("SIDE")) { Log.p("WARNING: Theme sets the commandBehavior constant which is deprecated. Please update the theme to NOT include this theme constant. Using commandBehavior may cause your app to perform in unexpected ways. In particular, using SIDE command behavior in conjunction with Toolbar.setOnTopSideMenu(true) may result in runtime exceptions.", Log.WARNING); Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_SIDE_NAVIGATION); setMenuBarClass(SideMenuBar.class); return; } } else { if(complete) { Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_DEFAULT); } } }
Example 15
Source File: AndroidAsyncView.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
@Override public void flushGraphics(Rect rect) { //Log.d(Display.getInstance().getProperty("AppName", "CodenameOne"), "Flush graphics invoked with pending: " + pendingRenderingOperations.size() + " and current " + renderingOperations.size()); // we might have pending entries in the rendering queue int counter = 0; while (!renderingOperations.isEmpty()) { try { synchronized (RENDERING_OPERATIONS_LOCK) { RENDERING_OPERATIONS_LOCK.wait(5); } // don't let the EDT die here counter++; if (counter > 10) { //Log.d(Display.getInstance().getProperty("AppName", "CodenameOne"), "Flush graphics timed out!!!"); return; } } catch (InterruptedException err) { } } ArrayList<AsyncOp> tmp = renderingOperations; renderingOperations = pendingRenderingOperations; pendingRenderingOperations = tmp; try { for (AsyncOp o : renderingOperations) { o.prepare(); } } catch (java.util.ConcurrentModificationException ex) { // This is a race condition that sometimes occurs // Rather than add synchronized here (which may have performance implications) // we'll just "give up" and issue a repaint. Log.p("NOTICE: Hit concurrent modification race condition in flushGraphics. Skipping flush, and issuing another repaint."); Log.e(ex); Display.getInstance().callSerially(new Runnable() { @Override public void run() { Form f = Display.getInstance().getCurrent(); if (f != null) { f.repaint(); } } }); return; } int children = getChildCount(); if(children > 0) { com.codename1.ui.Form c = Display.getInstance().getCurrent(); for (int iter = 0; iter < children; iter++) { final View v = getChildAt(iter); final AndroidAsyncView.LayoutParams lp = (AndroidAsyncView.LayoutParams) v.getLayoutParams(); //if (lp != null && c == lp.pc.getComponentForm()) { //v.postInvalidate(); /*if(lp.dirty) { lp.dirty = false; v.post(new Runnable() { @Override public void run() { if (v.getVisibility() == View.INVISIBLE) { v.setVisibility(View.VISIBLE); } v.requestLayout(); } }); } else { if (v.getVisibility() == View.INVISIBLE) { v.post(new Runnable() { @Override public void run() { v.setVisibility(View.VISIBLE); } }); } }*/ //} else { /*if(v.getVisibility() == View.VISIBLE) { v.post(new Runnable() { @Override public void run() { v.setVisibility(View.INVISIBLE); } }); }*/ //} } } if (rect == null) { postInvalidate(); } else { postInvalidate(rect.left, rect.top, rect.right, rect.bottom); } graphics.setClip(0, 0, cn1View.width, cn1View.height); graphics.setAlpha(255); graphics.setColor(0); }
Example 16
Source File: SQLMap.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
private Cursor executeQuery(String stmt) throws IOException { if(verbose) { Log.p(stmt); } return db.executeQuery(stmt); }
Example 17
Source File: PopulationData.java From codenameone-demos with GNU General Public License v2.0 | 4 votes |
public void load(InputStream is) throws IOException { CSVParser parser = new CSVParser(); String[][] pdata = parser.parse(is); String[] headings = null; int len=0; List<RegionData> tempRegionData = new ArrayList<RegionData>(); Map<String,RegionData> tempYearRegionData = new HashMap<String,RegionData>(); for (String[] row : pdata){ if (headings == null){ headings = row; len = headings.length; } else { Log.p("Processing row "+Arrays.toString(row)); if ( row.length == 0){ continue; } tempRegionData.clear(); tempYearRegionData.clear(); String region = row[0]; for (int i=1; i<len; i++){ RegionData d = null; List<String> parts = StringUtil.tokenize(headings[i], '_'); int year = Integer.parseInt(parts.get(0)); if (tempYearRegionData.containsKey(""+year)){ d = tempYearRegionData.get(""+year); } else { d = new RegionData(); d.region = region; d.year = year; tempYearRegionData.put(""+year, d); } String type = parts.get(1); row[i] = StringUtil.replaceAll(row[i], ",", ""); if (!"".equals(row[i])){ if ("POPULATION".equals(type)){ d.pop = Integer.parseInt(row[i]); } else if ("DENSITY".equals(type)){ d.density = Double.parseDouble(row[i]); } else if ("RANK".equals(type)){ d.rank = Integer.parseInt(row[i]); } else { throw new RuntimeException("Unexpected col heading. Expecting POPULATION, DENSITY, or RANK, but found "+type); } } if (!tempRegionData.contains(d)){ tempRegionData.add(d); } } data.put(region, tempRegionData.toArray(new RegionData[tempRegionData.size()])); } } }
Example 18
Source File: KitchenSink.java From codenameone-demos with GNU General Public License v2.0 | 4 votes |
public void stop(){ Log.p("Stop"); currentForm = Display.getInstance().getCurrent(); }
Example 19
Source File: TestReporting.java From CodenameOne with GNU General Public License v2.0 | 2 votes |
/** * Invoked when a unit test is started * @param test the test case */ public void startingTestCase(UnitTest test) { Log.p("Starting test case " + test.getClass().getName()); }
Example 20
Source File: CN.java From CodenameOne with GNU General Public License v2.0 | 2 votes |
/** * Prints to the log * @param s the string */ public static void log(String s) { Log.p(s); }