public void paint(Graphics g) { g.setColor(Color.YELLOW); int i = 0; for (Iterator<File> iterator = content.iterator(); iterator.hasNext(); i++) { g.drawString(iterator.next().getName(), 5, g.getFontMetrics().getAscent() * i + 20); } }
private void updateEditorView() { editorPane.setText(""); numParameters = 0; try { java.util.List elements = editableTemplate.getPrintfElements(); for (Iterator it = elements.iterator(); it.hasNext(); ) { PrintfUtil.PrintfElement el = (PrintfUtil.PrintfElement) it.next(); if (el.getFormat().equals(PrintfUtil.PrintfElement.FORMAT_NONE)) { appendText(el.getElement(), PLAIN_ATTR); } else { insertParameter( (ConfigParamDescr) paramKeys.get(el.getElement()), el.getFormat(), editorPane.getDocument().getLength()); } } } catch (Exception ex) { JOptionPane.showMessageDialog( this, "Invalid Format: " + ex.getMessage(), "Invalid Printf Format", JOptionPane.ERROR_MESSAGE); selectedPane = 1; printfTabPane.setSelectedIndex(selectedPane); updatePane(selectedPane); } }
public boolean importData(JComponent comp, Transferable t) { // Make sure we have the right starting points if (!(comp instanceof JTable)) { return false; } if (!t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { return false; } try { java.util.List data = (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor); Iterator i = data.iterator(); while (i.hasNext()) { File f = (File) i.next(); frame.importDataFile(f); } return true; } catch (UnsupportedFlavorException ufe) { System.err.println("Ack! we should not be here.\nBad Flavor."); } catch (IOException ioe) { System.out.println("Something failed during import:\n" + ioe); } catch (ImportException e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } return false; }
/** * Returns the set of pages contained in this wizard. * * @return Iterator */ public Iterator<WizardPage> getPages() { java.util.List<WizardPage> pages = new ArrayList<WizardPage>(); firstWizardPage = new FirstWizardPage(registration, getWizardContainer()); pages.add(firstWizardPage); return pages.iterator(); }
/** * Returns the set of pages contained in this wizard. * * @return Iterator */ public Iterator<WizardPage> getPages() { java.util.List<WizardPage> pages = new ArrayList<WizardPage>(); firstWizardPage = new FirstWizardPage(this); pages.add(firstWizardPage); return pages.iterator(); }
public List<Pair<String, TextWithImports>> getExpressions() { final ArrayList<Pair<String, TextWithImports>> pairs = new ArrayList<Pair<String, TextWithImports>>(myData.size()); for (Iterator<Row> it = myData.iterator(); it.hasNext(); ) { final Row row = it.next(); pairs.add(new Pair<String, TextWithImports>(row.name, row.value)); } return pairs; }
private void setAllPrinter() { java.util.List systemDruckerList = PM_XML_Utils.getElementListe(document, "//" + TAG_SYSTEM_DRUCKER); // -------------------------------------------------------------- // Loop ueber ALLE Systemdrucker // -------------------------------------------------------------- for (Iterator itSystemDrucker = systemDruckerList.iterator(); itSystemDrucker.hasNext(); ) { Element systemDrucker = (Element) itSystemDrucker.next(); String systemPrinterName = PM_XML_Utils.getAttribute(systemDrucker, ATTR_SYSTEM_DRUCKER_NAME); PM_SystemPrinter systemPrinter = systemPrinters.getSystemPrinter(systemPrinterName); if (systemPrinter == null) { continue; // system printer not found } // -------------------------------------------------------------- // loop ueber alle pm-drucker innerhalb EINES Systemdruckers // -------------------------------------------------------------- java.util.List pmDruckerList = PM_XML_Utils.getElementListe(systemDrucker, TAG_PM_DRUCKER); for (Iterator itPmDrucker = pmDruckerList.iterator(); itPmDrucker.hasNext(); ) { Element pmDrucker = (Element) itPmDrucker.next(); String pmDruckerName = PM_XML_Utils.getAttribute(pmDrucker, ATTR_PM_DRUCKER_NAME); // init pmPrinter PM_PmPrinter pmPrinter = new PM_PmPrinter(systemPrinter, pmDruckerName); // add to system printer systemPrinter.addPmDrucker(pmPrinter); // drucker.setPapierBereich(papierBereich); // ---- Druck-Bereich innerhalb eines pm-druckers ------- Element druckBereichElement = pmDrucker.element(TAG_DRUCK_BEREICH); if (druckBereichElement != null) { double oben = PM_XML_Utils.getAttributeDouble(druckBereichElement, ATTR_DRUCK_BEREICH_OBEN); double rechts = PM_XML_Utils.getAttributeDouble(druckBereichElement, ATTR_DRUCK_BEREICH_RECHTS); double unten = PM_XML_Utils.getAttributeDouble(druckBereichElement, ATTR_DRUCK_BEREICH_UNTEN); double links = PM_XML_Utils.getAttributeDouble(druckBereichElement, ATTR_DRUCK_BEREICH_LINKS); pmPrinter.setDruckBereichGesamtRaender(oben, rechts, unten, links); } } // ende alle pm-drucker fuer einen system-drucker } // ende alle Systemdrucker // Wenn kein Drucker, dann Default-Drucker anlegen }
public void tabRemoveHighlight(int tabIndex) { Iterator<Integer> highlightedIter = highlightedTabs.iterator(); while (highlightedIter.hasNext()) { if (highlightedIter.next().intValue() == tabIndex) { highlightedIter.remove(); break; } } }
/** * Sets the accelerator sequence * * @param accSeq The new accelSeq value */ public void setAccelSeq(AcceleratorSeq accSeq) { java.util.List<AcceleratorNode> accNodes = accSeq.getNodesOfType(Electromagnet.s_strType); java.util.Iterator<AcceleratorNode> itr = accNodes.iterator(); while (itr.hasNext()) { Electromagnet emg = (Electromagnet) itr.next(); if (emg.getStatus()) { emg.setUseFieldReadback(false); } } ringFoilPosCorr.setAccelSeq(accSeq); }
/** * Fire a property change event to each listener. * * @param bean Bean being edited. * @param propName Name of the property. * @param oldValue Old value. * @param newValue New value. */ protected void firePropertyChange( Object bean, String propName, Object oldValue, Object newValue) { PropertyChangeEvent e = new PropertyChangeEvent(bean, propName, oldValue, newValue); Iterator it = _changeListeners.iterator(); while (it.hasNext()) { PropertyChangeListener l = (PropertyChangeListener) it.next(); l.propertyChange(e); } }
public void paintComponent(Graphics g) { super.paintComponent(g); height = this.getHeight(); width = this.getWidth(); drawPlayers(g); g.setColor(Color.WHITE); g.drawString("Score", width - 60, 25); g.drawString(String.valueOf(score), width - 60, 40); if (countdownF) { g.drawString(String.valueOf(counterN), width / 2 - 10, height / 2); } else { if ((spawnCircleB) && (spawnIncrease)) { spawnCircles(); } if (spawnMonsterB) { spawnMonsters(); } if (spawnRandomersB) { spawnRandomers(); } if (spawnRainB) { spawnRain(); } if (spawnBombB()) { spawnBomb(); } try { Iterator i = enemies.iterator(); while (i.hasNext()) { Enemy e = (Enemy) i.next(); Iterator j = players.iterator(); while (j.hasNext()) { Player p = (Player) j.next(); e.move(players, programSpeedAdjust /*/players.size()*/); if ((e.collidesWith(p.getX(), p.getY())) && (!p.getImmunity())) { p.decLives(p.getX(), p.getY()); p.setImmunity(true); } } e.paint(g); } } catch (Exception e) { } } drawLayout(g); }
private void movePlayers() { onePlayerAlive = false; Iterator i = players.iterator(); while (i.hasNext()) { Player p = (Player) i.next(); if (p.getLives() == 0) { p.setActive(false); } if (p.isActive()) { onePlayerAlive = true; p.move(); } } }
/** * Returns the set of pages contained in this wizard. * * @param registration the registration object * @return Iterator */ public Iterator<WizardPage> getPages(JabberAccountRegistration registration) { java.util.List<WizardPage> pages = new ArrayList<WizardPage>(); // create new registration, our container needs the pages // this means this is a new wizard and we must reset all data // it will be invoked and when the wizard cleans and unregister // our pages, but this fix don't hurt in this situation. this.registration = registration; if (firstWizardPage == null) firstWizardPage = new FirstWizardPage(this); pages.add(firstWizardPage); return pages.iterator(); }
private void setup() { playerSetup(); deathLocation = new int[4]; Arrays.fill(deathLocation, -1); menu.setVisible(false); this.revalidate(); audioSetup(); Iterator i = players.iterator(); Player p; while (i.hasNext()) { p = (Player) i.next(); p.resetLives(3); p.setActive(true); } BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); Cursor blank = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "BLANK"); this.setCursor(blank); reset(); ballN = 1; level = 1; timeLast = 0; score = 0; counterN = 10; timeCircle = 0; timeCircleSwitch = 0; programLoopCounter = 1; programSpeedAdjust = 1; onePlayerAlive = true; countdownF = true; circular = true; spawnIncrease = true; spawnCircleB = false; spawnMonsterB = false; spawnRandomersB = false; levelSetup(); countdown(); animate(); }
public static Collection searchByAttribute( GeopistaLayer geopistaLayer, int attributeNumber, String value) { Collection finalFeatures = new ArrayList(); if (geopistaLayer == null) return finalFeatures; java.util.List allFeaturesList = geopistaLayer.getFeatureCollectionWrapper().getFeatures(); Iterator allFeaturesListIter = allFeaturesList.iterator(); while (allFeaturesListIter.hasNext()) { Feature localFeature = (Feature) allFeaturesListIter.next(); String nombreAtributo = localFeature.getString(attributeNumber).trim(); if (nombreAtributo.equals(value)) { finalFeatures.add(localFeature); } } return finalFeatures; }
private void drawPlayers(Graphics g) { Iterator i = players.iterator(); Player p; while (i.hasNext()) { p = (Player) i.next(); if (p.isActive()) { if (p.getImmunity()) { g.setColor(Color.red.brighter()); g.drawOval(p.getX() - 30, p.getY() - 30, 60, 60); } g.setColor(Color.WHITE); g.fillOval(p.getX() - 5, p.getY() - 5, 10, 10); } p.paint(g); } }
private void drawLayout(Graphics g) { g.setColor(Color.blue); g.drawRect(10, 10, width - 20, height - 20); g.setColor(Color.red.brighter()); Iterator f = players.iterator(); int lifeDisplayPosition = 0; while (f.hasNext()) { Player h = (Player) f.next(); if (h.isActive()) { lifeDisplayPosition++; String lifeInformation = "Player " + lifeDisplayPosition + ": "; for (int i = 0; i < h.getLives(); i++) { lifeInformation += "\u2606"; } g.drawString(lifeInformation, 20, lifeDisplayPosition * 40); } } borders[2] = width - 20; borders[3] = height - 20; Iterator i = players.iterator(); Player p; while (i.hasNext()) { p = (Player) i.next(); if (p.isActive() && !countdownF && (p.getX() < borders[0] || p.getY() < borders[1] || p.getX() > borders[2] || p.getY() > borders[3]) && (!p.getImmunity())) { p.decLives(width / 2, height / 2); p.setImmunity(true); } if (p.getLives() <= 0) { if (p instanceof MouseControlledPlayer) { MouseControlledPlayer m = (MouseControlledPlayer) p; removeMouseListener(m); removeMouseMotionListener(m); } else if (p instanceof KeyboardControlledPlayer) { KeyboardFocusManager.getCurrentKeyboardFocusManager() .removeKeyEventDispatcher((KeyboardControlledPlayer) p); } i.remove(); for (int h = 0; h < 4; h++) { if (deathLocation[h] == -1) { deathLocation[h] = p.getX(); deathLocation[h + 1] = p.getY(); break; } } } } if ((deathLocation[0] != -1) && (deathLocation[1] != -1)) { g.drawLine( deathLocation[0] - 15, deathLocation[1] - 15, deathLocation[0] + 15, deathLocation[1] + 15); g.drawLine( deathLocation[0] + 15, deathLocation[1] - 15, deathLocation[0] - 15, deathLocation[1] + 15); } if ((deathLocation[2] != -1) && (deathLocation[3] != -1)) { g.drawLine( deathLocation[2] - 15, deathLocation[3] - 15, deathLocation[2] + 15, deathLocation[3] + 15); g.drawLine( deathLocation[2] + 15, deathLocation[3] - 15, deathLocation[2] - 15, deathLocation[3] + 15); } if (!onePlayerAlive) { Font old = g.getFont(); g.setFont(new Font("monospaced", Font.BOLD, 20)); g.setColor(Color.red.darker()); g.drawString("GAME OVER", width / 2 - 40, height / 2); g.setFont(old); g.setColor(Color.WHITE); g.drawString("Score", width - 60, 25); g.drawString(String.valueOf(score), width - 60, 40); } }
public EditorPaneHTMLHelp(String htmlFile) { if (GlobalValues.useSystemBrowserForHelp) { Desktop d = GlobalValues.desktop; try { // create a temp file GlobalValues.forHTMLHelptempFile = new File("tempHTMLHelpSynthetic.html"); FileWriter fw = new FileWriter(GlobalValues.forHTMLHelptempFile); java.util.List<String> list = readTextFromJar(htmlFile); Iterator<String> it = list.iterator(); while (it.hasNext()) { fw.write(it.next() + "\n"); } String canonicalPathOfFile = GlobalValues.forHTMLHelptempFile.getCanonicalPath(); URL urlFile = new URL("file://" + canonicalPathOfFile); URI uriOfFile = urlFile.toURI(); fw.close(); d.browse(uriOfFile); } catch (Exception e) { e.printStackTrace(); } } else { URL initialURL = getClass().getResource(htmlFile); font = GlobalValues.htmlfont; String title = "HTML Help"; setTitle(title); final Stack<String> urlStack = new Stack<String>(); final JEditorPane editorPane; editorPane = new JEditorPane(new HTMLEditorKit().getContentType(), " "); editorPane.setOpaque(false); editorPane.setBorder(null); editorPane.setEditable(false); JPanel magPanel = new JPanel(); magnificationFactor = GlobalValues.helpMagnificationFactor; magFactor = new JTextField(Double.toString(magnificationFactor)); JButton magButton = new JButton("Set Magnification: "); magButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { magnificationFactor = Double.parseDouble(magFactor.getText()); GlobalValues.helpMagnificationFactor = magnificationFactor; } }); magPanel.setLayout(new GridLayout(1, 2)); magPanel.add(magButton); magPanel.add(magFactor); final JTextField url = new JTextField(initialURL.toString()); // set up hyperlink listener editorPane.setEditable(false); try { // remember URL for back button urlStack.push(initialURL.toString()); // show URL in text field url.setText(initialURL.toString()); // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() * GlobalValues.helpMagnificationFactor + "pt; }"; ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule); editorPane.setPage(initialURL); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } editorPane.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() * GlobalValues.helpMagnificationFactor + "pt; }"; ((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule); } }); editorPane.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { // remember URL for back button urlStack.push(event.getURL().toString()); // show URL in text field url.setText(event.getURL().toString()); editorPane.setPage(event.getURL()); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } } } }); // set up checkbox for toggling edit mode final JCheckBox editable = new JCheckBox(); editable.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { editorPane.setEditable(editable.isSelected()); } }); // set up load button for loading URL ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { try { // remember URL for back button urlStack.push(url.getText()); editorPane.setPage(url.getText()); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }; JButton loadButton = new JButton("Load/Magnify"); loadButton.addActionListener(listener); url.addActionListener(listener); // set up back button and button action JButton backButton = new JButton("Back"); backButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (urlStack.size() <= 1) return; try { // get URL from back button urlStack.pop(); // show URL in text field String urlString = urlStack.peek(); url.setText(urlString); editorPane.setPage(urlString); editorPane.firePropertyChange("dummyProp", true, false); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }); JPanel allPanel = new JPanel(new BorderLayout()); // put all control components in a panel JPanel ctrlPanel = new JPanel(new BorderLayout()); JPanel urlPanel = new JPanel(); urlPanel.add(new JLabel("URL")); urlPanel.add(url); JPanel buttonPanel = new JPanel(); buttonPanel.add(loadButton); buttonPanel.add(backButton); buttonPanel.add(new JLabel("Editable")); buttonPanel.add(magPanel); buttonPanel.add(editable); ctrlPanel.add(buttonPanel, BorderLayout.NORTH); ctrlPanel.add(urlPanel, BorderLayout.CENTER); allPanel.add(ctrlPanel, BorderLayout.NORTH); allPanel.add(new JScrollPane(editorPane), BorderLayout.CENTER); add(allPanel); } }
void setFields(java.util.List fields) { fieldChooser.setCollection(fields.iterator()); }