List of usage examples for com.google.gwt.i18n.client NumberFormat getFormat
public static NumberFormat getFormat(String pattern)
NumberFormat
instance for the default locale using the specified pattern and the default currencyCode. From source file:no.ovitas.compass2.web.client.components.SearchForm.java
License:Open Source License
protected void createAdvancedForm(final FormPanel formPanel, FormBinding formBinding) { formPanel.setHeaderVisible(false);/*from ww w. ja v a 2 s . com*/ formPanel.setButtonAlign(HorizontalAlignment.RIGHT); formPanel.setBodyBorder(false); formPanel.setBorders(false); FieldSet baseFieldSet = new FieldSet(); baseFieldSet.setLayout(new RowLayout(Orientation.VERTICAL)); LayoutContainer baseLayoutContainer = new LayoutContainer(new RowLayout(Orientation.HORIZONTAL)); baseLayoutContainer.setHeight(145); LayoutContainer leftLayoutContainer = new LayoutContainer(); FormLayout leftFormLayout = new FormLayout(); leftFormLayout.setLabelAlign(LabelAlign.TOP); leftLayoutContainer.setLayout(leftFormLayout); NumberField hopCount = new NumberField(); hopCount.setFieldLabel(Compass2Main.i18n.labelHopCount()); hopCount.setAllowBlank(false); hopCount.setAllowDecimals(false); hopCount.setAllowNegative(false); hopCount.setPropertyEditorType(Integer.class); formBinding.addFieldBinding(new FieldBinding(hopCount, Compass2Constans.HOP_COUNT)); leftLayoutContainer.add(hopCount, new FormData("100%")); NumberField expansionThreshold = new NumberField(); expansionThreshold.setFieldLabel(Compass2Main.i18n.labelExpansionThreshold()); expansionThreshold.setAllowBlank(false); expansionThreshold.setAllowDecimals(true); expansionThreshold.setAllowNegative(false); expansionThreshold.setFormat(NumberFormat.getFormat("#.00#")); expansionThreshold.setPropertyEditorType(Double.class); formBinding.addFieldBinding(new FieldBinding(expansionThreshold, Compass2Constans.EXPANSION_THRESHOLD)); leftLayoutContainer.add(expansionThreshold, new FormData("100%")); CheckBox topicPrefixMatch = new CheckBox(); topicPrefixMatch.setBoxLabel(Compass2Main.i18n.labelTopicPrefixMatch()); topicPrefixMatch.setHideLabel(true); formBinding.addFieldBinding(new FieldBinding(topicPrefixMatch, Compass2Constans.TOPIC_PREFIX_MATCH)); leftLayoutContainer.add(topicPrefixMatch, new FormData("100%")); CheckBox treeSearch = new CheckBox(); treeSearch.setBoxLabel(Compass2Main.i18n.labelTreeSearch()); treeSearch.setHideLabel(true); formBinding.addFieldBinding(new FieldBinding(treeSearch, Compass2Constans.TREE_SEARCH)); leftLayoutContainer.add(treeSearch, new FormData("100%")); baseLayoutContainer.add(leftLayoutContainer, new RowData(0.5, 1.0, new Margins(0, 0, 0, 0))); LayoutContainer rightLayoutContainer = new LayoutContainer(); FormLayout rightFormLayout = new FormLayout(); rightFormLayout.setLabelAlign(LabelAlign.TOP); rightLayoutContainer.setLayout(rightFormLayout); NumberField maxTopicNumberToExpand = new NumberField(); maxTopicNumberToExpand.setFieldLabel(Compass2Main.i18n.labelMaxTopicNumberToExpand()); maxTopicNumberToExpand.setAllowBlank(false); maxTopicNumberToExpand.setAllowDecimals(false); maxTopicNumberToExpand.setAllowNegative(false); maxTopicNumberToExpand.setPropertyEditorType(Integer.class); formBinding.addFieldBinding( new FieldBinding(maxTopicNumberToExpand, Compass2Constans.MAX_TOPIC_NUMBER_TO_EXPAND)); rightLayoutContainer.add(maxTopicNumberToExpand, new FormData("100%")); NumberField resultThreshold = new NumberField(); resultThreshold.setFieldLabel(Compass2Main.i18n.labelResultThreshold()); resultThreshold.setAllowBlank(false); resultThreshold.setAllowDecimals(true); resultThreshold.setAllowNegative(false); resultThreshold.setFormat(NumberFormat.getFormat("#.00#")); resultThreshold.setPropertyEditorType(Double.class); formBinding.addFieldBinding(new FieldBinding(resultThreshold, Compass2Constans.RESULT_THRESHOLD)); rightLayoutContainer.add(resultThreshold, new FormData("100%")); NumberField maxNumberOfHits = new NumberField(); maxNumberOfHits.setFieldLabel(Compass2Main.i18n.labelMaxNumberOfHits()); maxNumberOfHits.setAllowBlank(false); maxNumberOfHits.setAllowDecimals(false); maxNumberOfHits.setAllowNegative(false); maxNumberOfHits.setPropertyEditorType(Integer.class); formBinding.addFieldBinding(new FieldBinding(maxNumberOfHits, Compass2Constans.MAX_NUMBER_OF_HITS)); rightLayoutContainer.add(maxNumberOfHits, new FormData("100%")); baseLayoutContainer.add(rightLayoutContainer, new RowData(0.5, 1.0, new Margins(0, 0, 0, 10))); baseFieldSet.add(baseLayoutContainer); FieldSet kbField = new FieldSet(); kbField.setHeading(Compass2Main.i18n.titleKBGroup()); // kbSelectionModelAdvanced = new // CheckBoxSelectionModel<SelectedTreeModel>(); // kbSelectionModelAdvanced.setSelectionMode(SelectionMode.MULTI); // kbSelectionModelAdvanced // .addSelectionChangedListener(new // SelectionChangedListener<SelectedTreeModel>() { // // @Override // public void selectionChanged( // SelectionChangedEvent<SelectedTreeModel> se) { // loadRelationTypes(se.getSelection()); // } // }); kbGridAdvanced = createKnowledgeBaseGrid(kbTreeStoreAdvanced); kbGridAdvanced.setBorders(false); kbField.add(kbGridAdvanced, new FormData("100%")); baseFieldSet.add(kbField, new FormData("100%")); formPanel.add(baseFieldSet, new FormData("100%")); baseFieldSet.setHeading(Compass2Main.i18n.titleBaseSettings()); FieldSet advancedFieldSet = new FieldSet(); if (advancedSearchFields != null && advancedSearchFields.size() > 0) { int i = 0; for (SearchFieldModel searchField : advancedSearchFields) { switch (searchField.getType()) { case STRING: if (i != 0) { advancedFieldSet.add(createConnectField(searchField, advancedFormBinding), new RowData(1.0, 25.0, new Margins())); } advancedFieldSet.add(new TextSearchFieldWidget(searchField, advancedFormBinding), new RowData(1.0, 50.0, new Margins())); break; case FLOAT: if (i != 0) { advancedFieldSet.add(createConnectField(searchField, advancedFormBinding), new RowData(1.0, 25.0, new Margins())); } advancedFieldSet.add(createFloatField(searchField, advancedFormBinding), new RowData(1.0, 25.0, new Margins())); break; case INTEGER: if (i != 0) { advancedFieldSet.add(createConnectField(searchField, advancedFormBinding), new RowData(1.0, 25.0, new Margins())); } advancedFieldSet.add(createIntegerField(searchField, advancedFormBinding), new RowData(1.0, 25.0, new Margins())); break; case DATEINTERVAL: if (i != 0) { advancedFieldSet.add(createConnectField(searchField, advancedFormBinding), new RowData(1.0, 25.0, new Margins())); } advancedFieldSet.add(createDateIntervalField(searchField, advancedFormBinding), new RowData(1.0, 25.0, new Margins())); break; } i++; } } formPanel.add(advancedFieldSet, new FormData("100%")); advancedFieldSet.setHeading(Compass2Main.i18n.titleAdvancedSettings()); Button searchButton = new Button(Compass2Main.i18n.buttonSearch()); formPanel.add(searchButton, new FormData("100%")); searchButton.addSelectionListener(new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { if (formPanel.isValid()) { searchModel.setAdvancedSearch(true); Map<KnowledgeBaseTreeModel, Set<ScopeTreeModel>> knowledgeBase = new HashMap<KnowledgeBaseTreeModel, Set<ScopeTreeModel>>(); List<SelectedTreeModel> checkedSelection = getSelectedKBTreeModels(kbTreeStoreAdvanced); for (BaseTreeModel baseTreeModel : checkedSelection) { if (baseTreeModel instanceof KnowledgeBaseTreeModel) { knowledgeBase.put((KnowledgeBaseTreeModel) baseTreeModel, new HashSet<ScopeTreeModel>(0)); } } KnowledgeBaseTreeModel parent; Set<ScopeTreeModel> scopeTree; for (BaseTreeModel baseTreeModel : checkedSelection) { if (baseTreeModel instanceof ScopeTreeModel) { if (baseTreeModel.getParent() != null && baseTreeModel.getParent() instanceof KnowledgeBaseTreeModel) { parent = (KnowledgeBaseTreeModel) baseTreeModel.getParent(); scopeTree = knowledgeBase.get(parent); if (scopeTree != null) { scopeTree.add((ScopeTreeModel) baseTreeModel); } } } } searchModel.setKnowledgeBaseList(knowledgeBase); fireSearch(searchModel); } } }); }
From source file:nz.org.winters.appspot.acrareporter.client.ui.ACRAReportView.java
License:Apache License
private String memToMB(String mem) { double value = Double.parseDouble(mem); double valued = (double) value / 1024.0 / 1024.0; NumberFormat df = NumberFormat.getFormat("#0.00 mb"); return df.format(valued); }
From source file:org.activityinfo.core.client.type.converter.JsCoordinateNumberFormatter.java
License:Open Source License
public JsCoordinateNumberFormatter() { dddFormat = NumberFormat.getFormat("+0.000000;-0.000000"); shortFracFormat = NumberFormat.getFormat("0.00"); intFormat = NumberFormat.getFormat("0"); }
From source file:org.aksw.linkedqa.client.TaskGrid.java
License:Open Source License
public TaskGrid() { setLayout(new FlowLayout(10)); getAriaSupport().setPresentation(true); final NumberFormat currency = NumberFormat.getCurrencyFormat(); final NumberFormat number = NumberFormat.getFormat("0.00"); //final NumberCellRenderer<Grid<Stock>> numberRenderer = new NumberCellRenderer<Grid<Stock>>( // currency); /*/* w w w . j a v a 2s .c o m*/ GridCellRenderer<Stock> change = new GridCellRenderer<Stock>() { public String render(Stock model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<Stock> store, Grid<Stock> grid) { Object o = model.get(property); String v = "(not set)"; if(o == null) { double val = (Double)o; String style = val < 0 ? "red" : GXT.isHighContrastMode ? "#00ff5a" : "green"; v = number.format(val); } return "<span qtitle='" + cm.getColumnById(property).getHeader() + "' qtip='" + v + "' style='font-weight: bold;color:" + style + "'>" + v + "</span>"; } };*/ /* GridCellRenderer<Stock> gridNumber = new GridCellRenderer<Stock>() { public String render(Stock model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<Stock> store, Grid<Stock> grid) { return numberRenderer.render(null, property, model.get(property)); } };*/ List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); ColumnConfig column = new ColumnConfig(); column.setId("name"); column.setHeader("Linkset name"); column.setWidth(200); column.setRowHeader(true); configs.add(column); column = new ColumnConfig(); column.setId("direction"); column.setHeader("Direction"); column.setAlignment(HorizontalAlignment.RIGHT); column.setWidth(100); configs.add(column); column = new ColumnConfig(); column.setId("sampled"); column.setHeader("Sampled"); column.setAlignment(HorizontalAlignment.RIGHT); column.setWidth(100); configs.add(column); column = new ColumnConfig(); column.setId("sampleSize"); column.setHeader("Sample size"); column.setAlignment(HorizontalAlignment.RIGHT); column.setWidth(75); //column.setRenderer(gridNumber); configs.add(column); /* column = new ColumnConfig("change", "Change", 100); column.setAlignment(HorizontalAlignment.RIGHT); //column.setRenderer(change); configs.add(column); */ column = new ColumnConfig("date", "Finished", 100); column.setAlignment(HorizontalAlignment.RIGHT); column.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/yyyy")); configs.add(column); //ListStore<TaskDescription> store = new ListStore<TaskDescription>(); //store.add(getStocks()); //store.add(TaskData.getStocks()); //store.add(getStocks()); cm = new ColumnModel(configs); ContentPanel cp = new ContentPanel(); cp.setBodyBorder(true); // cp.setIcon(Resources.ICONS.table()); cp.setHeading("Available Linksets"); cp.setButtonAlign(HorizontalAlignment.CENTER); cp.setLayout(new FitLayout()); cp.getHeader().setIconAltText("Grid Icon"); cp.setSize(600, 300); //final Grid<TaskDescription> grid = new Grid<TaskDescription>(getStocks(), cm); grid.setStyleAttribute("borderTop", "none"); grid.setAutoExpandColumn("name"); grid.setBorders(false); grid.setStripeRows(true); grid.setColumnLines(true); grid.setColumnReordering(true); grid.getAriaSupport().setLabelledBy(cp.getHeader().getId() + "-label"); cp.add(grid); ToolBar toolBar = new ToolBar(); toolBar.getAriaSupport().setLabel("Grid Options"); toolBar.add(new LabelToolItem("Selection Mode: ")); final SimpleComboBox<String> type = new SimpleComboBox<String>(); type.getAriaSupport().setLabelledBy(toolBar.getItem(0).getId()); type.setTriggerAction(TriggerAction.ALL); type.setEditable(false); type.setFireChangeEventOnSetValue(true); type.setWidth(100); type.add("Row"); type.add("Cell"); type.setSimpleValue("Row"); type.addListener(Events.Change, new Listener<FieldEvent>() { public void handleEvent(FieldEvent be) { boolean cell = type.getSimpleValue().equals("Cell"); grid.getSelectionModel().deselectAll(); if (cell) { grid.setSelectionModel(new CellSelectionModel<TaskDescription>()); } else { grid.setSelectionModel(new GridSelectionModel<TaskDescription>()); } } }); toolBar.add(type); cp.setTopComponent(toolBar); add(cp); // needed to enable quicktips (qtitle for the heading and qtip for the // content) that are setup in the change GridCellRenderer new QuickTip(grid); }
From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Clampto3DModel.java
License:Apache License
Cartesian3 updatePosition(JulianDate time, Cartesian3 result) { double offset = (time.secondsOfDay % duration) / duration; cartographic.longitude = longitude - range + offset * range * 2.0; cartographic.latitude = latitude;/*www .j ava 2s . c om*/ double height = 0.0; if (csVPanel.getViewer().scene().sampleHeightSupported()) { height = csVPanel.getViewer().scene().sampleHeight(cartographic, objectsToExclude); } if (Cesium.defined(height)) { cartographic.height = height; point.label.text = new ConstantProperty<>( NumberFormat.getFormat("#.##").format(Math.abs(height)) + " m"); point.label.show = new ConstantProperty<>(true); } else { cartographic.height = 0.0; point.label.show = new ConstantProperty<>(false); } return Cartographic.toCartesian(cartographic, Ellipsoid.WGS84(), result); }
From source file:org.clevermore.monitor.client.utils.ClientStringFormatter.java
License:Apache License
public static String formatMillis(long ms) { return NumberFormat.getFormat("#,##0.0###").format(ms / (double) 1000); }
From source file:org.clevermore.monitor.client.utils.ClientStringFormatter.java
License:Apache License
public static String formatMillisShort(long ms) { return NumberFormat.getFormat("#,##0.0#").format(ms / (double) 1000); }
From source file:org.clevermore.monitor.client.utils.ClientStringFormatter.java
License:Apache License
public static String formatMillisShort(double ms) { return NumberFormat.getFormat("#,##0.0#").format(ms); }
From source file:org.clevermore.monitor.client.utils.ClientStringFormatter.java
License:Apache License
public static String formatNumber(Integer ms) { return NumberFormat.getFormat("#,##0").format(ms); }
From source file:org.clevermore.monitor.client.utils.ClientStringFormatter.java
License:Apache License
public static String formatNumber(Long ms) { return NumberFormat.getFormat("#,##0").format(ms); }