List of usage examples for java.lang ClassCastException printStackTrace
public void printStackTrace()
From source file:com.ninetwozero.battlelog.DashboardActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { // Declare... AdapterView.AdapterContextMenuInfo info; // Let's try to get some menu information via a try/catch try {//w ww .j a va 2 s . c o m info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); } catch (ClassCastException e) { e.printStackTrace(); return false; } if (slidingDrawer.isOpened()) { switch (viewPagerCom.getCurrentItem()) { case 0: fragmentComFriends.handleSelectedContextItem(info, item); break; default: break; } } else { switch (viewPager.getCurrentItem()) { case VIEWPAGER_POSITION_FEED: return fragmentFeed.handleSelectedContextItem(info, item); default: break; } } return true; }
From source file:org.metacsp.utility.UI.ConstraintNetworkFrame.java
public ConstraintNetworkFrame(ObservableGraph<Variable, Constraint> graph, String title, final Callback cb) { super(title); this.g = graph; g.addGraphEventListener(new GraphEventListener<Variable, Constraint>() { @Override/*w ww . j av a 2 s . c o m*/ public void handleGraphEvent(GraphEvent<Variable, Constraint> evt) { vv.getRenderContext().getPickedVertexState().clear(); vv.getRenderContext().getPickedEdgeState().clear(); try { layout.initialize(); try { Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); } catch (java.lang.ClassCastException e) { e.printStackTrace(); } StaticLayout<Variable, Constraint> staticLayout = new StaticLayout<Variable, Constraint>(g, layout); lt = new LayoutTransition<Variable, Constraint>(vv, vv.getGraphLayout(), staticLayout); animator = new MyAnimator(lt); animator.start(); //vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } catch (Exception e) { e.printStackTrace(); } } }); //create a graphdraw //layout = new FRLayout<Variable,Constraint>(g); //layout = new SpringLayout<Variable,Constraint>(g); //layout = new StaticLayout<Variable,Constraint>(g,new STNTransformer()); layout = new FRLayout2<Variable, Constraint>(g); //layout = new CircleLayout<Variable,Constraint>(g); //layout = new ISOMLayout<Variable,Constraint>(g); //layout = new KKLayout<Variable,Constraint>(g); layout.setSize(new Dimension(600, 600)); try { Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); } catch (java.lang.ClassCastException e) { e.printStackTrace(); } Layout<Variable, Constraint> staticLayout = new StaticLayout<Variable, Constraint>(g, layout); vv = new VisualizationViewer<Variable, Constraint>(staticLayout, new Dimension(600, 600)); JRootPane rp = this.getRootPane(); rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE); getContentPane().setLayout(new BorderLayout()); getContentPane().setBackground(java.awt.Color.lightGray); getContentPane().setFont(new Font("Serif", Font.PLAIN, 12)); vv.setGraphMouse(new DefaultModalGraphMouse<Variable, Constraint>()); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Variable>()); vv.setForeground(Color.black); //draw edge labels Transformer<Constraint, String> stringer = new Transformer<Constraint, String>() { @Override public String transform(Constraint e) { try { return e.getEdgeLabel(); } catch (NullPointerException ex) { return ""; } } }; Transformer<Variable, Paint> vertexPaint = new Transformer<Variable, Paint>() { public Paint transform(Variable v) { return v.getColor(); } }; Transformer<Constraint, Paint> constraintPaint = new Transformer<Constraint, Paint>() { public Paint transform(Constraint c) { return c.getColor(); } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); // vv.getRenderContext().setEdgeFillPaintTransformer(constraintPaint); vv.getRenderContext().setEdgeLabelTransformer(stringer); // vv.getRenderContext().setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Constraint>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.getRenderContext().setEdgeDrawPaintTransformer(constraintPaint); vv.addComponentListener(new ComponentAdapter() { /** * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent) */ @Override public void componentResized(ComponentEvent arg0) { super.componentResized(arg0); layout.setSize(arg0.getComponent().getSize()); } }); getContentPane().add(vv); performOperation = new JButton("Perform operation"); if (cb == null) performOperation.setEnabled(false); else performOperation.setEnabled(true); performOperation.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (cb != null) cb.performOperation(); } }); switchLayout = new JButton("Switch to SpringLayout"); switchLayout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Dimension d = vv.getSize();//new Dimension(600,600); if (switchLayout.getText().indexOf("Spring") > 0) { switchLayout.setText("Switch to FRLayout"); //layout = new SpringLayout<Variable,Constraint>(g, new ConstantTransformer(EDGE_LENGTH)); layout = new SpringLayout<Variable, Constraint>(g); layout.setSize(d); try { Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); } catch (java.lang.ClassCastException e) { e.printStackTrace(); } StaticLayout<Variable, Constraint> staticLayout = new StaticLayout<Variable, Constraint>(g, layout); lt = new LayoutTransition<Variable, Constraint>(vv, vv.getGraphLayout(), staticLayout); Animator animator = new MyAnimator(lt); animator.start(); // vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } else { switchLayout.setText("Switch to SpringLayout"); layout = new FRLayout<Variable, Constraint>(g, d); layout.setSize(d); try { Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); } catch (java.lang.ClassCastException e) { } StaticLayout<Variable, Constraint> staticLayout = new StaticLayout<Variable, Constraint>(g, layout); lt = new LayoutTransition<Variable, Constraint>(vv, vv.getGraphLayout(), staticLayout); Animator animator = new MyAnimator(lt); animator.start(); //vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } } }); getContentPane().add(performOperation, BorderLayout.SOUTH); //getContentPane().add(switchLayout, BorderLayout.SOUTH); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.pack(); this.setVisible(true); }
From source file:com.ohso.omgubuntu.BaseFragment.java
@Override public void articlesError() { onRefreshComplete();/*from ww w . jav a 2s . c o m*/ Log.e("OMG!", "FEED ERROR!"); // Need to make sure fragment still attached to activity, lest we get an IllegalStateException when toasting if (this.isAdded()) { Toast error = Toast.makeText(getActivity(), getResources().getString(R.string.refresh_error), Toast.LENGTH_SHORT); try { ((TextView) ((LinearLayout) error.getView()).getChildAt(0)).setGravity(Gravity.CENTER); } catch (ClassCastException e) { e.printStackTrace(); } error.show(); } }
From source file:com.jpeterson.util.etag.FileETag.java
/** * Calculates the ETag for a file based on file metadata. The file metadata * used in the ETag calculation is set via <code>setFlags(int)</code>. * //w ww .ja v a 2 s .c o m * @param o * The <code>File</code> to calculate the ETag for. * @return The ETag value. May be <code>null</code> if an ETag can not be * calculated. * @see #setFlags(int) */ public String calculate(Object o) { StringBuffer buffer = new StringBuffer(); MessageDigest messageDigest; byte[] digest; File file; try { file = (File) o; } catch (ClassCastException e) { System.err.println("Unable to cast the object to a File: " + o); return null; } if (!file.exists()) { System.err.println("Unable to calculate ETag; file doesn't exist: " + file); return null; } try { messageDigest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return null; } // order of the flags is important! changing the order will change the // ETag value if ((flags & FLAG_CONTENT) != 0) { try { DigestInputStream digestInputStream = new DigestInputStream(new FileInputStream(file), messageDigest); byte[] b = new byte[1024]; while (digestInputStream.read(b, 0, b.length) > 0) { // adding content to the MessageDigest } } catch (IOException e) { e.printStackTrace(); return null; } } if ((flags & FLAG_MTIME) != 0) { buffer.append(file.lastModified()); } if ((flags & FLAG_SIZE) != 0) { buffer.append(file.length()); } digest = messageDigest.digest(buffer.toString().getBytes()); return new String(Hex.encodeHex(digest)); }
From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.HierarchicalBarChart.java
private void buildFinalChart(String title, String subTitle, String xAxisLabel, String yAxisLabel, int height, int width, String filename, Chart.Scale scaleMode, Chart.LegendFormat legendFormatMode, int alpha) { @SuppressWarnings("unchecked") Vector<Counter>[] vec = new Vector[this.timers.length]; boolean exist; // create the dataset... for (int i = 0; i < this.timers.length; i++) { vec[i] = new Vector<Counter>(); @SuppressWarnings("unchecked") Iterator<Element> it = this.timers[i].getDescendants(); while (it.hasNext()) { try { Element elt = (Element) it.next(); String name = elt.getAttributeValue("name"); double value = Double.valueOf(elt.getAttributeValue("avg")); exist = false;/*w w w .j a va 2 s. c o m*/ for (int j = 0; j < vec[i].size(); j++) { if (((Counter) vec[i].get(j)).getName().equals(name)) { ((Counter) vec[i].get(j)).addValue(value); exist = true; break; } } if (!exist) { vec[i].add(new Counter(name, value)); } } catch (ClassCastException e) { continue; } } } CategoryDataset dataset = null; try { dataset = DatasetUtilities.createCategoryDataset(toSeries(vec[0]), this.categories, toDataset(vec)); } catch (IllegalArgumentException e) { e.printStackTrace(); throw new IllegalArgumentException( "Benchmark names must have different names. Be sure that your filter contains correct timers names"); } // create the chart... final CategoryAxis categoryAxis = new CategoryAxis(xAxisLabel); final ValueAxis valueAxis = new NumberAxis(yAxisLabel); final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, new HierarchicalBarRenderer()); plot.setOrientation(PlotOrientation.VERTICAL); final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.addSubtitle(new TextTitle(subTitle)); // set the background color for the chart... chart.setBackgroundPaint(Color.white); final HierarchicalBarRenderer renderer = (HierarchicalBarRenderer) plot.getRenderer(); renderer.setItemMargin(0.01); renderer.setDatasetTree(this.timers); renderer.setSeries(toSeries(vec[0])); renderer.setAlpha(alpha); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryMargin(HierarchicalBarChart.CATEGORY_MARGIN); domainAxis.setUpperMargin(0.05); domainAxis.setLowerMargin(0.05); try { if ((filename == null) || "".equals(filename)) { throw new RuntimeException( "The output filename for the HierarchicalBarChart cannot be null or empty !"); } ChartUtilities.saveChartAsPNG(XMLHelper.createFileWithDirs(filename + ".png"), chart, width, height); Utilities.saveChartAsSVG(chart, new Rectangle(width, height), XMLHelper.createFileWithDirs(filename + ".svg")); } catch (java.io.IOException e) { System.err.println("Error writing chart image to file"); e.printStackTrace(); } }
From source file:com.avapira.bobroreader.BoardFragment.java
/** * @deprecated Use {@link #onAttach(Context)} instead. */// w ww.j ava2s . c o m @Deprecated public void onAttach(Activity activity) { Log.d(TAG, "attach"); super.onAttach(activity); try { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); recentListSize = Integer.parseInt(prefs.getString("pref_board_recent_list_size", "3")); supervisor = (Castor) activity; } catch (ClassCastException e) { e.printStackTrace(); throw new ClassCastException(activity.toString() + " must implement OnFragmentInteractionListener"); } }
From source file:org.vfny.geoserver.config.web.tiles.definition.MultipleDefinitionsFactory.java
/** * Extract key that will be used to get the sub factory. * @param name Name of requested definition * @param request Current servlet request. * @param servletContext Current servlet context. * @return the key or <code>null</code> if not found. *///from w w w . j a va 2 s .c o m protected Object getDefinitionsFactoryKey(String name, ServletRequest request, ServletContext servletContext) { Locale locale = null; try { HttpSession session = ((HttpServletRequest) request).getSession(false); if (session != null) { locale = (Locale) session.getAttribute(ComponentConstants.LOCALE_KEY); } } catch (ClassCastException ex) { log.error("I18nFactorySet.getDefinitionsFactoryKey"); ex.printStackTrace(); } return locale; }
From source file:org.dvbviewer.controller.ui.fragments.ChannelEpg.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/*from ww w . j a va2 s . c o m*/ mDateInfo = (EpgDateInfo) activity; } catch (ClassCastException e) { e.printStackTrace(); } }
From source file:org.godhuli.rhipe.RHMRMapper.java
public void setup(Context context) { Configuration cfg = context.getConfiguration(); // Test External Jar File is Present! // RHMRHelper.invoke("org.godhuli.rhipe.HBase.TestCase","showMessage",new Class[]{String.class}, new Object[]{new String("Foo")}); try {//ww w. ja va 2 s. co m String mif = ((FileSplit) context.getInputSplit()).getPath().toString(); cfg.set("mapred.input.file", mif); } catch (java.lang.ClassCastException e) { } cfg.set("RHIPEWHAT", "0"); System.out.println("mapred.input.file == " + cfg.get("mapred.input.file")); helper.setup(cfg, getPipeCommand(cfg), getDoPipe()); copyFile = cfg.get("rhipe_copy_file").equals("TRUE") ? true : false; whichMapper = cfg.getInt("rhipe_send_keys_to_map", 1); helper.startOutputThreads(context); try { helper.writeCMD(RHTypes.EVAL_SETUP_MAP); helper.checkOuterrThreadsThrowable(); } catch (IOException e) { e.printStackTrace(); helper.mapRedFinished(context); throw new RuntimeException(e); } }
From source file:com.liferay.portal.struts.PortalTilesDefinitionsFactory.java
/** * Extract key that will be used to get the sub factory. * @param name Name of requested definition * @param request Current servlet request. * @param servletContext Current servlet context. * @return the key or <code>null</code> if not found. */// w w w .j a v a 2s .c o m protected Object getDefinitionsFactoryKey(String name, ServletRequest request, ServletContext servletContext) { Locale locale = null; try { HttpSession session = ((HttpServletRequest) request).getSession(false); if (session != null) { locale = (Locale) session.getAttribute(ComponentConstants.LOCALE_KEY); } } catch (ClassCastException ex) { log.error("I18nFactorySet.getDefinitionsFactoryKey"); ex.printStackTrace(); } return locale; }