List of usage examples for java.text NumberFormat getNumberInstance
public static final NumberFormat getNumberInstance()
From source file:com.edgenius.core.util.FileUtil.java
/** * Check whether file is executable according to its extenstion and executable extension name list from Edgenius configuaration. * @param filename//from w ww . j a v a 2 s. c om * @return */ // public static boolean isExecutableFile(String filename){ // String extname = FileUtil.getFileExtension(filename); // log.debug("Check executable file for extension name " + extname); // // if(StringUtils.isBlank(extname)) // return false; // extname = "." + extname; // // String exeListStr = Global.ExecuteFileExt; // String[] extList = StringUtils.split(exeListStr, ','); // boolean executable = false; // for (String ext : extList) { // if(StringUtils.equalsIgnoreCase(ext, extname)){ // executable = true; // break; // } // } // // return executable; // } public static String convertHumanSize(long byteSize) { String unit = ""; float size = (float) byteSize; if (size > 1024) { size = size / 1024; unit = "K"; } if (size > 1024) { size = size / 1024; unit = "M"; } if (size > 1024) { size = size / 1024; unit = "G"; } NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(1); String ret = format.format(size); return ret + unit; }
From source file:jgnash.ui.report.compiled.MonthlyAccountBalanceChart.java
private JFreeChart createVerticalXYBarChart(Account a) { DateFormat df = new SimpleDateFormat("MM/yy"); TimeSeriesCollection data = createTimeSeriesCollection(a); DateAxis dateAxis = new DateAxis(rb.getString("Column.Date")); dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, df)); dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); // if (a.getTransactionCount() > 0) { Date start = DateUtils.asDate(DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate())); Date end = DateUtils.asDate(DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate())); dateAxis.setRange(start, end);/*from w ww. ja va 2 s . c o m*/ // } NumberAxis valueAxis = new NumberAxis(rb.getString("Column.Balance")); StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance()); XYBarRenderer renderer = new XYBarRenderer(0.2); renderer.setBaseToolTipGenerator(tooltipGenerator); XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer); String title = rb.getString("Title.AccountBalance") + " - " + a.getPathName(); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(null); return chart; }
From source file:FormatterFactoryDemo.java
private void setUpFormats() { amountDisplayFormat = NumberFormat.getCurrencyInstance(); amountDisplayFormat.setMinimumFractionDigits(0); amountEditFormat = NumberFormat.getNumberInstance(); percentDisplayFormat = NumberFormat.getPercentInstance(); percentDisplayFormat.setMinimumFractionDigits(2); percentEditFormat = NumberFormat.getNumberInstance(); percentEditFormat.setMinimumFractionDigits(2); paymentFormat = NumberFormat.getCurrencyInstance(); }
From source file:massbank.BatchSearchWorker.java
/** * Ytt@C???ieLXg`?j// www . ja va 2 s . c om * @param resultFile t@C * @param textFile YtpeLXgt@C */ private void createTextFile(File resultFile, File textFile) { NumberFormat nf = NumberFormat.getNumberInstance(); LineNumberReader in = null; PrintWriter out = null; try { in = new LineNumberReader(new FileReader(resultFile)); out = new PrintWriter(new BufferedWriter(new FileWriter(textFile))); // wb_?[?o String reqIonStr = "Both"; try { if (Integer.parseInt(this.ion) > 0) { reqIonStr = "Positive"; } else if (Integer.parseInt(this.ion) < 0) { reqIonStr = "Negative"; } } catch (NumberFormatException nfe) { nfe.printStackTrace(); } out.println("***** MassBank Batch Service Results *****"); out.println(); out.println("Request Date: " + this.time); out.println("# Instrument Type: " + this.inst); out.println("# MS Type: " + this.ms); out.println("# Ion Mode: " + reqIonStr); out.println(); out.println(); // ?o String line; long queryCnt = 0; boolean readName = false; boolean readHit = false; boolean readNum = false; boolean isFinalLine = false; while ((line = in.readLine()) != null) { line = line.trim(); isFinalLine = false; if (!readName) { queryCnt++; out.println("### Query " + nf.format(queryCnt) + " ###"); out.println("# Name: " + line); readName = true; } else if (!readHit) { int num = Integer.parseInt(line); if (num == -1) { out.println("[ERROR] Invalid query\n"); break; } out.println("# Hit: " + nf.format(num)); out.println(); readHit = true; } else if (!readNum) { out.println("Top " + line + " List"); out.println("Accession\tTitle\tFormula\tMass\tScore\tHit"); out.println(); readNum = true; } else { if (!line.equals("")) { String[] data = formatLine(line); StringBuilder sb = new StringBuilder(); sb.append(data[0]).append("\t").append(data[1]).append("\t").append(data[2]).append("\t") .append(data[3]).append("\t").append(data[4]).append("\t").append(data[5]); out.println(sb.toString()); } else { out.println(); out.println(); readName = false; readHit = false; readNum = false; isFinalLine = true; } } } if (!isFinalLine) { out.println(); out.println(); } out.println("***** END ********************************"); out.println(); } catch (Exception e) { e.printStackTrace(); } finally { try { if (in != null) { in.close(); } } catch (IOException e) { } if (out != null) { out.flush(); out.close(); } } }
From source file:edu.mit.fss.examples.gui.ExecutionControlPanel.java
/** * Instantiates a new execution control panel. *///from w w w . ja v a2 s .co m public ExecutionControlPanel() { initializeAction.putValue(Action.SHORT_DESCRIPTION, "Initialize the execution."); initializeAction.setEnabled(false); runAction.putValue(Action.SHORT_DESCRIPTION, "Run the execution."); runAction.setEnabled(false); stopAction.putValue(Action.SHORT_DESCRIPTION, "Stop the execution."); stopAction.setEnabled(false); terminateAction.putValue(Action.SHORT_DESCRIPTION, "Terminate the execution."); terminateAction.setEnabled(false); setLayout(new BorderLayout()); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); buttonPanel.add(new JButton(initializeAction)); buttonPanel.add(new JButton(runAction)); buttonPanel.add(new JButton(stopAction)); buttonPanel.add(new JButton(terminateAction)); timeStepField = new JFormattedTextField(NumberFormat.getNumberInstance()); timeStepField.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { checkUpdate(); } private void checkUpdate() { long unitConversion = getTimeStepUnits(); long timeStep = FastMath.round(unitConversion * ((Number) timeStepField.getValue()).doubleValue()); setTimeStepAction.setEnabled(timeStep != federate.getTimeStep()); } @Override public void insertUpdate(DocumentEvent e) { checkUpdate(); } @Override public void removeUpdate(DocumentEvent e) { checkUpdate(); } }); timeStepField.setColumns(4); buttonPanel.add(new JLabel("Time Step: ")); buttonPanel.add(timeStepField); timeStepUnits.setSelectedItem(TimeUnit.SECONDS); buttonPanel.add(timeStepUnits); timeStepUnits.addActionListener(new ActionListener() { private long lastUnitConversion = getTimeStepUnits(); @Override public void actionPerformed(ActionEvent e) { long unitConversion = getTimeStepUnits(); // update field value using new units timeStepField.setValue(((Double) timeStepField.getValue()) * lastUnitConversion / unitConversion); // update stored value lastUnitConversion = unitConversion; } }); buttonPanel.add(new JButton(setTimeStepAction)); buttonPanel.add(new JLabel("Min. Step Duration")); stepDurationField = new JFormattedTextField(NumberFormat.getNumberInstance()); stepDurationField.setColumns(4); stepDurationField.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { checkUpdate(); } private void checkUpdate() { long unitConversion = getStepDurationUnits(); long minStepDuration = FastMath .round(unitConversion * ((Number) stepDurationField.getValue()).doubleValue()); setMinStepDurationAction.setEnabled(minStepDuration != federate.getMinimumStepDuration()); } @Override public void insertUpdate(DocumentEvent e) { checkUpdate(); } @Override public void removeUpdate(DocumentEvent e) { checkUpdate(); } }); buttonPanel.add(stepDurationField); stepDurationUnits.setSelectedItem(TimeUnit.MILLISECONDS); buttonPanel.add(stepDurationUnits); stepDurationUnits.addActionListener(new ActionListener() { private long lastUnitConversion = getStepDurationUnits(); @Override public void actionPerformed(ActionEvent e) { long unitConversion = getStepDurationUnits(); // update field value using new units stepDurationField .setValue(((Double) stepDurationField.getValue()) * lastUnitConversion / unitConversion); // update stored value lastUnitConversion = unitConversion; } }); buttonPanel.add(new JButton(setMinStepDurationAction)); add(buttonPanel, BorderLayout.CENTER); }
From source file:org.angnysa.yaba.swing.BudgetFrame.java
private void buildSimulationPanel() { simulationPanel = new JPanel(); SpringLayout springLayout = new SpringLayout(); simulationPanel.setLayout(springLayout); // chart data simulationDataset = new SimulationDataset(service); simulationDataset.setInitial(0D);/*www. j a va 2 s . c om*/ simulationDataset.setStart(new LocalDate()); simulationDataset.setEnd(new LocalDate().plus(Years.ONE)); simulationDataset.setPeriod(Period.months(1)); simulationDataset.updateDataset(); transactionModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { simulationDataset.updateDataset(); } }); reconciliationModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { simulationDataset.updateDataset(); } }); // initial amount label JLabel amountLbl = new JLabel(Messages.getString("simulation.field.initial-amount")); //$NON-NLS-1$ springLayout.putConstraint(SpringLayout.WEST, amountLbl, 10, SpringLayout.WEST, simulationPanel); simulationPanel.add(amountLbl); // initial amount field amountFld = new JFormattedTextField( new DefaultFormatterFactory(new NumberFormatter(NumberFormat.getNumberInstance()), new NumberFormatter(NumberFormat.getCurrencyInstance()))); amountFld.setColumns(8); amountFld.setValue(simulationDataset.getInitial()); amountFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$ @Override public void propertyChange(PropertyChangeEvent e) { simulationDataset.setInitial(((Number) amountFld.getValue()).doubleValue()); simulationDataset.updateDataset(); } }); springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, amountLbl, 0, SpringLayout.VERTICAL_CENTER, amountFld); springLayout.putConstraint(SpringLayout.WEST, amountFld, 0, SpringLayout.EAST, amountLbl); springLayout.putConstraint(SpringLayout.NORTH, amountFld, 10, SpringLayout.NORTH, simulationPanel); simulationPanel.add(amountFld); // start date label JLabel fromLbl = new JLabel(Messages.getString("simulation.field.start-date")); //$NON-NLS-1$ springLayout.putConstraint(SpringLayout.WEST, fromLbl, 10, SpringLayout.EAST, amountFld); simulationPanel.add(fromLbl); // start date field fromFld = new JFormattedTextField(new JodaLocalDateFormat()); fromFld.setColumns(8); fromFld.setValue(simulationDataset.getStart()); fromFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$ @Override public void propertyChange(PropertyChangeEvent e) { simulationDataset.setStart((LocalDate) fromFld.getValue()); simulationDataset.updateDataset(); } }); springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, fromLbl, 0, SpringLayout.VERTICAL_CENTER, fromFld); springLayout.putConstraint(SpringLayout.WEST, fromFld, 0, SpringLayout.EAST, fromLbl); springLayout.putConstraint(SpringLayout.NORTH, fromFld, 10, SpringLayout.NORTH, simulationPanel); simulationPanel.add(fromFld); // end date label JLabel toLbl = new JLabel(Messages.getString("simulation.field.end-date")); //$NON-NLS-1$ springLayout.putConstraint(SpringLayout.WEST, toLbl, 10, SpringLayout.EAST, fromFld); simulationPanel.add(toLbl); // end date field toFld = new JFormattedTextField(new JodaLocalDateFormat()); toFld.setColumns(8); toFld.setValue(simulationDataset.getEnd()); toFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$ @Override public void propertyChange(PropertyChangeEvent e) { simulationDataset.setEnd((LocalDate) toFld.getValue()); simulationDataset.updateDataset(); } }); springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, toLbl, 0, SpringLayout.VERTICAL_CENTER, toFld); springLayout.putConstraint(SpringLayout.WEST, toFld, 0, SpringLayout.EAST, toLbl); springLayout.putConstraint(SpringLayout.NORTH, toFld, 10, SpringLayout.NORTH, simulationPanel); simulationPanel.add(toFld); // period label JLabel periodLbl = new JLabel(Messages.getString("simulation.field.period")); //$NON-NLS-1$ springLayout.putConstraint(SpringLayout.WEST, periodLbl, 10, SpringLayout.EAST, toFld); simulationPanel.add(periodLbl); // period field periodFld = new JFormattedTextField(new JodaPeriodFormat()); periodFld.setColumns(5); periodFld.setValue(simulationDataset.getPeriod()); periodFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$ @Override public void propertyChange(PropertyChangeEvent e) { simulationDataset.setPeriod((ReadablePeriod) periodFld.getValue()); simulationDataset.updateDataset(); } }); springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, periodLbl, 0, SpringLayout.VERTICAL_CENTER, periodFld); springLayout.putConstraint(SpringLayout.WEST, periodFld, 0, SpringLayout.EAST, periodLbl); springLayout.putConstraint(SpringLayout.NORTH, periodFld, 10, SpringLayout.NORTH, simulationPanel); simulationPanel.add(periodFld); // chart panel JFreeChart chart = ChartFactory.createLineChart("", Messages.getString("simulation.chart.date-axis-label"), //$NON-NLS-1$//$NON-NLS-2$ Messages.getString("simulation.chart.amount-axis-label"), simulationDataset, //$NON-NLS-1$ PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesFilled(true); renderer.setBaseShapesVisible(true); renderer.setBaseToolTipGenerator(new SimulationTooltipGenerator(service)); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setDismissDelay(3600000); chartPanel.setInitialDelay(0); springLayout.putConstraint(SpringLayout.NORTH, chartPanel, 15, SpringLayout.SOUTH, periodFld); springLayout.putConstraint(SpringLayout.WEST, chartPanel, 10, SpringLayout.WEST, simulationPanel); springLayout.putConstraint(SpringLayout.SOUTH, chartPanel, -10, SpringLayout.SOUTH, simulationPanel); springLayout.putConstraint(SpringLayout.EAST, chartPanel, -10, SpringLayout.EAST, simulationPanel); simulationPanel.add(chartPanel); }
From source file:jgnash.ui.report.compiled.MonthlyAccountBalanceChartCompare.java
private JFreeChart createVerticalXYBarChart(final Account a, final Account a2) { DateFormat df = new SimpleDateFormat("MM/yy"); TimeSeriesCollection data = createTimeSeriesCollection(a, a2); DateAxis dateAxis = new DateAxis(rb.getString("Column.Date")); dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, df)); dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); // if (a.getTransactionCount() > 0) { Date start = DateUtils.asDate(DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate())); Date end = DateUtils.asDate(DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate())); dateAxis.setRange(start, end);// ww w. ja v a 2 s.c om // } NumberAxis valueAxis = new NumberAxis( rb.getString("Column.Balance") + "-" + a.getCurrencyNode().getSymbol()); StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance()); ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer(0.2, false); renderer.setBaseToolTipGenerator(tooltipGenerator); XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer); String title; if (jcb_compare.isSelected()) { title = a.getPathName() + " vs " + a2.getPathName(); } else { title = rb.getString("Title.AccountBalance") + " - " + a.getPathName(); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(null); return chart; }
From source file:ubic.gemma.core.analysis.preprocess.filter.RowLevelFilter.java
private void logInfo(int numRows, List<CompositeSequence> kept) { if (kept.size() == 0) { RowLevelFilter.log.warn("All rows filtered out!"); return;//from w ww . j a va 2s .c o m } if (RowLevelFilter.log.isDebugEnabled()) { NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(2); double fracFiltered = (double) (numRows - kept.size()) / numRows; RowLevelFilter.log.debug( "There are " + kept.size() + " rows left after " + this.method + " filtering. Filtered out " + (numRows - kept.size()) + " rows " + nf.format(100 * fracFiltered) + "%"); } }
From source file:com.nadmm.airports.wx.MetarFragment.java
protected void showMetar(Intent intent) { if (getActivity() == null) { // Not ready to do this yet return;/*from www . ja v a 2s . com*/ } Metar metar = (Metar) intent.getSerializableExtra(NoaaService.RESULT); if (metar == null) { return; } View detail = findViewById(R.id.wx_detail_layout); LinearLayout layout = (LinearLayout) findViewById(R.id.wx_status_layout); layout.removeAllViews(); TextView tv = (TextView) findViewById(R.id.status_msg); if (!metar.isValid) { tv.setVisibility(View.VISIBLE); layout.setVisibility(View.VISIBLE); tv.setText("Unable to get METAR for this location"); addRow(layout, "This could be due to the following reasons:"); addBulletedRow(layout, "Network connection is not available"); addBulletedRow(layout, "ADDS does not publish METAR for this station"); addBulletedRow(layout, "Station is currently out of service"); addBulletedRow(layout, "Station has not updated the METAR for more than 3 hours"); detail.setVisibility(View.GONE); stopRefreshAnimation(); setFragmentContentShown(true); return; } else { tv.setText(""); tv.setVisibility(View.GONE); layout.setVisibility(View.GONE); detail.setVisibility(View.VISIBLE); } tv = (TextView) findViewById(R.id.wx_station_info2); WxUtils.setFlightCategoryDrawable(tv, metar.flightCategory); tv = (TextView) findViewById(R.id.wx_age); tv.setText(TimeUtils.formatElapsedTime(metar.observationTime)); // Raw Text tv = (TextView) findViewById(R.id.wx_raw_metar); tv.setText(metar.rawText); // Winds tv = (TextView) findViewById(R.id.wx_wind_label); layout = (LinearLayout) findViewById(R.id.wx_wind_layout); layout.removeAllViews(); int visibility = View.GONE; if (metar.windSpeedKnots < Integer.MAX_VALUE) { showWindInfo(layout, metar); visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Visibility tv = (TextView) findViewById(R.id.wx_vis_label); layout = (LinearLayout) findViewById(R.id.wx_vis_layout); layout.removeAllViews(); visibility = View.GONE; if (metar.visibilitySM < Float.MAX_VALUE) { if (metar.flags.contains(Flags.AutoReport) && metar.visibilitySM == 10) { addRow(layout, "10+ statute miles horizontal"); } else { NumberFormat decimal2 = NumberFormat.getNumberInstance(); decimal2.setMaximumFractionDigits(2); decimal2.setMinimumFractionDigits(0); addRow(layout, String.format("%s statute miles horizontal", FormatUtils.formatNumber(metar.visibilitySM))); } if (metar.vertVisibilityFeet < Integer.MAX_VALUE) { addRow(layout, String.format("%s vertical", FormatUtils.formatFeetAgl(metar.vertVisibilityFeet))); } visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Weather layout = (LinearLayout) findViewById(R.id.wx_weather_layout); layout.removeAllViews(); for (WxSymbol wx : metar.wxList) { addWeatherRow(layout, wx, metar.flightCategory); } // Sky Conditions tv = (TextView) findViewById(R.id.wx_sky_cond_label); layout = (LinearLayout) findViewById(R.id.wx_sky_cond_layout); layout.removeAllViews(); visibility = View.GONE; if (!metar.skyConditions.isEmpty()) { for (SkyCondition sky : metar.skyConditions) { addSkyConditionRow(layout, sky, metar.flightCategory); } visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Temperature tv = (TextView) findViewById(R.id.wx_temp_label); layout = (LinearLayout) findViewById(R.id.wx_temp_layout); layout.removeAllViews(); visibility = View.GONE; if (metar.tempCelsius < Float.MAX_VALUE && metar.dewpointCelsius < Float.MAX_VALUE) { addRow(layout, "Temperature", FormatUtils.formatTemperature(metar.tempCelsius)); if (metar.dewpointCelsius < Float.MAX_VALUE) { addRow(layout, "Dew point", FormatUtils.formatTemperature(metar.dewpointCelsius)); addRow(layout, "Relative humidity", String.format("%.0f%%", WxUtils.getRelativeHumidity(metar))); long denAlt = WxUtils.getDensityAltitude(metar); if (denAlt > mElevation) { addRow(layout, "Density altitude", FormatUtils.formatFeet(denAlt)); } } else { addRow(layout, "Dew point", "n/a"); } if (metar.maxTemp6HrCentigrade < Float.MAX_VALUE) { addRow(layout, "6-hour maximum", FormatUtils.formatTemperature(metar.maxTemp6HrCentigrade)); } if (metar.minTemp6HrCentigrade < Float.MAX_VALUE) { addRow(layout, "6-hour minimum", FormatUtils.formatTemperature(metar.minTemp6HrCentigrade)); } if (metar.maxTemp24HrCentigrade < Float.MAX_VALUE) { addRow(layout, "24-hour maximum", FormatUtils.formatTemperature(metar.maxTemp24HrCentigrade)); } if (metar.minTemp24HrCentigrade < Float.MAX_VALUE) { addRow(layout, "24-hour minimum", FormatUtils.formatTemperature(metar.minTemp24HrCentigrade)); } visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Pressure tv = (TextView) findViewById(R.id.wx_pressure_label); layout = (LinearLayout) findViewById(R.id.wx_pressure_layout); layout.removeAllViews(); visibility = View.GONE; if (metar.altimeterHg < Float.MAX_VALUE) { addRow(layout, "Altimeter", FormatUtils.formatAltimeter(metar.altimeterHg)); if (metar.seaLevelPressureMb < Float.MAX_VALUE) { addRow(layout, "Sea level pressure", String.format("%s mb", FormatUtils.formatNumber(metar.seaLevelPressureMb))); } long presAlt = WxUtils.getPressureAltitude(metar); if (presAlt > mElevation) { addRow(layout, "Pressure altitude", FormatUtils.formatFeet(presAlt)); } if (metar.pressureTend3HrMb < Float.MAX_VALUE) { addRow(layout, "3-hour tendency", String.format("%+.2f mb", metar.pressureTend3HrMb)); } if (metar.presfr) { addRow(layout, "Pressure falling rapidly"); } if (metar.presrr) { addRow(layout, "Pressure rising rapidly"); } visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Precipitation tv = (TextView) findViewById(R.id.wx_precip_label); layout = (LinearLayout) findViewById(R.id.wx_precip_layout); layout.removeAllViews(); if (metar.precipInches < Float.MAX_VALUE) { addRow(layout, "1-hour precipitation", String.format("%.2f\"", metar.precipInches)); } if (metar.precip3HrInches < Float.MAX_VALUE) { addRow(layout, "3-hour precipitation", String.format("%.2f\"", metar.precip3HrInches)); } if (metar.precip6HrInches < Float.MAX_VALUE) { addRow(layout, "6-hour precipitation", String.format("%.2f\"", metar.precip6HrInches)); } if (metar.precip24HrInches < Float.MAX_VALUE) { addRow(layout, "24-hour precipitation", String.format("%.2f\"", metar.precip24HrInches)); } if (metar.snowInches < Float.MAX_VALUE) { addRow(layout, "Snow depth", String.format("%.0f\"", metar.snowInches)); } if (metar.snincr) { addRow(layout, "Snow is increasing rapidly"); } visibility = layout.getChildCount() > 0 ? View.VISIBLE : View.GONE; tv.setVisibility(visibility); layout.setVisibility(visibility); // Remarks tv = (TextView) findViewById(R.id.wx_remarks_label); layout = (LinearLayout) findViewById(R.id.wx_remarks_layout); layout.removeAllViews(); for (Flags flag : metar.flags) { addBulletedRow(layout, flag.toString()); } for (String remark : mRemarks) { addBulletedRow(layout, remark); } visibility = layout.getChildCount() > 0 ? View.VISIBLE : View.GONE; tv.setVisibility(visibility); layout.setVisibility(visibility); // Fetch time tv = (TextView) findViewById(R.id.wx_fetch_time); tv.setText("Fetched on " + TimeUtils.formatDateTime(getActivity(), metar.fetchTime)); tv.setVisibility(View.VISIBLE); stopRefreshAnimation(); setFragmentContentShown(true); }
From source file:ubic.gemma.analysis.preprocess.filter.RowLevelFilter.java
/** * @param numRows/*w ww . j av a2s. c om*/ * @param kept */ private void logInfo(int numRows, List<CompositeSequence> kept) { if (kept.size() == 0) { log.warn("All rows filtered out!"); return; } NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(2); double fracFiltered = (double) (numRows - kept.size()) / numRows; log.info("There are " + kept.size() + " rows left after " + this.method + " filtering. Filtered out " + (numRows - kept.size()) + " rows " + nf.format(100 * fracFiltered) + "%"); }