示例#1
0
 public InterfacePanel(
     org.nlogo.window.ViewWidgetInterface viewWidget, org.nlogo.window.GUIWorkspace workspace) {
   super(workspace);
   this.viewWidget = viewWidget;
   workspace.setWidgetContainer(this);
   // in 3d don't add the view widget since it's always
   // disabled there's no reason for it to take space 7/5/07
   if (!Version.is3D()) {
     addWidget((Widget) viewWidget, 0, 0, false, false);
   }
   ((Widget) viewWidget).deleteable_$eq(false);
   addKeyListener(this);
   addMouseListener(this);
 }
示例#2
0
 /**
  * opens a NetLogo model from the previously loaded source. This is complicated and I'm not
  * totally sure I understand it, but it really should be documented...
  *
  * @param source the model source. May not be null.
  * @param path the full pathname of the model, including the file. For example:
  *     "/home/mmh/models/My_Model.nlogo". This may be null, if, for example, this is a new model,
  *     or the origin is unknown.
  * @param message the message to display in the "loading" modal dialog.
  * @param modelType the type of this model. Must be one of the types defined in
  *     org.nlogo.workspace.Workspace.
  */
 void openFromSource(String source, String path, String message, ModelType modelType)
     throws UserCancelException {
   // map elements are { source, info, resources, version }
   Map<ModelSection, String[]> map = ModelReader.parseModel(source);
   if (map == null || map.get(ModelSectionJ.VERSION()).length == 0) {
     notifyUserNotValidFile();
   }
   String version = org.nlogo.api.ModelReader.parseVersion(map);
   if (version == null || !version.startsWith("NetLogo")) {
     notifyUserNotValidFile();
   }
   if (org.nlogo.api.Version.is3D() && !org.nlogo.api.Version.is3D(version)) {
     checkWithUserBeforeOpening2DModelin3D();
   }
   if (!org.nlogo.api.Version.is3D() && org.nlogo.api.Version.is3D(version)) {
     checkWithUserBeforeOpening3DModelin2D(version);
   } else {
     if (!org.nlogo.api.Version.knownVersion(version)) {
       checkWithUserBeforeOpeningModelFromFutureVersion(version);
     }
   }
   openFromMap(map, path, message, modelType);
   savedVersion = version;
 }
示例#3
0
  public FileMenu(App app, ModelSaver modelSaver, AppletSaver appletSaver) {
    super(I18N.guiJ().get("menu.file"));
    this.app = app;
    this.modelSaver = modelSaver;
    this.appletSaver = appletSaver;
    addMenuItem('N', new NewAction());
    addMenuItem('O', new OpenAction());
    addMenuItem('M', new ModelsLibraryAction());
    addSeparator();
    addMenuItem('S', new SaveAction());
    addMenuItem(new SaveAsAction());
    addMenuItem(new SaveAppletAction());
    addSeparator();
    addMenuItem(I18N.guiJ().get("menu.file.print"), 'P', app.tabs().printAction());
    addSeparator();
    org.nlogo.swing.Menu exportMenu = new org.nlogo.swing.Menu(I18N.guiJ().get("menu.file.export"));
    exportMenu.addMenuItem(new ExportWorldAction());
    exportMenu.addMenuItem(new ExportPlotAction());
    exportMenu.addMenuItem(new ExportAllPlotsAction());
    exportMenu.addMenuItem(new ExportGraphicsAction());
    exportMenu.addMenuItem(new ExportInterfaceAction());
    exportMenu.addMenuItem(new ExportOutputAction());
    add(exportMenu);
    addSeparator();
    org.nlogo.swing.Menu importMenu = new org.nlogo.swing.Menu(I18N.guiJ().get("menu.file.import"));
    importMenu.addMenuItem(new ImportWorldAction());
    importMenu.addMenuItem(new ImportPatchColorsAction());
    importMenu.addMenuItem(new ImportPatchColorsRGBAction());
    if (!org.nlogo.api.Version.is3D()) {
      importMenu.addMenuItem(new ImportDrawingAction());
    }
    importMenu.addMenuItem(new ImportClientAction());

    add(importMenu);
    if (!System.getProperty("os.name").startsWith("Mac")) {
      addSeparator();
      addMenuItem('Q', new QuitAction());
    }
    // initialize here, unless there's a big problem early on in the
    // initial load process it'll get initialize properly below
    // maybe this fixes Nigel Gilbert's bug. maybe. ev 1/30/07
    savedVersion = org.nlogo.api.Version.version();
  }
示例#4
0
 public static void doHelp(java.awt.Component comp, String token) {
   if (!quickHelpLoaded) {
     quickHelpWords = loadHelp(QUICKHELPWORDS_PATH);
     // if we're not in 3D don't load the 3d dictionary words
     // cause we don't need 'em and they'll override the 2d
     // dictionary ev 10/25/07
     if (org.nlogo.api.Version.is3D()) {
       quickHelpWords3d = loadHelp(QUICKHELPWORDS_PATH3D);
     } else {
       quickHelpWords3d = new HashMap<String, String>();
     }
     quickHelpLoaded = true;
   }
   if (token == null) {
     return;
   }
   token = token.toLowerCase();
   // if there is an entry in the 3D dictionary then it overrides
   // the 2D entry ev 10/25/07
   if (quickHelpWords3d.containsKey(token)) {
     openDictionary(comp, token, quickHelpWords3d);
   } else if (quickHelpWords.containsKey(token)) {
     openDictionary(comp, token, quickHelpWords);
   } else {
     if (0
         == javax.swing.JOptionPane.showConfirmDialog(
             comp,
             token.toUpperCase()
                 + " could not be found in the NetLogo Dictionary.\n"
                 + "Would you like to open the full NetLogo Dictionary?",
             "NetLogo",
             javax.swing.JOptionPane.YES_NO_OPTION)) {
       org.nlogo.swing.BrowserLauncher.openURL(comp, "docs/index2.html", true);
     }
   }
 }
示例#5
0
 public static String modelSuffix() {
   return org.nlogo.api.Version.is3D() ? "nlogo3d" : "nlogo";
 }
示例#6
0
 SaveAppletAction() {
   super(I18N.guiJ().get("menu.file.saveAsApplet"));
   // disabled for 3-D since it doesn't work - ST 2/25/05
   setEnabled(!org.nlogo.api.Version.is3D());
 }