예제 #1
0
파일: ToolBox.java 프로젝트: asw12/zoogas
  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;
  }
예제 #2
0
파일: ToolBox.java 프로젝트: asw12/zoogas
 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;
 }