// create from a dataset public VariableBean(Variable vs) { this.vs = vs; // vs = (v instanceof VariableEnhanced) ? (VariableEnhanced) v : new VariableStandardized( v); setName(vs.getShortName()); setDescription(vs.getDescription()); setUnits(vs.getUnitsString()); setDataType(vs.getDataType().toString()); // Attribute csAtt = vs.findAttribute("_coordSystems"); // if (csAtt != null) // setCoordSys( csAtt.getStringValue()); // collect dimensions StringBuilder lens = new StringBuilder(); StringBuilder names = new StringBuilder(); java.util.List dims = vs.getDimensions(); for (int j = 0; j < dims.size(); j++) { ucar.nc2.Dimension dim = (ucar.nc2.Dimension) dims.get(j); if (j > 0) { lens.append(","); names.append(","); } String name = dim.isShared() ? dim.getName() : "anon"; names.append(name); lens.append(dim.getLength()); } setDimensions(names.toString()); setShape(lens.toString()); }
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); } }
private void handleEntryAction(ActionEvent actionEvent) throws IOException, ParserConfigurationException, XPathExpressionException, SAXException, NoItemException { if (this.getGazetteer() == null) { Util.getLogger().severe("No gazeteer is registered"); return; } String lookupString; JComboBox cmb = ((JComboBox) actionEvent.getSource()); lookupString = cmb.getSelectedItem().toString(); if (lookupString == null || lookupString.length() < 1) return; java.util.List<PointOfInterest> results = this.gazetteer.findPlaces(lookupString); if (results == null || results.size() == 0) return; this.controller.moveToLocation(results.get(0)); // Add it to the list if not already there for (int i = 0; i < cmb.getItemCount(); i++) { Object oi = cmb.getItemAt(i); if (oi != null && oi.toString().trim().equals(lookupString)) return; // item exists } cmb.insertItemAt(lookupString, 0); }
/** Retrieve item types and fill in the item types combo box. */ private void init() { Response res = ClientUtils.getData("loadItemTypes", new GridParams()); Domain d = new Domain("ITEM_TYPES"); if (!res.isError()) { ItemTypeVO vo = null; list = ((VOListResponse) res).getRows(); for (int i = 0; i < list.size(); i++) { vo = (ItemTypeVO) list.get(i); d.addDomainPair(vo.getProgressiveHie02ITM02(), vo.getDescriptionSYS10()); } } controlHierarchy.setDomain(d); controlHierarchy .getComboBox() .addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == e.SELECTED) { ItemTypeVO typeVO = (ItemTypeVO) list.get(controlHierarchy.getSelectedIndex()); treePanel.setCompanyCode(typeVO.getCompanyCodeSys01ITM02()); treePanel.setProgressiveHIE02((BigDecimal) controlHierarchy.getValue()); DetailSupplierVO vo = (DetailSupplierVO) supplierPanel.getVOModel().getValueObject(); treePanel.setCompanyCode(vo.getCompanyCodeSys01REG04()); treePanel.reloadTree(); itemsGrid.clearData(); } } }); if (d.getDomainPairList().length == 1) controlHierarchy.getComboBox().setSelectedIndex(0); else controlHierarchy.getComboBox().setSelectedIndex(-1); }
public static void main(String args[]) { IntensityFeatureScaleSpacePyramidApp<ImageFloat32, ImageFloat32> app = new IntensityFeatureScaleSpacePyramidApp<ImageFloat32, ImageFloat32>( ImageFloat32.class, ImageFloat32.class); // IntensityFeatureScaleSpacePyramidApp<ImageUInt8, ImageSInt16> app2 = // new // IntensityFeatureScaleSpacePyramidApp<ImageUInt8,ImageSInt16>(ImageUInt8.class,ImageSInt16.class); java.util.List<PathLabel> inputs = new ArrayList<PathLabel>(); inputs.add(new PathLabel("shapes", "../data/evaluation/shapes01.png")); inputs.add(new PathLabel("sunflowers", "../data/evaluation/sunflowers.png")); inputs.add(new PathLabel("beach", "../data/evaluation/scale/beach02.jpg")); app.setInputList(inputs); // wait for it to process one image so that the size isn't all screwed up while (!app.getHasProcessedImage()) { Thread.yield(); } ShowImages.showWindow(app, "Feature Scale Space Pyramid Intensity"); }
private boolean isSynthIcon(Icon icon) { if (_synthIconMap == null) { _synthIconMap = new HashMap<String, Boolean>(); } Class<?> aClass = icon.getClass(); java.util.List<String> classNamesToPut = new ArrayList<String>(); boolean isSynthIcon = false; while (aClass != null) { String name = aClass.getCanonicalName(); if (name != null) { Boolean value = _synthIconMap.get(name); if (value != null) { return value; } classNamesToPut.add(name); if (isSynthIconClassName(name)) { isSynthIcon = true; break; } } aClass = aClass.getSuperclass(); } for (String name : classNamesToPut) { _synthIconMap.put(name, isSynthIcon); } return isSynthIcon; }
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; }
public void init(java.util.List<Pair<String, TextWithImports>> data) { myData.clear(); for (Iterator<Pair<String, TextWithImports>> it = data.iterator(); it.hasNext(); ) { final Pair<String, TextWithImports> pair = it.next(); myData.add(new Row(pair.getFirst(), pair.getSecond())); } }
private void listPeople() { try { jScrollPane1.getViewport().setView(null); JFlowPanel jPeople = new JFlowPanel(); jPeople.applyComponentOrientation(getComponentOrientation()); java.util.List people = m_dlSystem.listPeopleVisible(); for (int i = 0; i < people.size(); i++) { AppUser user = (AppUser) people.get(i); JButton btn = new JButton(new AppUserAction(user)); btn.applyComponentOrientation(getComponentOrientation()); btn.setFocusPainted(false); btn.setFocusable(false); btn.setRequestFocusEnabled(false); btn.setHorizontalAlignment(SwingConstants.LEADING); btn.setMaximumSize(new Dimension(150, 50)); btn.setPreferredSize(new Dimension(150, 50)); btn.setMinimumSize(new Dimension(150, 50)); jPeople.add(btn); } jScrollPane1.getViewport().setView(jPeople); } catch (BasicException ee) { ee.printStackTrace(); } }
private void spawnRandomers() { for (int i = 0; i < randomN; i++) { float x = (float) Math.random() * width; float y = (float) Math.random() * height; float r = (float) Math.sqrt( Math.pow(((Player) players.get(0)).getX() - x, 2) + Math.pow(((Player) players.get(0)).getY() - x, 2)); while (r < distanceLimit) { x = (float) Math.random() * width; y = (float) Math.random() * height; r = (float) Math.sqrt( Math.pow(((Player) players.get(0)).getX() - x, 2) + Math.pow(((Player) players.get(0)).getY() - y, 2)); } enemies.add(new EnemyTypes.Random(x, y, 0.5f, borders)); } spawnRandomersB = false; }
public void setTablaPrincipal(java.util.List val) { DefaultTableModel modelo = ((DefaultTableModel) this.tablaPrincipal.getModel()); for (int i = 0; i < val.size(); i++) { modelo.addRow(((java.util.ArrayList) val.get(i)).toArray()); } this.calculaSumas(); }
public void actionPerformed(ActionEvent e) { JTextField tf = getTextField(); final String text = tf.getText(); final int caretIndex = tf.getCaretPosition(); String pre = text.substring(0, caretIndex); java.util.List<TreeNode> nodes = null; // m_root.search(pre); // Collections.sort(nodes); if (nodes.isEmpty()) { return; } JPopupMenu jp = new JPopupMenu("options"); JMenuItem lastItem = null; for (TreeNode node : nodes) { String nodeName = node.toString(); String insertion = nodeName.substring(leaf(pre, ".").length()); lastItem = createInsertAction(nodeName, caretIndex, insertion); jp.add(lastItem); } if (nodes.size() == 0) { return; } if (nodes.size() == 1) { lastItem.getAction().actionPerformed(null); } else { Point pos = tf.getCaret().getMagicCaretPosition(); pos = pos != null ? pos : new Point(2, 2); jp.show(tf, pos.x, pos.y); } }
private void loadTopicsFromFile() throws IOException { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("ExtempFiller2"); chooser.setFileFilter( new FileFilter() { @Override public boolean accept(File f) { return f.isDirectory() || f.getName().toLowerCase().endsWith(".txt"); } @Override public String getDescription() { return "Text Files"; } }); int response = chooser.showOpenDialog(this); if (response == JFileChooser.APPROVE_OPTION) { // get everything currently researched java.util.List<String> researched = managerPanel.getTopics(); // load everything from file File file = chooser.getSelectedFile(); Scanner readScanner = new Scanner(file); while (readScanner.hasNext()) { String topic = readScanner.nextLine(); if (!researched.contains(topic)) { Topic t = new Topic(topic); managerPanel.addTopic(t); inQueue.add(new InMessage(InMessage.Type.RESEARCH, t)); } } } }
private Component iciciCodeMappings() { java.util.List<TableDisplayInput> displayInputs = new ArrayList<TableDisplayInput>(); displayInputs.add(new StringDisplayInput("ICICICode", "getIciciCode")); displayInputs.add(new StringDisplayInput("StockCode", "getStockCode")); List<ICICICodeMapping> list = Controller.getIciciMappings(); PMTableModel tableModel = new PMTableModel(list, displayInputs, false) { @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return columnIndex == 1; } @Override public void setValueAt(Object value, int rowIndex, int columnIndex) { ((ICICICodeMapping) dataVOs.get(rowIndex)).setStock((StockVO) value); } }; table = UIHelper.createTable(tableModel); table .getColumnModel() .getColumn(1) .setCellEditor(new DefaultCellEditor(UIHelper.createStockVOlistJCB())); return UIHelper.createScrollPane(table); }
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 reestimate() { SemOptimizer optimizer; String type = wrapper.getSemOptimizerType(); if ("Regression".equals(type)) { optimizer = new SemOptimizerRegression(); } else if ("EM".equals(type)) { optimizer = new SemOptimizerEm(); } else if ("Powell".equals(type)) { optimizer = new SemOptimizerPowell(); } else if ("Random Search".equals(type)) { optimizer = new SemOptimizerScattershot(); } else if ("RICF".equals(type)) { optimizer = new SemOptimizerRicf(); } else if ("Powell".equals(type)) { optimizer = new SemOptimizerPowell(); } else { throw new IllegalArgumentException("Unexpected optimizer " + "type: " + type); } int numRestarts = wrapper.getNumRestarts(); optimizer.setNumRestarts(numRestarts); java.util.List<SemEstimator> estimators = wrapper.getMultipleResultList(); java.util.List<SemEstimator> newEstimators = new ArrayList<>(); for (SemEstimator estimator : estimators) { SemPm semPm = estimator.getSemPm(); DataSet dataSet = estimator.getDataSet(); ICovarianceMatrix covMatrix = estimator.getCovMatrix(); SemEstimator newEstimator; if (dataSet != null) { newEstimator = new SemEstimator(dataSet, semPm, optimizer); newEstimator.setNumRestarts(numRestarts); newEstimator.setScoreType(wrapper.getScoreType()); } else if (covMatrix != null) { newEstimator = new SemEstimator(covMatrix, semPm, optimizer); newEstimator.setNumRestarts(numRestarts); newEstimator.setScoreType(wrapper.getScoreType()); } else { throw new IllegalStateException( "Only continuous " + "rectangular data sets and covariance matrices " + "can be processed."); } newEstimator.estimate(); newEstimators.add(newEstimator); } wrapper.setSemEstimator(newEstimators.get(0)); wrapper.setMultipleResultList(newEstimators); resetSemImEditor(); }
public java.util.List<SearchResult> search(String _info, String _searchString, int _mode) { String passName = getName(); if (passName.startsWith("Osejs.")) passName = passName.substring(6); java.util.List<SearchResult> list = new ArrayList<SearchResult>(); for (java.util.Enumeration<Editor> e = pageList.elements(); e.hasMoreElements(); ) list.addAll(e.nextElement().search(passName, _searchString, _mode)); return list; }
public void assignRobotRepresent(VivaeRobotRepresent repr) { int activePositionsCnt = positions.size(); PositionMark pattern = positions.get(actives.size() % activePositionsCnt); repr.getBody().setPosition((float) pattern.getX(), (float) pattern.getY()); repr.setArena(this); repr.setWorld(getWorld()); addActive((Active) repr); }
public void removeRow(int index) { remove(rows.get(index)); remove(struts.get(index)); rows.remove(index); struts.remove(index); repaint(); updateUI(); }
public static DefaultPieDataset getPieDataset(String chartName, DBSeerDataSet dataset) { StatisticalPackageRunner runner = DBSeerGUI.runner; runner.eval( "[title legends Xdata Ydata Xlabel Ylabel timestamp] = plotter.plot" + chartName + ";"); String title = runner.getVariableString("title"); Object[] legends = (Object[]) runner.getVariableCell("legends"); Object[] xCellArray = (Object[]) runner.getVariableCell("Xdata"); Object[] yCellArray = (Object[]) runner.getVariableCell("Ydata"); String xLabel = runner.getVariableString("Xlabel"); String yLabel = runner.getVariableString("Ylabel"); timestamp = runner.getVariableDouble("timestamp"); DefaultPieDataset pieDataSet = new DefaultPieDataset(); int numLegends = legends.length; int numXCellArray = xCellArray.length; int numYCellArray = yCellArray.length; int dataCount = 0; if (numXCellArray != numYCellArray) { JOptionPane.showMessageDialog( null, "The number of X dataset and Y dataset does not match.", "The number of X dataset and Y dataset does not match.", JOptionPane.ERROR_MESSAGE); return null; } final java.util.List<String> transactionTypeNames = dataset.getTransactionTypeNames(); for (int i = 0; i < numYCellArray; ++i) { double[] xArray = (double[]) xCellArray[i]; runner.eval("yArraySize = size(Ydata{" + (i + 1) + "});"); runner.eval("yArray = Ydata{" + (i + 1) + "};"); double[] yArraySize = runner.getVariableDouble("yArraySize"); double[] yArray = runner.getVariableDouble("yArray"); int xLength = xArray.length; int row = (int) yArraySize[0]; int col = (int) yArraySize[1]; for (int c = 0; c < col; ++c) { if (c < transactionTypeNames.size()) { String name = transactionTypeNames.get(c); if (!name.isEmpty()) { pieDataSet.setValue(name, yArray[c]); } else { pieDataSet.setValue("Transaction Type " + (c + 1), yArray[c]); } } } } return pieDataSet; }
private void mRemoveNode() { String old_node = (String) lstNodes.getSelectedValue(); java.util.List remove_list = ConfigUtilities.getElementsWithDefinition(mBroker.getElements(mContext), old_node); for (int i = 0; i < remove_list.size(); i++) { mBroker.remove(mContext, (ConfigElement) remove_list.get(i)); } }
/** Gets the GUI component for this pane. */ public JComponent getGUI() { if (cwp == null) { Object object = mWhiteBoard.get("device_definition"); Object ctx_obj = mWhiteBoard.get("context"); if (null != object && object instanceof ConfigDefinition && null != ctx_obj && ctx_obj instanceof ConfigContext) { mConfigContext = (ConfigContext) ctx_obj; ConfigDefinition def = (ConfigDefinition) object; String token = def.getToken(); // Create a temporary list of ConfigDefinitions to pass to factory. java.util.List def_list = new ArrayList(); def_list.add(def); // Initialize a ConfigElementFactory with the needed // ConfigDefinition. And create a new ConfigElement. ConfigElementFactory temp_factory = new ConfigElementFactory(def_list); mConfigElement = temp_factory.create("New " + token, def); List list = CustomEditorRegistry.findEditors(token); Color start_color = new Color(160, 160, 180); Object color = UIManager.get("window"); if (null != color && color instanceof Color) { start_color = (Color) color; } else { System.out.println("Could not get the desktop color from the UIManager."); } // XXX:This will be used after making findEditors -> findEditor // if(null != editor) if (null == list || list.size() == 0) { System.out.println("No CustomEditors registered for token: " + token); JScrollPane scroll_pane = new JScrollPane(); PropertySheet element_prop_sheet = PropertySheetFactory.instance() .makeSheet(mConfigContext, mConfigElement, start_color); scroll_pane.getViewport().removeAll(); scroll_pane.getViewport().add(element_prop_sheet, null); cwp = scroll_pane; } else if (null != list && list.size() > 0) { CustomEditor editor = (CustomEditor) list.get(0); cwp = (JComponent) editor.getPanel(); editor.setConfig(mConfigContext, mConfigElement); } } } // cwp.init(mWhiteBoard); return cwp; }
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; }
/** * Removes specific rows from the list of reading lists. * * @param aRows rows to remove. */ public void removeRows(int[] aRows) { Arrays.sort(aRows); java.util.List<ReadingList> newLists = new ArrayList<ReadingList>(Arrays.asList(lists)); for (int i = aRows.length - 1; i >= 0; i--) { newLists.remove(aRows[i]); } setLists(newLists.toArray(new ReadingList[newLists.size()])); }
public void mouseReleased(MouseEvent e) { armed = -1; int mx = e.getX(); int partIndex = partIndex(mx); if (partIndex == -1) return; java.util.List<Network> networks = getNetworkParts(); Network selectedNetwork = networks.get(partIndex); if (selectedNetwork != null) document.setCurrentNetwork(selectedNetwork); repaint(); }
/** * 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); }
public void testTest() throws Exception { java.util.List<Track> tracks = IGV.getInstance().getAllTracks(); System.out.println("# tracks: " + tracks.size()); for (Track track : tracks) { System.out.println(track.getName()); } java.util.List<Track> featureTracks = IGV.getInstance().getTrackPanel(IGV.FEATURE_PANEL_NAME).getTracks(); System.out.println(featureTracks.size()); }
private void moveItemDown() { int index = menuItemsTable.getSelectedRow(); // Return if nothing was selected. if (index == -1) return; java.util.List<Parameter.MenuItem> items = parameter.getMenuItems(); // Return if the last item is selected. if (index >= items.size() - 1) return; nodeAttributesDialog.moveParameterItemDown(parameter, index); // TODO: Changing the selection doesn't have any effect on Mac. menuItemsTable.changeSelection(index + 1, 1, false, false); }
/** * Gets the data from the <tt>ConfigurationService</tt> that will construct the * <tt>PropsTableModel</tt> for the properties table. * * @return The data necessary to initialize the <tt>PropsTableModel</tt> */ private Object[][] initTableModel() { ConfigurationService confService = PropertiesEditorActivator.getConfigurationService(); java.util.List<String> properties = confService.getAllPropertyNames(); Object[][] data = new Object[properties.size()][]; int i = 0; for (String property : properties) { data[i++] = new Object[] {property, confService.getProperty(property)}; } return data; }
private void loadLieferant() { EntityManager em = Main.getEMF().createEntityManager(); Query query = em.createQuery("SELECT l FROM Lieferanten l ORDER BY l.firma"); try { java.util.List lieferant = query.getResultList(); lieferant.add(0, "<html><i>Lieferant nicht ändern</i></html>"); cmbLieferant.setModel(tools.Tools.newComboboxModel(new ArrayList<Lieferanten>(lieferant))); } catch (Exception e) { // nicht gefunden // } finally { em.close(); } }