/** 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); }
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(); }
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(); } }
/** * 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(); } }
// 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) { } }
/** 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(); }
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(); }
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(); }
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(); }
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(); }
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 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 swapContainers(Container newContainer) { if (newContainer != null) { swappableContainer.removeAll(); swappableContainer.add(newContainer); swappableContainer.repaint(); swappableContainer.validate(); } }
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(); }
static void handleKeyTyped(KeyEvent e) { if (e.getKeyChar() == ' ') { currentSequenceNumDisplay++; scribbles = Collections.synchronizedList(new ArrayList<DrawObject>()); currentScribbleNum = 0; } drawArea.repaint(); }
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); }
private void restoreEmptyStatus() { removeAll(); setLayout(new BorderLayout()); add(myRefreshAndInfoPanel, BorderLayout.CENTER); myProgressIcon.suspend(); myRefreshAndInfoPanel.revalidate(); myRefreshAndInfoPanel.repaint(); }
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(); }
/** * 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(); } }
private void selectCompiler(BackendCompiler compiler) { if (compiler == null) { compiler = myDefaultCompiler; } myCompiler.setSelectedItem(compiler); mySelectedCompiler = compiler; myCardLayout.show(myContentPanel, compiler.getId()); myContentPanel.revalidate(); myContentPanel.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()); } }
private void resetPanel() { cal = new GregorianCalendar( Integer.parseInt(yearSpi.getValue().toString()), monthBox.getSelectedIndex(), Integer.parseInt(lastLabel.getText())); startPoint_x = 20; startPoint_y = 10; panel.removeAll(); panel.repaint(); initCalPanel(); }
public void removeElement(PanelElementAbstract b) { int idx = panelElements.indexOf(b); if (idx >= 0) { panelElements.remove(idx); listPanel.remove(b.getPanel()); listLayout.setRows(Math.max(panelElements.size() + 1, minNbRows)); listPanel.revalidate(); listPanel.repaint(); setAddButtonColor(); if (ml != null) b.unRegister(ml); for (int i = idx; i < panelElements.size(); i++) panelElements.get(i).setIdx(idx); } }
private void ensurePresentation() { if (myCurrentHorizontal != myConfiguration.SHORT_DIFF_HORISONTALLY) { final DiffPanel panel = getCurrentPanel(); myPanel.removeAll(); myPanel.add(myTopPanel, BorderLayout.NORTH); myPanel.add(panel.getComponent(), BorderLayout.CENTER); myPanel.revalidate(); myPanel.repaint(); myCurrentHorizontal = myConfiguration.SHORT_DIFF_HORISONTALLY; } }
private void setToComponent(final JComponent cmp, final boolean requestFocus) { myMatchingCountPanel.removeAll(); myMatchingCountPanel.add(cmp, BorderLayout.CENTER); myMatchingCountPanel.revalidate(); myMatchingCountPanel.repaint(); if (requestFocus) { SwingUtilities.invokeLater( new Runnable() { public void run() { myPatternField.getTextField().requestFocusInWindow(); } }); } }
private void showHelp(String help[]) { txtCommand.setText(help[0]); bHelp = true; pResult.removeAll(); pResult.add(txtResultScroll, BorderLayout.CENTER); pResult.doLayout(); txtResult.setText(help[1]); pResult.repaint(); txtCommand.requestFocus(); txtCommand.setCaretPosition(help[0].length()); }
public static void drawLineFromEquation(double a, double b, double c) { // Draw the equation ax+by+c=0 in the available range. DrawObject L = new DrawObject(); L.color = lineEqnColor; L.a = a; L.b = b; L.c = c; L.sequenceNum = currentSequenceNum; L.drawStroke = drawStroke; synchronized (eqnLines) { eqnLines.add(L); } drawArea.repaint(); }
public void edit(InitVariableAction var) { variable = var; if (editor != null) varEditPane.remove((EditorPanel) editor); var.addVariableListener(variableListener); editor = var.getVariableEditor(); varName.setText(var.getName()); varName.repaint(); if (editor != null) { editor.edit(var.getNewInitialization()); varEditPane.add((EditorPanel) editor, BorderLayout.CENTER); varEditPane.revalidate(); varEditPane.repaint(); } }