Example #1
0
 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);
 }
Example #2
0
 public void show() {
   for (int i = 0; i < resourceCount; i++) {
     Resource resource = (Resource) resources.elementAt(i);
     ((Label) resourceIdLabelVector.elementAt(i)).setText(Integer.toString(resource.getId()));
     ((Label) resourceAvailableLabelVector.elementAt(i))
         .setText(Integer.toString(resource.getCurrentAvailable()));
   }
   super.show();
 }
Example #3
0
 @Override
 public void copyTo(VGDLSprite target) {
   Resource targetSprite = (Resource) target;
   targetSprite.limit = limit;
   targetSprite.value = value;
   targetSprite.resource_type = resource_type;
   targetSprite.resource_name = resource_name;
   super.copyTo(targetSprite);
 }
Example #4
0
  /** 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);
  }
Example #5
0
 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));
   }
 }
Example #6
0
  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);
  }
Example #7
0
 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));
     }
   }
 }
Example #8
0
 /**
  * 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);
 }
Example #9
0
 /**
  * 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);
 }
Example #10
0
  RootWindow(Container container, Screen screen, Format[] format, Client c) {
    super(screen.rootId);
    rootwindow = container;
    client = c;
    screen.setRoot((Window) this);
    this.width = (short) (screen.width);
    this.height = (short) (screen.height);
    this.screen = screen;
    depth = screen.rootDepth;
    id = screen.rootId;
    type = DRAWABLE_WINDOW;
    x = y = 0;
    origin.x = 0;
    origin.y = 0;
    clss = (byte) InputOutput;
    for (int i = 0; i < format.length; i++) {
      if (format[i].depth == screen.rootDepth) {
        this.bitsPerPixel = format[i].bpp;
      }
    }
    setVisual(screen.rootVisual);
    setBackgroundIsPixel();
    background.pixel = screen.white;

    setBorderIsPixel();
    border.pixel = screen.black;
    borderWidth = 0;
    Resource.add(this);
    makeOptional();
    attr &= ~(1 << 3); // cursorIsNone

    optional.cursor = Cursor.rootCursor;
    setColormap(screen.defaultColormap);

    //  if(rootwindow instanceof JFrame){
    //    rootwindow.setSize(this.width+10, this.height+30); // ??
    //  }
    //  else{
    rootwindow.setSize(this.width, this.height);
    //  }

    try {
      ddxwindow = (DDXWindow) (Window.dDXWindow.newInstance());
    } catch (Exception e) {
      System.err.println(e);
      /*ddxwindow=new DDXWindowImp();*/
    }

    ddxwindow.init(this);
    ddxwindow.setLocation(0, 0);

    if (rootwindow instanceof Frame) {
      // ((Frame)rootwindow).setLayout(null);
      ((Frame) rootwindow).setResizable(false);
      ((Frame) rootwindow).setMenuBar(null);
      ((Frame) rootwindow).add((java.awt.Component) ddxwindow);
    } else if (rootwindow instanceof Applet) {
      ((Applet) rootwindow).add((java.awt.Component) ddxwindow);
    }
    /*
        else if(rootwindow instanceof JFrame){
          ((JFrame)rootwindow).getContentPane().setLayout(null);
          ((JFrame)rootwindow).setResizable(false);
          ((JFrame)rootwindow).setJMenuBar(null);
          ((JFrame)rootwindow).getContentPane().add((java.awt.Component)ddxwindow);
        }
        else if(rootwindow instanceof JWindow){
          ((JWindow)rootwindow).getContentPane().setLayout(null);
          ((JWindow)rootwindow).getContentPane().add((java.awt.Component)ddxwindow);
        }
        else if (rootwindow instanceof JApplet){
          ((JApplet)rootwindow).setJMenuBar(null);
          ((JApplet)rootwindow).getContentPane().add((java.awt.Component)ddxwindow);
        }
    */
    else {
      rootwindow.add((java.awt.Component) ddxwindow);
    }

    if (screen.windowmode != WeirdX.InBrowser) {
      rootwindow.addNotify();
    } else {
      rootwindow.setVisible(true);
    }
    ddxwindow.setVisible(true);

    {
      rootwindow.validate();
      Insets insets = rootwindow.getInsets();
      rootwindow.setSize(
          this.width + insets.left + insets.right, this.height + insets.top + insets.bottom);
      ddxwindow.setLocation(insets.left, insets.top);
      rootwindow.validate();
    }

    ddxwindow.requestFocus();
    Window.focus.win = id;

    Window.LOCK = rootwindow.getTreeLock();
    Client.LOCK = rootwindow.getTreeLock();
    Resource.LOCK = rootwindow.getTreeLock();

    spriteTrace[0] = this;
    sprite.win = this;
  }