private static void main2(String[] args) { Config.cmdline(args); try { javabughack(); } catch (InterruptedException e) { return; } setupres(); MainFrame f = new MainFrame(null); if (Utils.getprefb("fullscreen", false)) f.setfs(); f.mt.start(); try { f.mt.join(); } catch (InterruptedException e) { f.g.interrupt(); return; } dumplist(Resource.remote().loadwaited(), Config.loadwaited); dumplist(Resource.remote().cached(), Config.allused); if (ResCache.global != null) { try { Writer w = new OutputStreamWriter(ResCache.global.store("tmp/allused"), "UTF-8"); try { Resource.dumplist(Resource.remote().used(), w); } finally { w.close(); } } catch (IOException e) { } } System.exit(0); }
public void actionPerformed(ActionEvent e) { List<Resource> loadedDocuments; try { // get all the documents loaded in the system loadedDocuments = Gate.getCreoleRegister().getAllInstances("gate.Document"); } catch (GateException ge) { // gate.Document is not registered in creole.xml....what is!? throw new GateRuntimeException( "gate.Document is not registered in the creole register!\n" + "Something must be terribly wrong...take a vacation!"); } Vector<String> docNames = new Vector<String>(); for (Resource loadedDocument : new ArrayList<Resource>(loadedDocuments)) { if (corpus.contains(loadedDocument)) { loadedDocuments.remove(loadedDocument); } else { docNames.add(loadedDocument.getName()); } } JList docList = new JList(docNames); docList.getSelectionModel().setSelectionInterval(0, docNames.size() - 1); docList.setCellRenderer(renderer); final JOptionPane optionPane = new JOptionPane( new JScrollPane(docList), JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); final JDialog dialog = optionPane.createDialog(CorpusEditor.this, "Add document(s) to this corpus"); docList.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { optionPane.setValue(JOptionPane.OK_OPTION); dialog.dispose(); } } }); dialog.setVisible(true); if (optionPane.getValue().equals(JOptionPane.OK_OPTION)) { int[] selectedIndices = docList.getSelectedIndices(); for (int selectedIndice : selectedIndices) { corpus.add((Document) loadedDocuments.get(selectedIndice)); } } changeMessage(); }
/** Creates an places the components used by the GUI. */ private void placeComponents() { memory = new Resource("Memory"); cpu = new Resource("CPU"); io = new Resource("I/O"); loadImages(); backgroundPanel = new PicturePanel(background); getContentPane().setLayout(null); getContentPane().add(backgroundPanel); backgroundPanel.setBounds(0, 0, 494, 374); backgroundPanel.setLayout(null); backgroundPanel.add(memoryQueue); backgroundPanel.add(cpuQueue); backgroundPanel.add(ioQueue); backgroundPanel.add(memory); backgroundPanel.add(cpu); backgroundPanel.add(io); memoryQueue.setBounds(110, 20, 200, 50); memory.setBounds(310, 10, 90, 90); cpuQueue.setBounds(200, 120, 200, 50); cpu.setBounds(110, 110, 90, 90); ioQueue.setBounds(110, 220, 200, 50); io.setBounds(310, 210, 90, 90); JPanel lowerPanel = new JPanel(); lowerPanel.setLayout(null); getContentPane().add(lowerPanel); lowerPanel.setBounds(0, 374, 494, 100); simulationSpeedSlider = new JSlider(0, 10000, 8000); lowerPanel.add(simulationSpeedSlider); addSliderLabels(lowerPanel, 10, 10, 474, 20, "Slow", "Fast", "Simulation speed"); simulationSpeedSlider.setBounds(10, 30, 474, 20); timeElapsedLabel = new JLabel("Simulated time elapsed: " + timeElapsed + " ms."); lowerPanel.add(timeElapsedLabel); timeElapsedLabel.setBounds(10, 60, 300, 20); startButton = new JButton("Start simulation"); lowerPanel.add(startButton); startButton.setBounds(320, 60, 154, 20); startButton.addActionListener(this); }
private static void dumplist(Collection<Resource> list, String fn) { try { if (fn != null) { Writer w = new OutputStreamWriter(new FileOutputStream(fn), "UTF-8"); try { Resource.dumplist(list, w); } finally { w.close(); } } } catch (IOException e) { throw (new RuntimeException(e)); } }
synchronized void loadResource(Resource r) { if (DEBUG.RESOURCE || DEBUG.IMAGE) out("loadResource: " + Util.tag(r) + " " + r); mResource = r; if (r != null) mPreviewData = r.getPreview(); else mPreviewData = null; mImage = null; // URLResource decides this // if (mPreviewData == null && mResource.isImage()) // mPreviewData = mResource; loadPreview(mPreviewData); }
public static void setupres() { if (ResCache.global != null) Resource.setcache(ResCache.global); if (Config.resurl != null) Resource.addurl(Config.resurl); if (ResCache.global != null) { try { Resource.loadlist(Resource.remote(), ResCache.global.fetch("tmp/allused"), -10); } catch (IOException e) { } } if (!Config.nopreload) { try { InputStream pls; pls = Resource.class.getResourceAsStream("res-preload"); if (pls != null) Resource.loadlist(Resource.remote(), pls, -5); pls = Resource.class.getResourceAsStream("res-bgload"); if (pls != null) Resource.loadlist(Resource.remote(), pls, -10); } catch (IOException e) { throw (new Error(e)); } } }
void rootdraw(GLState.Applier state, UI ui, BGL gl) { GLState.Buffer ibuf = new GLState.Buffer(state.cfg); gstate.prep(ibuf); ostate.prep(ibuf); GOut g = new GOut(gl, state.cgl, state.cfg, state, ibuf, new Coord(w, h)); state.set(ibuf); g.state(ostate); g.apply(); gl.glClearColor(0, 0, 0, 1); gl.glClear(GL.GL_COLOR_BUFFER_BIT); synchronized (ui) { ui.draw(g); } if (Config.dbtext) { int y = h - 150; FastText.aprintf( g, new Coord(10, y -= 15), 0, 1, "FPS: %d (%d%%, %d%% idle)", fps, (int) (uidle * 100.0), (int) (ridle * 100.0)); Runtime rt = Runtime.getRuntime(); long free = rt.freeMemory(), total = rt.totalMemory(); FastText.aprintf( g, new Coord(10, y -= 15), 0, 1, "Mem: %,011d/%,011d/%,011d/%,011d", free, total - free, total, rt.maxMemory()); FastText.aprintf(g, new Coord(10, y -= 15), 0, 1, "Tex-current: %d", TexGL.num()); FastText.aprintf(g, new Coord(10, y -= 15), 0, 1, "GL progs: %d", g.st.numprogs()); GameUI gi = ui.root.findchild(GameUI.class); if ((gi != null) && (gi.map != null)) { try { FastText.aprintf( g, new Coord(10, y -= 15), 0, 1, "MV pos: %s (%s)", gi.map.getcc(), gi.map.camera); } catch (Loading e) { } if (gi.map.rls != null) FastText.aprintf( g, new Coord(10, y -= 15), 0, 1, "Rendered: %,d+%,d(%,d)", gi.map.rls.drawn, gi.map.rls.instanced, gi.map.rls.instancified); } if (Resource.remote().qdepth() > 0) FastText.aprintf( g, new Coord(10, y -= 15), 0, 1, "RQ depth: %d (%d)", Resource.remote().qdepth(), Resource.remote().numloaded()); } Object tooltip; try { synchronized (ui) { tooltip = ui.root.tooltip(mousepos, ui.root); } } catch (Loading e) { tooltip = "..."; } Tex tt = null; if (tooltip != null) { if (tooltip instanceof Text) { tt = ((Text) tooltip).tex(); } else if (tooltip instanceof Tex) { tt = (Tex) tooltip; } else if (tooltip instanceof Indir<?>) { Indir<?> t = (Indir<?>) tooltip; Object o = t.get(); if (o instanceof Tex) tt = (Tex) o; } else if (tooltip instanceof String) { if (((String) tooltip).length() > 0) tt = (Text.render((String) tooltip)).tex(); } } if (tt != null) { Coord sz = tt.sz(); Coord pos = mousepos.add(sz.inv()); if (pos.x < 0) pos.x = 0; if (pos.y < 0) pos.y = 0; g.chcolor(244, 247, 21, 192); g.rect(pos.add(-3, -3), sz.add(6, 6)); g.chcolor(35, 35, 35, 192); g.frect(pos.add(-2, -2), sz.add(4, 4)); g.chcolor(); g.image(tt, pos); } ui.lasttip = tooltip; Resource curs = ui.root.getcurs(mousepos); if (curs != null) { if (cursmode == "awt") { if (curs != lastcursor) { try { setCursor(makeawtcurs(curs.layer(Resource.imgc).img, curs.layer(Resource.negc).cc)); lastcursor = curs; } catch (Exception e) { cursmode = "tex"; } } } else if (cursmode == "tex") { Coord dc = mousepos.add(curs.layer(Resource.negc).cc.inv()); g.image(curs.layer(Resource.imgc), dc); } } state.clean(); GLObject.disposeall(state.cgl, gl); }
/** * Controls which process is being shown as the process active in the I/O device. * * @param p The process that is currently active, or null if the I/O device is idle. */ public void setIoActive(Process p) { io.setActiveProcess(p); }
/** * Controls which process is being shown as the process active in the CPU. * * @param p The process that is currently active, or null if the CPU is idle. */ public void setCpuActive(Process p) { cpu.setActiveProcess(p); }