예제 #1
0
 // This is used both when loading a model and when the user is making
 // new widgets in the UI.  For most widget types, the same type string
 // is used in both places. - ST 3/17/04
 public Widget makeWidget(String type, boolean loading) {
   type = "DUMMY " + type.toUpperCase();
   Widget fromRegistry = org.nlogo.window.WidgetRegistry.apply(type);
   if (fromRegistry != null) {
     return fromRegistry;
   } else if (type.equals("DUMMY SLIDER")) {
     return new org.nlogo.window.DummySliderWidget();
   } else if (type.equals("DUMMY CHOOSER")
       || // current name
       type.equals("DUMMY CHOICE")) // old name, used in old models
   {
     return new org.nlogo.window.DummyChooserWidget(
         new org.nlogo.nvm.DefaultCompilerServices(workspace.compiler()));
   } else if (type.equals("DUMMY BUTTON")) {
     return new org.nlogo.window.DummyButtonWidget();
   } else if (type.equals("DUMMY PLOT")) {
     // note that plots on the HubNet client must have the name of a plot
     // on the server, thus, feed the dummy plot widget the names of
     // the current plots so the user can select one. We override
     // this method in InterfacePanel since regular plots are handled
     // differently ev 1/25/07
     String[] names = workspace.plotManager().getPlotNames();
     if (names.length > 0) {
       return DummyPlotWidget.apply(names[0], workspace.plotManager());
     } else {
       return DummyPlotWidget.apply("plot 1", workspace.plotManager());
     }
   } else if (type.equals("DUMMY MONITOR")) {
     return new org.nlogo.window.DummyMonitorWidget();
   } else if (type.equals("DUMMY INPUT")
       || // in the GUI, it's "Input Box"
       type.equals("DUMMY INPUTBOX")) // in saved models, it's "INPUTBOX"
   {
     java.awt.Font font =
         new java.awt.Font(org.nlogo.awt.Fonts.platformMonospacedFont(), java.awt.Font.PLAIN, 12);
     return new org.nlogo.window.DummyInputBoxWidget(
         new org.nlogo.window.CodeEditor(
             1, 20, font, false, null, new EditorColorizer(workspace), I18N.guiJ().fn()),
         new org.nlogo.window.CodeEditor(
             5, 20, font, true, null, new EditorColorizer(workspace), I18N.guiJ().fn()),
         this,
         new org.nlogo.nvm.DefaultCompilerServices(workspace.compiler()));
   } else if (type.equals("DUMMY OUTPUT")) // currently in saved models only - ST 3/17/04
   {
     return new org.nlogo.window.OutputWidget();
   } else if (type.equals("DUMMY CC-WINDOW")) // definitely in saved models only
   {
     // in current NetLogo versions, the command center goes in
     // a JSplitPane instead of in the InterfacePanel, so we ignore
     // the entry in the model - ST 7/13/04, 3/14/06
     return null;
   } else if (type.equals("DUMMY GRAPHICS-WINDOW")
       || type.equals("DUMMY VIEW")
       || type.equals("VIEW")) {
     view = new org.nlogo.window.DummyViewWidget(workspace.world);
     return view;
   } else {
     throw new IllegalStateException("unknown widget type: " + type);
   }
 }
예제 #2
0
 public SpeedSliderPanel(GUIWorkspace workspace, boolean labelsBelow) {
   this.workspace = workspace;
   this.labelsBelow = labelsBelow;
   speedSlider = new SpeedSlider((int) workspace.speedSliderPosition());
   speedSlider.setFocusable(false);
   speedSlider.addChangeListener(this);
   speedSlider.addMouseListener(this);
   speedSlider.setOpaque(false);
   org.nlogo.awt.Fonts.adjustDefaultFont(normal);
   setOpaque(false);
   if (labelsBelow) {
     GridBagLayout gridbag = new GridBagLayout();
     GridBagConstraints c = new GridBagConstraints();
     setLayout(gridbag);
     c.gridwidth = GridBagConstraints.REMAINDER;
     add(speedSlider, c);
     c.gridwidth = 1;
     c.anchor = GridBagConstraints.CENTER;
     add(normal, c);
   } else {
     java.awt.BorderLayout layout = new java.awt.BorderLayout();
     layout.setVgap(0);
     setLayout(layout);
     add(speedSlider, java.awt.BorderLayout.CENTER);
     add(normal, java.awt.BorderLayout.EAST);
   }
   enableLabels(0);
 }
