List of usage examples for java.text NumberFormat getInstance
public static final NumberFormat getInstance()
From source file:com.streamsets.pipeline.cluster.ClusterFunctionImpl.java
private static synchronized void initialize(Properties properties, Integer id, String rootDataDir) throws Exception { if (initialized) { return;/*from ww w.j a v a2 s . co m*/ } File dataDir = new File(System.getProperty("user.dir"), "data"); FileUtils.copyDirectory(new File(rootDataDir), dataDir); System.setProperty("sdc.data.dir", dataDir.getAbsolutePath()); // must occur before creating the EmbeddedSDCPool as // the hdfs target validation evaluates the sdc:id EL NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumIntegerDigits(6); numberFormat.setGroupingUsed(false); final String sdcId = numberFormat.format(id); Utils.setSdcIdCallable(new Callable<String>() { @Override public String call() { return sdcId; } }); sdcPool = new EmbeddedSDCPool(properties); initialized = true; }
From source file:ClubSkeleton.java
public String callMethod(String request) { JSONObject result = new JSONObject(); NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2);/* w w w. j a v a 2 s .c o m*/ try { JSONObject theCall = new JSONObject(request); String method = theCall.getString("method"); int id = theCall.getInt("id"); JSONArray params = null; if (!theCall.isNull("params")) { params = theCall.getJSONArray("params"); } result.put("id", id); result.put("jsonrpc", "2.0"); double left = 0; double right = 0; if (params.length() > 0) { left = params.getDouble(0); } if (params.length() > 1) { right = params.getDouble(1); } if (method.equals("getAboutUs")) { //code to return the About Us page System.out.println("request: " + nf.format(left) + " + " + nf.format(right)); String res = ci.getAboutUs(); result.put("result", res); } else if (method.equals("getEvents")) { //code to return the About Us page System.out.println("request: " + nf.format(left) + " + " + nf.format(right)); String res = ci.getEvents(); result.put("result", res); } else if (method.equals("getNews")) { //code to return the About Us page System.out.println("request: " + nf.format(left) + " + " + nf.format(right)); String res = ci.getNews(); result.put("result", res); } else if (method.equals("getFAQ")) { //code to return the About Us page System.out.println("request: " + nf.format(left) + " + " + nf.format(right)); String res = ci.getFAQ(); result.put("result", res); } else if (method.equals("whoAreYou")) { System.out.println("request: whoAreYou"); result.put("result", ci.whoAreYou()); } } catch (Exception ex) { System.out.println("exception in callMethod: " + ex.getMessage()); } return "HTTP/1.0 200 Data follows\nServer:localhost:8080\nContent-Type:text/plain\nContent-Length:" + (result.toString()).length() + "\n\n" + result.toString(); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.LogCategoryItemLabelGenerator.java
public LogCategoryItemLabelGenerator() { super(DEFAULT_LABEL_FORMAT_STRING, NumberFormat.getInstance()); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.utils.LabelGenerator.java
public LabelGenerator() { super("", NumberFormat.getInstance()); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.LogXYItemLabelGenerator.java
/** * Creates a new generator with the specified number formatter. * * @param labelFormat the label format string (<code>null</code> not permitted). *///w ww .j a v a 2 s.c o m public LogXYItemLabelGenerator(final String labelFormat) { super(labelFormat, NumberFormat.getInstance(), NumberFormat.getInstance()); }
From source file:org.jfree.chart.demo.ItemLabelDemo3.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Item Label Demo 3", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, false, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setRangeGridlinePaint(Color.white); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setVisible(false);// ww w. j a va2 s .co m NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setUpperMargin(0.14999999999999999D); CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer(); StandardCategoryItemLabelGenerator standardcategoryitemlabelgenerator = new StandardCategoryItemLabelGenerator( "{1}", NumberFormat.getInstance()); categoryitemrenderer.setBaseItemLabelGenerator(standardcategoryitemlabelgenerator); categoryitemrenderer.setBaseItemLabelFont(new Font("SansSerif", 0, 12)); categoryitemrenderer.setBaseItemLabelsVisible(true); categoryitemrenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, -1.5707963267948966D)); return jfreechart; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.LogCategoryItemLabelGenerator.java
/** * Creates a new generator with the specified number formatter. * * @param labelFormat the label format string (<code>null</code> not permitted). * @param formatter the number formatter (<code>null</code> not permitted). *//*from www. j a va2 s . co m*/ public LogCategoryItemLabelGenerator(final String labelFormat) { super(labelFormat, NumberFormat.getInstance()); }
From source file:FieldValidator.java
private static JComponent createContent() { Dimension labelSize = new Dimension(80, 20); Box box = Box.createVerticalBox(); // A single LayerUI for all the fields. LayerUI<JFormattedTextField> layerUI = new ValidationLayerUI(); // Number field. JLabel numberLabel = new JLabel("Number:"); numberLabel.setHorizontalAlignment(SwingConstants.RIGHT); numberLabel.setPreferredSize(labelSize); NumberFormat numberFormat = NumberFormat.getInstance(); JFormattedTextField numberField = new JFormattedTextField(numberFormat); numberField.setColumns(16);/*from ww w .j ava 2 s . c o m*/ numberField.setFocusLostBehavior(JFormattedTextField.PERSIST); numberField.setValue(42); JPanel numberPanel = new JPanel(); numberPanel.add(numberLabel); numberPanel.add(new JLayer<JFormattedTextField>(numberField, layerUI)); // Date field. JLabel dateLabel = new JLabel("Date:"); dateLabel.setHorizontalAlignment(SwingConstants.RIGHT); dateLabel.setPreferredSize(labelSize); DateFormat dateFormat = DateFormat.getDateInstance(); JFormattedTextField dateField = new JFormattedTextField(dateFormat); dateField.setColumns(16); dateField.setFocusLostBehavior(JFormattedTextField.PERSIST); dateField.setValue(new java.util.Date()); JPanel datePanel = new JPanel(); datePanel.add(dateLabel); datePanel.add(new JLayer<JFormattedTextField>(dateField, layerUI)); // Time field. JLabel timeLabel = new JLabel("Time:"); timeLabel.setHorizontalAlignment(SwingConstants.RIGHT); timeLabel.setPreferredSize(labelSize); DateFormat timeFormat = DateFormat.getTimeInstance(); JFormattedTextField timeField = new JFormattedTextField(timeFormat); timeField.setColumns(16); timeField.setFocusLostBehavior(JFormattedTextField.PERSIST); timeField.setValue(new java.util.Date()); JPanel timePanel = new JPanel(); timePanel.add(timeLabel); timePanel.add(new JLayer<JFormattedTextField>(timeField, layerUI)); // Put them all in the box. box.add(Box.createGlue()); box.add(numberPanel); box.add(Box.createGlue()); box.add(datePanel); box.add(Box.createGlue()); box.add(timePanel); return box; }
From source file:ch.unibe.iam.scg.archie.ui.charts.HistogramTooltipGenerator.java
/** * @param labelFormat/*from w w w. ja v a 2s .com*/ * @param formatter */ protected HistogramTooltipGenerator() { super(HistogramTooltipGenerator.DEFAULT_TOOL_TIP_FORMAT_STRING, NumberFormat.getInstance()); }
From source file:com.ceabie.CandlestickToolTipGenerator.java
public static CandlestickToolTipGenerator getSeriesInstance() { return new CandlestickToolTipGenerator(DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("yyyy-MM-dd"), NumberFormat.getInstance()); }