List of usage examples for java.awt List add
public void add(String item)
From source file:brainflow.app.presentation.controls.FileObjectGroupSelector.java
private java.util.List<FileObject> matchChildren(FileExplorer.FileObjectNode node, String regex, java.util.List<FileObject> fileList, int depth) { if (depth > recursiveDepth) return fileList; if (node.isLeaf()) { String name = node.getFileObject().getName().getPath(); if (name.matches(regex)) { fileList.add(node.getFileObject()); }/* ww w . j a v a2 s . com*/ } else { Enumeration e = node.children(); while (e.hasMoreElements()) { matchChildren((FileExplorer.FileObjectNode) e.nextElement(), regex, fileList, depth + 1); } } return fileList; }
From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithScatterPlot.java
public void addDataRedBlueHeatmap(double[] xValues, double[] yValues, double[] zValues, int numShades) { int numPoints = xValues.length; double minZ = Double.MAX_VALUE; double maxZ = Double.MIN_VALUE; for (double zValue : zValues) { if (zValue < minZ) minZ = zValue;//from w w w. j a v a 2 s . c om if (zValue > maxZ) maxZ = zValue; } double zRange = maxZ - minZ; for (int j = 0; j < numShades; j++) { double minZValThisGroup = minZ + j * zRange / numShades; double maxZValThisGroup = minZ + (j + 1) * zRange / numShades; int red = (255 / numShades) * j; int blue = 255 - (255 / numShades) * j; Color color = new Color(blue, 10, red); java.util.List<Float> thisGroupX = new ArrayList<Float>(); java.util.List<Float> thisGroupY = new ArrayList<Float>(); for (int k = 0; k < numPoints; k++) { if (zValues[k] <= maxZValThisGroup && zValues[k] >= minZValThisGroup) { thisGroupX.add((float) xValues[k]); thisGroupY.add((float) yValues[k]); //if (Double.isNaN(xValues[k]) || Double.isInfinite(xValues[k]) || // Double.isNaN(yValues[k]) || Double.isInfinite(yValues[k]))System.err.println(xValues[k] + " , " + yValues[k]); } } addData(thisGroupX, thisGroupY, "" + minZValThisGroup); // setSeriesColor(j, color); // setPointSize(3); } }
From source file:com.kbot2.scriptable.methods.data.Bank.java
/** * Deposits item by itemID.//from w w w .j a va2 s. c o m * * @param itemID to deposit if it exists. * @param count exact number, or Bank.MENU_ALL or Bank.MENU_ALL_BUT_ONE */ public void deposit(int itemID, int count) { java.util.List<Integer> dropPositions = new LinkedList<Integer>(); Item[] inventoryArray = botEnv.inventory.getItems(); for (int iterator1 = 0; iterator1 < inventoryArray.length; iterator1++) { if (inventoryArray[iterator1].isValid()) { if (inventoryArray[iterator1].getID() == itemID) dropPositions.add(iterator1); } } if (dropPositions.size() == 0) return; int[] ascending = new int[dropPositions.size()]; int index = 0; for (int pos : dropPositions) { ascending[index] = pos; index++; } Arrays.sort(ascending); // Random drop position int randomIndex = random(0, ascending.length - 1); int pos = ascending[randomIndex]; if (botEnv.methods.menu.isMenuOpen()) { botEnv.methods.atMenu("cancel"); } Point p = botEnv.inventory.getInventoryItemLoc(pos); botEnv.methods.moveMouse(p); botEnv.methods.sleep(random(20, 100)); if (count == MENU_ALL) { getMethods().atMenu("Deposit-All"); } else if (count == MENU_ALL_BUT_ONE) { getMethods().atMenu("Deposit-All but one"); } else { if (!getMethods().atMenu("Deposit-" + count)) { getMethods().atMenu("Deposit-X"); for (int i = 0; i < 21; i++) { if (botEnv.interfaces.interfaceGroupExists(752)) { getMethods().sendText("" + count, true); } getMethods().sleep(80, 130); } } } botEnv.methods.atMenu("drop"); botEnv.methods.sleep(random(150, 300)); }
From source file:com.kbot2.scriptable.methods.data.Bank.java
public void depositAllExcept(int... itemIDs) { Item[] items = botEnv.inventory.getItems(); java.util.List<Integer> out = new LinkedList<Integer>(); if (items == null) return;// w ww. java2s . c o m for (Item item : items) { if (item.getID() > 0) { boolean found = false; for (int id : itemIDs) { if (item.getID() == id) { found = true; } } if (!found) { for (int id : out) { if (id == item.getID()) { found = true; } } if (!found) { out.add(item.getID()); } } } } if (out.isEmpty()) return; depositAll(ArrayUtils.toPrimitive(out.toArray(new Integer[1]))); }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
public MainForm(final Application application) throws Exception { Log.info("Start in application mode, application \"" + application.getID() + '\"'); this.application = application; initComponents();/*from w w w . java2s .c om*/ this.setJMenuBar(application.lookup(JMenuBar.class)); this.popupMenu = application.lookup(JPopupMenu.class); hexMapPanelDesktop = new Desktop(); layers = new LayerListModel(256, 128); try { this.setIconImage(ImageIO.read(this.getClass().getClassLoader() .getResource("com/igormaznitsa/jhexed/swing/editor/icons/logo.png"))); } catch (Exception ex) { Log.error("Can't load app icon", ex); } hexMapPanel = new HexMapPanel(this.layers); hexMapPanel.addHexMapPanelListener(this); hexMapPanel.addMouseListener(this); hexMapPanel.addMouseMotionListener(this); hexMapPanel.addMouseWheelListener(this); final Image icon = application.getApplicationIcon(); if (icon != null) { this.setIconImage(icon); } final String title = application.getTitle(); if (title != null) { this.setTitle(title); } this.panelMainArea.removeAll(); setComponentForPosition(this.panelMainArea, UIComponentPosition.TOP_PANEL, application.getUIComponent(UIComponentPosition.TOP_PANEL)); setComponentForPosition(this.panelMainArea, UIComponentPosition.LEFT_PANEL, application.getUIComponent(UIComponentPosition.LEFT_PANEL)); setComponentForPosition(this.panelMainArea, UIComponentPosition.RIGHT_PANEL, application.getUIComponent(UIComponentPosition.RIGHT_PANEL)); setComponentForPosition(this.panelMainArea, UIComponentPosition.BOTTOM_PANEL, application.getUIComponent(UIComponentPosition.BOTTOM_PANEL)); this.panelMainArea.add(hexMapPanelDesktop, BorderLayout.CENTER); hexMapPanelDesktop.setContentPane(hexMapPanel); this.applicationGraphics = application.lookup(ApplicationGraphics.class); this.frameLayers = null; this.frameToolOptions = null; this.frameTools = null; this.dsl = null; this.groovyShell = null; this.compilerConfiguration = null; this.lookupContainer = new ObjectLookup(this, this.hexMapPanel.getHexEngine(), this, Log.makeApplicationLog()); final InputStream initialMap = application.getInitialMap(this); try { final FileContainer container = new FileContainer(initialMap); loadState(container); } catch (Exception ex) { Log.error("Can't load initial map data or read that", ex); throw ex; } finally { IOUtils.closeQuietly(initialMap); } loadSettings(); final java.util.List<HexLayer> listOfLayers = new ArrayList<HexLayer>(); for (int i = 0; i < this.layers.getSize(); i++) { final LayerRecordPanel alayer = this.layers.getElementAt(i); listOfLayers.add(alayer); } this.hexLayerList = Collections.unmodifiableList(listOfLayers); this.hexMapPanel.setZoom(1.0f); }
From source file:com.openbravo.pos.sales.JRetailPanelTicket.java
private java.util.List<TicketLineConstructor> getMoveTableLines(RetailTicketInfo ticket, Object ticketext, java.util.List<RetailTicketLineInfo> kot) { java.util.List<TicketLineConstructor> allLines = new ArrayList<TicketLineConstructor>(); double qtySum = 0; allLines.add(new TicketLineConstructor(" Move Table Ticket")); allLines.add(new TicketLineConstructor("Date: " + (ticket.printDate().substring(0, 12)) + getSpaces(16 - (ticket.printDate().substring(0, 12).length())) + "Time: " + (ticket.printTime())));/*w w w . j a v a 2s.c o m*/ allLines.add(new TicketLineConstructor( "Table " + ticket.getOldTableName() + " is moved to table " + ticket.getTableName())); allLines.add(new TicketLineConstructor(getDottedLine(70))); return allLines; }
From source file:com.openbravo.pos.sales.JRetailPanelTicket.java
private java.util.List<TicketLineConstructor> getNonChargeableLines(RetailTicketInfo ticket, Object ticketext) { java.util.List<TicketLineConstructor> allLines = new ArrayList<TicketLineConstructor>(); allLines.add(new TicketLineConstructor("Bill No:" + getSpaces(8) + ticket.getDocumentNo())); allLines.add(new TicketLineConstructor("Bill Date:" + getSpaces(6) + (ticket.printDate()))); allLines.add(new TicketLineConstructor("Customer:" + getSpaces(7) + (cusName.getText()))); allLines.add(new TicketLineConstructor("Table: " + getSpaces(9) + ticketext)); allLines.add(new TicketLineConstructor("Captain:" + getSpaces(8) + (ticket.printUser()))); allLines.add(new TicketLineConstructor(getDottedLine(90))); allLines.add(new TicketLineConstructor( "Description" + getSpaces(17) + "Qty" + getSpaces(14) + "Price" + getSpaces(9) + "Value(INR)")); allLines.add(new TicketLineConstructor(getDottedLine(90))); for (RetailTicketLineInfo tLine : ticket.getLines()) { String prodName = tLine.printName(); String qty = tLine.printMultiply(); String subValue = tLine.printPriceLine(); String total = "0.00"; allLines.add(new TicketLineConstructor(prodName + getSpaces(28 - prodName.length()) + qty + getSpaces(15 - qty.length() + 7 - subValue.length()) + subValue + getSpaces(9 - qty.length() + 11 - subValue.length()) + total)); }//from w ww .jav a 2 s .c o m allLines.add(new TicketLineConstructor(getDottedLine(90))); allLines.add(new TicketLineConstructor(getSpaces(33) + "Total " + getSpaces(25) + "0.00")); allLines.add(new TicketLineConstructor(getSpaces(33) + "Discount " + getSpaces(22) + "0.00")); allLines.add(new TicketLineConstructor(getSpaces(33) + "Total After Discount " + getSpaces(10) + "0.00")); if (ticket.getTaxes().size() != 0) { for (int i = 0; i < ticket.getTaxes().size(); i++) { if (ticket.getTaxes().get(i).getTax() != 0.00) { allLines.add(new TicketLineConstructor(getSpaces(33) + ticket.getTaxes().get(i).getTaxInfo().getName() + getSpaces(31 - ticket.getTaxes().get(i).getTaxInfo().getName().length()) + "0.00")); } } } String aCount = ticket.printTicketCount(); allLines.add(new TicketLineConstructor(getSpaces(33) + "Service Charge 6%" + getSpaces(14) + "0.00")); allLines.add(new TicketLineConstructor(getSpaces(33) + "Service Tax 4.94%" + getSpaces(14) + "0.00")); allLines.add(new TicketLineConstructor(getSpaces(33) + "Grand Total : " + getSpaces(17) + "0.00")); return allLines; }
From source file:com.openbravo.pos.sales.JRetailPanelTicket.java
private java.util.List<TicketLineConstructor> getAllLines(RetailTicketInfo ticket, Object ticketext) { java.util.List<TicketLineConstructor> allLines = new ArrayList<TicketLineConstructor>(); allLines.add(new TicketLineConstructor(m_App.getProperties().getProperty("machine.address1"))); allLines.add(new TicketLineConstructor(m_App.getProperties().getProperty("machine.address2"))); allLines.add(new TicketLineConstructor(m_App.getProperties().getProperty("machine.address3"))); allLines.add(new TicketLineConstructor(m_App.getProperties().getProperty("machine.vatno"))); allLines.add(new TicketLineConstructor(m_App.getProperties().getProperty("machine.strc"))); allLines.add(new TicketLineConstructor("User:" + getSpaces(1) + (ticket.printUser()))); allLines.add(new TicketLineConstructor(getDottedLine(35))); allLines.add(new TicketLineConstructor("Bill No : " + getSpaces(1) + ticket.printId())); allLines.add(new TicketLineConstructor("Table : " + getSpaces(1) + ticketext)); allLines.add(new TicketLineConstructor("Date : " + getSpaces(1) + (ticket.printDateForReceipt()) + getSpaces(2) + "Time: " + getSpaces(1) + (ticket.printTime()))); allLines.add(new TicketLineConstructor(getDottedLine(35))); allLines.add(new TicketLineConstructor("Item Name" + getSpaces(10) + "Qty" + getSpaces(5) + "Amount")); allLines.add(new TicketLineConstructor(getDottedLine(35))); for (RetailTicketLineInfo tLine : ticket.getUniqueLines()) { String prodName = tLine.printName(); String qty = tLine.printMultiply(); // if (ticket.getTaxes().size() != 0) { // for (Map.Entry<String, NameTaxMapInfo> entry : m_oTicket.getNametaxMap().entrySet()) { // String taxName = entry.getValue().getName(); // double taxValue = entry.getValue().getTaxValue(); // System.out.println("TAX. getSubValueBeforeDiscount() : "+tLine.getSubValueBeforeDiscount()+taxValue); // } // } String total = Formats.DoubleValue.formatValue(tLine.getSubValueBeforeDiscount()); if (prodName.length() > 22) { prodName = WordUtils.wrap(prodName, 22); String[] prodNameArray = prodName.split("\n"); for (int i = 0; i < prodNameArray.length - 1; i++) { allLines.add(new TicketLineConstructor(prodNameArray[i])); }/* w w w. ja v a 2s. c o m*/ allLines.add(new TicketLineConstructor(prodNameArray[prodNameArray.length - 1] + getSpaces(23 - prodNameArray[prodNameArray.length - 1].length()) + qty + getSpaces((10 - total.length())) + total)); } else { allLines.add(new TicketLineConstructor(prodName + getSpaces(23 - prodName.length()) + qty + getSpaces((10 - total.length())) + total)); } } allLines.add(new TicketLineConstructor(getSpaces(20) + getDottedLine(15))); String subTotal = Formats.DoubleValue.formatValue(ticket.getSubTotal()); String discount = ticket.printDiscount();//Formats.DoubleValue.formatValue(ticket.getLineDiscountOnCategory()); String totalAfrDiscount = Formats.DoubleValue.formatValue(ticket.getSubtotalAfterDiscount()); String roundoff = Formats.DoubleValue.formatValue(ticket.getRoundOffvalue()); String total = Formats.DoubleValue.formatValue(ticket.getTotal()); allLines.add(new TicketLineConstructor("SubTotal " + getSpaces(26 - subTotal.length()) + (subTotal))); allLines.add(new TicketLineConstructor(getSpaces(20) + getDottedLine(15))); allLines.add(new TicketLineConstructor("Discount " + getSpaces(25 - discount.length()) + ("-" + discount))); String aCount = ticket.printTicketCount(); //calling consolidated tax (logic applied to bring erp tax configuration) by Shilpa if (ticket.getTaxes().size() != 0) { for (Map.Entry<String, NameTaxMapInfo> entry : m_oTicket.getNametaxMap().entrySet()) { String taxName = entry.getValue().getName(); double taxValue = entry.getValue().getTaxValue(); if (taxValue != 0.00) { allLines.add(new TicketLineConstructor(taxName + getSpaces( 35 - (Formats.DoubleValue.formatValue(taxValue).length() + taxName.length())) + (Formats.DoubleValue.formatValue(taxValue)))); } } } allLines.add(new TicketLineConstructor(getSpaces(20) + getDottedLine(15))); allLines.add(new TicketLineConstructor("Total Amount : " + getSpaces(20 - total.length()) + (total))); allLines.add(new TicketLineConstructor(getSpaces(20) + getDottedLine(15))); allLines.add(new TicketLineConstructor("Thank you! Please Visit Us again")); return allLines; }
From source file:com.openbravo.pos.sales.JRetailPanelTicket.java
private java.util.List<TicketLineConstructor> getRetailAllLines(RetailTicketInfo ticket, Object ticketext, java.util.List<RetailTicketLineInfo> kot, int kotTicket, String floorName) { java.util.List<TicketLineConstructor> allLines = new ArrayList<TicketLineConstructor>(); double qtySum = 0; if ("Habanero-Jarota".equals(m_App.getProperties().getStoreName()) || "Habanero-Goa".equals(m_App.getProperties().getStoreName())) { allLines.add(new TicketLineConstructor(" " + floorName.toUpperCase())); } else {//from w w w .ja v a2s . c o m allLines.add(new TicketLineConstructor(" KITCHEN ORDER TICKET")); } allLines.add(new TicketLineConstructor("Date: " + (ticket.printDate().substring(0, 12)) + getSpaces(13 - (ticket.printDate().substring(0, 12).length())) + "Kot No: " + kotTicket)); allLines.add(new TicketLineConstructor( "Time: " + (ticket.printTime()) + getSpaces(13 - (ticket.printTime().length())) + "Table No:" + getSpaces(1) + ticket.getName(m_oTicketExt))); allLines.add(new TicketLineConstructor("User Name: " + (m_oTicket.getUser()).getName())); allLines.add(new TicketLineConstructor(getDottedLine(40))); for (RetailTicketLineInfo tLine : kot) { String prodName = tLine.printName(); String qty = tLine.printMultiply(); qtySum = qtySum + tLine.getMultiply(); String instruction = tLine.printInstruction(); if (prodName.length() > 28) { prodName = WordUtils.wrap(prodName, 28); String[] prodNameArray = prodName.split("\n"); for (int i = 0; i < prodNameArray.length - 1; i++) { allLines.add(new TicketLineConstructor(prodNameArray[i])); } allLines.add(new TicketLineConstructor(prodNameArray[prodNameArray.length - 1] + getSpaces(30 - prodNameArray[prodNameArray.length - 1].length()) + qty)); if (instruction != null) { if (instruction.length() > 0) { // each instruction will be added/differentiated with the ';' String[] splitInstructValue = instruction.split(";"); for (int i = 0; i < splitInstructValue.length; i++) { if (splitInstructValue[i].length() > 0) { allLines.add(new TicketLineConstructor("I-[" + splitInstructValue[i] + "]")); } } } } } else { allLines.add(new TicketLineConstructor(prodName + getSpaces(30 - prodName.length()) + qty)); if (instruction != null) { if (instruction.length() > 0) { String[] splitInstructValue = instruction.split(";"); for (int i = 0; i < splitInstructValue.length; i++) { if (splitInstructValue[i].length() > 0) { allLines.add(new TicketLineConstructor("I-[" + splitInstructValue[i] + "]")); } } } } } } allLines.add(new TicketLineConstructor(" ")); allLines.add(new TicketLineConstructor(" ")); allLines.add(new TicketLineConstructor(" ")); allLines.add(new TicketLineConstructor(" ")); allLines.add(new TicketLineConstructor("------------------ ")); logger.info("sum of kot quantities = " + qtySum); return allLines; }
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 www .j a v a2 s . com 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"); } } } }