예제 #3
0
 public DummyMonitorWidget() {
   super();
   setOpaque(true);
   setBackground(InterfaceColors.MONITOR_BACKGROUND);
   setBorder(widgetBorder());
   org.nlogo.awt.Fonts.adjustDefaultFont(this);
 }
예제 #4
0
 public ThreedButton() {
   super(" 3D "); // spaces so it isn't so tiny
   setFont(new java.awt.Font(org.nlogo.awt.Fonts.platformFont(), java.awt.Font.PLAIN, 10));
   setBackground(InterfaceColors.GRAPHICS_BACKGROUND);
   setBorder(org.nlogo.swing.Utils.createWidgetBorder());
   setFocusable(false);
   setToolTipText("Switch to 3D view");
   addActionListener(workspace.switchTo3DViewAction);
 }
예제 #5
0
 // This is used both when loading a model and when the user is making
 // new widgets in the UI.  For most widget types, the same type string
 // is used in both places. - ST 3/17/04
 @Override
 public Widget makeWidget(String type, boolean loading) {
   type = type.toUpperCase();
   Widget fromRegistry = org.nlogo.window.WidgetRegistry.apply(type);
   if (fromRegistry != null) {
     return fromRegistry;
   } else if (type.equalsIgnoreCase("SLIDER")) {
     return new org.nlogo.window.SliderWidget(workspace.world.auxRNG) {
       @Override
       public int sourceOffset() {
         return org.nlogo.workspace.Evaluator.sourceOffset(org.nlogo.agent.Observer.class, false);
       }
     };
   } else if (type.equals("CHOOSER")
       || // current name
       type.equals("CHOICE")) // old name, used in old models
   {
     return new org.nlogo.window.ChooserWidget(workspace);
   } else if (type.equals("BUTTON")) {
     return new org.nlogo.window.ButtonWidget(workspace.world.mainRNG);
   } else if (type.equals("PLOT")) {
     return org.nlogo.window.PlotWidget.apply(workspace.plotManager());
   } else if (type.equals("MONITOR")) {
     return new org.nlogo.window.MonitorWidget(workspace.world.auxRNG);
   } else if (type.equals("INPUT")
       || // in the GUI, it's "Input Box"
       type.equals("INPUTBOX")) // in saved models, it's "INPUTBOX"
   {
     java.awt.Font font =
         new java.awt.Font(org.nlogo.awt.Fonts.platformMonospacedFont(), java.awt.Font.PLAIN, 12);
     return new org.nlogo.window.InputBoxWidget(
         new org.nlogo.window.CodeEditor(
             1, 20, font, false, null, new EditorColorizer(workspace), I18N.guiJ().fn()),
         new org.nlogo.window.CodeEditor(
             5, 20, font, true, null, new EditorColorizer(workspace), I18N.guiJ().fn()),
         workspace,
         this);
   } else if (type.equals("OUTPUT")) // currently in saved models only - ST 3/17/04
   {
     return new org.nlogo.window.OutputWidget();
   } else if (type.equals("CC-WINDOW")) // definitely in saved models only
   {
     // in current NetLogo versions, the command center goes in
     // a JSplitPane instead of in the InterfacePanel, so we ignore
     // the entry in the model - ST 7/13/04, 3/14/06
     return null;
   } else {
     throw new IllegalStateException("unknown widget type: " + type);
   }
 }