示例#1
0
  /** Clear the current cells and replace with the indicated starting pattern. */
  public void reset(String patternName) {
    stop = true;
    int temp = generationMax;
    setGenerationCount(0);
    setMaxGenerations(0);
    if (patternName.equals("Random")) {
      theModel.reset(0.5);
    } else if (patternName.equals("R-Pentamino")) {
      theModel.reset(1);
    } else if (patternName.equals("Box")) {
      theModel.reset(2);
    } else if (patternName.equals("X Box")) {
      theModel.reset(3);
    }

    canvas.repaint();
    // runGenerations(); //* Replace this by appropriate use of a thread

    synchronized (canvas) {
      canvas.notifyAll();
      stop = false;
      canvas.repaint();
    }
    setMaxGenerations(temp);
    setGenerationCount(0);
  }
示例#2
0
  public static void main(String[] args) {
    final JavaMixer sm = new JavaMixer();
    final JFrame jf = new JFrame("Mixer Test");
    final JPanel jp = new JPanel();
    jf.add(jp);
    jp.add(sm.getTree());
    jf.setSize(600, 500);
    jf.setVisible(true);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    sm.getTree()
        .addTreeSelectionListener(
            e -> {
              TreePath path = e.getPath();
              if (path.getLastPathComponent() instanceof ControlNode) {
                ControlNode controlNode = (ControlNode) path.getLastPathComponent();
                if (!(controlNode.getControl() instanceof CompoundControl)) {
                  if (jp.getComponentCount() > 1) jp.remove(1);
                  jp.add(controlNode.getComponent(), 1);
                  jp.repaint();
                }
              }
            });
    jp.add(sm.getPrefferedMasterVolume());
    jp.add(sm.getPrefferedMasterVolume());
    jp.add(sm.getPrefferedInputVolume());
    jp.repaint();
    sm.setMicrophoneInput();
    sm.setMuteForMicrophoneOutput();
  }
示例#3
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == easy) {
      invSpeed = 50000;
      bombN = 1;
      timeDifficulty1 = 1000;
      distanceLimit = 400;
      monsterMultiplier = 1;
      multiplier = 1;
      setup();
    } else if (e.getSource() == hard) {
      invSpeed = 30000;
      bombN = 4;
      timeDifficulty1 = 500;
      distanceLimit = 200;
      monsterMultiplier = 2;
      multiplier = 2;
      setup();
    } else if (e.getSource() == back) {
      r = null;
      menu.setVisible(true);
      back.setVisible(false);
      this.revalidate();
      repaint();
    } else if (e.getSource() == howTo) {
      menu.removeAll();

      menu.add(howToBack);
      menu.add(howToIMGL);

      menu.revalidate();
      menu.repaint();
    } else if (e.getSource() == howToBack) {
      menu.remove(howToIMGL);
      menu.remove(howToBack);

      menu.add(keyboardSpeedL1);
      menu.add(keyboardSpeedL2);
      menu.add(easy);
      menu.add(hard);
      menu.add(howTo);
      menu.add(onePlayerRB);
      menu.add(twoPlayerRB);
      menu.add(mouseRB);
      menu.add(keyboardRB);
      menu.add(keyboardSpeedS1);
      menu.add(keyboardSpeedS2);
      menu.add(musicCB);
      menu.add(highscoreL);
      menu.add(menuIMGL);

      menu.revalidate();
      menu.repaint();
    }
  }
示例#4
0
 /**
  * Method to set the mouse dragged actions
  *
  * @param e
  */
 public void mouseDragged(MouseEvent e) {
   if (dragging) {
     Point p = e.getPoint();
     int x = p.x - offset.x;
     int y = p.y - offset.y;
     Dimension d = selectedComponent.getSize();
     selectedComponent.setBounds(x, y, d.width, d.height);
     if (!selected) {
       activePanel.repaint();
       selected = false;
     }
     glassPanel.repaint();
   }
 }
