List of usage examples for java.awt List add
public void add(String item)
From source file:org.yccheok.jstock.gui.JStock.java
private StockNameDatabase loadStockNameDatabaseFromCSV(Country country) { final File stockNameDatabaseCSVFile = new File(org.yccheok.jstock.gui.Utils.getUserDataDirectory() + country + File.separator + "database" + File.separator + "stock-name-database.csv"); Statements statements = Statements.newInstanceFromCSVFile(stockNameDatabaseCSVFile); if (statements.getType() != Statement.Type.StockNameDatabase) { return null; }/*w w w . j a v a 2 s .co m*/ java.util.List<Stock> stocks = new ArrayList<Stock>(); for (int i = 0, ei = statements.size(); i < ei; i++) { Statement statement = statements.get(i); Atom atom0 = statement.getAtom(0); Atom atom1 = statement.getAtom(1); Code code = Code.newInstance(atom0.getValue().toString()); String name = atom1.getValue().toString(); // Symbol doesn't matter. Just provide a dummy value for it. Stock stock = new Stock.Builder(code, Symbol.newInstance(code.toString())).name(name).build(); stocks.add(stock); } return new StockNameDatabase(stocks); }
From source file:org.yccheok.jstock.gui.JStock.java
private StockInfoDatabase loadStockInfoDatabaseFromCSV(Country country) { final File stockInfoDatabaseCSVFile = org.yccheok.jstock.engine.Utils.getStockInfoDatabaseFile(country); Statements statements = Statements.newInstanceFromCSVFile(stockInfoDatabaseCSVFile); if (statements.getType() != Statement.Type.StockInfoDatabase) { return null; }/*from www . j a v a 2 s .c om*/ java.util.List<Stock> stocks = new ArrayList<Stock>(); for (int i = 0, ei = statements.size(); i < ei; i++) { Statement statement = statements.get(i); Atom atom0 = statement.getAtom(0); Atom atom1 = statement.getAtom(1); Atom atom2 = statement.getAtom(2); Atom atom3 = statement.getAtom(3); Code code = Code.newInstance(atom0.getValue().toString()); Symbol symbol = Symbol.newInstance(atom1.getValue().toString()); Industry industry = Industry.Unknown; Board board = Board.Unknown; try { industry = Industry.valueOf(atom2.getValue().toString()); } catch (Exception exp) { log.error(null, exp); } try { board = Board.valueOf(atom3.getValue().toString()); } catch (Exception exp) { log.error(null, exp); } Stock stock = new Stock.Builder(code, symbol).board(board).industry(industry).build(); stocks.add(stock); } return new StockInfoDatabase(stocks); }
From source file:org.yccheok.jstock.gui.JStock.java
private static java.util.List<Pair<Code, Symbol>> getUserDefinedPair(StockInfoDatabase stockInfoDatabase) { java.util.List<Pair<Code, Symbol>> pairs = new ArrayList<Pair<Code, Symbol>>(); java.util.List<StockInfo> stockInfos = stockInfoDatabase.getUserDefinedStockInfos(); for (StockInfo stockInfo : stockInfos) { pairs.add(new Pair(stockInfo.code, stockInfo.symbol)); }/*from w w w . ja va 2s. c o m*/ return pairs; }
From source file:org.yccheok.jstock.gui.JTableUtilities.java
/** * Get the keys for a given string and locale. * * @param string the string for the desired key * @param locale the locale for the desired key * @return the keys for a given string and locale *//* w ww.j a va2s .c o m*/ private static java.util.List<String> getKeys(String string, Locale locale) { if (string2KeyMap.containsKey(locale)) { final Map<String, java.util.List<String>> string2Key = string2KeyMap.get(locale); final java.util.List<String> result = string2Key.get(string); if (result == null) { return java.util.Collections.EMPTY_LIST; } return result; } final Map<String, java.util.List<String>> string2Key = new HashMap<String, java.util.List<String>>(); // Ensure correct resource file is being loaded. // When ResourceBundle.getBundle(..., locale) is being called, the // system will try to search in the following sequence. // 1. gui_<locale>.properties. // 2. gui_<default_locale>.properties. // 3. gui.properties. final Locale oldLocale = Locale.getDefault(); Locale.setDefault(locale); try { final ResourceBundle bundle = ResourceBundle.getBundle("org.yccheok.jstock.data.gui", locale); final Enumeration<String> enumeration = bundle.getKeys(); while (enumeration.hasMoreElements()) { final String key = enumeration.nextElement(); final String str = bundle.getString(key); java.util.List list = string2Key.get(str); if (list == null) { list = new ArrayList<String>(); string2Key.put(str, list); } list.add(key); } string2KeyMap.put(locale, string2Key); } finally { Locale.setDefault(oldLocale); } final java.util.List<String> result = string2Key.get(string); if (result == null) { return java.util.Collections.EMPTY_LIST; } return result; }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.queryresultspanel.QueryResultsPanel.java
/** * Hide concept Id and Entry time columns. * /*from www. j a va 2 s. c o m*/ * We know that column's follow the generic pattern : Concept_ID, Entry_Time, Free_Text_Entry * So we use this pattern to hide columns, 1 and 2 of the series. Note this patterns will change if * the table model is changed to use clinical entries. */ public void renderColumns() { java.util.List<TableColumnExt> cols = new ArrayList<TableColumnExt>(); for (int i = 0; i < resultsTable.getColumnCount(true); i++) { cols.add(resultsTable.getColumnExt(i)); } for (int i = 0; i < cols.size(); i++) { TableColumnExt col = cols.get(i); col.setCellRenderer(new QueryResultsTableCellRenderer()); if (i % 3 == 0) { // set column visible col.setVisible(true); } else { col.setVisible(false); } } }