chiark / gitweb /
replace commented-out debugging printlns with ones which use dtxt
[jarrg-ian.git] / src / com / tedpearson / ypp / market / MarketUploader.java
index 1b1382e7650d2be2e5e4aa622f94f5258a452292..b20e359e10bda3c58aa1cbb8988f693c5392d647 100644 (file)
@@ -76,7 +76,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                                int index = text.indexOf(":");
                                String name = text.substring(0,index);
                                islandName = name;
                                int index = text.indexOf(":");
                                String name = text.substring(0,index);
                                islandName = name;
-                               //System.out.println(islandName);
+                               // if (dtxt!=null) dtxt.println(islandName);
                                sidePanel.removePropertyChangeListener(this);
                                latch.countDown();
                        }
                                sidePanel.removePropertyChangeListener(this);
                                latch.countDown();
                        }
@@ -539,8 +539,8 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                    }
                    int[] offerCount = getBuySellMaps(data,buys,sells,stallMap,commodMap);
                    //println(buys.toString());
                    }
                    int[] offerCount = getBuySellMaps(data,buys,sells,stallMap,commodMap);
                    //println(buys.toString());
-                   //System.out.println(sells);
-                   //System.out.println("\n\n\n"+buys);
+                   // if (dtxt!=null) dtxt.println(sells);
+                   // if (dtxt!=null) dtxt.println("\n\n\n"+buys);
 
                    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
                    pm.setProgress(60);
 
                    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
                    pm.setProgress(60);
@@ -607,13 +607,13 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                Accessible node1 = window;
                Accessible node = descendNodes(node1,new int[] {0,1,0,0,0,0,1,0,0,1,0,0}); // commod market
                // commod market: {0,1,0,0,0,0,1,0,0,1,0}  {0,1,0,0,0,0,1,0,1,0,0,1,0,0})
                Accessible node1 = window;
                Accessible node = descendNodes(node1,new int[] {0,1,0,0,0,0,1,0,0,1,0,0}); // commod market
                // commod market: {0,1,0,0,0,0,1,0,0,1,0}  {0,1,0,0,0,0,1,0,1,0,0,1,0,0})
-               //System.out.println(node);
+               // if (dtxt!=null) dtxt.println(node);
                if (!(node instanceof JTable)) {
                        node = descendNodes(node1,new int[] {0,1,0,0,0,0,1,0,1,0,0,1,0,0}); // commod market
                }
                if (!(node instanceof JTable)) return null;
                AccessibleTable table = node.getAccessibleContext().getAccessibleTable();
                if (!(node instanceof JTable)) {
                        node = descendNodes(node1,new int[] {0,1,0,0,0,0,1,0,1,0,0,1,0,0}); // commod market
                }
                if (!(node instanceof JTable)) return null;
                AccessibleTable table = node.getAccessibleContext().getAccessibleTable();
-               //System.out.println(table);
+               // if (dtxt!=null) dtxt.println(table);
                return table;
        }
        
                return table;
        }
        
@@ -630,7 +630,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
        private Accessible descendNodes(Accessible parent, int[] path) {
                for(int i=0;i<path.length;i++) {
                        if (null == (parent = descend(parent, path[i]))) return null;
        private Accessible descendNodes(Accessible parent, int[] path) {
                for(int i=0;i<path.length;i++) {
                        if (null == (parent = descend(parent, path[i]))) return null;
-                       //System.out.println(parent.getClass());
+                       // if (dtxt!=null) dtxt.println(parent.getClass());
                }
                return parent;
        }
                }
                return parent;
        }
@@ -722,7 +722,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                        //        dtxt.println(xml);
                        //        dtxt.println("<<");
                        //}
                        //        dtxt.println(xml);
                        //        dtxt.println("<<");
                        //}
-                       //System.out.println(xml);
+                       // if (dtxt!=null) dtxt.println(xml);
                        Reader reader = new CharArrayReader(xml.toCharArray());
                        Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(reader));
                        NodeList maps = d.getElementsByTagName("CommodMap");
                        Reader reader = new CharArrayReader(xml.toCharArray());
                        Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(reader));
                        NodeList maps = d.getElementsByTagName("CommodMap");