示例#5
0
文件: LJ3MDApp.java 项目: eskilj/mvp
  //    int frame = 0;
  public void paint(Graphics g) {
    // System.out.println("frame: " + (frame++));
    lStatus.setText(
        "t = "
            + df.format(md.dt * md.step)
            + ", "
            + "N = "
            + md.N
            + ", "
            + "E/N = "
            + df.format(md.E / md.N)
            + ", "
            + "U/N = "
            + df.format(md.U / md.N)
            + ", "
            + "K/N = "
            + df.format(md.K / md.N)
            + ", "
            + "p = "
            + df.format(md.p)
            + ";");
    tAvK.setText(df.format(md.avK.getAve() / md.N) + "  ");
    tAvU.setText(df.format(md.avU.getAve() / md.N) + "  ");
    tTemp.setText(df.format((2 * md.K) / (3 * (md.N - 1))) + "  ");
    tAvp.setText(df.format(md.avp.getAve()) + "  ");
    canvas.refresh(md.getXWrap(), md.N, true, false);
    cpnl.repaint();
    spnl.repaint();

    try {

      PrintWriter wavefunc =
          new PrintWriter(new FileOutputStream(new File("energyData.txt"), true));
      wavefunc.print(md.E / md.N + " " + md.K / md.N + " " + md.U / md.N);
      wavefunc.println();
      wavefunc.close();
    } catch (IOException ex) {
    }

    try {

      PrintWriter tempwriter =
          new PrintWriter(new FileOutputStream(new File("tempData.txt"), true));
      tempwriter.print(df.format((2 * md.K) / (3 * (md.N - 1))));
      tempwriter.println();
      tempwriter.close();
    } catch (IOException ex) {
    }
  }
  private void resetSemImEditor() {
    java.util.List<SemEstimator> semEstimators = wrapper.getMultipleResultList();

    if (semEstimators.size() == 1) {
      SemEstimator estimatedSem = semEstimators.get(0);
      SemImEditor editor = new SemImEditor(new SemImWrapper(estimatedSem.getEstimatedSem()));
      panel.removeAll();
      panel.add(editor, BorderLayout.CENTER);
      panel.revalidate();
      panel.repaint();

    } else {
      JTabbedPane tabs = new JTabbedPane();

      for (int i = 0; i < semEstimators.size(); i++) {
        SemEstimator estimatedSem = semEstimators.get(i);
        SemImEditor editor = new SemImEditor(new SemImWrapper(estimatedSem.getEstimatedSem()));
        JPanel _panel = new JPanel();
        _panel.setLayout(new BorderLayout());
        _panel.add(editor, BorderLayout.CENTER);
        tabs.addTab(estimatedSem.getDataSet().getName(), _panel);
      }

      panel.removeAll();
      panel.add(tabs);
      panel.validate();
    }
  }
  private void setupPanels(@Nullable ProjectTemplate template) {

    restorePanel(myNamePathComponent, 4);
    restorePanel(myModulePanel, myWizardContext.isCreatingNewProject() ? 8 : 6);
    restorePanel(myExpertPanel, myWizardContext.isCreatingNewProject() ? 1 : 0);
    mySettingsStep = myModuleBuilder == null ? null : myModuleBuilder.modifySettingsStep(this);

    String description = null;
    if (template != null) {
      description = template.getDescription();
      if (StringUtil.isNotEmpty(description)) {
        StringBuilder sb = new StringBuilder("<html><body><font ");
        sb.append(SystemInfo.isMac ? "" : "face=\"Verdana\" size=\"-1\"").append('>');
        sb.append(description).append("</font></body></html>");
        description = sb.toString();
        myDescriptionPane.setText(description);
      }
    }

    myExpertPlaceholder.setVisible(
        !(myModuleBuilder instanceof TemplateModuleBuilder)
            && myExpertPanel.getComponentCount() > 0);
    for (int i = 0; i < 6; i++) {
      myModulePanel.getComponent(i).setVisible(!(myModuleBuilder instanceof EmptyModuleBuilder));
    }
    myDescriptionPanel.setVisible(StringUtil.isNotEmpty(description));

    mySettingsPanel.revalidate();
    mySettingsPanel.repaint();
  }
