List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:com.kinth.football.friend.touchgallery.GalleryWidget.GalleryViewPager.java
@Override public boolean onInterceptTouchEvent(MotionEvent event) { if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) { //super.onInterceptTouchEvent(event); float endX = event.getX(); float endY = event.getY(); if (isAClick(startX, endX, startY, endY)) { if (mOnItemClickListener != null) { mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem()); }//from ww w. j av a 2s. co m } else { try { super.onInterceptTouchEvent(event); } catch (IllegalArgumentException e) { e.printStackTrace(); } } } if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) { startX = event.getX(); startY = event.getY(); } float[] difference = handleMotionEvent(event); if (mCurrentView.pagerCanScroll()) { try { return super.onInterceptTouchEvent(event); } catch (IllegalArgumentException e) { e.printStackTrace(); } } else { try { if (difference != null && mCurrentView.onRightSide && difference[0] < 0) //move right { return super.onInterceptTouchEvent(event); } if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) //move left { return super.onInterceptTouchEvent(event); } if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) { return super.onInterceptTouchEvent(event); } } catch (IllegalArgumentException e) { e.printStackTrace(); } } return false; }
From source file:org.dphibernate.serialization.HibernateDeserializer.java
private Object readBean(Object obj) { try {/*from ww w . j a va2 s . co m*/ BeanInfo info = Introspector.getBeanInfo(obj.getClass()); for (PropertyDescriptor pd : info.getPropertyDescriptors()) { String propName = pd.getName(); if (!"class".equals(propName) && !"annotations".equals(propName) && !"hibernateLazyInitializer".equals(propName)) { Object val = pd.getReadMethod().invoke(obj, null); if (val != null) { Object newVal = translate(val, pd.getPropertyType()); try { Method writeMethod = pd.getWriteMethod(); if (writeMethod != null) { writeMethod.invoke(obj, newVal); } } catch (IllegalArgumentException e) { e.printStackTrace(); throw new RuntimeException(e); } catch (NullPointerException npe) { throw npe; } } } } } catch (Exception ex) { ex.printStackTrace(); throw new RuntimeException(ex); } return obj; }
From source file:com.javielinux.dialogs.CreateDefaultColumnsUserDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { userId = getArguments().getLong("user_id"); userEntity = new Entity("users", userId); CharSequence[] choices = new CharSequence[3]; choices[0] = getString(R.string.timeline); choices[1] = getString(R.string.mentions); choices[2] = getString(R.string.direct_messages); final boolean[] isChoices = new boolean[] { true, true, true }; LinearLayout llTitle = new LinearLayout(getActivity()); llTitle.setOrientation(LinearLayout.VERTICAL); final CheckBox boxInvite = new CheckBox(getActivity()); boxInvite.setText(R.string.follow_tweettopics); boxInvite.setChecked(true);/*from w w w .j av a 2s . co m*/ llTitle.addView(boxInvite); TextView txtTitle = new TextView(getActivity()); txtTitle.setText(R.string.create_columns); txtTitle.setTextSize(25); llTitle.addView(txtTitle); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setCustomTitle(llTitle); builder.setMultiChoiceItems(choices, isChoices, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { isChoices[whichButton] = isChecked; } }); builder.setCancelable(false); builder.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // choices int count = DataFramework.getInstance().getEntityListCount("columns", "") + 1; if (isChoices[0]) { Entity type = new Entity("type_columns", (long) TweetTopicsUtils.COLUMN_TIMELINE); Entity timeline = new Entity("columns"); timeline.setValue("description", type.getString("description")); timeline.setValue("type_id", type); timeline.setValue("position", count); timeline.setValue("user_id", userEntity.getId()); timeline.save(); count++; } if (isChoices[1]) { Entity type = new Entity("type_columns", (long) TweetTopicsUtils.COLUMN_MENTIONS); Entity mentions = new Entity("columns"); mentions.setValue("description", type.getString("description")); mentions.setValue("type_id", type); mentions.setValue("position", count); mentions.setValue("user_id", userEntity.getId()); mentions.save(); count++; } if (isChoices[2]) { Entity type = new Entity("type_columns", (long) TweetTopicsUtils.COLUMN_DIRECT_MESSAGES); Entity dms = new Entity("columns"); dms.setValue("description", type.getString("description")); dms.setValue("type_id", type); dms.setValue("position", count); dms.setValue("user_id", userEntity.getId()); dms.save(); } ((TweetTopicsActivity) getActivity()).refreshColumns(); // create friend if (boxInvite.isChecked()) { Utils.showMessage(getActivity(), getActivity().getString(R.string.thanks)); new Thread(new Runnable() { @Override public void run() { try { ConnectionManager.getInstance().getTwitter(userEntity.getId()) .createFriendship("tweettopics_app"); } catch (TwitterException e1) { e1.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } } }).start(); } } }); return builder.create(); }
From source file:org.digitalcampus.oppia.utils.mediaplayer.VideoPlayerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video_player); prefs = PreferenceManager.getDefaultSharedPreferences(this); videoSurface = (SurfaceView) findViewById(R.id.videoSurface); SurfaceHolder videoHolder = videoSurface.getHolder(); videoHolder.addCallback(this); player = new MediaPlayer(); controller = new VideoControllerView(this); Bundle bundle = this.getIntent().getExtras(); if (bundle != null) { mediaFileName = (String) bundle.getSerializable(MEDIA_TAG); activity = (Activity) bundle.getSerializable(Activity.TAG); course = (Course) bundle.getSerializable(Course.TAG); } else {/*from www. j ava2 s.co m*/ this.finish(); } try { player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setDataSource(this, Uri.parse(FileUtils.getMediaPath(this) + mediaFileName)); player.setOnPreparedListener(this); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:es.udc.gii.common.eaf.plugin.multiobjective.crowding.ObjectiveSpaceCrowding.java
@Override public void calculate(List<NSGA2Individual> list) { /* Reset all crowding distances. */ resetCrowdingDistance(list);/*w w w . j a v a 2s . c o m*/ if (list == null || list.isEmpty()) { return; } /* Comparator. */ MinimizingObjectiveComparator<NSGA2Individual> comparator = new MinimizingObjectiveComparator<NSGA2Individual>(); /* Number of objectives. */ int nObjectives = list.get(0).getObjectives().size(); /* For each objective. */ for (int obj = 0; obj < nObjectives; obj++) { /* Set the objective to consider. */ comparator.setObjectiveIndex(obj); /* Sort individuals considering the objective above. */ try { Collections.sort(list, comparator); } catch (IllegalArgumentException ex) { System.out.println(list.get(0).getClass().getSimpleName()); ex.printStackTrace(); } /* Individuals on the boundaries have maximal crowding distance. */ NSGA2Individual firstInd = list.get(0); firstInd.setCrowdingDistance(Double.MAX_VALUE); NSGA2Individual lastInd = list.get(list.size() - 1); lastInd.setCrowdingDistance(Double.MAX_VALUE); double minValue = firstInd.getObjectives().get(obj); double maxValue = lastInd.getObjectives().get(obj); /* If there are diferent values, i.e. if there is some distance * between individuals in objective space. */ if (minValue != maxValue) { /* Calculate the increase of crowding distance for each individual. */ for (int i = 1; i < list.size() - 1; i++) { NSGA2Individual i0 = list.get(i); NSGA2Individual i1 = list.get(i - 1); NSGA2Individual i2 = list.get(i + 1); double delta = (i2.getObjectives().get(obj) - i1.getObjectives().get(obj)) / (maxValue - minValue); i0.increaseCrowdingDistance(delta); } } } for (int i = 1; i < list.size() - 1; i++) { NSGA2Individual ind = list.get(i); double cd = ind.getCrowdingDistance() / (double) nObjectives; ind.setCrowdingDistance(cd); } }
From source file:geogebra.common.kernel.statistics.AlgoTMeanEstimate.java
@Override public final void compute() { try {/*from w w w . ja va 2s . c om*/ // get statistics from sample data input if (input.length == 2) { int size = geoList.size(); if (!geoList.isDefined() || size < 2) { result.setUndefined(); return; } val = new double[size]; for (int i = 0; i < size; i++) { GeoElement geo = geoList.get(i); if (geo instanceof NumberValue) { NumberValue num = (NumberValue) geo; val[i] = num.getDouble(); } else { result.setUndefined(); return; } } stats = new SummaryStatistics(); for (int i = 0; i < val.length; i++) { stats.addValue(val[i]); } n = stats.getN(); sd = stats.getStandardDeviation(); mean = stats.getMean(); } else { mean = geoMean.getDouble(); sd = geoSD.getDouble(); n = geoN.getDouble(); } level = geoLevel.getDouble(); // validate statistics if (level < 0 || level > 1 || sd < 0 || n < 1) { result.setUndefined(); return; } // get interval estimate me = getMarginOfError(sd, n, level); // return list = {low limit, high limit, mean, margin of error, df } result.clear(); boolean oldSuppress = cons.isSuppressLabelsActive(); cons.setSuppressLabelCreation(true); result.add(new GeoNumeric(cons, mean - me)); result.add(new GeoNumeric(cons, mean + me)); // result.add(new GeoNumeric(cons, mean)); // result.add(new GeoNumeric(cons, me)); // result.add(new GeoNumeric(cons, n-1)); // df cons.setSuppressLabelCreation(oldSuppress); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (MathException e) { e.printStackTrace(); } }
From source file:com.univpm.s1055802.faceplusplustester.Detect.AcquireVideo.java
/** * Estrae un frame per ogni secondo del video e li salva sul dispositivo * @param uri uri della cartella dove salvare i frames *//*from ww w. j ava2 s. c om*/ private void captureFrames(Uri uri) { String filePath = FileUtils.getPath(getApplicationContext(), uri); File video = new File(filePath); MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { retriever.setDataSource(filePath); double duration = Double .parseDouble(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)); Log.v("duration", String.valueOf(duration)); int timeSkip = 1000000; for (int i = 0; i < duration * 1000; i = i + timeSkip) { File img = null; try { img = new File(framesDir, "Frame_" + String.valueOf(i / timeSkip) + ".jpg"); OutputStream fOut = null; fOut = new FileOutputStream(img); Bitmap imgBmp = retriever.getFrameAtTime(i, MediaMetadataRetriever.OPTION_NEXT_SYNC); imgBmp.compress(Bitmap.CompressFormat.JPEG, 85, fOut); fOut.flush(); fOut.close(); } catch (IOException e) { e.printStackTrace(); } } } catch (IllegalArgumentException ex) { ex.printStackTrace(); } catch (RuntimeException ex) { ex.printStackTrace(); } finally { try { retriever.release(); } catch (RuntimeException ex) { } } }
From source file:py.una.pol.karaku.test.test.configuration.KarakuWSClientConfigurationTest.java
@Before public void initialize() { Field[] campos = wsConf.getClass().getDeclaredFields(); for (Field f : campos) { if ("properties".equals(f.getName())) { f.setAccessible(true);//from www . j a v a 2s. co m try { f.set(wsConf, properties); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } }
From source file:org.apache.axis2.wsdl.codegen.jaxws.JAXWSCodeGenerationEngine.java
/** * Merge original args.// ww w . ja v a 2 s .c om * * @param args * the args */ private void mergeOriginalArgs(ArrayList<String> args) { Map<String, CommandLineOption> allOptions = commandLineOptionParser.getAllOptions(); List<String> axisOptionList = new ArrayList<String>(); List<String> originalArgsOps = new ArrayList<String>(Arrays.asList(originalArgs)); originalArgsOps.remove("-".concat(CommandLineOptionConstants.WSDL2JavaConstants.JAX_WS_SERVICE_OPTION)); originalArgsOps .remove("-".concat(CommandLineOptionConstants.WSDL2JavaConstants.JAX_WS_SERVICE_OPTION_LONG)); Field[] allFields = CommandLineOptionConstants.WSDL2JavaConstants.class.getFields(); Iterator<String> mapItr = allOptions.keySet().iterator(); for (Field field : allFields) { if (String.class.equals(field.getType())) { try { axisOptionList.add((String) field.get(CommandLineOptionConstants.WSDL2JavaConstants.class)); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } while (mapItr.hasNext()) { CommandLineOption op = allOptions.get(mapItr.next()); if (axisOptionList.contains(op.getOptionType())) { if (op.getOptionType() != null) { originalArgsOps.remove("-".concat(op.getOptionType())); } if (op.getOptionValue() != null) { originalArgsOps.remove(op.getOptionValue()); } } } args.addAll(originalArgsOps); log.info("Original WSImport options" + Arrays.asList(originalArgsOps)); log.info("All WSImport options" + Arrays.asList(args)); }
From source file:de.clusteval.run.statistics.RunDataStatisticCalculator.java
@SuppressWarnings("unchecked") @Override/*from w w w . j ava 2 s . c om*/ public RunDataStatisticCalculator<T> clone() { try { return this.getClass().getConstructor(RunDataStatisticCalculator.class).newInstance(this); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } this.log.warn("Cloning instance of class " + this.getClass().getSimpleName() + " failed"); return null; }