List of usage examples for java.text NumberFormat setMinimumFractionDigits
public void setMinimumFractionDigits(int newValue)
From source file:au.org.theark.lims.web.component.biospecimen.batchcreate.form.ManualBatchCreateBiospecimenForm.java
/** * /*ww w.j a va 2 s.com*/ * @return the listEditor of BatchBiospecimen(s) */ public AbstractListEditor<BatchBiospecimenVO> buildListEditor() { listEditor = new AbstractListEditor<BatchBiospecimenVO>("batchBiospecimenList", new PropertyModel(this, "batchBiospecimenList")) { private static final long serialVersionUID = 1L; @SuppressWarnings("serial") @Override protected void onPopulateItem(final ListItem<BatchBiospecimenVO> item) { item.setOutputMarkupId(true); item.getModelObject().getBiospecimen() .setLinkSubjectStudy(cpModel.getObject().getLinkSubjectStudy()); item.getModelObject().getBiospecimen() .setStudy(cpModel.getObject().getLinkSubjectStudy().getStudy()); biospecimenUidTxtFld = new TextField<String>("biospecimen.biospecimenUid", new PropertyModel(item.getModelObject(), "biospecimen.biospecimenUid")); initBioCollectionDdc(item); initSampleTypeDdc(item); sampleDateTxtFld = new DateTextField("biospecimen.sampleDate", new PropertyModel(item.getModelObject(), "biospecimen.sampleDate"), au.org.theark.core.Constants.DD_MM_YYYY); ArkDatePicker sampleDatePicker = new ArkDatePicker(); sampleDatePicker.bind(sampleDateTxtFld); sampleDateTxtFld.add(sampleDatePicker); quantityTxtFld = new TextField<Double>("biospecimen.quantity", new PropertyModel(item.getModelObject(), "biospecimen.quantity")) { private static final long serialVersionUID = 1L; @Override public <C> IConverter<C> getConverter(Class<C> type) { DoubleConverter doubleConverter = new DoubleConverter(); NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumFractionDigits(1); doubleConverter.setNumberFormat(getLocale(), numberFormat); return (IConverter<C>) doubleConverter; } }; initUnitDdc(item); initTreatmentTypeDdc(item); concentrationTxtFld = new TextField<Number>("biospecimen.concentration", new PropertyModel(item.getModelObject(), "biospecimen.concentration")); // Added onchange events to ensure model updated when any change made item.add(biospecimenUidTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { // Check BiospecimenUID is unique String biospecimenUid = (getComponent().getDefaultModelObject().toString() != null ? getComponent().getDefaultModelObject().toString() : new String()); Biospecimen biospecimen = iLimsService.getBiospecimenByUid(biospecimenUid, item.getModelObject().getBiospecimen().getStudy()); if (biospecimen != null && biospecimen.getId() != null) { ManualBatchCreateBiospecimenForm.this .error("Biospecimen UID must be unique. Please try again."); target.focusComponent(getComponent()); } target.add(feedbackPanel); } })); item.add(bioCollectionDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { } })); item.add(sampleTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { } })); item.add(sampleDateTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { } })); item.add(quantityTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { } })); item.add(unitDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { } })); item.add(treatmentTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { } })); item.add(concentrationTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { } })); // Copy button allows entire row details to be copied item.add(new AjaxEditorButton(Constants.COPY) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { BatchBiospecimenVO batchBiospecimenVo = new BatchBiospecimenVO(); try { PropertyUtils.copyProperties(batchBiospecimenVo.getBiospecimen(), item.getModelObject().getBiospecimen()); batchBiospecimenVo.getBiospecimen().setBiospecimenUid(new String()); listEditor.addItem(batchBiospecimenVo); target.add(form); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } }.setDefaultFormProcessing(false)); item.add(new AjaxEditorButton(Constants.DELETE) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { listEditor.removeItem(item); target.add(form); } }.setDefaultFormProcessing(false).setVisible(item.getIndex() > 0)); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return listEditor; }
From source file:au.org.theark.lims.web.component.biospecimen.batchaliquot.form.BatchAliquotBiospecimenForm.java
/** * // w w w . j a v a2s . com * @return the listEditor of Biospecimens to aliquot */ public AbstractListEditor<Biospecimen> buildListEditor() { listEditor = new AbstractListEditor<Biospecimen>("aliquots", new PropertyModel(getModelObject(), "aliquots")) { private static final long serialVersionUID = 1L; @SuppressWarnings("serial") @Override protected void onPopulateItem(final ListItem<Biospecimen> item) { item.setOutputMarkupId(true); Biospecimen parentBiospecimen = BatchAliquotBiospecimenForm.this.getModelObject() .getParentBiospecimen(); try { PropertyUtils.copyProperties(item.getModelObject(), parentBiospecimen); } catch (IllegalAccessException e1) { log.error(e1.getMessage()); } catch (InvocationTargetException e1) { log.error(e1.getMessage()); } catch (NoSuchMethodException e1) { log.error(e1.getMessage()); } if (copyBiospecimen) { item.getModelObject().setParent(parentBiospecimen); item.getModelObject().setParentUid(parentBiospecimen.getBiospecimenUid()); item.getModelObject().setQuantity(biospecimenToCopy.getQuantity()); item.getModelObject().setTreatmentType(biospecimenToCopy.getTreatmentType()); item.getModelObject().setConcentration(biospecimenToCopy.getConcentration()); } else { item.getModelObject().setParent(parentBiospecimen); item.getModelObject().setParentUid(parentBiospecimen.getBiospecimenUid()); item.getModelObject().setQuantity(null); item.getModelObject().setConcentration(null); } biospecimenUidTxtFld = new TextField<String>("biospecimenUid", new PropertyModel(item.getModelObject(), "biospecimenUid")); if (parentBiospecimen.getStudy().getAutoGenerateBiospecimenUid()) { biospecimenUidTxtFld.setEnabled(false); biospecimenUidTxtFld.setModelObject(Constants.AUTO_GENERATED); } else { biospecimenUidTxtFld.setEnabled(true); biospecimenUidTxtFld.setModelObject(null); } quantityTxtFld = new TextField<Double>("quantity", new PropertyModel(item.getModelObject(), "quantity")) { private static final long serialVersionUID = 1L; @Override public <C> IConverter<C> getConverter(Class<C> type) { DoubleConverter doubleConverter = new DoubleConverter(); NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumFractionDigits(1); doubleConverter.setNumberFormat(getLocale(), numberFormat); return (IConverter<C>) doubleConverter; } }; initTreatmentTypeDdc(item); concentrationTxtFld = new TextField<Number>("concentration", new PropertyModel(item.getModelObject(), "concentration")); item.add(biospecimenUidTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { if (!item.getModelObject().getStudy().getAutoGenerateBiospecimenUid()) { // Check BiospecimenUID is unique String biospecimenUid = (getComponent().getDefaultModelObject().toString() != null ? getComponent().getDefaultModelObject().toString() : new String()); Biospecimen biospecimen = iLimsService.getBiospecimenByUid(biospecimenUid, item.getModelObject().getStudy()); if (biospecimen != null && biospecimen.getId() != null) { error("Biospecimen UID must be unique. Please try again."); target.focusComponent(getComponent()); } } target.add(feedbackPanel); biospecimenToCopy.setBiospecimenUid(getComponent().getDefaultModelObject().toString()); } })); item.add(quantityTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { if (!totalQuantityLessThanParentQuantity()) { target.focusComponent(getComponent()); } target.add(feedbackPanel); biospecimenToCopy.setQuantity((Double) getComponent().getDefaultModelObject()); item.getModelObject().setQuantity((Double) getComponent().getDefaultModelObject()); } @Override protected void onError(AjaxRequestTarget target, RuntimeException e) { target.add(feedbackPanel); } })); item.add(treatmentTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { biospecimenToCopy.setTreatmentType((TreatmentType) getComponent().getDefaultModelObject()); item.getModelObject() .setTreatmentType((TreatmentType) getComponent().getDefaultModelObject()); } })); item.add(concentrationTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { biospecimenToCopy.setConcentration((Double) getComponent().getDefaultModelObject()); item.getModelObject().setConcentration((Double) getComponent().getDefaultModelObject()); } })); // Copy button allows entire row details to be copied item.add(new AjaxEditorButton(Constants.COPY) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Biospecimen biospecimen = new Biospecimen(); copyBiospecimen = true; try { PropertyUtils.copyProperties(biospecimen, getItem().getModelObject()); PropertyUtils.copyProperties(biospecimenToCopy, getItem().getModelObject()); listEditor.addItem(biospecimen); target.add(form); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } }.setDefaultFormProcessing(false)); item.add(new AjaxEditorButton(Constants.DELETE) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { listEditor.removeItem(item); target.add(form); } }.setDefaultFormProcessing(false).setVisible(item.getIndex() > 0)); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return listEditor; }
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 .j ava2 s. c o m } 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:org.apache.cocoon.template.instruction.FormatNumber.java
private void configureFormatter(NumberFormat formatter, Boolean isGroupingUsed, Number maxIntegerDigits, Number minIntegerDigits, Number maxFractionDigits, Number minFractionDigits) { if (isGroupingUsed != null) formatter.setGroupingUsed(isGroupingUsed.booleanValue()); if (maxIntegerDigits != null) formatter.setMaximumIntegerDigits(maxIntegerDigits.intValue()); if (minIntegerDigits != null) formatter.setMinimumIntegerDigits(minIntegerDigits.intValue()); if (maxFractionDigits != null) formatter.setMaximumFractionDigits(maxFractionDigits.intValue()); if (minFractionDigits != null) formatter.setMinimumFractionDigits(minFractionDigits.intValue()); }
From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java
/** * Generates a generic Time Bar Chart.//from ww w. j a v a 2s.co m * * @param title the title of the Chart. * @param valueLabel the X Axis Label. * @param data the data to populate with. * @return the generated Chart. */ private JFreeChart createTimeBarChart(String title, String color, String valueLabel, XYDataset data) { PlotOrientation orientation = PlotOrientation.VERTICAL; DateAxis xAxis = generateTimeAxis(); NumberAxis yAxis = new NumberAxis(valueLabel); NumberFormat formatter = NumberFormat.getNumberInstance(JiveGlobals.getLocale()); formatter.setMaximumFractionDigits(2); formatter.setMinimumFractionDigits(0); yAxis.setNumberFormatOverride(formatter); yAxis.setAutoRangeIncludesZero(true); return createChart(title, data, xAxis, yAxis, orientation, new XYBarRenderer(), GraphDefinition.getDefinition(color)); }
From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java
/** * Generates a generic Time Area Chart.//from w ww .ja v a 2 s . c o m * * @param title the title of the Chart. * @param valueLabel the Y Axis label. * @param data the data to populate with. * @return the generated Chart. */ private JFreeChart createTimeAreaChart(String title, String color, String valueLabel, XYDataset data) { PlotOrientation orientation = PlotOrientation.VERTICAL; DateAxis xAxis = generateTimeAxis(); NumberAxis yAxis = new NumberAxis(valueLabel); NumberFormat formatter = NumberFormat.getNumberInstance(JiveGlobals.getLocale()); formatter.setMaximumFractionDigits(2); formatter.setMinimumFractionDigits(0); yAxis.setNumberFormatOverride(formatter); XYAreaRenderer renderer = new XYAreaRenderer(XYAreaRenderer.AREA); renderer.setOutline(true); return createChart(title, data, xAxis, yAxis, orientation, renderer, GraphDefinition.getDefinition(color)); }
From source file:com.vgi.mafscaling.Rescale.java
private void createControlPanel(JPanel dataPanel) { JPanel cntlPanel = new JPanel(); GridBagConstraints gbl_ctrlPanel = new GridBagConstraints(); gbl_ctrlPanel.insets = insets3;/*from ww w. j ava 2s.c o m*/ gbl_ctrlPanel.anchor = GridBagConstraints.PAGE_START; gbl_ctrlPanel.fill = GridBagConstraints.HORIZONTAL; gbl_ctrlPanel.weightx = 1.0; gbl_ctrlPanel.gridx = 0; gbl_ctrlPanel.gridy = 0; dataPanel.add(cntlPanel, gbl_ctrlPanel); GridBagLayout gbl_cntlPanel = new GridBagLayout(); gbl_cntlPanel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; gbl_cntlPanel.rowHeights = new int[] { 0, 0 }; gbl_cntlPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; gbl_cntlPanel.rowWeights = new double[] { 0 }; cntlPanel.setLayout(gbl_cntlPanel); NumberFormat doubleFmt = NumberFormat.getNumberInstance(); doubleFmt.setGroupingUsed(false); doubleFmt.setMaximumIntegerDigits(1); doubleFmt.setMinimumIntegerDigits(1); doubleFmt.setMaximumFractionDigits(3); doubleFmt.setMinimumFractionDigits(1); doubleFmt.setRoundingMode(RoundingMode.HALF_UP); NumberFormat scaleDoubleFmt = NumberFormat.getNumberInstance(); scaleDoubleFmt.setGroupingUsed(false); scaleDoubleFmt.setMaximumIntegerDigits(1); scaleDoubleFmt.setMinimumIntegerDigits(1); scaleDoubleFmt.setMaximumFractionDigits(8); scaleDoubleFmt.setMinimumFractionDigits(1); scaleDoubleFmt.setRoundingMode(RoundingMode.HALF_UP); GridBagConstraints gbc_cntlPanelLabel = new GridBagConstraints(); gbc_cntlPanelLabel.anchor = GridBagConstraints.EAST; gbc_cntlPanelLabel.insets = new Insets(2, 3, 2, 1); gbc_cntlPanelLabel.gridx = 0; gbc_cntlPanelLabel.gridy = 0; GridBagConstraints gbc_cntlPanelInput = new GridBagConstraints(); gbc_cntlPanelInput.anchor = GridBagConstraints.WEST; gbc_cntlPanelInput.insets = new Insets(2, 1, 2, 3); gbc_cntlPanelInput.gridx = 1; gbc_cntlPanelInput.gridy = 0; cntlPanel.add(new JLabel("New Max V"), gbc_cntlPanelLabel); newMaxVFmtTextBox = new JFormattedTextField(doubleFmt); newMaxVFmtTextBox.setColumns(7); newMaxVFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Object source = e.getSource(); if (source == newMaxVFmtTextBox) updateNewMafScale(); } }); cntlPanel.add(newMaxVFmtTextBox, gbc_cntlPanelInput); gbc_cntlPanelLabel.gridx += 2; cntlPanel.add(new JLabel("Min V"), gbc_cntlPanelLabel); minVFmtTextBox = new JFormattedTextField(doubleFmt); minVFmtTextBox.setColumns(7); minVFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Object source = e.getSource(); if (source == minVFmtTextBox) updateNewMafScale(); } }); gbc_cntlPanelInput.gridx += 2; cntlPanel.add(minVFmtTextBox, gbc_cntlPanelInput); gbc_cntlPanelLabel.gridx += 2; cntlPanel.add(new JLabel("Max Unchanged"), gbc_cntlPanelLabel); maxVUnchangedFmtTextBox = new JFormattedTextField(doubleFmt); maxVUnchangedFmtTextBox.setColumns(7); maxVUnchangedFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { Object source = e.getSource(); if (source == maxVUnchangedFmtTextBox) updateNewMafScale(); } }); gbc_cntlPanelInput.gridx += 2; cntlPanel.add(maxVUnchangedFmtTextBox, gbc_cntlPanelInput); gbc_cntlPanelLabel.gridx += 2; cntlPanel.add(new JLabel("Mode deltaV"), gbc_cntlPanelLabel); modeDeltaVFmtTextBox = new JFormattedTextField(scaleDoubleFmt); modeDeltaVFmtTextBox.setColumns(7); modeDeltaVFmtTextBox.setEditable(false); modeDeltaVFmtTextBox.setBackground(new Color(210, 210, 210)); gbc_cntlPanelInput.gridx += 2; cntlPanel.add(modeDeltaVFmtTextBox, gbc_cntlPanelInput); }
From source file:com.saiton.ccs.validations.FormatAndValidate.java
public String FormatDecimal(Float d) { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2);/*from w w w. j a v a 2 s.c o m*/ nf.setMinimumFractionDigits(2); return nf.format(d); }
From source file:com.saiton.ccs.validations.FormatAndValidate.java
public String FormatDecimal(double d) { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2);/*ww w . j av a2 s . c o m*/ nf.setMinimumFractionDigits(2); return nf.format(d); }
From source file:de.tor.tribes.ui.views.DSWorkbenchSOSRequestAnalyzer.java
private String buildSimpleRequestTable(Village pTarget, TroopAmountFixed pNeed, DefenseInformation pDefense) { StringBuilder b = new StringBuilder(); SimpleDateFormat df = new SimpleDateFormat("dd.MM.yy HH:mm:ss"); b.append("[table]\n"); b.append("[**]").append(pTarget.toBBCode()); int colCount = 0; for (UnitHolder unit : DataHolder.getSingleton().getUnits()) { int value = pNeed.getAmountForUnit(unit); if (value > 0) { b.append("[|]").append("[unit]").append(unit.getPlainName()).append("[/unit]"); colCount++;/* w ww . j ava2 s . c o m*/ } } b.append("[/**]\n"); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(0); nf.setMaximumFractionDigits(0); b.append("[*]"); for (UnitHolder unit : DataHolder.getSingleton().getUnits()) { int value = pNeed.getAmountForUnit(unit); if (value > 0) { b.append("[|]").append(nf.format(value)); } } b.append("[*][b]Angriffe/Fakes:[/b] ").append(pDefense.getAttackCount()).append("/") .append(pDefense.getFakeCount()); for (int i = 0; i < colCount; i++) { b.append("[|]"); } b.append("\n"); b.append("[*][b]Zeitraum:[/b] ").append(df.format(pDefense.getFirstAttack())).append(" bis ") .append(df.format(pDefense.getLastAttack())); for (int i = 0; i < colCount; i++) { b.append("[|]"); } b.append("\n"); b.append("[/table]\n"); return b.toString(); }