List of usage examples for java.net MalformedURLException printStackTrace
public void printStackTrace()
From source file:Viewer3D.java
public void init() { if (filename == null) { // the path to the file for an applet try {/*from w ww .j a v a 2s . co m*/ java.net.URL path = getCodeBase(); filename = new java.net.URL(path.toString() + "./ballcone.lws"); } catch (java.net.MalformedURLException ex) { System.err.println(ex.getMessage()); ex.printStackTrace(); System.exit(1); } } // Construct the Lw3d loader and load the file Loader lw3dLoader = new Lw3dLoader(Loader.LOAD_ALL); Scene loaderScene = null; try { loaderScene = lw3dLoader.load(filename); } catch (Exception e) { e.printStackTrace(); System.exit(1); } // Construct the applet canvas setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); add("Center", c); // Create a basic universe setup and the root of our scene u = new SimpleUniverse(c); BranchGroup sceneRoot = new BranchGroup(); // Change the back clip distance; the default is small for // some lw3d worlds View theView = u.getViewer().getView(); theView.setBackClipDistance(50000f); // Now add the scene graph defined in the lw3d file if (loaderScene.getSceneGroup() != null) { // Instead of using the default view location (which may be // completely bogus for the particular file you're loading), // let's use the initial view from the file. We can get // this by getting the view groups from the scene (there's // only one for Lightwave 3D), then using the inverse of the // transform on that view as the transform for the entire scene. // First, get the view groups (shouldn't be null unless there // was something wrong in the load TransformGroup viewGroups[] = loaderScene.getViewGroups(); // Get the Transform3D from the view and invert it Transform3D t = new Transform3D(); viewGroups[0].getTransform(t); Matrix4d m = new Matrix4d(); t.get(m); m.invert(); t.set(m); // Now we've got the transform we want. Create an // appropriate TransformGroup and parent the scene to it. // Then insert the new group into the main BranchGroup. TransformGroup sceneTransform = new TransformGroup(t); sceneTransform.addChild(loaderScene.getSceneGroup()); sceneRoot.addChild(sceneTransform); } // Make the scene graph live by inserting the root into the universe u.addBranchGraph(sceneRoot); }
From source file:com.falcon.orca.handlers.StandAloneHandler.java
@Override public void handle() { BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); Options options = createOptions();//from www . ja v a 2 s.c o m printOnCmd("Welcome to ORCA type --help | -h to see what ORCA can do."); try { String command = br.readLine(); while (command != null) { if (!StringUtils.isEmpty(command)) { try { String[] treatedCommandParts = treatCommands(command); commandLine = commandLineParser.parse(options, treatedCommandParts); if (commandLine.hasOption("start")) { if (manager != null && !manager.isTerminated()) { printOnCmd("Already running a job, please wait!!"); } else { RunDetails runDetails = createRunDetails(commandLine); if (runDetails.isBodyDynamic() || runDetails.isUrlDynamic()) { DataReader dataReader = new JsonFileReader(runDetails.getDataFilePath(), runDetails.getTemplateFilePath()); HashMap<String, HashMap<String, List<Object>>> dynDataFromFile = dataReader .readVariableValues(); HashMap<String, HashMap<String, DynVarUseType>> dynVarUseTypeFromFile = dataReader .readVariableUseType(); HashMap<String, List<Object>> bodyParams = null; String template = null; HashMap<String, DynVarUseType> bodyParamsUseType = null; HashMap<String, List<Object>> urlParams = null; HashMap<String, DynVarUseType> urlParamsUseType = null; if (runDetails.isBodyDynamic()) { bodyParams = dynDataFromFile.get("bodyData"); template = dataReader.readTemplate(); bodyParamsUseType = dynVarUseTypeFromFile.get("bodyVarUseType"); } if (runDetails.isUrlDynamic()) { urlParams = dynDataFromFile.get("urlData"); urlParamsUseType = dynVarUseTypeFromFile.get("urlVarUseType"); } HashMap<String, DynGenerator> generators = dataReader.readGenerators(); DynDataStore dataStore = new DynDataStore(bodyParams, urlParams, bodyParamsUseType, urlParamsUseType, generators, template, runDetails.getUrl()); manager = actorSystem.actorOf(Manager.props(runDetails, dataStore)); } else { manager = actorSystem.actorOf(Manager.props(runDetails, null)); } ManagerCommand managerCommand = new ManagerCommand(); managerCommand.setType(ManagerCommandType.START); manager.tell(managerCommand, manager); } } else if (commandLine.hasOption("stop")) { if (manager != null && !manager.isTerminated()) { ManagerCommand managerCommand = new ManagerCommand(); managerCommand.setType(ManagerCommandType.STOP); manager.tell(managerCommand, manager); printOnCmd("Job killed successfully."); } else { printOnCmd("No job running."); } } else if (commandLine.hasOption("exit")) { if (manager != null && !manager.isTerminated()) { ManagerCommand managerCommand = new ManagerCommand(); managerCommand.setType(ManagerCommandType.STOP); manager.tell(managerCommand, manager); } printOnCmd("Exiting the system gracefully now."); actorSystem.shutdown(); actorSystem.awaitTermination(new FiniteDuration(1, TimeUnit.MINUTES)); break; } else if (commandLine.hasOption("pause")) { if (manager != null && !manager.isTerminated()) { ManagerCommand managerCommand = new ManagerCommand(); managerCommand.setType(ManagerCommandType.PAUSE); manager.tell(managerCommand, manager); } else { printOnCmd("No active jobs to pause."); } } else if (commandLine.hasOption("resume")) { if (manager != null && !manager.isTerminated()) { ManagerCommand managerCommand = new ManagerCommand(); managerCommand.setType(ManagerCommandType.RESUME); manager.tell(managerCommand, manager); } else { printOnCmd("No paused job to resume."); } } else { printOnCmd(printHelpStandAloneMode()); } } catch (ParseException pe) { printOnCmd(printHelpStandAloneMode()); } catch (MalformedURLException me) { me.printStackTrace(); } } else { printOnCmd("", false); } command = br.readLine(); } } catch (IOException e) { printOnCmd("Something went wrong in reading input, please try again."); } }
From source file:com.sciamlab.ckan4j.CKANRating.java
private CKANRating(CKANRatingBuilder builder) { this.dao = builder.dao; this.rating_table = builder.rating_table; try {//from w w w .j a va 2 s . c om this.ckan = CKANApiClientBuilder.getInstance(builder.ckan_api_endpoint.toString()) .apiKey(builder.ckan_api_key).build(); } catch (MalformedURLException e) { //should never be thrown e.printStackTrace(); } }
From source file:gov.nih.nci.nbia.StandaloneDMV2.java
protected List<SeriesData> getSeriesInfo(String userId, String password) { List<String> seriesInfo = null; try {/*from w ww . j a va 2 s . c o m*/ seriesInfo = connectAndReadFromURL(new URL(serverUrl), fileLoc + basketId, userId, password); } catch (MalformedURLException e1) { e1.printStackTrace(); } String[] strResult = new String[seriesInfo.size()]; seriesInfo.toArray(strResult); return JnlpArgumentsParser.parse(strResult); }
From source file:com.ankit.touchreview.FinalActivity.java
public void setThemeImage(final String themeimage) { new Thread() { public void run() { try { InputStream is = (InputStream) new URL(themeimage).getContent(); Bitmap bmImg = BitmapFactory.decodeStream(is); @SuppressWarnings("deprecation") final BitmapDrawable background = new BitmapDrawable(bmImg); runOnUiThread(new Runnable() { @SuppressWarnings("deprecation") @Override/*from www.ja va 2 s . co m*/ public void run() { LinearLayout1.setBackgroundDrawable(background); } }); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }.start(); }
From source file:eu.city4ageproject.delivery.InfoGrabber.java
public VCard getVCard(String pilotID, String userID) { //resolve pilot URL Service URL service = null;//w w w . j av a2 s. c o m try { service = new URL(getPilotVcardService(pilotID) + userID); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } //get Serialised card for userID ServiceGrabber sg = new ServiceGrabber(service); //parse vCard if (sg.type != null) { VCard res = parse(sg.serialised, sg.type); if (res != null) { return res; } } for (VcardType t : VcardType.values()) { VCard res = parse(sg.serialised, t); if (res != null) { return res; } } return null; }
From source file:com.github.hipchat.api.Room.java
public List<HistoryMessage> getHistory(Date date) { HipChat hc = getOrigin();/*w w w . j av a 2 s .c o m*/ Calendar c = Calendar.getInstance(); String dateString = null; String tzString = null; if (date != null) { c.setTime(date); TimeZone tz = c.getTimeZone(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); dateString = sdf.format(date); tzString = tz.getDisplayName(tz.inDaylightTime(date), TimeZone.SHORT); } else { Date tDate = new Date(); c.setTime(tDate); TimeZone tz = c.getTimeZone(); dateString = "recent"; tzString = tz.getDisplayName(tz.inDaylightTime(tDate), TimeZone.SHORT); } String query = String.format(HipChatConstants.ROOMS_HISTORY_QUERY_FORMAT, getId(), dateString, tzString, HipChatConstants.JSON_FORMAT, hc.getAuthToken()); OutputStream output = null; InputStream input = null; HttpURLConnection connection = null; List<HistoryMessage> messages = null; try { URL requestUrl = new URL(HipChatConstants.API_BASE + HipChatConstants.ROOMS_HISTORY + query); connection = (HttpURLConnection) requestUrl.openConnection(); connection.setDoInput(true); input = connection.getInputStream(); messages = MessageParser.parseRoomHistory(this, input); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(output); connection.disconnect(); } return messages; }
From source file:eu.impact_project.wsclient.HtmlServiceProvider.java
private Service createServiceObjectFor(Node a, int id) { String title = formatTitle(a.getTextContent()); String wsdlPath = a.getAttributes().getNamedItem("href").getTextContent(); URL wsdlUrl = null;/* w ww. ja v a 2 s. c o m*/ try { wsdlUrl = new URL(configUrl + wsdlPath); } catch (MalformedURLException e) { e.printStackTrace(); } String description = getWsdlDescription(wsdlUrl); Service result = new HtmlService(id, title, description, wsdlUrl); return result; }
From source file:com.clevertrail.mobile.findtrail.Activity_FindTrail_ByName.java
private int submitSearch() { JSONArray jsonArray = null;/*w w w . ja v a2 s .c om*/ HttpURLConnection urlConnection = null; try { //api call to find trails by name String requestURL = "http://clevertrail.com/ajax/handleGetArticles.php"; String sSearch = mActivity.sSearchText; sSearch = sSearch.replace(" ", "%20"); sSearch = sSearch.replace("'", "\'"); requestURL = requestURL.concat("?name=").concat(sSearch); URL url = new URL(requestURL); urlConnection = (HttpURLConnection) url.openConnection(); InputStream in = new BufferedInputStream(urlConnection.getInputStream()); BufferedReader r = new BufferedReader(new InputStreamReader(in)); String line; //did we get a match from clevertrail.com? if ((line = r.readLine()) != null) { jsonArray = new JSONArray(line); } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); return R.string.error_contactingclevertrail; } catch (IOException e) { // TODO Auto-generated catch block // could not connect to clevertrail.com e.printStackTrace(); return R.string.error_contactingclevertrail; } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); return R.string.error_corrupttrailinfo; } finally { if (urlConnection != null) urlConnection.disconnect(); } //clear the static object that holds the trails Object_TrailList.clearTrails(); if (jsonArray != null && jsonArray.length() > 0) { int len = jsonArray.length(); try { //add each trail to the array of trails for (int i = 0; i < len && i < 20; ++i) { JSONObject trail = jsonArray.getJSONObject(i); Object_TrailList.addTrailWithJSON(trail); } } catch (JSONException e) { return R.string.error_corrupttrailinfo; } } //prepare the extras before starting the trail list activity int icon = R.drawable.ic_viewtrailtab_details_unselected; Intent i = new Intent(mActivity, Activity_ListTrails.class); i.putExtra("icon", icon); i.putExtra("title", mActivity.getString(R.string.title_foundtrails)); mActivity.startActivity(i); return 0; }
From source file:com.comcast.cats.video.service.VideoServiceImpl.java
/** * Makes the HTTP connection to the Axis Server device. *//*from w w w . j a va2 s . co m*/ public void connectVideoServer() { try { videoController.connect(); } catch (MalformedURLException e) { e.printStackTrace(); } }