public void ecrireEnregistrement(Programme prog, StringBuffer buf, int indent) { Divers.ecrire(buf, "function " + nom + "()" + " {", indent); for (Iterator<org.javascool.proglets.plurialgo.langages.modele.Variable> iter = proprietes.iterator(); iter.hasNext(); ) { Variable prop = (Variable) iter.next(); prop.ecrirePropriete(prog, buf, indent + 1); } Divers.ecrire(buf, "}", indent); }
/** * Get intent to call activity for select an image from official google gallery * * @param pm PackageManager * @return intent * @throws IntentException if intent is not reachable (official google gallery removed) */ public static Intent intentGetImage(PackageManager pm) throws IntentException { Intent i = new Intent( Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); if (!Divers.isIntentReachable(pm, i)) throw new IntentException(); return i; }
/** * Get intent to call activity for take a photo with official google app * * @param pm PackageManager * @param imageUri Uri for output file * @return intent * @throws IntentException if intent is not reachable (official google app removed) * <h3>WARNING</h3> * many bug with this official intent. * @deprecated use intentTakePhoto(Context c, String outputFilePath ) */ public static Intent intentTakePhoto(PackageManager pm, Uri imageUri) throws IntentException { Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); i.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); if (!Divers.isIntentReachable(pm, i)) throw new IntentException(); return i; }
private void nettoyer(String txt_xml) { buf_xml = new StringBuffer(); buf_xml.append(txt_xml); Divers.remplacer(buf_xml, "\t", ""); StringTokenizer tok = new StringTokenizer(buf_xml.toString(), "\n\r", false); buf_xml = new StringBuffer(); while (tok.hasMoreTokens()) { String ligne = tok.nextToken(); if (ligne.isEmpty()) continue; buf_xml.append(ligne + "\n"); } }
public void ecrire(Programme prog, StringBuffer buf, int indent) { Divers.ecrire(buf, "function " + nom + "()" + " {", indent); if ((proprietes.size() > 0)) prog.commenter(buf, "proprietes", indent + 1); for (Iterator<org.javascool.proglets.plurialgo.langages.modele.Variable> iter = proprietes.iterator(); iter.hasNext(); ) { Variable prop = (Variable) iter.next(); prop.ecrirePropriete(prog, buf, indent + 1); } if ((operations.size() > 0)) prog.commenter(buf, "methodes", indent + 1); for (Iterator<org.javascool.proglets.plurialgo.langages.modele.Operation> iter = operations.iterator(); iter.hasNext(); ) { Operation oper = (Operation) iter.next(); Divers.ecrire(buf, "this." + oper.nom + "=" + oper.nom + ";", indent + 1); } Divers.ecrire(buf, "}", indent); for (Iterator<org.javascool.proglets.plurialgo.langages.modele.Operation> iter = operations.iterator(); iter.hasNext(); ) { Operation oper = (Operation) iter.next(); oper.ecrire(prog, buf, indent); } }
/** * Get intent to call activity for crop an image from official google app * * @param pm PackageManager * @param source Uri of source image file * @param destination Uri of destination file * @param aspectX X ratio * @param aspectY Y ratio * @return intent * @throws IntentException if intent is not reachable (official google app removed) * @deprecated */ public static Intent intentCropImage( PackageManager pm, Uri source, Uri destination, int aspectX, int aspectY) throws IntentException { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(source, "image/*"); intent.putExtra("crop", "true"); // this defines the aspect ration intent.putExtra("aspectX", aspectX); intent.putExtra("aspectY", aspectY); // true to return a Bitmap, false to directly save the cropped image intent.putExtra("return-data", false); intent.putExtra("output", destination); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG); if (!Divers.isIntentReachable(pm, intent)) throw new IntentException(); return intent; }
private Object creerObjet(String nom_classe) { Object obj = null; try { String nom_paq = this.getClass().getPackage().getName(); nom_paq = nom_paq.substring(0, nom_paq.indexOf(".modele")); String nom_cl = nom_paq + "." + nom_lang + "." + nom_classe; if (nom_lang.equals("xml")) { nom_cl = Divers.remplacer(nom_cl, ".xml.", ".xml.Xml"); } // obj = Class.forName(nom_cl).newInstance(); obj = Class.forName(nom_cl, true, this.getClass().getClassLoader()).newInstance(); // obj = Thread.currentThread().getContextClassLoader().loadClass(nom_cl).newInstance(); } catch (Exception ex) { System.out.println("echec de loadClass()"); System.out.println(ex.getClass()); System.out.println(ex.getMessage()); System.out.println("fin echec de loadClass()"); // prog_xml.buf_error.append(ex.getClass() + " : " + ex.getMessage() + "\n"); // return creerObjetSecours(nom_classe); } return obj; }