List of usage examples for java.awt List size
@Deprecated
public Dimension size()
From source file:org.yccheok.jstock.gui.JStock.java
private void portfolioNavigation() { if (this.getSelectedComponent() != this.portfolioManagementJPanel) { // The page is not active. Make it active. JStock.this.jTabbedPane1.setSelectedIndex(3); return;// www .java2 s .c o m } final java.util.List<String> portfolioNames = org.yccheok.jstock.portfolio.Utils.getPortfolioNames(); final int size = portfolioNames.size(); if (size <= 1) { // Nothing to navigate. return; } final String currentPortfolioName = this.getJStockOptions().getPortfolioName(); int index = 0; for (; index < size; index++) { if (portfolioNames.get(index).equals(currentPortfolioName)) { index++; if (index >= size) index = 0; break; } } this.selectActivePortfolio(portfolioNames.get(index)); }
From source file:org.yccheok.jstock.gui.JStock.java
private void watchlistNavigation() { if (this.getSelectedComponent() != this.jPanel8) { // The page is not active. Make it active. JStock.this.jTabbedPane1.setSelectedIndex(0); return;/*ww w . j av a 2 s . c o m*/ } final java.util.List<String> watchlistNames = org.yccheok.jstock.watchlist.Utils.getWatchlistNames(); final int size = watchlistNames.size(); if (size <= 1) { // Nothing to navigate. return; } final String currentWatchlistName = this.getJStockOptions().getWatchlistName(); int index = 0; for (; index < size; index++) { if (watchlistNames.get(index).equals(currentWatchlistName)) { index++; if (index >= size) index = 0; break; } } this.selectActiveWatchlist(watchlistNames.get(index)); }
From source file:org.yccheok.jstock.gui.MainFrame.java
private void update(RealTimeStockMonitor monitor, final java.util.List<Stock> stocks) { // We need to ignore symbol names given by stock server. Replace them // with database's. final boolean isSymbolImmutable = org.yccheok.jstock.engine.Utils.isSymbolImmutable(); for (int i = 0, size = stocks.size(); i < size; i++) { final Stock stock = stocks.get(i); Stock new_stock = stock; // Sometimes server goes crazy by returning empty symbol. if (isSymbolImmutable || new_stock.symbol.toString().isEmpty()) { // Use local variable to ensure thread safety. final StockInfoDatabase stock_info_database = this.stockInfoDatabase; //final StockNameDatabase name_database = this.stockNameDatabase; if (stock_info_database != null) { final Symbol symbol = stock_info_database.codeToSymbol(stock.code); if (symbol != null) { new_stock = new_stock.deriveStock(symbol); } else { // Shouldn't be null. Let's give some warning on this. log.error("Wrong stock code " + stock.code + " given by stock server."); }//from w ww .jav a 2s . c om } else { // stockCodeAndSymbolDatabase is not ready yet. Use the information // from stock table. final StockTableModel tableModel = (StockTableModel) jTable1.getModel(); final int row = tableModel.findRow(stock); if (row >= 0) { final Symbol symbol = tableModel.getStock(row).symbol; new_stock = new_stock.deriveStock(symbol); } } // if (symbol_database != null) // Doesn't matter, as we do not need to show "name" in table. // Need not to perform derive for speed optimization. //if (org.yccheok.jstock.engine.Utils.isNameImmutable()) { // if (name_database != null) { // final String name = name_database.codeToName(stock.code); // if (name != null) { // new_stock = new_stock.deriveStock(name); // } else { // // Shouldn't be null. Let's give some warning on this. // log.error("Wrong stock code " + stock.code + " given by stock server."); // } // } else { // // stockNameDatabase is not ready yet. Use the information // // from stock table. // final StockTableModel tableModel = (StockTableModel)jTable1.getModel(); // final int row = tableModel.findRow(stock); // if (row >= 0) { // final String name = tableModel.getStock(row).getName(); // new_stock = new_stock.deriveStock(name); // } // } //} if (stock != new_stock) { stocks.set(i, new_stock); } } // if (isSymbolImmutable || new_stock.symbol.toString().isEmpty()) } // for (int i = 0, size = stocks.size(); i < size; i++) // Update status bar with current time string. this.timestamp = System.currentTimeMillis(); ((StockTableModel) jTable1.getModel()).setTimestamp(this.timestamp); MainFrame.getInstance().updateStatusBarWithLastUpdateDateMessageIfPossible(); // Do it in GUI event dispatch thread. Otherwise, we may face deadlock. // For example, we lock the jTable, and try to remove the stock from the // real time monitor. While we wait for the real time monitor to complete, // real time monitor will call this function and, be locked at function // updateStockToTable. javax.swing.SwingUtilities.invokeLater(new Runnable() { @Override public void run() { for (Stock stock : stocks) { updateStockToTable(stock); if (isStockBeingSelected(stock)) { MainFrame.this.updateDynamicChart(stock); } } } }); // Dynamic charting. Intraday trader might love this. for (Stock stock : stocks) { final Code code = stock.code; DynamicChart dynamicChart = this.dynamicCharts.get(code); if (dynamicChart == null) { // Not found. Try to create a new dynamic chart. if (this.dynamicCharts.size() <= MainFrame.MAX_DYNAMIC_CHART_SIZE) { dynamicChart = new DynamicChart(); this.dynamicCharts.put(code, dynamicChart); } else { // Full already. Shall we remove? if (this.isStockBeingSelected(stock)) { Set<Code> codes = this.dynamicCharts.keySet(); for (Code c : codes) { // Random remove. We do not care who is being removed. this.dynamicCharts.remove(c); if (this.dynamicCharts.size() <= MainFrame.MAX_DYNAMIC_CHART_SIZE) { // Remove success. break; } } dynamicChart = new DynamicChart(); this.dynamicCharts.put(code, dynamicChart); } } } /* if (dynamicChart == null) */ // Still null? if (dynamicChart == null) { // This usually indicate that dynamic chart list is full, and // no one is selecting this particular stock. continue; } if (this.isStockBeingSelected(stock)) { dynamicChart.addPriceObservation(stock.getTimestamp(), stock.getLastPrice()); final Stock s = stock; javax.swing.SwingUtilities.invokeLater(new Runnable() { @Override public void run() { MainFrame.this.updateDynamicChart(s); } }); } else { // Although no one is watching at us, we still need to perform notification. // Weird? dynamicChart.addPriceObservation(stock.getTimestamp(), stock.getLastPrice()); } } /* for (Stock stock : stocks) */ // No alert is needed. Early return. if ((jStockOptions.isSMSEnabled() == false) && (jStockOptions.isPopupMessage() == false) && (jStockOptions.isSoundEnabled() == false) && (jStockOptions.isSendEmail() == false)) { return; } final StockTableModel stockTableModel = (StockTableModel) jTable1.getModel(); for (Stock stock : stocks) { final Double fallBelow = stockTableModel.getFallBelow(stock); if (fallBelow != null) { final Indicator indicator = Utils.getLastPriceFallBelowIndicator(fallBelow); indicator.setStock(stock); alertStateManager.alert(indicator); } else { /* * Having FALL_BELOW_INDICATOR and RISE_ABOVE_INDICATOR, is to enable us * to remove a particular indicator from AlertStateManager, without the need * to call time-consuming getLastPriceFallBelowIndicator and * getLastPriceRiseAboveIndicator. In order for indicator to perform * correctly, we need to call indicator's mutable method (setStock). * However, since FALL_BELOW_INDICATOR and RISE_ABOVE_INDICATOR are * sharable variables, we are not allowed to call setStock outside * synchronized block. We need to perfrom a hacking liked workaround * Within syncrhonized block, call getStock (To get old stock), setStock and * restore back old stock. */ alertStateManager.clearState(FALL_BELOW_INDICATOR, stock); } final Double riseAbove = stockTableModel.getRiseAbove(stock); if (riseAbove != null) { final Indicator indicator = Utils.getLastPriceRiseAboveIndicator(riseAbove); indicator.setStock(stock); alertStateManager.alert(indicator); } else { /* * Having FALL_BELOW_INDICATOR and RISE_ABOVE_INDICATOR, is to enable us * to remove a particular indicator from AlertStateManager, without the need * to call time-consuming getLastPriceFallBelowIndicator and * getLastPriceRiseAboveIndicator. In order for indicator to perform * correctly, we need to call indicator's mutable method (setStock). * However, since FALL_BELOW_INDICATOR and RISE_ABOVE_INDICATOR are * sharable variables, we are not allowed to call setStock outside * synchronized block. We need to perfrom a hacking liked workaround * Within syncrhonized block, call getStock (To get old stock), setStock and * restore back old stock. */ alertStateManager.clearState(RISE_ABOVE_INDICATOR, stock); } } }
From source file:org.yccheok.jstock.gui.JStock.java
private boolean initCSVWatchlist() { java.util.List<String> availableWatchlistNames = org.yccheok.jstock.watchlist.Utils.getWatchlistNames(); // Do we have any watchlist for this country? if (availableWatchlistNames.size() <= 0) { // If not, create an empty watchlist. org.yccheok.jstock.watchlist.Utils .createEmptyWatchlist(org.yccheok.jstock.watchlist.Utils.getDefaultWatchlistName()); availableWatchlistNames = org.yccheok.jstock.watchlist.Utils.getWatchlistNames(); }/* w w w . j av a2s .co m*/ assert (availableWatchlistNames.isEmpty() == false); // Is user selected watchlist name within current available watchlist names? if (false == availableWatchlistNames.contains(jStockOptions.getWatchlistName())) { // Nope. Reset user selected watchlist name to the first available name. jStockOptions.setWatchlistName(availableWatchlistNames.get(0)); } // openAsCSVFile will "append" stocks. We need to clear previous stocks // explicitly. // Clear the previous data structures. clearAllStocks(); File realTimeStockFile = org.yccheok.jstock.watchlist.Utils .getWatchlistFile(org.yccheok.jstock.watchlist.Utils.getWatchlistDirectory()); return this.openAsCSVFile(realTimeStockFile); }
From source file:org.yccheok.jstock.gui.JStock.java
private void solveCaseSensitiveFoldersIssue() { final Country currentCountry = this.jStockOptions.getCountry(); final String currentWatchlist = this.jStockOptions.getWatchlistName(); final String currentPortfolio = this.jStockOptions.getPortfolioName(); //////////////////////////////////////////////////////////////////////// // WATCHLIST/* w w w .j a va2s .c o m*/ //////////////////////////////////////////////////////////////////////// for (Country country : Country.values()) { java.util.List<String> watchlistNames = org.yccheok.jstock.watchlist.Utils.getWatchlistNames(country); Map<String, java.util.List<String>> watchlistNamesMap = new HashMap<String, java.util.List<String>>(); java.util.List<java.util.List<String>> duplicatedNames = new ArrayList<java.util.List<String>>(); Set<String> lowerCaseNames = new HashSet<String>(); for (String watchlistName : watchlistNames) { String lowerCaseWatchlistName = watchlistName.toLowerCase(); lowerCaseNames.add(lowerCaseWatchlistName); java.util.List<String> names = watchlistNamesMap.get(lowerCaseWatchlistName); if (names == null) { names = new ArrayList<String>(); watchlistNamesMap.put(lowerCaseWatchlistName, names); } names.add(watchlistName); if (names.size() > 1) { duplicatedNames.add(names); } } for (java.util.List<String> names : duplicatedNames) { int counter = 0; boolean originalNameUsed = false; for (int i = 0, ei = names.size(); i < ei; i++) { final String originalName = names.get(i); if (currentCountry == country && currentWatchlist.equals(originalName)) { originalNameUsed = true; continue; } String newName = originalName; if (originalNameUsed || i < (ei - 1)) { // Cannot use the original name. newName = originalName + counter++; while (lowerCaseNames.contains(newName.toLowerCase())) { newName = originalName + counter++; } lowerCaseNames.add(newName.toLowerCase()); } else { // Use original name. originalNameUsed = true; } String originalDirectory = org.yccheok.jstock.watchlist.Utils.getWatchlistDirectory(country, originalName); String newDirectory = org.yccheok.jstock.watchlist.Utils.getWatchlistDirectory(country, newName); if (false == originalDirectory.equalsIgnoreCase(newDirectory)) { new File(originalDirectory).renameTo(new File(newDirectory)); } } } } //////////////////////////////////////////////////////////////////////// // PORTFOLIO //////////////////////////////////////////////////////////////////////// for (Country country : Country.values()) { java.util.List<String> portfolioNames = org.yccheok.jstock.portfolio.Utils.getPortfolioNames(country); Map<String, java.util.List<String>> portfolioNamesMap = new HashMap<String, java.util.List<String>>(); java.util.List<java.util.List<String>> duplicatedNames = new ArrayList<java.util.List<String>>(); Set<String> lowerCaseNames = new HashSet<String>(); for (String portfolioName : portfolioNames) { String lowerCasePortfolioName = portfolioName.toLowerCase(); lowerCaseNames.add(lowerCasePortfolioName); java.util.List<String> names = portfolioNamesMap.get(lowerCasePortfolioName); if (names == null) { names = new ArrayList<String>(); portfolioNamesMap.put(lowerCasePortfolioName, names); } names.add(portfolioName); if (names.size() > 1) { duplicatedNames.add(names); } } for (java.util.List<String> names : duplicatedNames) { int counter = 0; boolean originalNameUsed = false; for (int i = 0, ei = names.size(); i < ei; i++) { final String originalName = names.get(i); if (currentCountry == country && currentPortfolio.equals(originalName)) { originalNameUsed = true; continue; } String newName = originalName; if (originalNameUsed || i < (ei - 1)) { // Cannot use the original name. newName = originalName + counter++; while (lowerCaseNames.contains(newName.toLowerCase())) { newName = originalName + counter++; } lowerCaseNames.add(newName.toLowerCase()); } else { // Use original name. originalNameUsed = true; } String originalDirectory = org.yccheok.jstock.portfolio.Utils.getPortfolioDirectory(country, originalName); String newDirectory = org.yccheok.jstock.portfolio.Utils.getPortfolioDirectory(country, newName); if (false == originalDirectory.equalsIgnoreCase(newDirectory)) { new File(originalDirectory).renameTo(new File(newDirectory)); } } } } }
From source file:org.yccheok.jstock.gui.JStock.java
private void update(RealTimeStockMonitor monitor, final java.util.List<Stock> stocks) { // We need to ignore symbol names given by stock server. Replace them // with database's. final boolean isSymbolImmutable = org.yccheok.jstock.engine.Utils.isSymbolImmutable(); for (int i = 0, size = stocks.size(); i < size; i++) { final Stock stock = stocks.get(i); Stock new_stock = stock; // Sometimes server goes crazy by returning empty symbol. if (isSymbolImmutable || new_stock.symbol.toString().isEmpty()) { // Use local variable to ensure thread safety. final StockInfoDatabase stock_info_database = this.stockInfoDatabase; //final StockNameDatabase name_database = this.stockNameDatabase; if (stock_info_database != null) { final Symbol symbol = stock_info_database.codeToSymbol(stock.code); if (symbol != null) { new_stock = new_stock.deriveStock(symbol); } else { // Shouldn't be null. Let's give some warning on this. log.error("Wrong stock code " + stock.code + " given by stock server."); }//from w ww . j av a 2 s . c o m } else { // stockCodeAndSymbolDatabase is not ready yet. Use the information // from stock table. final StockTableModel tableModel = (StockTableModel) jTable1.getModel(); final int row = tableModel.findRow(stock); if (row >= 0) { final Symbol symbol = tableModel.getStock(row).symbol; new_stock = new_stock.deriveStock(symbol); } } // if (symbol_database != null) // Doesn't matter, as we do not need to show "name" in table. // Need not to perform derive for speed optimization. //if (org.yccheok.jstock.engine.Utils.isNameImmutable()) { // if (name_database != null) { // final String name = name_database.codeToName(stock.code); // if (name != null) { // new_stock = new_stock.deriveStock(name); // } else { // // Shouldn't be null. Let's give some warning on this. // log.error("Wrong stock code " + stock.code + " given by stock server."); // } // } else { // // stockNameDatabase is not ready yet. Use the information // // from stock table. // final StockTableModel tableModel = (StockTableModel)jTable1.getModel(); // final int row = tableModel.findRow(stock); // if (row >= 0) { // final String name = tableModel.getStock(row).getName(); // new_stock = new_stock.deriveStock(name); // } // } //} if (stock != new_stock) { stocks.set(i, new_stock); } } // if (isSymbolImmutable || new_stock.symbol.toString().isEmpty()) } // for (int i = 0, size = stocks.size(); i < size; i++) // Update status bar with current time string. this.timestamp = System.currentTimeMillis(); ((StockTableModel) jTable1.getModel()).setTimestamp(this.timestamp); JStock.instance().updateStatusBarWithLastUpdateDateMessageIfPossible(); // Do it in GUI event dispatch thread. Otherwise, we may face deadlock. // For example, we lock the jTable, and try to remove the stock from the // real time monitor. While we wait for the real time monitor to complete, // real time monitor will call this function and, be locked at function // updateStockToTable. javax.swing.SwingUtilities.invokeLater(new Runnable() { @Override public void run() { for (Stock stock : stocks) { updateStockToTable(stock); if (isStockBeingSelected(stock)) { JStock.this.updateDynamicChart(stock); } } } }); // Dynamic charting. Intraday trader might love this. for (Stock stock : stocks) { final Code code = stock.code; DynamicChart dynamicChart = this.dynamicCharts.get(code); if (dynamicChart == null) { // Not found. Try to create a new dynamic chart. if (this.dynamicCharts.size() <= JStock.MAX_DYNAMIC_CHART_SIZE) { dynamicChart = new DynamicChart(); this.dynamicCharts.put(code, dynamicChart); } else { // Full already. Shall we remove? if (this.isStockBeingSelected(stock)) { Set<Code> codes = this.dynamicCharts.keySet(); for (Code c : codes) { // Random remove. We do not care who is being removed. this.dynamicCharts.remove(c); if (this.dynamicCharts.size() <= JStock.MAX_DYNAMIC_CHART_SIZE) { // Remove success. break; } } dynamicChart = new DynamicChart(); this.dynamicCharts.put(code, dynamicChart); } } } /* if (dynamicChart == null) */ // Still null? if (dynamicChart == null) { // This usually indicate that dynamic chart list is full, and // no one is selecting this particular stock. continue; } if (this.isStockBeingSelected(stock)) { dynamicChart.addPriceObservation(stock.getTimestamp(), stock.getLastPrice()); final Stock s = stock; javax.swing.SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JStock.this.updateDynamicChart(s); } }); } else { // Although no one is watching at us, we still need to perform notification. // Weird? dynamicChart.addPriceObservation(stock.getTimestamp(), stock.getLastPrice()); } } /* for (Stock stock : stocks) */ // No alert is needed. Early return. if ((jStockOptions.isPopupMessage() == false) && (jStockOptions.isSoundEnabled() == false) && (jStockOptions.isSendEmail() == false)) { return; } final StockTableModel stockTableModel = (StockTableModel) jTable1.getModel(); for (Stock stock : stocks) { final Double fallBelow = stockTableModel.getFallBelow(stock); if (fallBelow != null) { final Indicator indicator = Utils.getLastPriceFallBelowIndicator(fallBelow); indicator.setStock(stock); alertStateManager.alert(indicator); } else { /* * Having FALL_BELOW_INDICATOR and RISE_ABOVE_INDICATOR, is to enable us * to remove a particular indicator from AlertStateManager, without the need * to call time-consuming getLastPriceFallBelowIndicator and * getLastPriceRiseAboveIndicator. In order for indicator to perform * correctly, we need to call indicator's mutable method (setStock). * However, since FALL_BELOW_INDICATOR and RISE_ABOVE_INDICATOR are * sharable variables, we are not allowed to call setStock outside * synchronized block. We need to perfrom a hacking liked workaround * Within syncrhonized block, call getStock (To get old stock), setStock and * restore back old stock. */ alertStateManager.clearState(FALL_BELOW_INDICATOR, stock); } final Double riseAbove = stockTableModel.getRiseAbove(stock); if (riseAbove != null) { final Indicator indicator = Utils.getLastPriceRiseAboveIndicator(riseAbove); indicator.setStock(stock); alertStateManager.alert(indicator); } else { /* * Having FALL_BELOW_INDICATOR and RISE_ABOVE_INDICATOR, is to enable us * to remove a particular indicator from AlertStateManager, without the need * to call time-consuming getLastPriceFallBelowIndicator and * getLastPriceRiseAboveIndicator. In order for indicator to perform * correctly, we need to call indicator's mutable method (setStock). * However, since FALL_BELOW_INDICATOR and RISE_ABOVE_INDICATOR are * sharable variables, we are not allowed to call setStock outside * synchronized block. We need to perfrom a hacking liked workaround * Within syncrhonized block, call getStock (To get old stock), setStock and * restore back old stock. */ alertStateManager.clearState(RISE_ABOVE_INDICATOR, stock); } } }
From source file:com.openbravo.pos.sales.JRetailPanelTicket.java
private synchronized void printRetailMoveTableTicket(RetailTicketInfo ticket, java.util.List<RetailTicketLineInfo> kot, Object ticketExt, java.util.List<ProductionPrinterInfo> printerInfo) { java.util.List<TicketLineConstructor> allLines = null; logger.info("start printing the kot" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date())); com.openbravo.pos.printer.printer.KotImagePrinter printer = new KotImagePrinter(); kotTicketlist = kot;/*from w w w . jav a 2s. c om*/ for (int j = 0; j < printerInfo.size(); j++) { java.util.List<RetailTicketLineInfo> uniqueProductionAreas = new ArrayList<RetailTicketLineInfo>(); for (int i = 0; i < kotTicketlist.size(); i++) { if (printerInfo.get(j).getProductionAreaType() .equals(kotTicketlist.get(i).getProductionAreaType())) { uniqueProductionAreas.add(kotTicketlist.get(i)); } } logger.info("kot print count based on production areas" + uniqueProductionAreas.size()); if (uniqueProductionAreas.size() != 0) { allLines = getMoveTableLines(ticket, ticketExt, uniqueProductionAreas); try { printer.printKot(allLines, printerInfo.get(j).getPath()); } catch (PrinterException ex) { logger.info("Order NO." + m_oTicket.getOrderId() + " The printer action" + ex.getMessage()); showMessage(this, "Print Unsucessfull! Please retry"); } } } }
From source file:com.openbravo.pos.sales.JRetailPanelTicket.java
private final synchronized void setKotServedAndPrintOnSplit(final RetailTicketInfo splitTicket) throws BasicException { Transaction t = new Transaction(m_App.getSession()) { @Override//from w ww. j ava2s .co m protected Object transact() throws BasicException { int orderId = 0; orderId = dlSales.getNextTicketOrderNumber(); splitTicket.setOrderId(orderId); String storeLocation = m_App.getProperties().getProperty("machine.storelocation"); doPrintValidation(); String file; file = "Printer.Bill"; try { taxeslogic.calculateTaxes(m_oTicket); consolidateTaxes(m_oTicket); } catch (TaxesException ex) { logger.info("Order NO." + m_oTicket.getOrderId() + "exception in setKotAndServedOnSplit calculateTaxes" + ex.getMessage()); Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } if (storeLocation.equals("BlrIndranagar") || storeLocation.equals("ITPL")) { printTicketGeneric(file, m_oTicket, m_oTicketExt); } else { printTicket(file, m_oTicket, m_oTicketExt); } splitTicket.setPrinted(true); final java.util.List<RetailTicketLineInfo> panelLines = splitTicket.getLines(); for (final RetailTicketLineInfo l : panelLines) { l.setIsKot(1); l.setPreparationStatus(3); String tbl_orderitemId = UUID.randomUUID().toString(); tbl_orderitemId = tbl_orderitemId.replaceAll("-", ""); l.setTbl_orderId(tbl_orderitemId); setServedStatus(1); } for (int i = 0; i < panelLines.size(); i++) { paintKotTicketLine(i, splitTicket.getLine(i)); setServedStatus(0); } return null; } }; t.execute(); }
From source file:com.openbravo.pos.sales.JRetailPanelTicket.java
private synchronized void printCancelKotTicket(RetailTicketInfo ticket, RetailTicketLineInfo kotLine, Object ticketExt, java.util.List<ProductionPrinterInfo> printerInfo) { java.util.List<TicketLineConstructor> allLines = null; String productionAreaName = ""; String storeLocation = m_App.getProperties().getProperty("machine.storelocation"); logger.info("cancel kot" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date())); com.openbravo.pos.printer.printer.KotImagePrinter printer = new KotImagePrinter(); com.openbravo.pos.printer.printer.KotBillPrinter printerKot = new KotBillPrinter(); for (int j = 0; j < printerInfo.size(); j++) { if (printerInfo.get(j).getProductionAreaType().equals(kotLine.getProductionAreaType())) { productionAreaName = printerInfo.get(j).getName(); allLines = getCancelKotLines(ticket, ticketExt, kotLine, productionAreaName); try { if (storeLocation.equals("BlrIndranagar")) { printer.printKot(allLines, printerInfo.get(j).getPath()); } else { printerKot.print(allLines, printerInfo.get(j).getPath()); }//w ww .j av a 2 s . c o m break; } catch (PrinterException ex) { Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:com.openbravo.pos.sales.JRetailPanelTicket.java
private void printTicketGeneric(String sresourcename, RetailTicketInfo ticket, Object ticketext) { java.util.List<TicketLineConstructor> allLines = null; java.util.List<TicketLineConstructor> startallLines = new ArrayList<TicketLineConstructor>(); int count = 0; com.openbravo.pos.printer.printer.ImageBillPrinter printer = new ImageBillPrinter(); if (sresourcename.equals("Printer.Bill")) { allLines = getAllLines(ticket, ticketext); } else if (sresourcename.equals("Printer.NonChargableBill")) { allLines = getNonChargeableLines(ticket, ticketext); }//from w ww . j a va 2 s.c om int divideLines = allLines.size() / 48; int remainder = allLines.size() % 48; int value = 48; int k = 0; if (divideLines > 0) { for (int i = 0; i < divideLines; i++) { for (int j = k; j < value; j++) { startallLines.add(new TicketLineConstructor(allLines.get(j).getLine())); } try { printer.print(startallLines); } catch (PrinterException ex) { Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } if (allLines.size() > 48) { try { Thread.sleep(5000); } catch (InterruptedException ex) { Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } int res = JOptionPane.showConfirmDialog(this, AppLocal.getIntString("message.wannaPrintcontinue"), AppLocal.getIntString("message.title"), JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE); if (res == JOptionPane.OK_OPTION) { k = value; value = value + 48; startallLines = new ArrayList<TicketLineConstructor>(); startallLines.clear(); } else { break; } } } } if (remainder > 0) { startallLines = new ArrayList<TicketLineConstructor>(); startallLines.clear(); for (int m = k; m < k + remainder; m++) { startallLines.add(new TicketLineConstructor(allLines.get(m).getLine())); } try { printer.print(startallLines); } catch (PrinterException ex) { Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } } }