List of usage examples for java.text NumberFormat getNumberInstance
public static final NumberFormat getNumberInstance()
From source file:com.clustercontrol.sql.factory.RunMonitorSqlString.java
/** * SQL?//from ww w. ja va 2 s. c o m * * @param facilityId ID * @return ???????true */ @Override public boolean collect(String facilityId) { // set Generation Date if (m_now != null) { m_nodeDate = m_now.getTime(); } boolean result = false; AccessDB access = null; ResultSet rSet = null; String url = m_url; try { // ???URL?? if (nodeInfo != null && nodeInfo.containsKey(facilityId)) { Map<String, String> nodeParameter = RepositoryUtil.createNodeParameter(nodeInfo.get(facilityId)); StringBinder strbinder = new StringBinder(nodeParameter); url = strbinder.bindParam(m_url); if (m_log.isTraceEnabled()) m_log.trace("jdbc request. (nodeInfo = " + nodeInfo + ", facilityId = " + facilityId + ", url = " + url + ")"); } // DB?? access = new AccessDB(m_jdbcDriver, url, m_user, m_password); // SQL????? if (m_query.length() >= 6) { String work = m_query.substring(0, 6); if (work.equalsIgnoreCase("SELECT")) { rSet = access.read(m_query); //1?1?? rSet.first(); m_value = rSet.getString(1); //? rSet.last(); int number = rSet.getRow(); NumberFormat numberFormat = NumberFormat.getNumberInstance(); m_messageOrg = MessageConstant.RECORD_VALUE.getMessage() + " : " + m_value + ", " + MessageConstant.RECORDS_NUMBER.getMessage() + " : " + numberFormat.format(number); m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url; result = true; } else { //SELECT? m_log.info("collect(): " + MessageConstant.MESSAGE_PLEASE_SET_SELECT_STATEMENT_IN_SQL.getMessage()); m_unKnownMessage = MessageConstant.MESSAGE_PLEASE_SET_SELECT_STATEMENT_IN_SQL.getMessage(); m_messageOrg = MessageConstant.SQL_STRING.getMessage() + " : " + m_query; m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url; } } else { //SELECT? m_log.info("collect(): " + MessageConstant.MESSAGE_PLEASE_SET_SELECT_STATEMENT_IN_SQL.getMessage()); m_unKnownMessage = MessageConstant.MESSAGE_PLEASE_SET_SELECT_STATEMENT_IN_SQL.getMessage(); m_messageOrg = MessageConstant.SQL_STRING.getMessage() + " : " + m_query; m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url; } } catch (ClassNotFoundException e) { m_log.debug("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage()); m_unKnownMessage = MessageConstant.MESSAGE_CANNOT_FIND_JDBC_DRIVER.getMessage(); m_messageOrg = MessageConstant.SQL_STRING.getMessage() + " : " + m_query + " (" + e.getMessage() + ")"; m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url; } catch (SQLException e) { // SQL m_log.info("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage()); m_unKnownMessage = MessageConstant.MESSAGE_FAILED_TO_EXECUTE_SQL.getMessage(); m_messageOrg = MessageConstant.SQL_STRING.getMessage() + " : " + m_query + " (" + e.getMessage() + ")"; m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url; } finally { try { if (rSet != null) { rSet.close(); } if (access != null) { // DB? access.terminate(); } } catch (SQLException e) { m_log.warn("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); } } return result; }
From source file:eu.choreos.chart.XYChart.java
private JFreeChart createChart(XYDataset dataset, String chartTitle) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title "Execution size", // domain axis label "Range", // range axis label dataset, // initial series PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );// w ww. j a va2 s .c o m // set chart background chart.setBackgroundPaint(Color.white); // set a few custom plot features XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // set the plot's axes to display integers TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setStandardTickUnits(ticks); domain.resizeRange(1.1); domain.setLowerBound(0.5); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setStandardTickUnits(ticks); range.setUpperBound(range.getUpperBound() * 1.1); // render shapes and lines XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true); plot.setRenderer(renderer); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // set the renderer's stroke Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); renderer.setBaseOutlineStroke(stroke); // label the points NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(2); XYItemLabelGenerator generator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); return chart; }
From source file:com.clustercontrol.sql.factory.RunMonitorSql.java
/** * SQL?/*from w ww . j ava 2s. c o m*/ * * @param facilityId ID * @return ???????true */ @Override public boolean collect(String facilityId) { // set Generation Date if (m_now != null) { m_nodeDate = m_now.getTime(); } boolean result = false; AccessDB access = null; ResultSet rSet = null; String url = m_url; try { // ???URL?? if (nodeInfo != null && nodeInfo.containsKey(facilityId)) { Map<String, String> nodeParameter = RepositoryUtil.createNodeParameter(nodeInfo.get(facilityId)); StringBinder strbinder = new StringBinder(nodeParameter); url = strbinder.bindParam(m_url); if (m_log.isTraceEnabled()) m_log.trace("jdbc request. (nodeInfo = " + nodeInfo + ", facilityId = " + facilityId + ", url = " + url + ")"); } // DB?? access = new AccessDB(m_jdbcDriver, url, m_user, m_password); // SQL????? if (m_query.length() >= 6) { String work = m_query.substring(0, 6); if (work.equalsIgnoreCase("SELECT")) { rSet = access.read(m_query); //1?1?? rSet.first(); double count = rSet.getDouble(1); m_value = count; //? rSet.last(); int number = rSet.getRow(); NumberFormat numberFormat = NumberFormat.getNumberInstance(); m_message = MessageConstant.SELECT_VALUE.getMessage() + " : " + m_value; m_messageOrg = MessageConstant.RECORD_VALUE.getMessage() + " : " + numberFormat.format(m_value) + ", " + MessageConstant.RECORDS_NUMBER.getMessage() + " : " + numberFormat.format(number); m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url; result = true; } else { //SELECT? m_log.info("collect(): " + MessageConstant.MESSAGE_PLEASE_SET_SELECT_STATEMENT_IN_SQL.getMessage()); m_unKnownMessage = MessageConstant.MESSAGE_PLEASE_SET_SELECT_STATEMENT_IN_SQL.getMessage(); m_messageOrg = MessageConstant.SQL_STRING.getMessage() + " : " + m_query; m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url; } } else { //SELECT? m_log.info("collect(): " + MessageConstant.MESSAGE_PLEASE_SET_SELECT_STATEMENT_IN_SQL.getMessage()); m_unKnownMessage = MessageConstant.MESSAGE_PLEASE_SET_SELECT_STATEMENT_IN_SQL.getMessage(); m_messageOrg = MessageConstant.SQL_STRING.getMessage() + " : " + m_query; m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url; } } catch (ClassNotFoundException e) { m_log.debug("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage()); m_unKnownMessage = MessageConstant.MESSAGE_CANNOT_FIND_JDBC_DRIVER.getMessage(); m_messageOrg = MessageConstant.SQL_STRING.getMessage() + " : " + m_query + " (" + e.getMessage() + ")"; m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url; } catch (SQLException e) { // SQL m_log.info("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage()); m_unKnownMessage = MessageConstant.MESSAGE_FAILED_TO_EXECUTE_SQL.getMessage(); m_messageOrg = MessageConstant.SQL_STRING.getMessage() + " : " + m_query + " (" + e.getMessage() + ")"; m_messageOrg += "\n" + MessageConstant.CONNECTION_URL.getMessage() + " : " + url; } finally { try { if (rSet != null) { rSet.close(); } if (access != null) { // DB? access.terminate(); } } catch (SQLException e) { m_log.warn("collect() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); } } return result; }
From source file:eu.choreos.vv.chart.YIntervalChart.java
private static JFreeChart createChart(XYDataset dataset, String chartTitle, String xLabel, String yLabel) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // initial series PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );//from www .j a v a2s . co m // set chart background chart.setBackgroundPaint(Color.white); // set a few custom plot features XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // set the plot's axes to display integers TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setStandardTickUnits(ticks); domain.resizeRange(1.1); domain.setLowerBound(0.5); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setStandardTickUnits(ticks); range.setUpperBound(range.getUpperBound() * 1.1); // render shapes and lines DeviationRenderer renderer = new DeviationRenderer(true, true); plot.setRenderer(renderer); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // set the renderer's stroke Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); renderer.setBaseOutlineStroke(stroke); //TODO: render the deviation with the same color as the line // renderer.setBaseFillPaint(new Color(255, 200, 200)); // renderer.setUseOutlinePaint(flag); // renderer.setUseFillPaint(flag); // label the points NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(2); XYItemLabelGenerator generator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); //TODO: fix the visible area to show the deviation return chart; }
From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.OtherIndividualsGeneSubInspector.java
@Override protected JPanel getIndividualSummaryPanel(String dnaID) { JPanel outerPanel = new JPanel(); outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS)); //dnaIDVariantMap.get(DNAId) -- all variants within gene corresponding to individual Set<VariantRecord> variantRecords = getVariantRecords(dnaID); Map<Long, Set<VariantRecord>> positionVariantMap = new TreeMap<Long, Set<VariantRecord>>(); for (VariantRecord variantRecord : variantRecords) { //Get all variants at that overlap at that position, regardless of individual. Set<VariantRecord> variantsAtPosition = positionVariantMap.get(variantRecord.getStartPosition()); if (variantsAtPosition == null) { variantsAtPosition = new HashSet<VariantRecord>(); }/*from ww w .j av a2 s . c o m*/ variantsAtPosition.add(variantRecord); positionVariantMap.put(variantRecord.getStartPosition(), variantsAtPosition); } for (Map.Entry<Long, Set<VariantRecord>> e : positionVariantMap.entrySet()) { Long pos = e.getKey(); Set<VariantRecord> variantsAtPosition = e.getValue(); for (final VariantRecord variantRecord : variantsAtPosition) { final JPanel rowContainer = new JPanel(); rowContainer.setLayout(new BoxLayout(rowContainer, BoxLayout.Y_AXIS)); final JPanel row = new JPanel(); row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS)); row.setBorder(new EmptyBorder(0, MIDDLE_LEVEL_INDENT, 0, 0)); final JLabel showDetailsButton = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND)); String posStr = NumberFormat.getNumberInstance().format(pos); JLabel rowTitle = new JLabel( " " + variantRecord.getZygosity().name() + " " + variantRecord.getType() + " @ " + posStr); row.add(showDetailsButton); row.add(rowTitle); row.add(Box.createHorizontalGlue()); rowContainer.add(row); outerPanel.add(rowContainer); showDetailsButton.addMouseListener(new MouseAdapter() { private boolean expanded = true; @Override public void mousePressed(MouseEvent me) { if (expanded) { showDetailsButton .setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.COLLAPSE)); int last_level_indent = MIDDLE_LEVEL_INDENT + IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND) .getIconWidth() + rowContainer.getFontMetrics(rowContainer.getFont()).charWidth(' '); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.setBorder(new EmptyBorder(0, last_level_indent, 0, 0)); JPanel textPanel = new JPanel(); textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS)); textPanel.add(new JLabel("Ref: " + variantRecord.getRef())); textPanel.add(Box.createHorizontalGlue()); p.add(textPanel); textPanel = new JPanel(); textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS)); textPanel.add(new JLabel("Alt: " + variantRecord.getAlt())); textPanel.add(Box.createHorizontalGlue()); p.add(textPanel); rowContainer.add(p); } else { showDetailsButton .setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND)); rowContainer.removeAll(); rowContainer.add(row); } rowContainer.revalidate(); rowContainer.repaint(); expanded = !expanded; } }); } } return outerPanel; }
From source file:dk.nsi.haiba.lprimporter.importer.StatisticsTest.java
private List<String> generateCprList(int size) { List<String> returnValue = new ArrayList<String>(); NumberFormat numberFormat = NumberFormat.getNumberInstance(); numberFormat.setMinimumIntegerDigits(10); for (int i = 0; i < size; i++) { returnValue.add(numberFormat.format(i)); }/*from w w w . ja v a2 s . co m*/ return returnValue; }
From source file:de.uniol.ui.tsv.ui.RelativeHourFormat.java
/** * Creates a new instance./*from w w w .j a va 2 s . c o m*/ * * @param baseMillis the time zone (<code>null</code> not permitted). */ public RelativeHourFormat(long baseMillis) { super(); this.baseMillis = baseMillis; this.hourSuffix = "h"; this.minuteSuffix = "m"; this.secondFormatter = NumberFormat.getNumberInstance(); this.secondFormatter.setMaximumFractionDigits(3); this.secondFormatter.setMinimumFractionDigits(3); this.secondSuffix = "s"; this.milliSuffix = "ms"; // we don't use the calendar or numberFormat fields, but equals(Object) // is failing without them being non-null this.calendar = new GregorianCalendar(); this.numberFormat = new DecimalFormat("0"); }
From source file:plugin.exporttokens.CampaignHistoryToken.java
/** * @param entry/* ww w . ja v a2s. c o m*/ * @param token * @return String Chronicle Value or NULL */ private String getChronicleValue(ChronicleEntry entry, String token) { if (token.equals("TEXT")) { return entry.getChronicle(); } if (token.equals("CAMPAIGN")) { return entry.getCampaign(); } if (token.equals("ADVENTURE")) { return entry.getAdventure(); } if (token.equals("PARTY")) { return entry.getParty(); } if (token.equals("DATE")) { return entry.getDate(); } if (token.equals("XP")) { NumberFormat fmt = NumberFormat.getNumberInstance(); return fmt.format(entry.getXpField()); } if (token.equals("GM")) { return entry.getGmField(); } // Anything else is an error return null; }
From source file:org.renjin.parser.NumericLiterals.java
public static NumberFormat createRealFormat() { NumberFormat format = NumberFormat.getNumberInstance(); format.setMinimumFractionDigits(0);// w w w. j a v a2s .c o m format.setMaximumFractionDigits(14); format.setGroupingUsed(false); return format; }
From source file:Servizi.GraficoJ.java
/** * * Metodo deputato alla creazione del grafico. * * @param dataset il dataset creato dal metodo createDataset * * @return il grafico./*w w w .ja v a2 s. c o m*/ * */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart("Grafico a Linea", //titolo "n individuo", //label asse delle X "Valore Funzione Fitness", //label asse dell Y dataset, // sorgente dei dati PlotOrientation.VERTICAL, //orientamento del grafico true, // mostra la legenda true, //usa i tooltip false); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true); plot.setRenderer(renderer); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(2); XYItemLabelGenerator generator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); return chart; }