示例#8
0
  protected void moveBall() {
    // System.out.println("I'm in the moveBall() function!");
    int width = getWidth();
    int height = getHeight();
    int min, max, randomX, randomY;
    min = 0;
    max = 200;
    randomX = min + (int) (Math.random() * ((max - min) + 1));
    randomY = min + (int) (Math.random() * ((max - min) + 1));
    // System.out.println(randomX + ", " + randomY);

    Rectangle ballBounds = ball.getBounds();
    //      //System.out.println(ballBounds.x + ", " + ballBounds.y);
    //      if (ballBounds.x + randomX < 0) {
    //          randomX = 200;
    //      } else if (ballBounds.x + ballBounds.width + randomX > width) {
    //          randomX = -200;
    //      }
    //      if (ballBounds.y + randomY < 0) {
    //          randomY = 200;
    //      } else if (ballBounds.y + ballBounds.height + randomY > height) {
    //          randomY = -200;
    //      }

    ballBounds.x = randomX;
    ballBounds.y = randomY;
    _ballXpos = ballBounds.x;
    _ballYpos = ballBounds.y;
    ball.setFrame(ballBounds);
    thePlacebo.repaint();
  }
  private void buildExternalsPanel() {

    FormBuilder builder = FormBuilder.create().layout(new FormLayout("fill:pref:grow", "p"));
    int row = 1;
    for (ExternalFileEntry efe : externals) {
      builder.add(efe.getPanel()).xy(1, row);
      builder.appendRows("2dlu, p");
      row += 2;
    }
    builder.add(Box.createVerticalGlue()).xy(1, row);
    builder.appendRows("2dlu, p, 2dlu, p");
    builder.add(addExtPan).xy(1, row + 2);
    builder.add(Box.createVerticalGlue()).xy(1, row + 2);

    // builder.getPanel().setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.green));
    // externalFilesPanel.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red));
    JScrollPane pane = new JScrollPane(builder.getPanel());
    pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    externalFilesPanel.setMinimumSize(new Dimension(400, 400));
    externalFilesPanel.setPreferredSize(new Dimension(400, 400));
    externalFilesPanel.removeAll();
    externalFilesPanel.add(pane, BorderLayout.CENTER);
    externalFilesPanel.revalidate();
    externalFilesPanel.repaint();
  }
示例#10
0
 /** Set the number of cells in the width & height of the model. */
 public void setModelSize(int newSize) {
   modelSize = newSize;
   theModel.setSize(modelSize);
   sizeDisplay.setText("" + modelSize);
   setGenerationCount(0);
   canvas.repaint();
 }
 public void filterPacks() {
   packPanels.clear();
   packs.removeAll();
   currentPacks.clear();
   packMapping.clear();
   int counter = 0;
   selectedPack = 0;
   packInfo.setText("");
   // all removed, repaint
   packs.repaint();
   // not really needed
   // modPacksAdded = false;
   for (ModPack pack : ModPack.getPackArray()) {
     if (filterForTab(pack)
         && mcVersionCheck(pack)
         && avaliabilityCheck(pack)
         && textSearch(pack)) {
       currentPacks.put(counter, pack);
       packMapping.put(counter, pack.getIndex());
       addPack(pack);
       counter++;
     }
   }
   updateDatas();
   updatePacks();
 }
