List of usage examples for java.lang Float toString
public static String toString(float f)
From source file:com.example.android.SoundSettingsActivity.java
/** * Handle changing volume./*from w w w.j a va 2s . c o m*/ */ public void onStopTrackingTouch(SeekBar seekBar) { // Tracking off soundVolume = seekBar.getProgress(); SoundPlayer.setCurrentVolume(soundVolume); Context context = getApplicationContext(); CharSequence text = Float.toString(soundVolume); int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); float volume = (float) (one - (Math.log(MAX_VOLUME - soundVolume) / Math.log(MAX_VOLUME))); SoundPlayer.setVolume(volume, volume); }
From source file:com.variable.demo.api.fragment.MotionFragment.java
@Override public void onGyroscopeUpdate(MotionSensor sensor, MotionReading reading) { Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_GYROSCOPE_READING); Bundle b = m.getData();/*from w w w. ja v a 2 s . co m*/ b.putFloat(MessageConstants.X_VALUE_KEY, (reading.getX() + 2000) * DECIMAL_PRECISION); b.putFloat(MessageConstants.Y_VALUE_KEY, (reading.getY() + 2000) * DECIMAL_PRECISION); b.putFloat(MessageConstants.Z_VALUE_KEY, (reading.getZ() + 2000) * DECIMAL_PRECISION); //For this demo we are streaming all time stamp from the node device. b.putLong(MessageConstants.TIME_STAMP, reading.getTimeStamp().getTime()); b.putInt(MessageConstants.TIME_SOURCE, reading.getTimeStampSource()); final Context thiscontext = this.getActivity(); final String serialnumOne = sensor.getSerialNumber(); final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", ""); final String scanX = Float.toString((reading.getX() + 16) * DECIMAL_PRECISION); final String scanY = Float.toString((reading.getY() + 16) * DECIMAL_PRECISION); final String scanZ = Float.toString((reading.getZ() + 16) * DECIMAL_PRECISION); String json = "gyroscope;" + serialnum + ";" + scanX + "," + scanY + "," + scanZ; // POST to variable dashboard Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false); Ion.with(thiscontext).load( "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]=" + json) .setLogging("MyLogs", Log.DEBUG).asString().withResponse() .setCallback(new FutureCallback<Response<String>>() { @Override public void onCompleted(Exception e, Response<String> result) { if (e == null) { Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString()); } else { Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION"); e.printStackTrace(); } } }); m.sendToTarget(); }
From source file:org.opencommercesearch.feed.RuleFeed.java
/** * Initializes the strength map./*from w ww .j ava2s . c om*/ */ private void initializeStrengthMap() { //TODO move this mappings to configuration file strengthMap = new HashMap<String, String>(STRENGTH_LEVELS); strengthMap.put(STRENGTH_MAXIMUM_DEMOTE, Float.toString(1 / 10f)); strengthMap.put(STRENGTH_STRONG_DEMOTE, Float.toString(1 / 5f)); strengthMap.put(STRENGTH_MEDIUM_DEMOTE, Float.toString(1 / 2f)); strengthMap.put(STRENGTH_WEAK_DEMOTE, Float.toString(1 / 1.5f)); strengthMap.put(STRENGTH_NEUTRAL, Float.toString(1f)); strengthMap.put(STRENGTH_WEAK_BOOST, Float.toString(1.5f)); strengthMap.put(STRENGTH_MEDIUM_BOOST, Float.toString(2f)); strengthMap.put(STRENGTH_STRONG_BOOST, Float.toString(5f)); strengthMap.put(STRENGTH_MAXIMUM_BOOST, Float.toString(10f)); }
From source file:eu.europeana.portal2.web.presentation.model.FullDocPage.java
/** * Returns a collection of Meta Data fields * /*from www.j a v a 2 s . co m*/ * @return collection of meta data fields * @throws EuropeanaQueryException */ public List<MetaDataFieldPresentation> getMetaDataFields() { List<MetaDataFieldPresentation> fields = new ArrayList<MetaDataFieldPresentation>(); addMetaField(fields, Field.EUROPEANA_URI, document.getId()); addMetaField(fields, Field.EDM_COUNTRY, getDocument().getEdmCountry()); addMetaField(fields, Field.EDM_PROVIDER, shortcut, "EdmProvider"); addMetaField(fields, Field.EDM_COLLECTIONNAME, document.getEuropeanaCollectionName()); addMetaField(fields, Field.EDM_ISSHOWNAT, shortcut, "EdmIsShownAt"); addMetaField(fields, Field.EDM_ISSHOWNBY, shortcut, "EdmIsShownBy"); // addMetaField(fields, Field.EUROPEANA_OBJECT, document.getThumbnails()); addMetaField(fields, Field.EDM_OBJECT, shortcut, "EdmObject"); addMetaField(fields, Field.EDM_LANGUAGE, getDocument().getEdmLanguage()); // addMetaField(fields, Field.EUROPEANA_TYPE, document.getType().toString()); // addMetaField(fields, Field.EUROPEANA_USERTAG, document.getEdmUserTag()); // addMetaField(fields, Field.EUROPEANA_YEAR, getDocument().getEdmYear()); addMetaField(fields, Field.EDM_RIGHTS, shortcut, "EdmRights"); addMetaField(fields, Field.EDM_DATAPROVIDER, getDocument().getEdmDataProvider()); addMetaField(fields, Field.EDM_UGC, shortcut, "EdmUGC"); addMetaField(fields, Field.DCTERMS_ALTERNATIVE, shortcut, "DctermsAlternative"); addMetaField(fields, Field.DCTERMS_CONFORMSTO, shortcut, "DctermsConformsTo"); addMetaField(fields, Field.DCTERMS_CREATED, shortcut, "DctermsCreated"); addMetaField(fields, Field.DCTERMS_EXTENT, shortcut, "DctermsExtent"); addMetaField(fields, Field.DCTERMS_HASFORMAT, shortcut, "DctermsHasFormat"); addMetaField(fields, Field.DCTERMS_HASPART, shortcut, "DctermsHasPart"); addMetaField(fields, Field.DCTERMS_HASVERSION, getDocument().getDctermsHasVersion()); addMetaField(fields, Field.DCTERMS_ISFORMATOF, getDocument().getDctermsIsFormatOf()); addMetaField(fields, Field.DCTERMS_ISPARTOF, shortcut, "DctermsIsPartOf"); addMetaField(fields, Field.DCTERMS_ISREFERENCEDBY, shortcut, "DctermsIsReferencedBy"); addMetaField(fields, Field.DCTERMS_ISREPLACEDBY, shortcut, "DctermsIsReplacedBy"); addMetaField(fields, Field.DCTERMS_ISREQUIREDBY, shortcut, "DctermsIsRequiredBy"); addMetaField(fields, Field.DCTERMS_ISSUED, shortcut, "DctermsIssued"); addMetaField(fields, Field.DCTERMS_ISVERSIONOF, shortcut, "DctermsIsVersionOf"); addMetaField(fields, Field.DCTERMS_MEDIUM, shortcut, "DctermsMedium"); addMetaField(fields, Field.DCTERMS_PROVENANCE, shortcut, "DctermsProvenance"); addMetaField(fields, Field.DCTERMS_REFERENCES, shortcut, "DctermsReferences"); addMetaField(fields, Field.DCTERMS_REPLACES, shortcut, "DctermsReplaces"); addMetaField(fields, Field.DCTERMS_REQUIRES, shortcut, "DctermsRequires"); addMetaField(fields, Field.DCTERMS_SPATIAL, shortcut, "DctermsSpatial"); addMetaField(fields, Field.DCTERMS_TABLEOFCONTENTS, shortcut, "DctermsTableOfContents"); addMetaField(fields, Field.DCTERMS_TEMPORAL, shortcut, "DctermsTemporal"); addMetaField(fields, Field.DC_CONTRIBUTOR, shortcut, "DcContributor"); addMetaField(fields, Field.DC_COVERAGE, shortcut, "DcCoverage"); addMetaField(fields, Field.DC_CREATOR, shortcut, "DcCreator"); addMetaField(fields, Field.DC_DATE, getDocument().getDcDate()); addMetaField(fields, Field.DC_DESCRIPTION, getDocument().getDcDescription()); addMetaField(fields, Field.DC_FORMAT, getDocument().getDcFormat()); addMetaField(fields, Field.DC_IDENTIFIER, shortcut, "DcIdentifier"); addMetaField(fields, Field.DC_LANGUAGE, getDocument().getDcLanguage()); addMetaField(fields, Field.DC_PUBLISHER, shortcut, "DcPublisher"); addMetaField(fields, Field.DC_RELATION, shortcut, "DcRelation"); addMetaField(fields, Field.DC_RIGHTS, getDocument().getDcRights()); addMetaField(fields, Field.DC_SOURCE, shortcut, "DcSource"); addMetaField(fields, Field.DC_SUBJECT, getDocument().getDcSubject()); addMetaField(fields, Field.DC_TITLE, getDocument().getDcTitle()); addMetaField(fields, Field.DC_TYPE, getDocument().getDcType()); addMetaField(fields, Field.EUROPEANA_COMPLETENESS, Integer.toString(document.getEuropeanaCompleteness())); if (document.getPlaces() != null) { for (Place place : document.getPlaces()) { addMetaField(fields, Field.ENRICHMENT_PLACE_ABOUT, place.getAbout()); if (place.getPrefLabel() != null) { for (String key : place.getPrefLabel().keySet()) { addMetaField(fields, Field.ENRICHMENT_PLACE_LABEL, place.getPrefLabel().get(key) + " (" + key + ")"); } } if ((place.getLatitude() != 0) || (place.getLongitude() != 0)) { addMetaField(fields, Field.ENRICHMENT_PLACE_LATITUDE, Float.toString(place.getLatitude())); addMetaField(fields, Field.ENRICHMENT_PLACE_LONGITUDE, Float.toString(place.getLongitude())); } } } if (document.getTimespans() != null) { for (Timespan timespan : document.getTimespans()) { addMetaField(fields, Field.ENRICHMENT_TIMESPAN_ABOUT, timespan.getAbout()); for (String key : timespan.getPrefLabel().keySet()) { addMetaField(fields, Field.ENRICHMENT_TIMESPAN_LABEL, timespan.getPrefLabel().get(key) + " (" + key + ")"); } if (timespan.getBegin() != null) { for (Entry<String, List<String>> item : timespan.getBegin().entrySet()) { for (String value : item.getValue()) { addMetaField(fields, Field.ENRICHMENT_TIMESPAN_BEGIN, value); } } } if (timespan.getEnd() != null) { for (Entry<String, List<String>> item : timespan.getEnd().entrySet()) { for (String value : item.getValue()) { addMetaField(fields, Field.ENRICHMENT_TIMESPAN_END, value); } } } } } if (document.getConcepts() != null) { for (Concept concept : document.getConcepts()) { addMetaField(fields, Field.ENRICHMENT_CONCEPT_ABOUT, concept.getAbout()); for (String key : concept.getPrefLabel().keySet()) { addMetaField(fields, Field.ENRICHMENT_CONCEPT_LABEL, concept.getPrefLabel().get(key) + " (" + key + ")"); } addMetaField(fields, Field.ENRICHMENT_CONCEPT_BROADER_TERM, concept.getBroader()); } } if (document.getAgents() != null) { for (Agent agent : document.getAgents()) { addMetaField(fields, Field.ENRICHMENT_AGENT_ABOUT, agent.getAbout()); for (String key : agent.getPrefLabel().keySet()) { addMetaField(fields, Field.ENRICHMENT_AGENT_LABEL, agent.getPrefLabel().get(key) + " (" + key + ")"); } } } return fields; }
From source file:com.jug.MoMA.java
/** * PROJECT MAIN/* w w w . j a va2 s . c om*/ * * @param args */ public static void main(final String[] args) { if (showIJ) new ImageJ(); // // ===== set look and feel ======================================================================== // try { // // Set cross-platform Java L&F (also called "Metal") // UIManager.setLookAndFeel( // UIManager.getCrossPlatformLookAndFeelClassName() ); // } catch ( final UnsupportedLookAndFeelException e ) { // // handle exception // } catch ( final ClassNotFoundException e ) { // // handle exception // } catch ( final InstantiationException e ) { // // handle exception // } catch ( final IllegalAccessException e ) { // // handle exception // } // ===== command line parsing ====================================================================== // create Options object & the parser final Options options = new Options(); final CommandLineParser parser = new BasicParser(); // defining command line options final Option help = new Option("help", "print this message"); final Option headless = new Option("h", "headless", false, "start without user interface (note: input-folder must be given!)"); headless.setRequired(false); final Option timeFirst = new Option("tmin", "min_time", true, "first time-point to be processed"); timeFirst.setRequired(false); final Option timeLast = new Option("tmax", "max_time", true, "last time-point to be processed"); timeLast.setRequired(false); final Option optRange = new Option("orange", "opt_range", true, "initial optimization range"); optRange.setRequired(false); final Option numChannelsOption = new Option("c", "channels", true, "number of channels to be loaded and analyzed."); numChannelsOption.setRequired(true); final Option minChannelIdxOption = new Option("cmin", "min_channel", true, "the smallest channel index (usually 0 or 1, default is 1)."); minChannelIdxOption.setRequired(false); final Option infolder = new Option("i", "infolder", true, "folder to read data from"); infolder.setRequired(false); final Option outfolder = new Option("o", "outfolder", true, "folder to write preprocessed data to (equals infolder if not given)"); outfolder.setRequired(false); final Option userProps = new Option("p", "props", true, "properties file to be loaded (mm.properties)"); userProps.setRequired(false); options.addOption(help); options.addOption(headless); options.addOption(numChannelsOption); options.addOption(minChannelIdxOption); options.addOption(timeFirst); options.addOption(timeLast); options.addOption(optRange); options.addOption(infolder); options.addOption(outfolder); options.addOption(userProps); // get the commands parsed CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (final ParseException e1) { final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp( "... [-p props-file] -i in-folder [-o out-folder] -c <num-channels> [-cmin start-channel-ids] [-tmin idx] [-tmax idx] [-orange num-frames] [-headless]", "", options, "Error: " + e1.getMessage()); System.exit(0); } if (cmd.hasOption("help")) { final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("... -i <in-folder> -o [out-folder] [-headless]", options); System.exit(0); } if (cmd.hasOption("h")) { System.out.println(">>> Starting MM in headless mode."); HEADLESS = true; if (!cmd.hasOption("i")) { final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Headless-mode requires option '-i <in-folder>'...", options); System.exit(0); } } File inputFolder = null; if (cmd.hasOption("i")) { inputFolder = new File(cmd.getOptionValue("i")); if (!inputFolder.isDirectory()) { System.out.println("Error: Input folder is not a directory!"); System.exit(2); } if (!inputFolder.canRead()) { System.out.println("Error: Input folder cannot be read!"); System.exit(2); } } File outputFolder = null; if (!cmd.hasOption("o")) { if (inputFolder == null) { System.out.println( "Error: Output folder would be set to a 'null' input folder! Please check your command line arguments..."); System.exit(3); } outputFolder = inputFolder; STATS_OUTPUT_PATH = outputFolder.getAbsolutePath(); } else { outputFolder = new File(cmd.getOptionValue("o")); if (!outputFolder.isDirectory()) { System.out.println("Error: Output folder is not a directory!"); System.exit(3); } if (!inputFolder.canWrite()) { System.out.println("Error: Output folder cannot be written to!"); System.exit(3); } STATS_OUTPUT_PATH = outputFolder.getAbsolutePath(); } fileUserProps = null; if (cmd.hasOption("p")) { fileUserProps = new File(cmd.getOptionValue("p")); } if (cmd.hasOption("cmin")) { minChannelIdx = Integer.parseInt(cmd.getOptionValue("cmin")); } if (cmd.hasOption("c")) { numChannels = Integer.parseInt(cmd.getOptionValue("c")); } if (cmd.hasOption("tmin")) { minTime = Integer.parseInt(cmd.getOptionValue("tmin")); } if (cmd.hasOption("tmax")) { maxTime = Integer.parseInt(cmd.getOptionValue("tmax")); } if (cmd.hasOption("orange")) { initOptRange = Integer.parseInt(cmd.getOptionValue("orange")); } // ******** CHECK GUROBI ********* CHECK GUROBI ********* CHECK GUROBI ********* final String jlp = System.getProperty("java.library.path"); // System.out.println( jlp ); try { new GRBEnv("MoMA_gurobi.log"); } catch (final GRBException e) { final String msgs = "Initial Gurobi test threw exception... check your Gruobi setup!\n\nJava library path: " + jlp; if (HEADLESS) { System.out.println(msgs); } else { JOptionPane.showMessageDialog(MoMA.guiFrame, msgs, "Gurobi Error?", JOptionPane.ERROR_MESSAGE); } e.printStackTrace(); System.exit(98); } catch (final UnsatisfiedLinkError ulr) { final String msgs = "Could initialize Gurobi.\n" + "You might not have installed Gurobi properly or you miss a valid license.\n" + "Please visit 'www.gurobi.com' for further information.\n\n" + ulr.getMessage() + "\nJava library path: " + jlp; if (HEADLESS) { System.out.println(msgs); } else { JOptionPane.showMessageDialog(MoMA.guiFrame, msgs, "Gurobi Error?", JOptionPane.ERROR_MESSAGE); ulr.printStackTrace(); } System.out.println("\n>>>>> Java library path: " + jlp + "\n"); System.exit(99); } // ******* END CHECK GUROBI **** END CHECK GUROBI **** END CHECK GUROBI ******** final MoMA main = new MoMA(); if (!HEADLESS) { guiFrame = new JFrame(); main.initMainWindow(guiFrame); } System.out.println("VERSION: " + VERSION_STRING); props = main.loadParams(); BGREM_TEMPLATE_XMIN = Integer .parseInt(props.getProperty("BGREM_TEMPLATE_XMIN", Integer.toString(BGREM_TEMPLATE_XMIN))); BGREM_TEMPLATE_XMAX = Integer .parseInt(props.getProperty("BGREM_TEMPLATE_XMAX", Integer.toString(BGREM_TEMPLATE_XMAX))); BGREM_X_OFFSET = Integer.parseInt(props.getProperty("BGREM_X_OFFSET", Integer.toString(BGREM_X_OFFSET))); GL_WIDTH_IN_PIXELS = Integer .parseInt(props.getProperty("GL_WIDTH_IN_PIXELS", Integer.toString(GL_WIDTH_IN_PIXELS))); MOTHER_CELL_BOTTOM_TRICK_MAX_PIXELS = Integer.parseInt(props.getProperty( "MOTHER_CELL_BOTTOM_TRICK_MAX_PIXELS", Integer.toString(MOTHER_CELL_BOTTOM_TRICK_MAX_PIXELS))); GL_FLUORESCENCE_COLLECTION_WIDTH_IN_PIXELS = Integer .parseInt(props.getProperty("GL_FLUORESCENCE_COLLECTION_WIDTH_IN_PIXELS", Integer.toString(GL_FLUORESCENCE_COLLECTION_WIDTH_IN_PIXELS))); GL_OFFSET_BOTTOM = Integer .parseInt(props.getProperty("GL_OFFSET_BOTTOM", Integer.toString(GL_OFFSET_BOTTOM))); if (GL_OFFSET_BOTTOM == -1) { GL_OFFSET_BOTTOM_AUTODETECT = true; } else { GL_OFFSET_BOTTOM_AUTODETECT = false; } GL_OFFSET_TOP = Integer.parseInt(props.getProperty("GL_OFFSET_TOP", Integer.toString(GL_OFFSET_TOP))); GL_OFFSET_LATERAL = Integer .parseInt(props.getProperty("GL_OFFSET_LATERAL", Integer.toString(GL_OFFSET_LATERAL))); MIN_CELL_LENGTH = Integer.parseInt(props.getProperty("MIN_CELL_LENGTH", Integer.toString(MIN_CELL_LENGTH))); MIN_GAP_CONTRAST = Float .parseFloat(props.getProperty("MIN_GAP_CONTRAST", Float.toString(MIN_GAP_CONTRAST))); SIGMA_PRE_SEGMENTATION_X = Float.parseFloat( props.getProperty("SIGMA_PRE_SEGMENTATION_X", Float.toString(SIGMA_PRE_SEGMENTATION_X))); SIGMA_PRE_SEGMENTATION_Y = Float.parseFloat( props.getProperty("SIGMA_PRE_SEGMENTATION_Y", Float.toString(SIGMA_PRE_SEGMENTATION_Y))); SIGMA_GL_DETECTION_X = Float .parseFloat(props.getProperty("SIGMA_GL_DETECTION_X", Float.toString(SIGMA_GL_DETECTION_X))); SIGMA_GL_DETECTION_Y = Float .parseFloat(props.getProperty("SIGMA_GL_DETECTION_Y", Float.toString(SIGMA_GL_DETECTION_Y))); SEGMENTATION_MIX_CT_INTO_PMFRF = Float.parseFloat(props.getProperty("SEGMENTATION_MIX_CT_INTO_PMFRF", Float.toString(SEGMENTATION_MIX_CT_INTO_PMFRF))); SEGMENTATION_CLASSIFIER_MODEL_FILE = props.getProperty("SEGMENTATION_CLASSIFIER_MODEL_FILE", SEGMENTATION_CLASSIFIER_MODEL_FILE); CELLSIZE_CLASSIFIER_MODEL_FILE = props.getProperty("CELLSIZE_CLASSIFIER_MODEL_FILE", CELLSIZE_CLASSIFIER_MODEL_FILE); DEFAULT_PATH = props.getProperty("DEFAULT_PATH", DEFAULT_PATH); GUROBI_TIME_LIMIT = Double .parseDouble(props.getProperty("GUROBI_TIME_LIMIT", Double.toString(GUROBI_TIME_LIMIT))); GUROBI_MAX_OPTIMALITY_GAP = Double.parseDouble( props.getProperty("GUROBI_MAX_OPTIMALITY_GAP", Double.toString(GUROBI_MAX_OPTIMALITY_GAP))); GUI_POS_X = Integer.parseInt(props.getProperty("GUI_POS_X", Integer.toString(DEFAULT_GUI_POS_X))); GUI_POS_Y = Integer.parseInt(props.getProperty("GUI_POS_Y", Integer.toString(DEFAULT_GUI_POS_X))); GUI_WIDTH = Integer.parseInt(props.getProperty("GUI_WIDTH", Integer.toString(GUI_WIDTH))); GUI_HEIGHT = Integer.parseInt(props.getProperty("GUI_HEIGHT", Integer.toString(GUI_HEIGHT))); GUI_CONSOLE_WIDTH = Integer .parseInt(props.getProperty("GUI_CONSOLE_WIDTH", Integer.toString(GUI_CONSOLE_WIDTH))); if (!HEADLESS) { // Iterate over all currently attached monitors and check if sceen // position is actually possible, // otherwise fall back to the DEFAULT values and ignore the ones // coming from the properties-file. boolean pos_ok = false; final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice[] gs = ge.getScreenDevices(); for (int i = 0; i < gs.length; i++) { if (gs[i].getDefaultConfiguration().getBounds() .contains(new java.awt.Point(GUI_POS_X, GUI_POS_Y))) { pos_ok = true; } } // None of the screens contained the top-left window coordinates --> // fall back onto default values... if (!pos_ok) { GUI_POS_X = DEFAULT_GUI_POS_X; GUI_POS_Y = DEFAULT_GUI_POS_Y; } } String path = props.getProperty("import_path", System.getProperty("user.home")); if (inputFolder == null || inputFolder.equals("")) { inputFolder = main.showStartupDialog(guiFrame, path); } System.out.println("Default filename decoration = " + inputFolder.getName()); defaultFilenameDecoration = inputFolder.getName(); path = inputFolder.getAbsolutePath(); props.setProperty("import_path", path); GrowthLineSegmentationMagic.setClassifier(SEGMENTATION_CLASSIFIER_MODEL_FILE, ""); if (!HEADLESS) { // Setting up console window... main.initConsoleWindow(); main.showConsoleWindow(true); } // ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------ final MoMAModel mmm = new MoMAModel(main); instance = main; try { main.processDataFromFolder(path, minTime, maxTime, minChannelIdx, numChannels); } catch (final Exception e) { e.printStackTrace(); System.exit(11); } // ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------ // show loaded and annotated data if (showIJ) { new ImageJ(); ImageJFunctions.show(main.imgRaw, "Rotated & cropped raw data"); // ImageJFunctions.show( main.imgTemp, "Temporary" ); // ImageJFunctions.show( main.imgAnnotated, "Annotated ARGB data" ); // main.getCellSegmentedChannelImgs() // ImageJFunctions.show( main.imgClassified, "Classification" ); // ImageJFunctions.show( main.getCellSegmentedChannelImgs(), "Segmentation" ); } gui = new MoMAGui(mmm); if (!HEADLESS) { System.out.print("Build GUI..."); main.showConsoleWindow(false); // final JFrameSnapper snapper = new JFrameSnapper(); // snapper.addFrame( main.frameConsoleWindow ); // snapper.addFrame( guiFrame ); gui.setVisible(true); guiFrame.add(gui); guiFrame.setSize(GUI_WIDTH, GUI_HEIGHT); guiFrame.setLocation(GUI_POS_X, GUI_POS_Y); guiFrame.setVisible(true); // SwingUtilities.invokeLater( new Runnable() { // // @Override // public void run() { // snapper.snapFrames( main.frameConsoleWindow, guiFrame, JFrameSnapper.EAST ); // } // } ); System.out.println(" done!"); } else { // final String name = inputFolder.getName(); gui.exportHtmlOverview(); gui.exportDataFiles(); instance.saveParams(); System.exit(0); } }
From source file:com.anjalimacwan.fragment.NoteViewFragment.java
@SuppressLint("SetJavaScriptEnabled") @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override// ww w . ja va 2s . co m public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Set values setRetainInstance(true); setHasOptionsMenu(true); // Get filename of saved note filename = getArguments().getString("filename"); // Change window title String title; try { title = listener.loadNoteTitle(filename); } catch (IOException e) { title = getResources().getString(R.string.view_note); } getActivity().setTitle(title); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(title, null, ContextCompat.getColor(getActivity(), R.color.primary)); getActivity().setTaskDescription(taskDescription); } // Show the Up button in the action bar. ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Animate elevation change if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit); LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList); noteList.animate().z(0f); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) noteViewEdit.animate() .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land)); else noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation)); } // Set up content view TextView noteContents = (TextView) getActivity().findViewById(R.id.textView); markdownView = (MarkdownView) getActivity().findViewById(R.id.markdownView); // Apply theme SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE); ScrollView scrollView = (ScrollView) getActivity().findViewById(R.id.scrollView); String theme = pref.getString("theme", "light-sans"); int textSize = -1; int textColor = -1; String fontFamily = null; if (theme.contains("light")) { if (noteContents != null) { noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary)); noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); } if (markdownView != null) { markdownView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); textColor = ContextCompat.getColor(getActivity(), R.color.text_color_primary); } scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); } if (theme.contains("dark")) { if (noteContents != null) { noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary_dark)); noteContents .setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); } if (markdownView != null) { markdownView .setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); textColor = ContextCompat.getColor(getActivity(), R.color.text_color_primary_dark); } scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); } if (theme.contains("sans")) { if (noteContents != null) noteContents.setTypeface(Typeface.SANS_SERIF); if (markdownView != null) fontFamily = "sans-serif"; } if (theme.contains("serif")) { if (noteContents != null) noteContents.setTypeface(Typeface.SERIF); if (markdownView != null) fontFamily = "serif"; } if (theme.contains("monospace")) { if (noteContents != null) noteContents.setTypeface(Typeface.MONOSPACE); if (markdownView != null) fontFamily = "monospace"; } switch (pref.getString("font_size", "normal")) { case "smallest": textSize = 12; break; case "small": textSize = 14; break; case "normal": textSize = 16; break; case "large": textSize = 18; break; case "largest": textSize = 20; break; } if (noteContents != null) noteContents.setTextSize(textSize); if (markdownView != null) { String topBottom = " " + Float.toString(getResources().getDimension(R.dimen.padding_top_bottom) / getResources().getDisplayMetrics().density) + "px"; String leftRight = " " + Float.toString(getResources().getDimension(R.dimen.padding_left_right) / getResources().getDisplayMetrics().density) + "px"; String fontSize = " " + Integer.toString(textSize) + "px"; String fontColor = " #" + StringUtils.remove(Integer.toHexString(textColor), "ff"); final String css = "body { " + "margin:" + topBottom + topBottom + leftRight + leftRight + "; " + "font-family:" + fontFamily + "; " + "font-size:" + fontSize + "; " + "color:" + fontColor + "; " + "}"; final String js = "var styleNode = document.createElement('style');\n" + "styleNode.type = \"text/css\";\n" + "var styleText = document.createTextNode('" + css + "');\n" + "styleNode.appendChild(styleText);\n" + "document.getElementsByTagName('head')[0].appendChild(styleNode);\n"; markdownView.getSettings().setJavaScriptEnabled(true); markdownView.getSettings().setLoadsImagesAutomatically(false); markdownView.setWebViewClient(new WebViewClient() { @TargetApi(Build.VERSION_CODES.N) @Override public void onLoadResource(WebView view, String url) { view.stopLoading(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) try { startActivity(intent); } catch (ActivityNotFoundException | FileUriExposedException e) { /* Gracefully fail */ } else try { startActivity(intent); } catch (ActivityNotFoundException e) { /* Gracefully fail */ } } @Override public void onPageFinished(WebView view, String url) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) view.evaluateJavascript(js, null); else view.loadUrl("javascript:" + js); } }); } // Load note contents try { contentsOnLoad = listener.loadNote(filename); } catch (IOException e) { showToast(R.string.error_loading_note); // Add NoteListFragment or WelcomeFragment Fragment fragment; if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-normal")) fragment = new NoteListFragment(); else fragment = new WelcomeFragment(); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteListFragment") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit(); } // Set TextView contents if (noteContents != null) noteContents.setText(contentsOnLoad); if (markdownView != null) markdownView.loadMarkdown(contentsOnLoad); // Show a toast message if this is the user's first time viewing a note final SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); firstLoad = sharedPref.getInt("first-load", 0); if (firstLoad == 0) { // Show dialog with info DialogFragment firstLoad = new FirstViewDialogFragment(); firstLoad.show(getFragmentManager(), "firstloadfragment"); // Set first-load preference to 1; we don't need to show the dialog anymore SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt("first-load", 1); editor.apply(); } // Detect single and double-taps using GestureDetector final GestureDetector detector = new GestureDetector(getActivity(), new GestureDetector.OnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return false; } @Override public void onShowPress(MotionEvent e) { } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } @Override public void onLongPress(MotionEvent e) { } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return false; } @Override public boolean onDown(MotionEvent e) { return false; } }); detector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() { @Override public boolean onDoubleTap(MotionEvent e) { if (sharedPref.getBoolean("show_double_tap_message", true)) { SharedPreferences.Editor editor = sharedPref.edit(); editor.putBoolean("show_double_tap_message", false); editor.apply(); } Bundle bundle = new Bundle(); bundle.putString("filename", filename); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment") .commit(); return false; } @Override public boolean onDoubleTapEvent(MotionEvent e) { return false; } @Override public boolean onSingleTapConfirmed(MotionEvent e) { if (sharedPref.getBoolean("show_double_tap_message", true) && showMessage) { showToastLong(R.string.double_tap); showMessage = false; } return false; } }); if (noteContents != null) noteContents.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { detector.onTouchEvent(event); return false; } }); if (markdownView != null) markdownView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { detector.onTouchEvent(event); return false; } }); }
From source file:com.cloudera.oryx.rdf.common.pmml.DecisionForestPMML.java
private static Predicate buildPredicate(Decision decision, List<String> columnNames, Map<Integer, BiMap<String, Integer>> columnToCategoryNameToIDMapping) { Predicate predicate;/*from w w w. ja v a 2 s. c o m*/ if (decision == null) { predicate = new True(); } else { int columnNumber = decision.getFeatureNumber(); FieldName fieldName = new FieldName(columnNames.get(columnNumber)); if (decision.getType() == FeatureType.CATEGORICAL) { CategoricalDecision categoricalDecision = (CategoricalDecision) decision; Map<Integer, String> categoryIDToName = columnToCategoryNameToIDMapping.get(columnNumber).inverse(); BitSet includedCategoryIDs = categoricalDecision.getCategoryIDs(); List<String> categoryNames = Lists.newArrayList(); int categoryID = -1; while ((categoryID = includedCategoryIDs.nextSetBit(categoryID + 1)) >= 0) { categoryNames.add(categoryIDToName.get(categoryID)); } Array categories = new Array(DelimitedDataUtils.encode(categoryNames, ' '), Array.Type.STRING); predicate = new SimpleSetPredicate(categories, fieldName, SimpleSetPredicate.BooleanOperator.IS_IN); } else { NumericDecision numericDecision = (NumericDecision) decision; SimplePredicate numericPredicate = new SimplePredicate(fieldName, SimplePredicate.Operator.GREATER_OR_EQUAL); numericPredicate.setValue(Float.toString(numericDecision.getThreshold())); predicate = numericPredicate; } } return predicate; }
From source file:eu.itesla_project.eurostag.EurostagImpactAnalysis.java
private static void dumpLimits(EurostagDictionary dictionary, BufferedWriter writer, String branchId, CurrentLimits cl1, CurrentLimits cl2, float nominalV1, float nominalV2) throws IOException { writer.write(dictionary.getEsgId(branchId)); writer.write(";"); writer.write(Float.toString(cl1 != null ? cl1.getPermanentLimit() : Float.MAX_VALUE)); writer.write(";"); writer.write(Float.toString(cl2 != null ? cl2.getPermanentLimit() : Float.MAX_VALUE)); writer.write(";"); writer.write(Float.toString(nominalV1)); writer.write(";"); writer.write(Float.toString(nominalV2)); writer.write(";"); writer.write(branchId);// ww w .ja v a 2s . co m writer.newLine(); }
From source file:com.gelakinetic.mtgfam.helpers.ResultListAdapter.java
/** * Binds all of the field names passed into the "to" parameter of the constructor with their corresponding cursor * columns as specified in the "from" parameter. Binding occurs in two phases. First, if a * SimpleCursorAdapter.ViewBinder is available, setViewValue(android.view.View, android.database.Cursor, int) is * invoked. If the returned value is true, binding has occurred. If the returned value is false and the view to bind * is a TextView, setViewText(TextView, String) is invoked. If the returned value is false and the view to bind is * an ImageView, setViewImage(ImageView, String) is invoked. If no appropriate binding can be found, an * IllegalStateException is thrown./* w ww.j a v a 2 s. c o m*/ * * @param view Existing view, returned earlier by newView * @param context Interface to application's global information * @param cursor The cursor from which to get the data. The cursor is already moved to the correct position. */ @Override public void bindView(@NotNull View view, Context context, @NotNull Cursor cursor) { boolean hideCost = true; boolean hideSet = true; boolean hideType = true; boolean hideAbility = true; boolean hidePT = true; boolean hideLoyalty = true; boolean hideRarity = true; /* make sure these elements are showing (views get recycled) */ view.findViewById(R.id.cardp).setVisibility(View.VISIBLE); view.findViewById(R.id.cardslash).setVisibility(View.VISIBLE); view.findViewById(R.id.cardt).setVisibility(View.VISIBLE); /* Iterate through the mFrom, find the appropriate view in mTo */ for (int i = 0; i < mFrom.length; i++) { TextView textField = (TextView) view.findViewById(mTo[i]); switch (mFrom[i]) { case CardDbAdapter.KEY_NAME: { String name = cursor.getString(cursor.getColumnIndex(mFrom[i])); textField.setText(name); break; } case CardDbAdapter.KEY_MANACOST: { String name = cursor.getString(cursor.getColumnIndex(mFrom[i])); hideCost = false; CharSequence csq = ImageGetterHelper.formatStringWithGlyphs(name, mImgGetter); textField.setText(csq); break; } case CardDbAdapter.KEY_SET: { char rarity = (char) cursor.getInt(cursor.getColumnIndex(CardDbAdapter.KEY_RARITY)); String name = cursor.getString(cursor.getColumnIndex(mFrom[i])); hideSet = false; textField.setText(name); switch (rarity) { case 'c': case 'C': textField.setTextColor( ContextCompat.getColor(context, getResourceIdFromAttr(R.attr.color_common))); break; case 'u': case 'U': textField.setTextColor( ContextCompat.getColor(context, getResourceIdFromAttr(R.attr.color_uncommon))); break; case 'r': case 'R': textField.setTextColor( ContextCompat.getColor(context, getResourceIdFromAttr(R.attr.color_rare))); break; case 'm': case 'M': textField.setTextColor( ContextCompat.getColor(context, getResourceIdFromAttr(R.attr.color_mythic))); break; case 't': case 'T': textField.setTextColor( ContextCompat.getColor(context, getResourceIdFromAttr(R.attr.color_timeshifted))); break; } break; } case CardDbAdapter.KEY_RARITY: { char rarity = (char) cursor.getInt(cursor.getColumnIndex(CardDbAdapter.KEY_RARITY)); textField.setText("(" + rarity + ")"); hideRarity = false; break; } case CardDbAdapter.KEY_SUPERTYPE: { String name = CardDbAdapter.getTypeLine(cursor); hideType = false; textField.setText(name); break; } case CardDbAdapter.KEY_ABILITY: { String name = cursor.getString(cursor.getColumnIndex(mFrom[i])); hideAbility = false; CharSequence csq = ImageGetterHelper.formatStringWithGlyphs(name, mImgGetter); textField.setText(csq); break; } case CardDbAdapter.KEY_POWER: float p = cursor.getFloat(cursor.getColumnIndex(mFrom[i])); if (p != CardDbAdapter.NO_ONE_CARES) { String pow; hidePT = false; if (p == CardDbAdapter.STAR) pow = "*"; else if (p == CardDbAdapter.ONE_PLUS_STAR) pow = "1+*"; else if (p == CardDbAdapter.TWO_PLUS_STAR) pow = "2+*"; else if (p == CardDbAdapter.SEVEN_MINUS_STAR) pow = "7-*"; else if (p == CardDbAdapter.STAR_SQUARED) pow = "*^2"; else if (p == CardDbAdapter.X) pow = "X"; else { if (p == (int) p) { pow = Integer.valueOf((int) p).toString(); } else { pow = Float.valueOf(p).toString(); } } textField.setText(pow); } break; case CardDbAdapter.KEY_TOUGHNESS: float t = cursor.getFloat(cursor.getColumnIndex(mFrom[i])); if (t != CardDbAdapter.NO_ONE_CARES) { hidePT = false; String tou; if (t == CardDbAdapter.STAR) tou = "*"; else if (t == CardDbAdapter.ONE_PLUS_STAR) tou = "1+*"; else if (t == CardDbAdapter.TWO_PLUS_STAR) tou = "2+*"; else if (t == CardDbAdapter.SEVEN_MINUS_STAR) tou = "7-*"; else if (t == CardDbAdapter.STAR_SQUARED) tou = "*^2"; else if (t == CardDbAdapter.X) tou = "X"; else { if (t == (int) t) { tou = Integer.valueOf((int) t).toString(); } else { tou = Float.valueOf(t).toString(); } } textField.setText(tou); } break; case CardDbAdapter.KEY_LOYALTY: float l = cursor.getFloat(cursor.getColumnIndex(mFrom[i])); if (l != CardDbAdapter.NO_ONE_CARES) { hideLoyalty = false; if (l == CardDbAdapter.X) { ((TextView) textField.findViewById(R.id.cardt)).setText("X"); } else if (l == (int) l) { ((TextView) textField.findViewById(R.id.cardt)).setText(Integer.toString((int) l)); } else { ((TextView) textField.findViewById(R.id.cardt)).setText(Float.toString(l)); } } break; } } /* Hide the fields if they should be hidden (didn't exist in mTo)*/ if (hideCost) { view.findViewById(R.id.cardcost).setVisibility(View.GONE); } if (hideSet) { view.findViewById(R.id.cardset).setVisibility(View.GONE); } if (hideType) { view.findViewById(R.id.cardtype).setVisibility(View.GONE); } if (hideAbility) { view.findViewById(R.id.cardability).setVisibility(View.GONE); } if (!hideLoyalty) { view.findViewById(R.id.cardp).setVisibility(View.GONE); view.findViewById(R.id.cardslash).setVisibility(View.GONE); } else if (hidePT) { view.findViewById(R.id.cardp).setVisibility(View.GONE); view.findViewById(R.id.cardslash).setVisibility(View.GONE); view.findViewById(R.id.cardt).setVisibility(View.GONE); } if (hideRarity) { view.findViewById(R.id.rarity).setVisibility(View.GONE); } }
From source file:de.ingrid.iplug.sns.SNSIndexingInterface.java
private void getReferences() throws Exception, ParseException { // initialize Lists here ! So we can differ whether getReferences() already called ! fTopicIds = new ArrayList<String>(); fTemporal = new ArrayList<Temporal>(); fWgs84Box = new ArrayList<Wgs84Box>(); fLocationNames = new ArrayList<String>(); // NOTICE: the fTopicIds go into the "areaid" index field in the SE ! // so we first process locations and then the terms, see below. for (Location location : fLocations) { this.fTopicIds.add(location.getId()); this.fLocationNames.add(location.getName()); boolean wgs84BoxSet = false; final Wgs84Box wgs84Box = new Wgs84Box(location.getName(), 0, 0, 0, 0, ""); float[] bbox = location.getBoundingBox(); if (bbox != null) { // we want keep exactly same precision ! wgs84Box.setX1(Double.parseDouble(Float.toString(bbox[0]))); wgs84Box.setY1(Double.parseDouble(Float.toString(bbox[1]))); wgs84Box.setX2(Double.parseDouble(Float.toString(bbox[2]))); wgs84Box.setY2(Double.parseDouble(Float.toString(bbox[3]))); wgs84BoxSet = true;/*from ww w . j a v a 2 s . co m*/ } if (location.getNativeKey() != null) { String gemeindekennziffer = SNSUtil.transformSpacialReference(this.fGemeindeKennzifferPrefix, location.getNativeKey()); if (gemeindekennziffer.startsWith("lawa:")) { gemeindekennziffer = SNSUtil.transformSpacialReference("lawa:", location.getNativeKey()); } wgs84Box.setGemeindekennziffer(gemeindekennziffer); wgs84BoxSet = true; } if (wgs84BoxSet) { this.fWgs84Box.add(wgs84Box); } } // NOTICE: the fTopicIds go into the "areaid" index field in the SE ! // So why add the ids of the terms ? We move this one behind the locations // to guarantee locations first in index field (number of entries in index // field may be limited) for (Term term : fTerms) { this.fTopicIds.add(term.getId()); } for (Event event : fEvents) { // may be not set if NOT using SNS and event is just a time reference ! if (event.getId() != null && event.getId().length() > 0) { this.fTopicIds.add(event.getId()); } final Temporal temporal = new Temporal(); temporal.setAt(event.getTimeAt()); temporal.setFrom(event.getTimeRangeFrom()); temporal.setTo(event.getTimeRangeTo()); if (!temporal.isEmpty()) { this.fTemporal.add(temporal); } } }