List of usage examples for java.text NumberFormat getIntegerInstance
public static final NumberFormat getIntegerInstance()
From source file:org.kalypso.ogc.sensor.timeseries.TimeseriesUtils.java
/** * Returns the adequate NumberFormat for the given format-string. It currently only supports formats of the form %X.Yf * where actually only the Y is used to build a NumberFormat with Y minimum/maximum-fraction-digits. * <p>/*from w ww . jav a 2 s .c o m*/ * The plan is, once we'll be using JDK 5.0, we'll try to replace this with the built-in functionality provided with * formated printing. * <p> * TODO once on JDK 5.0 use formated printing if possible. Note that some refactoring might need to be done since we * currently work with NumberFormats. */ public static synchronized NumberFormat getNumberFormat(final String format) { final NumberFormat nf = FORMAT_MAP.get(format); if (nf != null) return nf; if ("%d".equals(format)) //$NON-NLS-1$ { final NumberFormat wf = NumberFormat.getIntegerInstance(); wf.setGroupingUsed(false); FORMAT_MAP.put(format, wf); return wf; } // parse the format spec and only take the min-fraction-digit part final String regex = "%([0-9]*)\\.?([0-9]*)f"; //$NON-NLS-1$ final Pattern pattern = Pattern.compile(regex); final Matcher matcher = pattern.matcher(format); if (matcher.matches()) { final String minfd = matcher.group(2); final NumberFormat wf = NumberFormat.getInstance(); final int intValue = Integer.valueOf(minfd).intValue(); wf.setMinimumFractionDigits(intValue); wf.setMaximumFractionDigits(intValue); FORMAT_MAP.put(format, wf); return wf; } return getDefaultFormat(); }
From source file:org.cruk.genologics.api.cache.GenologicsAPICacheTest.java
/** * This test modifies the database, and so is controlled by the system property * "live.cache.test".//from www .j a v a 2 s. c o m * * @throws Exception */ @Test public void fullTest() throws Exception { Assume.assumeTrue("Not in the CRUK-CI institute. This test will not work.", UnitTestApplicationContextFactory.inCrukCI()); checkCredentialsSet(); boolean runThisTest = Boolean.parseBoolean(System.getProperty("live.cache.test", Boolean.FALSE.toString())); Assume.assumeTrue("Not running the test \"GenologicsAPICachingAspectTest.fullTest\". " + "Set the property -Dlive.cache.test=true to make it run.", runThisTest); final String projectName = "Caching Aspect Test"; if (apiUser == null || plateType == null) { readonlyTest(); } // Find or create project Map<String, String> projectSearch = Collections.singletonMap("name", projectName); List<LimsLink<Project>> foundProjects = api.find(projectSearch, Project.class); if (foundProjects.isEmpty()) { project = new Project(); project.setName(projectName); project.setResearcher(apiUser); project.setOpenDate(new Date()); api.create(project); } else { LimsLink<Project> link = foundProjects.get(0); testAspect.setAllowedUris(link.getUri().toString()); project = api.load(link); testAspect.clear(); } testNotReloading(project); // Create a container for some samples. container = new Container(plateType, projectName + " Plate"); api.create(container); testNotReloading(container); // Create some samples in the container. samples = new Sample[5]; for (int i = 0; i < samples.length; i++) { Sample s = new Sample(); s.setName(projectName + " sample #" + (i + 1)); s.setDateReceived(new Date()); s.setProject(project); s.setSubmitter(apiUser); UDF.setUDF(s, "Read Length", "50"); UDF.setUDF(s, "Column", "2"); UDF.setUDF(s, "Concentration", "-1"); UDF.setUDF(s, "Library Type", "Other"); UDF.setUDF(s, "Number of Lanes", "2"); UDF.setUDF(s, "Pool Size", "-1"); UDF.setUDF(s, "Priority Status", "Standard"); UDF.setUDF(s, "Reference Genome", "Homo sapiens [GRCh37]"); UDF.setUDF(s, "Row", "A"); UDF.setUDF(s, "Sample Source", "Not Assigned"); UDF.setUDF(s, "Sample Type", "DNA"); UDF.setUDF(s, "Sequencer", "Not Assigned"); UDF.setUDF(s, "SLX Identifier", "SLX-0000"); UDF.setUDF(s, "Sequencing Type", "Paired End"); UDF.setUDF(s, "Index Type", "Unspecified (Other)"); UDF.setUDF(s, "Volume", "-1"); UDF.setUDF(s, "Average Library Length", "-1"); UDF.setUDF(s, "Version Number", "Not Assigned"); UDF.setUDF(s, "Workflow", "MiSeq Express"); s.setCreationLocation(container, (char) ('A' + i) + ":" + Integer.valueOf(i + 1)); samples[i] = s; } api.createAll(Arrays.asList(samples)); testNotReloading(samples[0]); // Try loading the samples' artifacts by individually and by batch. @SuppressWarnings("unchecked") LimsLink<Artifact>[] artifactLinks = new LimsLink[samples.length]; for (int i = 0; i < samples.length; i++) { artifactLinks[i] = samples[i].getArtifact(); } testAspect.setAllowedUris(artifactLinks[0], artifactLinks[4]); Artifact[] artifacts = new Artifact[samples.length]; artifacts[0] = api.load(artifactLinks[0]); artifacts[4] = api.load(artifactLinks[4]); testNotReloading(artifacts[0]); // Mass fetch. Should only fetch the middle three. testAspect.setAllowedUris(artifactLinks[1], artifactLinks[2], artifactLinks[3]); api.loadAll(Arrays.asList(artifactLinks)).toArray(artifacts); testNotReloading(artifacts[2]); // Check fetched artifacts match their original links. for (int i = 0; i < samples.length; i++) { assertEquals("Sample/artifact " + i + " don't match", samples[i].getArtifact().getLimsid(), artifacts[i].getLimsid()); } // Try pooling the artifacts. // First, assign reagent labels. NumberFormat reagentFormat = NumberFormat.getIntegerInstance(); reagentFormat.setMinimumIntegerDigits(3); for (int i = 0; i < artifacts.length; i++) { artifacts[i].addReagentLabel("A" + reagentFormat.format(i + 1)); } api.updateAll(Arrays.asList(artifacts)); // Now the actual pooling. poolContainer = new Container(tubeType, projectName + " pool container"); api.create(poolContainer); ExecutableProcess execProcess = new ExecutableProcess("Pool Accepted SLX", apiUser); ExecutableInputOutputMap iomap = execProcess.newInputOutputMap(); iomap.setShared(true); iomap.setInputs(Arrays.asList(artifacts)); iomap.setOutput(OutputType.ANALYTE, poolContainer, "1:1"); GenologicsProcess poolProcess = api.executeProcess(execProcess); assertNotNull("No pool process returned", poolProcess); testNotReloading(poolProcess); // Try attaching a file to a sample. File toUpload = new File("pom.xml").getAbsoluteFile(); try { GenologicsFile uploadedFile = api.uploadFile(samples[0], toUpload.toURI().toURL(), false); assertNotNull("No file returned", uploadedFile); testNotReloading(uploadedFile); try { api.deleteAndRemoveFile(uploadedFile); Object fetched = cacheAspect.getCache(GenologicsFile.class) .getQuiet(cacheAspect.keyFromLocatable(uploadedFile)); assertNull("Deleted file is still in the cache", fetched); } catch (IOException e) { api.delete(uploadedFile); } } catch (IOException e) { logger.warn("Could not upload the file to the server: ", e); } }
From source file:us.fatehi.pointlocation6709.format.PointLocationFormatter.java
private static NumberFormat getIntegerFormat(final int integerDigits) { final NumberFormat numberFormat = NumberFormat.getIntegerInstance(); numberFormat.setMinimumIntegerDigits(integerDigits); return numberFormat; }
From source file:com.norconex.collector.core.crawler.AbstractCrawler.java
private void setProgress(JobStatusUpdater statusUpdater, ICrawlDataStore db) { int queued = db.getQueueSize(); int processed = processedCount; int total = queued + processed; double progress = 0; if (total != 0) { progress = BigDecimal.valueOf(processed) .divide(BigDecimal.valueOf(total), DOUBLE_PROGRESS_SCALE, RoundingMode.DOWN).doubleValue(); }/*from w w w.j a va 2s. c om*/ statusUpdater.setProgress(progress); statusUpdater.setNote(NumberFormat.getIntegerInstance().format(processed) + " references processed out of " + NumberFormat.getIntegerInstance().format(total)); if (LOG.isInfoEnabled()) { long currentTime = System.currentTimeMillis(); if (currentTime - lastStatusLoggingTime > STATUS_LOGGING_INTERVAL) { lastStatusLoggingTime = currentTime; int percent = BigDecimal.valueOf(progress).movePointLeft(DOUBLE_PERCENT_SCALE).intValue(); LOG.info( getId() + ": " + percent + "% completed (" + processed + " processed/" + total + " total)"); } } }
From source file:InputVerificationDialogDemo.java
private void setUpFormats() { moneyFormat = (NumberFormat) NumberFormat.getNumberInstance(); percentFormat = NumberFormat.getNumberInstance(); percentFormat.setMinimumFractionDigits(3); decimalFormat = (DecimalFormat) NumberFormat.getNumberInstance(); decimalFormat.setParseIntegerOnly(true); paymentFormat = (DecimalFormat) NumberFormat.getNumberInstance(); paymentFormat.setMaximumFractionDigits(2); paymentFormat.setNegativePrefix("("); paymentFormat.setNegativeSuffix(")"); integerFormat = NumberFormat.getIntegerInstance(); }
From source file:nlp.mediawiki.parser.MultistreamBzip2XmlDumpParser.java
@Override public String toString() { NumberFormat nf = NumberFormat.getIntegerInstance(); nf.setGroupingUsed(true);// w ww .j a v a 2 s .c o m return String.format( "Multistreamed Bzip2 XML Dump parser { \n * Threads: %s, \n * Batch size: %s, \n * Index: %s, \n * Pages: %s, \n * Basepath: %s \n}", nf.format(workers.length), nf.format(batchsize), indexFile.getName(), pageFile.getName(), pageFile.getParentFile().getAbsolutePath()); }
From source file:edu.berkeley.boinc.PrefsFragment.java
private void setupSliderDialog(PrefsListItemWrapper item, final Dialog dialog) { final PrefsListItemWrapperValue valueWrapper = (PrefsListItemWrapperValue) item; dialog.setContentView(R.layout.prefs_layout_dialog_pct); TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status); SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar); if (valueWrapper.ID == R.string.battery_charge_min_pct_header || valueWrapper.ID == R.string.prefs_disk_max_pct_header || valueWrapper.ID == R.string.prefs_cpu_time_max_header || valueWrapper.ID == R.string.prefs_cpu_other_load_suspension_header || valueWrapper.ID == R.string.prefs_memory_max_idle_header) { Double seekBarDefault = valueWrapper.status / 10; slider.setProgress(seekBarDefault.intValue()); final SeekBar.OnSeekBarChangeListener onSeekBarChangeListener; slider.setOnSeekBarChangeListener(onSeekBarChangeListener = new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) { final String progressString = NumberFormat.getPercentInstance().format(progress / 10.0); TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status); sliderProgress.setText(progressString); }//from w w w . j a v a 2 s . c o m @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); onSeekBarChangeListener.onProgressChanged(slider, seekBarDefault.intValue(), false); } else if (valueWrapper.ID == R.string.prefs_cpu_number_cpus_header) { if (!getHostInfo()) { if (Logging.WARNING) Log.w(Logging.TAG, "onItemClick missing hostInfo"); return; } slider.setMax(hostinfo.p_ncpus <= 1 ? 0 : hostinfo.p_ncpus - 1); final int statusValue; slider.setProgress((statusValue = valueWrapper.status.intValue()) <= 0 ? 0 : statusValue - 1 > slider.getMax() ? slider.getMax() : statusValue - 1); Log.d(Logging.TAG, String.format("statusValue == %,d", statusValue)); final SeekBar.OnSeekBarChangeListener onSeekBarChangeListener; slider.setOnSeekBarChangeListener(onSeekBarChangeListener = new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) { final String progressString = NumberFormat.getIntegerInstance() .format(progress <= 0 ? 1 : progress + 1); // do not allow 0 cpus TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status); sliderProgress.setText(progressString); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); onSeekBarChangeListener.onProgressChanged(slider, statusValue - 1, false); } else if (valueWrapper.ID == R.string.prefs_gui_log_level_header) { slider.setMax(5); slider.setProgress(valueWrapper.status.intValue()); final SeekBar.OnSeekBarChangeListener onSeekBarChangeListener; slider.setOnSeekBarChangeListener(onSeekBarChangeListener = new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) { String progressString = NumberFormat.getIntegerInstance().format(progress); TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status); sliderProgress.setText(progressString); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); onSeekBarChangeListener.onProgressChanged(slider, valueWrapper.status.intValue(), false); } setupDialogButtons(item, dialog); }
From source file:org.apache.ambari.server.serveraction.kerberos.MITKerberosOperationHandler.java
/** * Retrieves the current key number assigned to the identity identified by the specified principal * * @param principal a String declaring the principal to look up * @return an Integer declaring the current key number * @throws KerberosKDCConnectionException if a connection to the KDC cannot be made * @throws KerberosAdminAuthenticationException if the administrator credentials fail to authenticate * @throws KerberosRealmException if the realm does not map to a KDC * @throws KerberosOperationException if an unexpected error occurred *///from w w w . j av a2 s . co m private Integer getKeyNumber(String principal) throws KerberosOperationException { if (!isOpen()) { throw new KerberosOperationException("This operation handler has not been opened"); } if (StringUtils.isEmpty(principal)) { throw new KerberosOperationException( "Failed to get key number for principal - no principal specified"); } else { // Create the kdamin query: get_principal <principal> ShellCommandUtil.Result result = invokeKAdmin(String.format("get_principal %s", principal)); String stdOut = result.getStdout(); if (stdOut == null) { String message = String.format( "Failed to get key number for %s:\n\tExitCode: %s\n\tSTDOUT: NULL\n\tSTDERR: %s", principal, result.getExitCode(), result.getStderr()); LOG.warn(message); throw new KerberosOperationException(message); } Matcher matcher = PATTERN_GET_KEY_NUMBER.matcher(stdOut); if (matcher.matches()) { NumberFormat numberFormat = NumberFormat.getIntegerInstance(); String keyNumber = matcher.group(1); numberFormat.setGroupingUsed(false); try { Number number = numberFormat.parse(keyNumber); return (number == null) ? 0 : number.intValue(); } catch (ParseException e) { String message = String.format( "Failed to get key number for %s - invalid key number value (%s):\n\tExitCode: %s\n\tSTDOUT: NULL\n\tSTDERR: %s", principal, keyNumber, result.getExitCode(), result.getStderr()); LOG.warn(message); throw new KerberosOperationException(message); } } else { String message = String.format( "Failed to get key number for %s - unexpected STDOUT data:\n\tExitCode: %s\n\tSTDOUT: NULL\n\tSTDERR: %s", principal, result.getExitCode(), result.getStderr()); LOG.warn(message); throw new KerberosOperationException(message); } } }
From source file:search2go.UIFrame.java
public UIFrame() throws IOException, ParseException { topLevels = new TopLevelGTermSet[] { CCs, MFs, BPs }; this.addWindowListener(new WindowAdapter() { @Override/*from w ww .j a v a 2 s. com*/ public void windowClosing(WindowEvent et) { try { if (os.isWindows()) { Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM python.exe -F"); } else { Runtime.getRuntime().exec("killAll -KILL blastx"); Runtime.getRuntime().exec("killAll -KILL blastn"); Runtime.getRuntime().exec("killAll -KILL blastp"); Runtime.getRuntime().exec("killAll -KILL python"); } } catch (IOException ex) { System.out.println("Error closing child processes"); } } }); initComponents(); txtBlastOutput.getDocument().addDocumentListener(new BufferEnforcer(txtBlastOutput)); txtFullOutput.getDocument().addDocumentListener(new BufferEnforcer(txtFullOutput)); txtMapOutput.getDocument().addDocumentListener(new BufferEnforcer(txtMapOutput)); ((DefaultCaret) txtBlastOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtMapOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtFullOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); webSaveMenu = new JPopupMenu(); JMenuItem saveWeb = new JMenuItem(); saveWeb.setText("Save"); saveWeb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { webSaveDialogue.showSaveDialog(pnlChartHolder); File saveFile = webSaveDialogue.getSelectedFile(); if (!saveFile.getPath().contains(".png")) saveFile = new File(saveFile.getPath() + ".png"); try { BufferedImage webChartImage = new BufferedImage(pnlChartHolder.getWidth(), pnlChartHolder.getHeight(), BufferedImage.TYPE_INT_RGB); pnlChartHolder.print(webChartImage.getGraphics()); ImageIO.write(webChartImage, "png", saveFile); } catch (Exception ex) { javax.swing.JOptionPane.showMessageDialog(pnlChartHolder, "Error saving chart. Please try again."); } } }); webSaveMenu.add(saveWeb); pnlChartHolder.add(webSaveMenu); pnlChartHolder.setLayout(new java.awt.BorderLayout()); try { currentProj = Workspace.open(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); txtQuery.setText(currentProj.getQueryPath()); txtQueryFP.setText(currentProj.getQueryPath()); txtDatabase.setText(currentProj.getPathToDB()); txtDatabaseFP.setText(currentProj.getPathToDB()); txtThreads.setValue(currentProj.getThreadNo()); txtThreadsFP.setValue(currentProj.getThreadNo()); cbxNXP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxNXPFP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxDBID.setSelectedIndex(currentProj.getSelectedDBIndex()); cbxDBIDFP.setSelectedIndex(currentProj.getSelectedDBIndex()); txtBitScore.setValue(currentProj.getBitScoreThreshold()); txtBitScoreFP.setValue(currentProj.getBitScoreThreshold()); txtBlastE.setValue(currentProj.getEThreshold()); txtMapE.setValue(currentProj.getEThreshold()); txtEFP.setValue(currentProj.getEThreshold()); } catch (FileNotFoundException e) { currentProj = Workspace.create(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); } this.setTitle("Search2GO " + currentProj.getPath().toString()); GTermTableModel = new DefaultTableModel(); GTermTableModel.setColumnCount(2); GTermTableModel.setColumnIdentifiers(new String[] { "GO ID", "Frequency" }); ListSelectionModel GTermSelector = tblGOFreq.getSelectionModel(); GTermSelector.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (tblGOFreq.getSelectedRow() > -1) { DefaultListModel emptyModel = new DefaultListModel(); lstQueries.setModel(emptyModel); txtTermInfo.setText(""); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); JTextArea tempHolderInfo = new JTextArea(); JTextArea tempHolderQueries = new JTextArea(); if (tblGOFreq.getSelectedRow() != -1) { ResetGTermInfoGetter(tempHolderInfo, tempHolderQueries); gTermInfoGetter.getProcess(0).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("db", currentGTerm.getTopLevel().getCode()); gTermInfoGetter.setTail(new ProcessSequenceEnd() { @Override public void run() { tempHolderInfo.setText("id: " + selectedID + "\n" + tempHolderInfo.getText()); txtTermInfo.setText(tempHolderInfo.getText()); DefaultListModel queryList = new DefaultListModel(); for (String str : tempHolderQueries.getText().split(";")) { queryList.addElement(str.replaceAll("Query: ", "")); } lstQueries.setModel(queryList); prgIdentification.setIndeterminate(false); } }); try { gTermInfoGetter.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } } } }); lstQueries.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting() && !e.toString().contains("invalid") && lstQueries.getSelectedValue() != null) { JTextArea tempHolder = new JTextArea(); ProcessSequence fetchLocusSequence = new ProcessSequence(new ProcessSequenceEnd() { @Override public void run() { if (txtTermInfo.getText().contains("Score")) { txtTermInfo.setText( txtTermInfo.getText().substring(0, txtTermInfo.getText().indexOf("Score"))); } txtTermInfo.append(tempHolder.getText()); prgIdentification.setIndeterminate(false); } }); Path fetchLocusPath = new Path("Processes"); fetchLocusPath.append("fetchLocus.py"); Process fetchLocus = new Process(tempHolder); fetchLocus.setScriptCommand(fetchLocusPath.toEscString()); fetchLocus.addParameter("dir", currentProj.getPath().toEscString()); fetchLocus.addParameter("q", new ParameterString(lstQueries.getSelectedValue().replace("\n", "")).toString()); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); fetchLocus.addParameter("db", currentGTerm.getTopLevel().getCode()); fetchLocus.addParameter("id", currentGTerm.getID()); fetchLocusSequence.addProcess(fetchLocus); try { fetchLocusSequence.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } }); DocumentListener filterListener = new DocumentListener() { private void anyUpdate() { gTerms.getFilter().setFilterString(txtSearchTerms.getText()); if (!txtMinFreqFilter.getText().equals("")) gTerms.getFilter().setMinFreq(Integer.parseInt(txtMinFreqFilter.getText())); else gTerms.getFilter().setMinFreq(0); if (!txtMaxFreqFilter.getText().equals("")) gTerms.getFilter().setMaxFreq(Integer.parseInt(txtMaxFreqFilter.getText())); else gTerms.getFilter().setMaxFreq(-1); fillIdentTable(gTerms.stringFilter(), false); } @Override public void insertUpdate(DocumentEvent e) { anyUpdate(); } @Override public void removeUpdate(DocumentEvent e) { anyUpdate(); } @Override public void changedUpdate(DocumentEvent e) { anyUpdate(); } }; txtSearchTerms.getDocument().addDocumentListener(filterListener); txtMinFreqFilter.getDocument().addDocumentListener(filterListener); txtMaxFreqFilter.getDocument().addDocumentListener(filterListener); NumberFormat numberMask = NumberFormat.getIntegerInstance(); numberMask.setGroupingUsed(false); NumberFormatter numberMasker = new NumberFormatter(numberMask); NumberFormatter numberMaskerAndBlank = new NumberFormatter(numberMask) { @Override public Object stringToValue(String s) throws ParseException { if (s == null || s.length() == 0) return null; return super.stringToValue(s); } }; DefaultFormatterFactory numberMaskFactory = new DefaultFormatterFactory(numberMasker); DefaultFormatterFactory numberMaskAndBlankFactory = new DefaultFormatterFactory(numberMaskerAndBlank); txtThreads.setFormatterFactory(numberMaskFactory); txtThreadsFP.setFormatterFactory(numberMaskFactory); txtBitScore.setFormatterFactory(numberMaskAndBlankFactory); txtBitScoreFP.setFormatterFactory(numberMaskAndBlankFactory); txtMinFreqFilter.setFormatterFactory(numberMaskFactory); txtMaxFreqFilter.setFormatterFactory(numberMaskFactory); txtBlastE.setFormatterFactory(numberMaskAndBlankFactory); txtMapE.setFormatterFactory(numberMaskAndBlankFactory); txtEFP.setFormatterFactory(numberMaskAndBlankFactory); blastButton = new StopButton(btnBlast); mapButton = new StopButton(btnMapIDs); identButton = new StopButton(btnGTermIdent); fullButton = new StopButton(btnProcessFP); if (currentProj.getStage() >= 2) identify(false); }
From source file:org.kalypso.ogc.sensor.tableview.swing.tablemodel.ObservationTableModel.java
/** * Exports the contents of the model//ww w.jav a 2 s . c om */ public void dump(final String separator, final BufferedWriter writer) throws IOException { if (m_sharedModel.isEmpty()) return; final Object checkObject = m_sharedModel.first(); // will be used for formating the various columns final Format[] nf = new Format[m_columns.size() + 1]; // find appropriate format for shared column (Attention: can still be null) if (checkObject instanceof Date) nf[0] = TimeseriesUtils.getDateFormat(); else if (checkObject instanceof Integer) nf[0] = NumberFormat.getIntegerInstance(); else if (checkObject instanceof Number) nf[0] = NumberFormat.getNumberInstance(); // dump header and fetch numberformats writer.write(m_sharedAxis.getName()); if (nf[0] instanceof DateFormat) { final DateFormat df = (DateFormat) nf[0]; final TimeZone timeZone = df.getTimeZone(); if (timeZone != null) { writer.write(" ("); //$NON-NLS-1$ writer.write(timeZone.getID()); writer.write(")"); //$NON-NLS-1$ } } int col = 1; for (final Object element : m_columns) { final TableViewColumn tvc = (TableViewColumn) element; nf[col] = TimeseriesUtils.getNumberFormat(tvc.getFormat()); writer.write(separator); writer.write(tvc.getName()); col++; } writer.newLine(); // dump values int row = 0; for (final Object key : m_sharedModel) { writer.write(nf[0] == null ? key.toString() : nf[0].format(key)); col = 1; for (; col < getColumnCount(); col++) { final Object value = getValueAt(row, col); writer.write(separator); if (nf[col] != null && value != null) writer.write(nf[col].format(value)); else writer.write(""); //$NON-NLS-1$ } writer.newLine(); row++; } }