示例#12
0
  public static void updateResultsTable(Object[][] data) {
    // remove old route table
    resultsPanel.removeAll();

    // create new route table
    String[] columnNames = {
      "Route #", "Carrier", "Dep. Airport", "Dep. Time", "Arr. Airport", "Arr. Time", "Price"
    };
    JScrollPane routeTable =
        new JScrollPane(
            new JTable(data, columnNames) {
              public boolean isCellEditable(int rowIndex, int vColIndex) {
                return false;
              };
            });
    // create the routes table in a scrollPane
    routeTable.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    routeTable.setPreferredSize(new Dimension(resultsPanelWidth, resultsPanelHeight));
    resultsPanel.add(routeTable); // add the table to the JPanel
    resultsPanel.setBorder(BorderFactory.createTitledBorder("Search Results"));

    // display new route table
    resultsPanel.revalidate();
    resultsPanel.repaint();
  }
示例#13
0
文件: InGame.java 项目: eR3tbvK/1.96
  public void drawPanel() {
    try {
      // System.out.println("right before the while loop of the thread");
      // layeredPane.add(background,99);

      panel.remove(layeredPane);
      Iterator<PlayerMob> allPlayers = players.iterator();
      PlayerMob aPlayer = null;
      /*while(allPlayers.hasNext()){
      	aPlayer = (PlayerMob) allPlayers.next();
      	//System.out.println("INTHELOOP:info.getUsername ="******" myChat.getUsername ="******"for loop index catch");
      	continue;
      }*/

    } catch (NullPointerException ed) {
      System.err.println("for loop null catch");
      // startDrawingPanelThread();
    } catch (Exception ev) {
      System.err.println("for loop catch");
      ev.printStackTrace();
    }
  }
示例#14
0
 public static void drawImage(int[][][] pixels, int startX, int startY) {
   // Key idea: draw a bunch (lots of rectangles) with the appropriate color
   DrawObject R = new DrawObject();
   R.pixels = pixels;
   R.startX = startX;
   R.startY = startY;
   R.sequenceNum = currentSequenceNum;
   images.add(R);
   // Rescale if needed.
   int leftX = startX;
   int rightX = startX + pixels.length;
   int lowY = startY;
   int highY = startY + pixels[0].length;
   if (minX > leftX) {
     minX = leftX;
   }
   if (maxX < rightX) {
     maxX = rightX;
   }
   if (minY > lowY) {
     minY = lowY;
   }
   if (maxY < highY) {
     maxY = highY;
   }
   drawArea.repaint();
 }
示例#15
0
 private void moveCacheToState(ComponentStatus state) {
   switch (state) {
     case INITIALIZING:
       cacheStatus.setText(statusStarting);
       processAction(actionButton, true);
       break;
     case RUNNING:
       setCacheTabsStatus(true);
       actionButton.setText(stopCacheButtonLabel);
       processAction(actionButton, false);
       cacheStatus.setText(statusStarted);
       updateTitleBar();
       break;
     case STOPPING:
       cacheStatus.setText(statusStopping);
       processAction(actionButton, true);
       break;
     case TERMINATED:
       setCacheTabsStatus(false);
       actionButton.setText(startCacheButtonLabel);
       processAction(actionButton, false);
       cacheStatus.setText(statusStopped);
       updateTitleBar();
   }
   controlPanelTab.repaint();
 }
    private void checkSdk() {
      final String path = mySdkEditor.getPath();
      if (StringUtil.isEmptyOrSpaces(path)) {
        myErrorLabel.setVisible(true);
        myErrorLabel.setHyperlinkText("App Engine SDK path not specified. ", "Download", "");
        myMainPanel.repaint();
        return;
      }

      final ValidationResult result = AppEngineSdkUtil.checkPath(path);
      myErrorLabel.setVisible(!result.isOk());
      if (!result.isOk()) {
        myErrorLabel.setText("App Engine SDK path is not correct");
      }
      myMainPanel.repaint();
    }
