Example usage for java.awt List size

List of usage examples for java.awt List size

Introduction

In this page you can find the example usage for java.awt List size.

Prototype

@Deprecated
public Dimension size() 

Source Link

Document

Returns the size of this component in the form of a Dimension object.

Usage

From source file:com.openbravo.pos.sales.JRetailPanelTicket.java

private synchronized void printRetailKotTicket(String sresourcename, RetailTicketInfo ticket,
        java.util.List<RetailTicketLineInfo> kot, Object ticketExt,
        java.util.List<ProductionPrinterInfo> printerInfo, int kotTicket, String floorName) {
    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();
    com.openbravo.pos.printer.printer.KotBillPrinter printerKot = new KotBillPrinter();

    String storeLocation = m_App.getProperties().getProperty("machine.storelocation");
    kotTicketlist = kot;//w ww.  j a  v  a  2  s.c  om
    //iterate the printers with non kot items
    for (int j = 0; j < printerInfo.size(); j++) {
        // list for saving the items having same production area type
        java.util.List<RetailTicketLineInfo> uniqueProductionAreas = new ArrayList<RetailTicketLineInfo>();
        for (int i = 0; i < kotTicketlist.size(); i++) {
            // if printer production area type matches with item production area type , add the line to the list
            if (printerInfo.get(j).getProductionAreaType()
                    .equals(kotTicketlist.get(i).getProductionAreaType())) {
                uniqueProductionAreas.add(kotTicketlist.get(i));
                kotTicketlist.get(i).setProductionArea(printerInfo.get(j).getProductionArea());
            }
        }
        logger.info("kot print count based on production areas" + uniqueProductionAreas.size());
        if (uniqueProductionAreas.size() != 0) {
            allLines = getRetailAllLines(ticket, ticketExt, uniqueProductionAreas, kotTicket, floorName);
            try {
                // sending for kot print based on store
                if (storeLocation.equals("BlrIndranagar") || storeLocation.equals("BlrKoramangala")
                        || storeLocation.equals("Chennai") || storeLocation.equals("Hyderabad")) {
                    //Thermal ?
                    printer.printKot(allLines, printerInfo.get(j).getPath());
                } else {
                    printerKot.print(allLines, printerInfo.get(j).getPath());
                }
                for (int i = 0; i < uniqueProductionAreas.size(); i++) {
                    kotlogger.info("KOT Printed Successfully " + "," + "Username: " + m_oTicket.printUser()
                            + "," + "Total kot count: " + uniqueProductionAreas.size() + "," + "Printer Name: "
                            + printerInfo.get(j).getPath() + "," + "Kot No: " + kotTicket + "," + "Table: "
                            + m_oTicketExt.toString() + "," + "Order No: " + ticket.getOrderId() + ","
                            + "Product Name: " + uniqueProductionAreas.get(i).getProductName() + "," + "Qty: "
                            + uniqueProductionAreas.get(i).getMultiply() + "," + "Timestamp: "
                            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
                    uniqueProductionAreas.get(i).setIsKot(1);
                    if (uniqueProductionAreas.get(i).getPreparationStatus() != 3) {
                        uniqueProductionAreas.get(i).setPreparationStatus(4);
                    }
                    System.out.println("uniqueProductionAreas.get(i). Station : "
                            + uniqueProductionAreas.get(i).getStation());
                    //New KDS Added on 7-03-17
                    String txstatus = "ADD";
                    String tableid_unique = uniqueProductionAreas.get(i).getTbl_orderId();
                    dlReceipts.insertServedTransaction(m_oTicket, txstatus, tableid_unique);

                }
            } catch (PrinterException ex) {
                logger.info("Order NO." + m_oTicket.getOrderId() + " The printer action" + ex.getMessage());
                ex.printStackTrace();
                kotprintIssue = 1;
                Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
                for (int i = 0; i < uniqueProductionAreas.size(); i++) {
                    logger.info("KOT Print Failed  " + "," + "Username: " + m_oTicket.printUser() + ","
                            + "Total kot count: " + uniqueProductionAreas.size() + "," + "Printer Name: "
                            + printerInfo.get(j).getPath() + "," + "Kot No: " + kotTicket + "," + "Table: "
                            + m_oTicketExt.toString() + "," + "Order No: " + ticket.getOrderId() + ","
                            + "Product Name: " + uniqueProductionAreas.get(i).getProductName() + "," + "Qty: "
                            + uniqueProductionAreas.get(i).getMultiply() + "," + "Timestamp: "
                            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
                    uniqueProductionAreas.get(i).setIsKot(0);
                    if (uniqueProductionAreas.get(i).getPreparationStatus() != 3) {
                        uniqueProductionAreas.get(i).setPreparationStatus(0);
                    }

                    //New KDS Added on 7-03-17
                    String txstatus = "ADD";
                    String tableid_unique = uniqueProductionAreas.get(i).getTbl_orderId();
                    System.out.println(
                            "uniqueProductionAreas Station " + uniqueProductionAreas.get(i).getStation());

                    dlReceipts.insertServedTransaction(m_oTicket, txstatus, tableid_unique);
                }
                kotaction = 1;
                showMessage(this, "KOT action not happened! Please retry");
            }
        }
    }

    for (int i = 0; i < ticket.getLinesCount(); i++) {
        paintKotTicketLine(i, ticket.getLine(i));
    }
    // Date updated = new Date();
    Object[] values = new Object[] { m_oTicket.getPlaceId(), m_oTicket.getName(), m_oTicket,
            m_oTicket.getSplitSharedId(), m_oTicket.isPrinted(), m_oTicket.isListModified() };
    Datas[] datas = new Datas[] { Datas.STRING, Datas.STRING, Datas.SERIALIZABLE, Datas.STRING, Datas.BOOLEAN,
            Datas.BOOLEAN };
    try {
        try {
            new PreparedSentence(m_App.getSession(),
                    "UPDATE SHAREDTICKETS SET NAME = ?, CONTENT = ?, ISPRINTED = ?, ISMODIFIED = ?,UPDATED=NOW() ,ISKDS=0  WHERE ID = ? AND SPLITID=? ",
                    new SerializerWriteBasicExt(datas, new int[] { 1, 2, 4, 5, 0, 3 })).exec(values);

        } catch (BasicException ex) {
            logger.info("Order NO." + m_oTicket.getOrderId() + " exception in  updating shared ticket"
                    + ex.getMessage());
            ex.printStackTrace();
            Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
        }
        String splitId = m_oTicket.getSplitSharedId();
        Object[] record = (Object[]) new StaticSentence(m_App.getSession(),
                "SELECT UPDATED FROM SHAREDTICKETS WHERE ID = ? AND SPLITID='" + splitId + "'",
                SerializerWriteString.INSTANCE, new SerializerReadBasic(new Datas[] { Datas.STRING }))
                        .find(m_oTicket.getPlaceId());
        if (record != null) {

            m_oTicket.setObjectUpdateDate(DateFormats.StringToDateTime((String) record[0]));

        }
    } catch (BasicException ex) {
        logger.info("Order NO." + m_oTicket.getOrderId()
                + " exception in  printRetailKotTicket updating shared ticket" + ex.getMessage());
        Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
    }

    logger.info("kot lines passing to print" + kotTicketlist.size());
    logger.info("end printing the kot" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

public final synchronized void serveAllLines() throws BasicException {

    Transaction t = new Transaction(m_App.getSession()) {
        int isallServed = 0;

        @Override/*from w w w .j  a  va  2  s.  c o  m*/
        protected Object transact() throws BasicException {
            final java.util.List<RetailTicketLineInfo> panelLines = m_oTicket.getLines();
            logger.info("serveAllLines method items are " + panelLines.size());
            for (final RetailTicketLineInfo l : panelLines) {
                if (l.getPreparationStatus() != 3 && l.getPreparationStatus() != 0) {
                    isallServed = 1;
                    l.setPreparationStatus(3);
                    l.setIsKot(1);
                    l.setTbl_orderId(l.getTbl_orderId());
                    setServedStatus(1);
                }

            }
            for (int i = 0; i < panelLines.size(); i++) {
                paintKotTicketLine(i, panelLines.get(i));
            }
            setServedStatus(0);
            return null;
        }
    };
    t.execute();
    logger.info("updated sharedticket");
}

From source file:com.openbravo.pos.sales.JRetailPanelTicket.java

public final synchronized void kotDisplay() throws BasicException {
    //   System.out.println("ticket.setObjectUpdateDate KOT1  : " + m_oTicket.getObjectUpdateDate());

    boolean updated = checkTicketUpdation();
    System.out.println("updated " + updated);

    if (!updated) {
        dbUpdatedDate = null;//  ww  w .ja  v  a2 s. c o m
        kotprintIssue = 0;
        logger.info("kotaction value" + kotaction);
        int orderId = 0;
        if (m_oTicket.getOrderId() == 0) {
            if (m_oTicket.getLinesCount() != 0) {
                //Setting the new order no
                orderId = dlSales.getNextTicketOrderNumber();
                m_oTicket.setOrderId(orderId);
            }
        }

        final int kotTicket;
        int kotTicketId = 0;
        kotTicketId = dlSales.getNextKotIndex();
        if (kotTicketId == 0) {
            kotTicket = 1;
        } else {
            kotTicket = kotTicketId;
        }

        RetailTicketInfo info = getActiveTicket();
        java.util.List<kotPrintedInfo> kPrintedInfolist = null;
        //Getting all the lines from current bill
        final java.util.List<RetailTicketLineInfo> panelLines = info.getLines();
        final java.util.List<RetailTicketLineInfo> panelNonKotLines = new ArrayList();

        String sessionId = null;
        String floorName = null;
        java.util.List<Floor> m_afloors;
        //Fetch the floor id and based on floor id get all the printer details

        SentenceList sent = new StaticSentence(m_App.getSession(),
                "SELECT FLOORS.ID, FLOORS.NAME,'' FROM PLACES LEFT JOIN FLOORS ON PLACES.FLOOR=FLOORS.ID WHERE  PLACES.ID='"
                        + m_oTicket.getPlaceId() + "'",
                null, new SerializerReadClass(Floor.class));
        m_afloors = sent.list();
        //  sessionId = dlReceipts.getFloorId(m_oTicket.getPlaceId());
        sessionId = m_afloors.get(0).getID();
        floorName = m_afloors.get(0).getName();
        printerInfo = dlReceipts.getPrinterInfo(sessionId);
        for (int i = 0; i < panelLines.size(); i++) {
            //Add all the non kot lines to the list for printing the kot based on production area
            if (panelLines.get(i).getIsKot() == 0) {
                String tbl_orderitemId = UUID.randomUUID().toString();
                tbl_orderitemId = tbl_orderitemId.replaceAll("-", "");
                panelLines.get(i).setTbl_orderId(tbl_orderitemId);
                panelLines.get(i).setKotid(kotTicket);
                panelLines.get(i).setKotdate(m_oTicket.getDate());
                panelLines.get(i).setKottable(m_oTicket.getPlaceId());
                panelLines.get(i).setKotuser(m_oTicket.getUser().getId());
                panelNonKotLines.add(panelLines.get(i));
            }

        }
        //Method is used for print the non kot lines
        printRetailKotTicket("Printer.Kot", m_oTicket, panelNonKotLines, m_oTicketExt, printerInfo, kotTicket,
                floorName);
        Runtime.getRuntime().gc();

    }
}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

private final synchronized void setKotServedAndPrintOnSplit(final RetailTicketInfo splitTicket)
        throws BasicException {

    Transaction t = new Transaction(m_App.getSession()) {
        @Override//from www .ja  v  a2 s. c om
        protected Object transact() throws BasicException {
            int orderId = 0;
            orderId = dlSales.getNextTicketOrderNumber();
            splitTicket.setOrderId(orderId);
            //doPrintValidationSplitTicket(splitTicket);
            doPrintValidation();
            String file;
            file = "Printer.TakeAway";
            try {
                taxeslogic.calculateTakeAwayTaxes(m_oTicket);
                //   chargeslogic.calculateCharges(m_oTicket);
                //  staxeslogic.calculateTakeAwayServiceTaxes(m_oTicket);
                // taxeslogic.calculateTaxes(m_oTicket);
            } catch (TaxesException ex) {
                logger.info("Order NO." + m_oTicket.getOrderId()
                        + "exception in setKotAndServedOnSplit calculateTaxes" + ex.getMessage());
                Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
            }
            // calculateServiceChargeSplitTicket(splitTicket);
            //                              calculateServiceCharge();
            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.JRetailPanelTakeAway.java

private synchronized void printCancelKotTicket(RetailTicketInfo ticket, RetailTicketLineInfo kotLine,
        Object ticketExt, java.util.List<ProductionPrinterInfo> printerInfo) {
    java.util.List<TicketLineConstructor> allLines = null;
    String productionAreaName = "";
    com.openbravo.pos.printer.printer.KotImagePrinter printer = new KotImagePrinter();
    com.openbravo.pos.printer.printer.KotBillPrinter printerKot = new KotBillPrinter();
    String storeLocation = m_App.getProperties().getProperty("machine.storelocation");
    logger.info("cancel  kot" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));

    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") || storeLocation.equals("BlrKoramangala")
                        || storeLocation.equals("Chennai") || storeLocation.equals("Hyderabad")) {
                    printer.printKot(allLines, printerInfo.get(j).getPath());
                } else {
                    printerKot.print(allLines, printerInfo.get(j).getPath());
                }/*from  w  w w. ja v  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.JRetailPanelTakeAway.java

private synchronized void printRetailKotTicket(String sresourcename, RetailTicketInfo ticket,
        java.util.List<RetailTicketLineInfo> kot, Object ticketExt,
        java.util.List<ProductionPrinterInfo> printerInfo, int kotTicket) {
    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();
    com.openbravo.pos.printer.printer.KotBillPrinter printerKot = new KotBillPrinter();
    String storeLocation = m_App.getProperties().getProperty("machine.storelocation");
    kotTicketlist = kot;/* w w  w  . j a v  a 2 s .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));
                kotTicketlist.get(i).setProductionArea(printerInfo.get(j).getProductionArea());
            }
        }
        logger.info("kot print count based on production areas" + uniqueProductionAreas.size());
        //  System.out.println("unique---"+uniqueProductionAreas.get(j).printName());
        System.out.println("uniqueProductionAreas:" + uniqueProductionAreas.size());
        if (uniqueProductionAreas.size() != 0) {
            allLines = getRetailAllLines(ticket, ticketExt, uniqueProductionAreas, kotTicket);
            try {
                if (storeLocation.equals("BlrIndranagar") || storeLocation.equals("BlrKoramangala")
                        || storeLocation.equals("Chennai") || storeLocation.equals("Hyderabad")) {
                    printer.printKot(allLines, printerInfo.get(j).getPath());
                } else {
                    printerKot.print(allLines, printerInfo.get(j).getPath());
                }
                //   kotprintIssue=0;
                // kotlogger.info("items printed successfully "+"By "+m_oTicket.printUser()+""+" in POS System "+m_App.getProperties().getPosNo()+" Table name "+m_oTicketExt.toString());
                for (int i = 0; i < uniqueProductionAreas.size(); i++) {
                    // kotlogger.info(uniqueProductionAreas.get(i).getProductName());
                    kotlogger.info("KOT Printed Successfully " + "," + "Username: " + m_oTicket.printUser()
                            + "," + "Total kot count: " + uniqueProductionAreas.size() + "," + "Printer Name: "
                            + printerInfo.get(j).getPath() + "," + "Kot No: " + kotTicket + "," + ","
                            + "Order No: " + ticket.getOrderId() + "," + "Product Name: "
                            + uniqueProductionAreas.get(i).getProductName() + "," + "Qty: "
                            + uniqueProductionAreas.get(i).getMultiply() + "," + "Timestamp: "
                            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
                    uniqueProductionAreas.get(i).setIsKot(1);
                    if (uniqueProductionAreas.get(i).getPreparationStatus() != 3) {
                        uniqueProductionAreas.get(i).setPreparationStatus(4);
                    }

                    //New KDS Added on 7-03-17
                    String txstatus = "ADD";
                    String tableid_unique = uniqueProductionAreas.get(i).getTbl_orderId();

                    System.out.println("STATION: " + uniqueProductionAreas.get(i).getStation());
                    dlReceipts.insertServedTransaction(m_oTicket, txstatus, tableid_unique);

                }
            } catch (PrinterException ex) {
                logger.info("Order NO." + m_oTicket.getOrderId() + " The printer action" + ex.getMessage());
                kotprintIssue = 1;
                System.out.println("within the catch of printer");
                Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
                for (int i = 0; i < uniqueProductionAreas.size(); i++) {
                    // kotlogger.info("items failed to print "+"By "+m_oTicket.printUser()+""+" in POS System "+m_App.getProperties().getPosNo()+" Table name "+m_oTicketExt.toString());
                    //  kotlogger.info("items failed to print :"+uniqueProductionAreas.get(i).getProductName());
                    logger.info("KOT Print Failed  " + "," + "Username: " + m_oTicket.printUser() + ","
                            + "Total kot count: " + uniqueProductionAreas.size() + "," + "Printer Name: "
                            + printerInfo.get(j).getPath() + "," + "Kot No: " + kotTicket + "," + "Table: "
                            + m_oTicketExt.toString() + "," + "Order No: " + ticket.getOrderId() + ","
                            + "Product Name: " + uniqueProductionAreas.get(i).getProductName() + "," + "Qty: "
                            + uniqueProductionAreas.get(i).getMultiply() + "," + "Timestamp: "
                            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
                    uniqueProductionAreas.get(i).setIsKot(0);
                    if (uniqueProductionAreas.get(i).getPreparationStatus() != 3) {
                        uniqueProductionAreas.get(i).setPreparationStatus(0);
                    }

                    //New KDS Added on 7-03-17
                    String txstatus = "ADD";
                    String tableid_unique = uniqueProductionAreas.get(i).getTbl_orderId();
                    dlReceipts.insertServedTransaction(m_oTicket, txstatus, tableid_unique);
                }
                kotaction = 1;
                showMessage(this, "KOT action not happened! Please retry");
            }
        }

    }

    for (int i = 0; i < ticket.getLinesCount(); i++) {
        paintKotTicketLine(i, ticket.getLine(i));
    }
    //        Object[] values = new Object[] {m_oTicket.getPlaceId(), m_oTicket.getName(), m_oTicket,m_oTicket.getSplitSharedId(),m_oTicket.isPrinted(),m_oTicket.isListModified()};
    //        Datas[] datas = new Datas[] {Datas.STRING, Datas.STRING, Datas.SERIALIZABLE, Datas.STRING,Datas.BOOLEAN,Datas.BOOLEAN};
    //        try {
    //            new PreparedSentence(m_App.getSession()
    //          , "UPDATE SHAREDTICKETS SET NAME = ?, CONTENT = ?, ISPRINTED = ?, ISMODIFIED = ? WHERE ID = ? AND SPLITID=? "
    //          , new SerializerWriteBasicExt(datas, new int[] {1, 2, 4, 5, 0,3})).exec(values);
    //        } catch (BasicException ex) {
    //            logger.info("Order NO."+m_oTicket.getOrderId()+" exception in  printRetailKotTicket updating shared ticket"+ex.getMessage());
    //            Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
    //        }
    logger.info("kot lines passing to print" + kotTicketlist.size());
    logger.info("end printing the kot" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.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);
    }/*  w w w  .j  a v  a 2  s . co m*/
    //try {
    //printer.print(allLines);
    //        try {
    int divideLines = allLines.size() / 48;
    int remainder = allLines.size() % 48;
    System.out.println("divideLines---" + divideLines + "--" + remainder);
    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()));
                System.out.println("allLines.get(j).getLine()--" + 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>();
                    System.out.println("startallLinest--" + startallLines.size());
                    startallLines.clear();
                } else {
                    break;
                }
            }

        }
    }
    System.out.println("value---" + value + k + "--" + remainder);
    if (remainder > 0) {
        startallLines = new ArrayList<TicketLineConstructor>();
        System.out.println("startallLinest--" + startallLines.size());
        startallLines.clear();
        for (int m = k; m < k + remainder; m++) {

            startallLines.add(new TicketLineConstructor(allLines.get(m).getLine()));
            System.out.println("allLines.get(j).getLine()--" + allLines.get(m).getLine());
        }
        try {
            printer.print(startallLines);
        } catch (PrinterException ex) {
            Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    //                        try {
    //                            printer.print(allLines);
    //
    //                        } catch (PrinterException ex) {
    //                            Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
    //                        }
}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

public final synchronized void kotDisplay() throws BasicException {
    kotprintIssue = 0;// www .  ja  v a 2 s .  c o m
    logger.info("kotaction value" + kotaction);
    int orderId = 0;
    if (m_oTicket.getOrderId() == 0) {
        if (m_oTicket.getLinesCount() != 0) {
            orderId = dlSales.getNextTicketOrderNumber();
            m_oTicket.setOrderId(orderId);
        }
    }

    final int kotTicket;
    int kotTicketId = 0;
    kotTicketId = dlSales.getNextKotIndex();
    if (kotTicketId == 0) {
        kotTicket = 1;
    } else {
        kotTicket = kotTicketId;
        //  kotTicket = kotTicket+1;
    }
    RetailTicketInfo info = getActiveTicket();
    java.util.List<kotPrintedInfo> kPrintedInfolist = null;
    final java.util.List<RetailTicketLineInfo> panelLines = info.getLines();
    final java.util.List<RetailTicketLineInfo> panelNonKotLines = new ArrayList();

    //Transaction t = new Transaction(m_App.getSession()) { 
    //     @Override
    //    protected Object transact() throws BasicException {
    String sessionId = null;
    String tableId = null;
    System.out
            .println("m_App.getProperties().getProperty(" + m_App.getProperties().getProperty("machine.Floor"));
    //                 sessionId = dlReceipts.getTakeAwayFloorId(m_App.getProperties().getProperty("machine.Floor"));
    java.util.List<BeanInfo> takeawayInfo = dlReceipts.getTakeAwayInfoList();
    tableId = takeawayInfo.get(0).getId();
    m_oTicket.setPlaceid(tableId);
    sessionId = takeawayInfo.get(0).getName();
    printerInfo = dlReceipts.getPrinterInfo(sessionId);
    for (int i = 0; i < panelLines.size(); i++) {
        if (panelLines.get(i).getIsKot() == 0) {
            String tbl_orderitemId = UUID.randomUUID().toString();
            tbl_orderitemId = tbl_orderitemId.replaceAll("-", "");
            panelLines.get(i).setTbl_orderId(tbl_orderitemId);

            panelLines.get(i).setKotid(kotTicket);
            panelLines.get(i).setKotdate(m_oTicket.getDate());
            System.out.println("m_oTicket.getDate()" + m_oTicket.getDate());
            panelLines.get(i).setKottable(m_oTicket.getPlaceId());
            panelLines.get(i).setKotuser(m_oTicket.getUser().getId());
            panelNonKotLines.add(panelLines.get(i));
            //  panelLines.get(i).setIsKot(1);
        }

        //                        if(panelLines.get(i).getPreparationStatus()!=3){
        //                            panelLines.get(i).setPreparationStatus(4);
        //                        }
    }
    //                  Object[] values = new Object[] {m_oTicket.getPlaceId(), m_oTicket.getName(), m_oTicket,m_oTicket.getSplitSharedId(),m_oTicket.isPrinted(),m_oTicket.isListModified()};
    //                  Datas[] datas = new Datas[] {Datas.STRING, Datas.STRING, Datas.SERIALIZABLE, Datas.STRING,Datas.BOOLEAN,Datas.BOOLEAN};
    //                  new PreparedSentence(m_App.getSession()
    //                , "UPDATE SHAREDTICKETS SET NAME = ?, CONTENT = ?, ISPRINTED = ?, ISMODIFIED = ? WHERE ID = ? AND SPLITID=? "
    //                , new SerializerWriteBasicExt(datas, new int[] {1, 2, 4, 5, 0,3})).exec(values);
    //                  logger.info("updating shared tickets in kotaction successfully");  
    printRetailKotTicket("Printer.Kot", m_oTicket, panelNonKotLines, m_oTicketExt, printerInfo, kotTicket);
    //                  for(int i=0;i<panelLines.size();i++){
    //                   if(panelLines.get(i).getPreparationStatus()!=3){
    //                        paintKotTicketLine(i,  panelLines.get(i));
    //                        }
    //                  }
    //   return null;

    // }
    //   };
    //            try{
    //            t.execute();
    //             logger.info("kot transaction happened successfully"); 
    //             kotaction=0;
    //            } catch (Exception e) {
    //                 logger.info("kot transaction failed"+e.getMessage()); 
    //                for(int i=0;i<panelNonKotLines.size();i++){
    //                     panelNonKotLines.get(i).setIsKot(0);
    //                     panelNonKotLines.get(i).setPreparationStatus(0);
    //                  }
    //                kotaction=1;
    //               showMessage(this, "please re try the KOT action");  
    //            }
    Runtime.getRuntime().gc();
    System.out.println("current time after kot" + new Date());
}

From source file:org.fhcrc.cpl.viewer.gui.SpectrumComponent.java

/**
 * update the chart with new data/*from www . j  a v  a 2s.c  o m*/
 */
public void updateChart(boolean preserveDomain) {
    _log.debug("updateChart: start");
    float[][] spectrumIN = null;
    MSRun run = (MSRun) ApplicationContext.getProperty(SharedProperties.MS_RUN);
    MSRun.MSScan selectedScan = getSelectedScan();

    FloatRange rangeSpectrum = null; // restricted range of displayed data (for autoZoom)
    Pair<Spectrum.Peak, Spectrum.Peak> chartRange = null; // tell other components what we are displaying

    Range domainRange = null;
    if (preserveDomain && _chart != null)
        domainRange = _chart.getXYPlot().getDomainAxis().getRange();

    if (null == run || null == selectedScan) {
        clearChart();
        //if no chart to display, show white background
        chartArea.setBackground(java.awt.Color.WHITE);
        return;
    }

    chartArea.setBackground(_backgroundColor);

    if ("scan".equals(_type)) {
        scanSpinner.setValue(new Integer(selectedScan.getNum()));
        double t = selectedScan.getDoubleRetentionTime();
        timeTextField.setText("" + Math.round(t * 10) / 10.0);
        scanSpinner.setEnabled(true);
        //mzTextField.setText("");
        //mzTextField.setEnabled(false);
        mzSpinner.setValue(new Double(_selectedMZ));
        mzSpinner.setEnabled(false);

        /*         ArrayList l = new ArrayList();
                 l.add(selectedScan.getSpectrum());
                    spectrumIN = Spectrum.CombineRawSpectra(
            run.getTemplateSpectrum(),
            l,
            new FloatRange(selectedScan.getLowMz(),selectedScan.getHighMz())
            ); */

        spectrumIN = selectedScan.getSpectrum();

        if (autoZoom()) {
            // we don't want to filter the analyzed data, in case
            // that affects any of the algorithms
            // we only filter the result Datasets
            // UNDONE: choose range based on size of MSDetailPanel

            // range of 27+ is enough to see 4 ICAT labelled features (9*(4-1))
            rangeSpectrum = new FloatRange((float) _selectedMZ - 10F, (float) _selectedMZ + 30F);
        }

        if (null == rangeSpectrum) {
            chartRange = new Pair<Spectrum.Peak, Spectrum.Peak>(
                    new Spectrum.Peak(_selectedScanNum, spectrumIN[0][0], 0.0F),
                    new Spectrum.Peak(_selectedScanNum, spectrumIN[0][spectrumIN[0].length - 1]));
        } else {
            chartRange = new Pair<Spectrum.Peak, Spectrum.Peak>(
                    new Spectrum.Peak(_selectedScanNum, rangeSpectrum.min, 0.0F),
                    new Spectrum.Peak(_selectedScanNum, rangeSpectrum.max, 0.0F));
        }
    } else // elution
    {
        if (_selectedMZ == -1) {
            clearChart();
            return;
        }

        int RESAMPLE = 36;
        float mz = (float) Math.round(_selectedMZ * RESAMPLE) / RESAMPLE;
        _log.debug("updateChart mz=" + mz);

        scanSpinner.setValue(new Integer(selectedScan.getNum()));
        scanSpinner.setEnabled(false);
        double t = selectedScan.getDoubleRetentionTime();
        timeTextField.setText("" + Math.round(t * 10) / 10.0);
        //mzTextField.setText("" + mz);
        //mzTextField.setEnabled(true);
        mzSpinner.setValue(new Double(_selectedMZ));
        mzSpinner.setEnabled(true);

        FloatArray arrayIntensity = new FloatArray();
        FloatArray arrayScan = new FloatArray();
        int scanIndex = run.getIndexForScanNum(selectedScan.getNum());
        int scanStart = Math.max(0, scanIndex - 64);
        int scanEnd = Math.min(run.getScanCount() - 1, scanStart + 128);
        FloatRange r = new FloatRange(mz, mz);
        for (int s = scanStart; s < scanEnd; s++) {
            MSRun.MSScan scan = run.getScan(s);
            float[][] spectrumRaw = scan.getSpectrum();
            float[] resample = Spectrum.Resample(spectrumRaw, r, RESAMPLE);
            float f = resample[0];
            arrayIntensity.add(f);
            //arrayScan.add((float)scan.getDoubleRetentionTime());
            //            arrayScan.add((float)s);
            arrayScan.add((float) scan.getNum());
        }
        spectrumIN = new float[][] { arrayScan.toArray(null), arrayIntensity.toArray(null) };

        chartRange = new Pair<Spectrum.Peak, Spectrum.Peak>(
                new Spectrum.Peak(run.getScan(scanStart).getNum(), mz, 0.0F),
                new Spectrum.Peak(run.getScan(scanEnd).getNum(), mz, 0.0F));
    }

    String mode = (String) displayMode.getSelectedItem();

    java.util.List<XYSeriesCollection> listMultipleCharts = null;
    XYSeriesCollection series = new XYSeriesCollection();
    series.setIntervalWidth(0.0);

    //
    // Process source spectrum
    //

    float[][] spectrum = new float[][] { (float[]) spectrumIN[0].clone(), (float[]) spectrumIN[1].clone() };
    ProcessSpectrum: {
        if ("raw".equals(mode)) {
            break ProcessSpectrum;
        }

        if ("background centroided".equals(mode)) {
            if (run.getHeaderInfo().getDataProcessing().getCentroided() == 1)
                spectrum = FeatureStrategyCentroided.backgroundSpectrum(spectrum);
            break ProcessSpectrum;
        }

        if ("clean centroided".equals(mode)) {
            if (run.getHeaderInfo().getDataProcessing().getCentroided() == 1)
                spectrum = FeatureStrategyCentroided.cleanSpectrum(spectrum);
            break ProcessSpectrum;
        }

        // all subsequent processing expects resampling
        // don't resample elution profile
        if ("scan".equals(_type)) {
            int len = spectrum[0].length;
            spectrum = Spectrum.ResampleSpectrum(spectrumIN,
                    new FloatRange((float) Math.floor(spectrum[0][0]), (float) Math.ceil(spectrum[0][len - 1])),
                    36, false);
        } else {
            spectrum[1] = Spectrum.MedianSmooth(spectrum[1]);
            Spectrum.SmoothALittle(spectrum[1]);
        }

        if ("resampled".equals(mode))
            break ProcessSpectrum;

        /*         if ("compressed".equals(mode)) (data encoding test)
                    {
                    float[] s = spectrum[1];
                    short c[] = new short[s.length];
                    double m = 1.0;
                    for (int i = 0 ; i<c.length ; i++)
                       m = Math.max(m, s[i]);
                    double sqrt = Math.sqrt(m+1);
                    m = Math.round(Math.log(sqrt))+1;
                    double f = Math.floor(0x7fff / Math.log(sqrt));
                    m = 0;
                    for (int i = 0 ; i<c.length ; i++)
                       {
                       c[i] = (short)(Math.round(Math.log((s[i]+1)/sqrt) * f));
                       m = Math.max(m, Math.abs(c[i]));
                       }
                    System.err.println("MAX " + m);
                    for (int i = 0 ; i<c.length ; i++)
                       s[i] = (float)((Math.exp((double)c[i]/f) * sqrt) - 1);
                    break ProcessSpectrum;
                    } */

        // remove background for further processing
        if (run.getHeaderInfo().getDataProcessing().getCentroided() != 1) {
            int window = "scan".equals(_type) ? 72 : 15;
            float x[] = spectrum[1];
            float bg[] = Spectrum.MinimaWindow(x, spectrum[0].length, window, null);
            for (int i = 0; i < bg.length; i++)
                bg[i] = Math.max(0, x[i] - bg[i]);
            spectrum = new float[][] { spectrum[0], bg };
        }

        if ("subtract background".equals(mode))
            break ProcessSpectrum;

        if (mode.startsWith("threshold")) {
            spectrum[1] = Spectrum.WaveletD3(spectrum[1], null);
            break ProcessSpectrum;
        }

        if ("peaks".equals(mode) || "smoothed".equals(mode)) {
            if ("scan".equals(_type)) {
                double s = Smooth2D.smoothYfactor;
                spectrum[1] = Spectrum.FFTsmooth(spectrum[1], s, false);
            } else {
                //FeatureStrategyPeakClusters.smoothTHRESHOLD sm = new FeatureStrategyPeakClusters.smoothTHRESHOLD();
                spectrum[1] = SmootherCreator._thresholdElution(spectrum[1]);
            }
            break ProcessSpectrum;
        }
    } // ProcessSpectrum:

    //
    // This is the source spectrum
    //

    String name = mode.indexOf("peaks") != -1 ? "-spectrum" : "|spectrum";
    series.addSeries(new SpectrumXYSeries(name, spectrum, rangeSpectrum));
    _spectrum = spectrum;

    //
    // add additional series/charts
    //

    // show min/med for reference
    if (mode.equals("resampled") || mode.equals("subtract background")) {
        float[] T;
        if (mode.equals("resampled")) {
            T = Spectrum.MinimaWindow(spectrum[1], spectrum[0].length, 72, null);
            series.addSeries(new SpectrumXYSeries("-min", new float[][] { spectrum[0], T }, rangeSpectrum));
        }
        T = Spectrum.MedianWindow(spectrum[1], spectrum[0].length, 72, false);
        series.addSeries(new SpectrumXYSeries("-med", new float[][] { spectrum[0], T }, rangeSpectrum));
    }

    if (mode.startsWith("wavelet decomposition") || mode.startsWith("wavelet multiresolution")) {
        Filter f = new Filter("haar");
        float[] signal = spectrum[1]; // Spectrum.PadToDouble(spectrum[1], 32);
        int N = spectrum[0].length; // signal.length;
        int levels = 5;

        //if ("wavelet decomposition 2".equals(mode)) Spectrum.SmoothALittle(signal);

        float[][] modwt1 = Transform.decompose(signal, N, levels, f, "modwt", "periodic", null);
        float[][] t = modwt1;

        if ("wavelet multiresolution".equals(mode)) {
            t = Transform.multiresolution(t, N, levels, f, "modwt", "periodic", null);
        } else if ("wavelet decomposition 2".equals(mode)) {
            float[][] mra = Transform.multiresolution(t, N, levels, f, "modwt", "periodic", null);
            float[][] modwt2 = Transform.decompose(t[2], N, levels, f, "modwt", "periodic", null);
            // show original, d1, and d2
            float[] a = modwt1[2];
            float[] b = modwt2[2];
            float[] m = mra[2];
            Spectrum.Rotate(a, -3);
            Spectrum.Rotate(b, -7);
            t = new float[][] { a, /*b,*/ m }; // b is a mirror image of m
        }

        // copy array into data series
        listMultipleCharts = new java.util.LinkedList<XYSeriesCollection>();
        XYSeriesCollection ds = new XYSeriesCollection(
                new SpectrumXYSeries("spectrum", spectrum, rangeSpectrum));
        ds.setIntervalWidth(0.0);
        listMultipleCharts.add(ds);
        for (int i = 0; i < t.length; i++) {
            //float[] s = Spectrum.UnpadToFloat(t[i], 32, null);
            float[][] l = new float[][] { spectrum[0], t[i] };
            ds = new XYSeriesCollection(new SpectrumXYSeries("level " + (i + 1), l, rangeSpectrum));
            ds.setIntervalWidth(0.0);
            listMultipleCharts.add(ds);
        }
    } else if (mode.startsWith("haar")) {
        int l = Integer.parseInt(mode.substring(4));
        listMultipleCharts = new LinkedList<XYSeriesCollection>();

        float[] t1 = Haar.transform(spectrum[1], l);
        float[] t2 = Haar.transform(t1, l);
        XYSeriesCollection ds = new XYSeriesCollection(
                new SpectrumXYSeries("spectrum", spectrum, rangeSpectrum));
        ds.setIntervalWidth(0.0);
        listMultipleCharts.add(ds);
        XYSeriesCollection ds1 = new XYSeriesCollection(
                new SpectrumXYSeries(mode, new float[][] { spectrum[0], t1 }, rangeSpectrum));
        ds1.setIntervalWidth(0.0);
        listMultipleCharts.add(ds1);
        XYSeriesCollection ds2 = new XYSeriesCollection(
                new SpectrumXYSeries(mode, new float[][] { spectrum[0], t2 }, rangeSpectrum));
        ds2.setIntervalWidth(0.0);
        listMultipleCharts.add(ds2);
    } else if ("peaks".equals(mode) || "threshold peaks".equals(mode)) {
        double noise = 0.1; //"peaks".equals(mode) ? 2.0 : 1.0; // Spectrum.Noise(spectrum[1], 0, spectrum[1].length);
        int[] peakList = Spectrum.PickPeakIndexes(spectrum[1], noise);

        float[][] peaks = new float[2][peakList.length];
        for (int i = 0; i < peakList.length; i++) {
            int p = peakList[i];
            if (p >= spectrum[0].length)
                continue;
            peaks[0][i] = spectrum[0][p];
            peaks[1][i] = spectrum[1][p];
        }
        series.addSeries(new SpectrumXYSeries("|peaks", peaks, rangeSpectrum));
        _spectrum = peaks;
    } else if ("wavelet peaks".equals(mode)) {
        //Spectrum.Peak[] peaks = Spectrum.WaveletPeaks(spectrum);
        Spectrum.Peak[] peaks = Spectrum.WaveletPeaksD3(spectrum);
        float[][] peakSpectrum = new float[2][peaks.length];
        for (int p = 0; p < peaks.length; p++) {
            peakSpectrum[0][p] = peaks[p].mz;
            peakSpectrum[1][p] = peaks[p].intensity;
        }

        // show d3 and thresholded spectrum
        int levels = 3, N = spectrum[0].length;
        Filter f = new Filter("haar");
        float[][] modwt = Transform.decompose(spectrum[1], N, levels, f, "modwt", "periodic", null);
        float[][] mra = Transform.multiresolution(modwt, N, levels, f, "modwt", "periodic", null);
        float[] thresholded = new float[N];
        for (int i = 0; i < N; i++)
            thresholded[i] = mra[2][i] + mra[3][i];

        series.removeAllSeries();
        //series.addSeries(new SpectrumXYSeries("-spectrum", new float[][] {spectrum[0],thresholded}, rangeSpectrum));
        series.addSeries(new SpectrumXYSeries("-mra", new float[][] { spectrum[0], mra[2] }, rangeSpectrum));
        series.addSeries(new SpectrumXYSeries("|peaks", peakSpectrum, rangeSpectrum));
        _spectrum = peakSpectrum;
    }

    //
    // now update or create chart
    //

    Color[] colors = series.getSeriesCount() == 3 ? new Color[] { Color.RED, Color.BLUE, Color.BLUE }
            : series.getSeriesCount() == 2 ? new Color[] { Color.BLUE, Color.RED } : new Color[] { Color.RED };

    // NOTE: the more often we call setDatasets instead of creating new chart the better
    // CONSIDER: if we don't save chart, at least preserve zoom settings
    if (false && _chart != null && _chartPanel != null && !(_chart.getPlot() instanceof CombinedDomainXYPlot)
            && listMultipleCharts == null) {
        SpectrumChartFactory.setColors(_chartPanel, colors);
        _chart.getXYPlot().setDataset(series);
        _chartPanel.updateUI();
    } else {
        if (listMultipleCharts == null) {
            _log.debug(
                    "updateChart: series=" + series.getSeriesCount() + " length(0)=" + series.getItemCount(0));
            _chartPanel = SpectrumChartFactory.CreateChartPanel(series, colors);
        } else {
            _log.debug("updateChart: charts=" + listMultipleCharts.size());
            _chartPanel = SpectrumChartFactory.CreateChartPanel(listMultipleCharts, colors);
        }
        _chart = _chartPanel.getChart();

        // there seem to be mystery margins so give a little extra space
        Dimension size = chartArea.getSize();
        _chartPanel.setPreferredSize(new Dimension(size.width - 10, size.height - 10));
        chartArea.removeAll();
        chartArea.add(_chartPanel);
        chartArea.doLayout();
    }
    if (null != domainRange)
        _chart.getXYPlot().getDomainAxis().setRange(domainRange);

    //dhmay: if the user has locked the Y axis, then try to use the stored Y axis range
    if (isYAxisLocked()) {
        //a locked axis value won't be available if the axis was _just_ locked
        if (null == _lockedYAxisRange) {
            //if we've already displayed a chart, use that chart's axis range.  Otherwise,
            //don't force, and record this chart's axis range
            if (_previousYAxisRange != null)
                _lockedYAxisRange = _previousYAxisRange;
            else
                _lockedYAxisRange = _chart.getXYPlot().getRangeAxis().getRange();
        }
        _chart.getXYPlot().getRangeAxis().setRange(_lockedYAxisRange);
    } else {
        //if the Y axis isn't locked, then dump the stored range so it isn't used later
        _lockedYAxisRange = null;
    }

    //always store the previous Y axis range
    if (_chart.getXYPlot() != null && _chart.getXYPlot().getRangeAxis() != null
            && _chart.getXYPlot().getRangeAxis().getRange() != null) {
        _previousYAxisRange = _chart.getXYPlot().getRangeAxis().getRange();
    }

    ApplicationContext.setProperty(SharedProperties.CHART_RANGE, chartRange);
}