Ejemplo n.º 1
0
  public static ToolBox fromFile(
      String filename, Board board, int toolHeight, int toolReserveBarWidth, int toolTextWidth) {
    InputStream fis = null;
    try {
      fis = new FileInputStream(filename);
    } catch (FileNotFoundException e) {
      fis = ClassLoader.getSystemClassLoader().getResourceAsStream(filename);
    }

    ToolBox toolBox = fromStream(fis, board);
    toolBox.toolHeight = toolHeight;
    toolBox.toolReserveBarWidth = toolReserveBarWidth;
    toolBox.toolTextWidth = toolTextWidth;
    return toolBox;
  }
Ejemplo n.º 2
0
 static ToolBox fromStream(InputStream in, Board board) {
   ToolBox tb = new ToolBox();
   InputStreamReader read = new InputStreamReader(in);
   BufferedReader buff = new BufferedReader(read);
   try {
     while (buff.ready()) {
       String s = buff.readLine();
       SprayTool st = SprayTool.fromString(s, board);
       if (st != null) {
         tb.tools.add(st);
         tb.toolKeys.put(st.getHotKey(), st);
       }
     }
     buff.close();
     tb.currentTool = tb.tools.size() > 0 ? tb.tools.get(0) : null;
   } catch (IOException e) {
     e.printStackTrace();
   }
   return tb;
 }