示例#17
0
 static void handleMouseClick(MouseEvent e) {
   double midX = (maxX + minX) / 2;
   double midXDist = midX - minX;
   double midY = (maxY + minY) / 2;
   double midYDist = midY - minY;
   // See if any of the navigation icons were under the mouse.
   if (withinBounds(e.getX(), e.getY(), D.width - 20, D.width - 15, 10, 20)) {
     // Plus.
     setXYRange(minX, midX, minY, midY);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 20, D.width - 15, 40, 50)) {
     // Minus.
     setXYRange(minX, 2 * maxX, minY, 2 * maxY);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 75, D.width - 65, 0, 20)) {
     //
     setXYRange(minX, maxX, minY + midYDist, maxY + midYDist);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 75, D.width - 65, 30, 50)) {
     //
     setXYRange(minX, maxX, minY - midYDist, maxY - midYDist);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 65, D.width - 45, 20, 30)) {
     //
     setXYRange(minX + midXDist, maxX + midXDist, minY, maxY);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 95, D.width - 75, 20, 30)) {
     //
     setXYRange(minX - midXDist, maxX - midXDist, minY, maxY);
   }
   drawArea.repaint();
 }
 private void clearDeleteRecord() {
   if (deleteList != null) {
     java.util.List list = deleteList.getSelection();
     if (list.size() > 0) {
       try {
         java.util.List dbIDs = new ArrayList(list.size());
         for (Iterator it = list.iterator(); it.hasNext(); ) {
           GKInstance instance = (GKInstance) it.next();
           dbIDs.add(instance.getDBID());
         }
         fileAdaptor.clearDeleteRecord(dbIDs);
       } catch (IOException e) {
         System.err.println("SynchronizationDialog.clearDeleteRecord(): " + e);
         e.printStackTrace();
       }
       deleteList.deleteInstances(list);
       // Check if deleteList needs to be removed
       if (deleteList.getDisplayedInstances().size() == 0) {
         centerPane.remove(deleteList);
         centerPane.validate();
         centerPane.repaint();
       }
     }
   }
 }
示例#19
0
 static void handleKeyTyped(KeyEvent e) {
   if (e.getKeyChar() == ' ') {
     currentSequenceNumDisplay++;
     scribbles = Collections.synchronizedList(new ArrayList<DrawObject>());
     currentScribbleNum = 0;
   }
   drawArea.repaint();
 }
 private void removeInstanceList(InstanceListPane listPane) {
   SectionTitlePane titlePane = (SectionTitlePane) listToTitle.get(listPane);
   centerPane.remove(titlePane);
   centerPane.remove(listPane);
   centerPane.validate();
   centerPane.repaint();
   listToTitle.remove(listPane);
 }
示例#21
0
 static void handleMouseDragged(MouseEvent e) {
   DrawObject L = new DrawObject();
   L.scribbleX = e.getX();
   L.scribbleY = e.getY();
   L.scribbleNum = currentScribbleNum;
   scribbles.add(L);
   drawArea.repaint();
 }
示例#22
0
 private void swapContainers(Container newContainer) {
   if (newContainer != null) {
     swappableContainer.removeAll();
     swappableContainer.add(newContainer);
     swappableContainer.repaint();
     swappableContainer.validate();
   }
 }
 public void setValue(String key, JComponent value) {
   JPanel p = keyValueComponentMap.get(key);
   p.removeAll();
   p.add(value);
   p.add(Box.createHorizontalGlue());
   p.repaint();
   p.getParent().repaint();
 }
 private void showStepComponent(final Component component) {
   String id = myComponentToIdMap.get(component);
   if (id == null) {
     id = addStepComponent(component);
     myContentPanel.revalidate();
     myContentPanel.repaint();
   }
   ((CardLayout) myContentPanel.getLayout()).show(myContentPanel, id);
 }
示例#25
0
 public void toggleSoundText(boolean muted) {
   if (!muted) {
     taSound.setText("Sound is:    on");
   } else {
     taSound.setText("Sound is:    off");
   }
   contentPane.revalidate();
   contentPane.repaint();
 }
示例#26
0
  private void restoreEmptyStatus() {
    removeAll();
    setLayout(new BorderLayout());
    add(myRefreshAndInfoPanel, BorderLayout.CENTER);

    myProgressIcon.suspend();
    myRefreshAndInfoPanel.revalidate();
    myRefreshAndInfoPanel.repaint();
  }