@@ -962,7 +962,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
        */
        private boolean finishUpload(InputStream in) throws IOException {
                String html = readstreamstring(in);
        */
        private boolean finishUpload(InputStream in) throws IOException {
                String html = readstreamstring(in);
-               //System.out.println(html);
+               // if (dtxt!=null) dtxt.println(html);
                Matcher m;
 
                Pattern params = Pattern.compile("(?s)<input type=\"hidden\" name=\"action\" value=\"setisland\" />.+?<input type=\"hidden\" name=\"forcereload\" value=\"([^\"]+)\" />.+?<input type=\"hidden\" name=\"filename\" value=\"([^\"]+)\" />");
                Matcher m;
 
                Pattern params = Pattern.compile("(?s)<input type=\"hidden\" name=\"action\" value=\"setisland\" />.+?<input type=\"hidden\" name=\"forcereload\" value=\"([^\"]+)\" />.+?<input type=\"hidden\" name=\"filename\" value=\"([^\"]+)\" />");
@@ -1053,7 +1053,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
     }
 
     private int calculateArbitrageCommodity(ArrayList<SortedSet<int[]>> arb_bs) {
     }
 
     private int calculateArbitrageCommodity(ArrayList<SortedSet<int[]>> arb_bs) {
-       //System.out.println("ARBITRAGE?");
+       // if (dtxt!=null) dtxt.println("ARBITRAGE?");
        int profit = 0;
        SortedSet<int[]> buys = arb_bs.get(0);
        SortedSet<int[]> sells = arb_bs.get(1);
        int profit = 0;
        SortedSet<int[]> buys = arb_bs.get(0);
        SortedSet<int[]> sells = arb_bs.get(1);
@@ -1069,7 +1069,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
 
            int unitprofit = buy[0] - sell[0];
            int count = buy[1] < sell[1] ? buy[1] : sell[1];
 
            int unitprofit = buy[0] - sell[0];
            int count = buy[1] < sell[1] ? buy[1] : sell[1];
-           //System.out.println(" sell @"+sell[0]+" x"+sell[1]+" buy @"+buy[0]+" x"+buy[1]
+           // if (dtxt!=null) dtxt.println(" sell @"+sell[0]+" x"+sell[1]+" buy @"+buy[0]+" x"+buy[1]
            //                 +" => x"+count+" @"+unitprofit);
 
            if (unitprofit <= 0)
            //                 +" => x"+count+" @"+unitprofit);
 
            if (unitprofit <= 0)
@@ -1081,7 +1081,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
            if (buy[1]==0) buys.remove(buy);
            if (sell[1]==0) sells.remove(sell);
        }
            if (buy[1]==0) buys.remove(buy);
            if (sell[1]==0) sells.remove(sell);
        }
-       //System.out.println(" PROFIT "+profit);
+       // if (dtxt!=null) dtxt.println(" PROFIT "+profit);
        return profit;
     }
 
        return profit;
     }
 
@@ -1102,15 +1102,15 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
 
        for (ArrayList<String> row : data) {
            String thiscommod = row.get(0);
 
        for (ArrayList<String> row : data) {
            String thiscommod = row.get(0);
-           //System.out.println("ROW "+row.toString());
+           // if (dtxt!=null) dtxt.println("ROW "+row.toString());
            if (lastcommod == null || !thiscommod.equals(lastcommod)) {
                if (lastcommod != null)
                    arbitrage += calculateArbitrageCommodity(arb_bs);
            if (lastcommod == null || !thiscommod.equals(lastcommod)) {
                if (lastcommod != null)
                    arbitrage += calculateArbitrageCommodity(arb_bs);
-               //System.out.println("ROW rdy");
+               // if (dtxt!=null) dtxt.println("ROW rdy");
                arb_bs = new ArrayList<SortedSet<int[]>>(2);
                arb_bs.add(0, new TreeSet<int[]>(compar));
                arb_bs.add(1, new TreeSet<int[]>(compar));
                arb_bs = new ArrayList<SortedSet<int[]>>(2);
                arb_bs.add(0, new TreeSet<int[]>(compar));
                arb_bs.add(1, new TreeSet<int[]>(compar));
-               //System.out.println("ROW init");
+               // if (dtxt!=null) dtxt.println("ROW init");
                lastcommod = thiscommod;
            }
            for (int bs = 0; bs < 2; bs++) {
                lastcommod = thiscommod;
            }
            for (int bs = 0; bs < 2; bs++) {
@@ -1118,7 +1118,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis
                if (pricestr == null)
                    continue;
                int[] entry = new int[2];
                if (pricestr == null)
                    continue;
                int[] entry = new int[2];
-               //System.out.println("ROW BS "+bs);
+               // if (dtxt!=null) dtxt.println("ROW BS "+bs);
                entry[0] = parseQty(pricestr);
                entry[1] = parseQty(row.get(bs*2 + 3));
                arb_bs.get(bs).add(entry);
                entry[0] = parseQty(pricestr);
                entry[1] = parseQty(row.get(bs*2 + 3));
                arb_bs.get(bs).add(entry);