示例#27
0
  private void repaintContent() {
    if (content != null) {
      remove(content);
    }
    content = new JPanel();

    content.setLayout(new GridBagLayout());
    content.setBackground(Colors.TEMPLATE);
    int gridY = 0;
    GridBagConstraints c;
    for (Parameter p : shownParams.getParamList()) {
      c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = gridY;
      c.anchor = GridBagConstraints.WEST;
      c.fill = GridBagConstraints.NONE;
      c.insets = new Insets(0, 0, 0, 8);
      content.add(new JLabel(p.getName()), c);

      c = new GridBagConstraints();
      c.gridx = 1;
      c.gridy = gridY++;
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1;
      final Parameter pFinal = p;
      final JTextField jTextField = new DJTextField();
      jTextField.setText(p.getValue());
      jTextField.addKeyListener(
          new KeyListener() {
            public void keyTyped(KeyEvent keyEvent) {
              // TODO
            }

            public void keyPressed(KeyEvent keyEvent) {
              // TODO
            }

            public void keyReleased(KeyEvent keyEvent) {
              pFinal.setValue(jTextField.getText());
            }
          });
      content.add(jTextField, c);
    }

    GridBagConstraints nc = new GridBagConstraints();
    nc.gridx = 0;
    nc.gridy = 0;
    nc.weightx = 1;
    nc.fill = GridBagConstraints.HORIZONTAL;

    add(content, nc);

    content.updateUI();
    content.repaint();
    this.repaint();
  }
示例#28
0
 private void selectCompiler(BackendCompiler compiler) {
   if (compiler == null) {
     compiler = myDefaultCompiler;
   }
   myCompiler.setSelectedItem(compiler);
   mySelectedCompiler = compiler;
   myCardLayout.show(myContentPanel, compiler.getId());
   myContentPanel.revalidate();
   myContentPanel.repaint();
 }
示例#29
0
 /**
  * Remove the currently display gui and insert the given one.
  *
  * @param comp The new gui.
  */
 private void addToContents(JComponent comp) {
   handlerHolder.removeAll();
   comp.setPreferredSize(new Dimension(200, 300));
   handlerHolder.add(comp, BorderLayout.CENTER);
   if (myContents != null) {
     myContents.invalidate();
     myContents.validate();
     myContents.repaint();
   }
 }
 /** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user pressed the remove button
   if (e.getSource() == remove_button) {
     int row = table.getSelectedRow();
     model.removeRow(row);
     table.clearSelection();
     table.repaint();
     valueChanged(null);
   }
   // Check if the user pressed the remove all button
   if (e.getSource() == remove_all_button) {
     model.clearAll();
     table.setRowSelectionInterval(0, 0);
     table.repaint();
     valueChanged(null);
   }
   // Check if the user pressed the filter button
   if (e.getSource() == filter_button) {
     filter.showDialog();
     if (filter.okPressed()) {
       // Update the display with new filter
       model.setFilter(filter);
       table.repaint();
     }
   }
   // Check if the user pressed the start button
   if (e.getSource() == start_button) {
     start();
   }
   // Check if the user pressed the stop button
   if (e.getSource() == stop_button) {
     stop();
   }
   // Check if the user wants to switch layout
   if (e.getSource() == layout_button) {
     details_panel.remove(details_soap);
     details_soap.removeAll();
     if (details_soap.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
       details_soap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
     } else {
       details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
     }
     details_soap.setTopComponent(request_panel);
     details_soap.setRightComponent(response_panel);
     details_soap.setResizeWeight(.5);
     details_panel.add(details_soap, BorderLayout.CENTER);
     details_panel.validate();
     details_panel.repaint();
   }
   // Check if the user is changing the reflow option
   if (e.getSource() == reflow_xml) {
     request_text.setReflowXML(reflow_xml.isSelected());
     response_text.setReflowXML(reflow_xml.isSelected());
   }
 }