List of usage examples for java.lang Double MIN_VALUE
double MIN_VALUE
To view the source code for java.lang Double MIN_VALUE.
Click Source Link
From source file:org.jcamp.parser.CommonSpectrumJCAMPReader.java
License:asdf
/** * create peak spectrum from peak table. adds all intensities belonging to * the same x-position up//from www .j ava 2s.c om * * @param peaks Peak1D[] * @return double[][] array of {x, y} */ protected static double[][] peakTableToPeakSpectrum(Peak1D[] peaks) throws JCAMPException { int n = peaks.length; if (n == 0) { throw new JCAMPException("empty peak table"); } Arrays.sort(peaks); ArrayList<Double> px = new ArrayList<Double>(n); ArrayList<Double> py = new ArrayList<Double>(n); double x0 = peaks[0].getPosition()[0]; double y0 = peaks[0].getHeight(); for (int i = 1; i < n; i++) { double x = peaks[i].getPosition()[0]; double y = peaks[i].getHeight(); if (x - x0 > Double.MIN_VALUE) { px.add(x0); py.add(y0); x0 = x; y0 = y; } else { y0 += y; } } px.add(x0); py.add(x0); double[][] xy = new double[2][px.size()]; for (int i = 0; i < px.size(); i++) { xy[0][i] = px.get(i); xy[1][i] = py.get(i); } return xy; }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJDoubleEditor.java
public void setMinValue(Double value) { final String S_ProcName = "setMinValue"; if (value == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1, "value"); }//from w w w .ja v a 2 s. co m if (value.compareTo(Double.MIN_VALUE) < 0) { throw CFLib.getDefaultExceptionFactory().newArgumentUnderflowException(getClass(), S_ProcName, 1, "value", value, Float.MIN_VALUE); } minValue = value; }
From source file:com.jennifer.ui.chart.brush.LineBrush.java
protected DomUtil createLine(JSONObject pos, int index) { JSONArray x = JSONUtil.clone(pos.getJSONArray("x")); JSONArray y = JSONUtil.clone(pos.getJSONArray("y")); JSONArray valueList = JSONUtil.clone(pos.getJSONArray("value")); DecimalFormat format = new DecimalFormat(".##"); String _color = color(index); Transform t = null;//from w w w . ja v a 2 s . com Transform g = new Transform("g"); Path p = new Path(new JSONObject().put("stroke", _color).put("stroke-width", chart.theme("lineBorderWidth")) .put("fill", "transparent")); p.MoveTo(x.getDouble(0), y.getDouble(0)); if (Brush.SYMBOL_CURVE.equals(symbol)) { JSONObject px = this.curvePoints(x); JSONObject py = this.curvePoints(y); for (int i = 0, len = x.length(); i < len; i++) { p.CurveTo(px.getJSONArray("p1").getDouble(i), py.getJSONArray("p1").getDouble(i), px.getJSONArray("p2").getDouble(i), py.getJSONArray("p2").getDouble(i), x.getDouble(i + 1), y.getDouble(i + 1)); } } else { double maxValue = Double.MIN_VALUE; t = null; for (int i = 0, len = x.length(); i < len - 1; i++) { if (Brush.SYMBOL_STEP.equals(symbol)) { p.LineTo(x.getDouble(i), y.getDouble(i + 1)); } double xValue = x.getDouble(i + 1); double yValue = y.getDouble(i + 1); double valueValue = valueList.getDouble(i + 1); p.LineTo(xValue, yValue); // display max value if (valueValue > maxValue) { maxValue = valueValue; t = createMaxElement(xValue, yValue, formatNumber(valueValue), _color); } } } // ?? if (move) { double range = (x.getDouble(2) - x.getDouble(1)) / 2; g.translate(range, 0); } g.append(p); g.append(t); return g; }
From source file:com.litt.core.security.license.gui.CustomerPanel.java
public CustomerPanel() { GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0 }; gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; setLayout(gridBagLayout);//from w w w .j a v a 2s .co m JLabel lblProduct = new JLabel("\u4EA7\u54C1\uFF1A"); GridBagConstraints gbc_lblProduct = new GridBagConstraints(); gbc_lblProduct.insets = new Insets(0, 0, 5, 5); gbc_lblProduct.anchor = GridBagConstraints.EAST; gbc_lblProduct.gridx = 0; gbc_lblProduct.gridy = 0; add(lblProduct, gbc_lblProduct); comboBoxProduct = new JComboBox(); GridBagConstraints gbc_comboBoxProduct = new GridBagConstraints(); gbc_comboBoxProduct.insets = new Insets(0, 0, 5, 5); gbc_comboBoxProduct.fill = GridBagConstraints.HORIZONTAL; gbc_comboBoxProduct.gridx = 1; gbc_comboBoxProduct.gridy = 0; add(comboBoxProduct, gbc_comboBoxProduct); JButton btnRefresh = new JButton(""); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { initProduct(); } }); btnRefresh.setIcon(new ImageIcon(CustomerPanel.class.getResource("/images/icon_refresh.png"))); GridBagConstraints gbc_btnRefresh = new GridBagConstraints(); gbc_btnRefresh.insets = new Insets(0, 0, 5, 0); gbc_btnRefresh.gridx = 2; gbc_btnRefresh.gridy = 0; add(btnRefresh, gbc_btnRefresh); JLabel lblProductVersion = new JLabel("\u4EA7\u54C1\u7248\u672C\uFF1A"); GridBagConstraints gbc_lblProductVersion = new GridBagConstraints(); gbc_lblProductVersion.anchor = GridBagConstraints.EAST; gbc_lblProductVersion.insets = new Insets(0, 0, 5, 5); gbc_lblProductVersion.gridx = 0; gbc_lblProductVersion.gridy = 1; add(lblProductVersion, gbc_lblProductVersion); textFieldProductVersion = new VersionTextField(); textFieldProductVersion.setColumns(10); GridBagConstraints gbc_textFieldProductVersion = new GridBagConstraints(); gbc_textFieldProductVersion.anchor = GridBagConstraints.WEST; gbc_textFieldProductVersion.insets = new Insets(0, 0, 5, 5); gbc_textFieldProductVersion.gridx = 1; gbc_textFieldProductVersion.gridy = 1; add(textFieldProductVersion, gbc_textFieldProductVersion); JLabel lblCompanyName = new JLabel("\u516C\u53F8\u540D\u79F0\uFF1A"); GridBagConstraints gbc_lblCompanyName = new GridBagConstraints(); gbc_lblCompanyName.anchor = GridBagConstraints.EAST; gbc_lblCompanyName.insets = new Insets(0, 0, 5, 5); gbc_lblCompanyName.gridx = 0; gbc_lblCompanyName.gridy = 2; add(lblCompanyName, gbc_lblCompanyName); textFieldCompanyName = new JTextField(); GridBagConstraints gbc_textFieldCompanyName = new GridBagConstraints(); gbc_textFieldCompanyName.insets = new Insets(0, 0, 5, 5); gbc_textFieldCompanyName.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldCompanyName.gridx = 1; gbc_textFieldCompanyName.gridy = 2; add(textFieldCompanyName, gbc_textFieldCompanyName); textFieldCompanyName.setColumns(10); JLabel lblCustomerCode = new JLabel("\u5BA2\u6237\u7F16\u53F7\uFF1A"); GridBagConstraints gbc_lblCustomerCode = new GridBagConstraints(); gbc_lblCustomerCode.anchor = GridBagConstraints.EAST; gbc_lblCustomerCode.insets = new Insets(0, 0, 5, 5); gbc_lblCustomerCode.gridx = 0; gbc_lblCustomerCode.gridy = 3; add(lblCustomerCode, gbc_lblCustomerCode); textFieldCustomerCode = new JTextField(); GridBagConstraints gbc_textFieldCustomerCode = new GridBagConstraints(); gbc_textFieldCustomerCode.insets = new Insets(0, 0, 5, 5); gbc_textFieldCustomerCode.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldCustomerCode.gridx = 1; gbc_textFieldCustomerCode.gridy = 3; add(textFieldCustomerCode, gbc_textFieldCustomerCode); textFieldCustomerCode.setColumns(10); JLabel lblCustomerName = new JLabel("\u5BA2\u6237\u540D\u79F0\uFF1A"); GridBagConstraints gbc_lblCustomerName = new GridBagConstraints(); gbc_lblCustomerName.anchor = GridBagConstraints.EAST; gbc_lblCustomerName.insets = new Insets(0, 0, 5, 5); gbc_lblCustomerName.gridx = 0; gbc_lblCustomerName.gridy = 4; add(lblCustomerName, gbc_lblCustomerName); textFieldCustomerName = new JTextField(); GridBagConstraints gbc_textFieldCustomerName = new GridBagConstraints(); gbc_textFieldCustomerName.insets = new Insets(0, 0, 5, 5); gbc_textFieldCustomerName.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldCustomerName.gridx = 1; gbc_textFieldCustomerName.gridy = 4; add(textFieldCustomerName, gbc_textFieldCustomerName); textFieldCustomerName.setColumns(10); JLabel lblLicenseType = new JLabel("\u8BC1\u4E66\u7C7B\u578B\uFF1A"); GridBagConstraints gbc_lblLicenseType = new GridBagConstraints(); gbc_lblLicenseType.anchor = GridBagConstraints.EAST; gbc_lblLicenseType.insets = new Insets(0, 0, 5, 5); gbc_lblLicenseType.gridx = 0; gbc_lblLicenseType.gridy = 5; add(lblLicenseType, gbc_lblLicenseType); comboBoxLicenseType = new JComboBox(); GridBagConstraints gbc_comboBoxLicenseType = new GridBagConstraints(); gbc_comboBoxLicenseType.insets = new Insets(0, 0, 5, 5); gbc_comboBoxLicenseType.fill = GridBagConstraints.HORIZONTAL; gbc_comboBoxLicenseType.gridx = 1; gbc_comboBoxLicenseType.gridy = 5; add(comboBoxLicenseType, gbc_comboBoxLicenseType); JLabel lblExpiredDate = new JLabel("\u8FC7\u671F\u65F6\u95F4\uFF1A"); GridBagConstraints gbc_lblExpiredDate = new GridBagConstraints(); gbc_lblExpiredDate.insets = new Insets(0, 0, 5, 5); gbc_lblExpiredDate.gridx = 0; gbc_lblExpiredDate.gridy = 6; add(lblExpiredDate, gbc_lblExpiredDate); datePickerExpiredDate = new DatePicker(new Date(), "yyyy-MM-dd", null, null); GridBagConstraints gbc_datePicker = new GridBagConstraints(); gbc_datePicker.anchor = GridBagConstraints.WEST; gbc_datePicker.insets = new Insets(0, 0, 5, 5); gbc_datePicker.gridx = 1; gbc_datePicker.gridy = 6; add(datePickerExpiredDate, gbc_datePicker); JButton btnSave = new JButton("\u4FDD\u5B58"); btnSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { //???????? if (comboBoxProduct.getSelectedIndex() <= 0) { JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "??"); return; } String[] array = StringUtils.split(comboBoxProduct.getSelectedItem().toString(), '-'); String productCode = array[0]; String productName = array[1]; String customerCode = textFieldCustomerCode.getText(); //?? File configFile = ResourceUtils.getFile(Gui.HOME_PATH + File.separator + "config.xml"); Document document = XmlUtils.readXml(configFile); Element customerNode = (Element) document.selectSingleNode( "//product[@code='" + productCode + "']/customer[@code='" + customerCode + "']"); if (customerNode != null) { JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "???"); return; } String licenseId = new RandomGUID().toString(); String licenseType = Utility.splitStringAll(comboBoxLicenseType.getSelectedItem().toString(), " - ")[0]; String companyName = textFieldCompanyName.getText(); String customerName = textFieldCustomerName.getText(); String version = textFieldProductVersion.getText(); Date expiredDate = Utility.parseDate(datePickerExpiredDate.getText()); License license = new License(); license.setLicenseId(licenseId); license.setLicenseType(licenseType); license.setProductName(productName); license.setCompanyName(companyName); license.setCustomerName(customerName); license.setVersion(Version.parseVersion(version)); license.setCreateDate(new Date()); license.setExpiredDate(expiredDate); LicenseService service = new LicenseService(); String productPath = Gui.HOME_PATH + File.separator + productCode; File licenseDir = new File(productPath, customerCode); if (!licenseDir.exists()) { licenseDir.mkdir(); //? FileUtils.copyFileToDirectory(new File(productPath, "license.key"), licenseDir); } File priKeyFile = new File(Gui.HOME_PATH + File.separator + productCode, "private.key"); File licenseFile = new File(licenseDir, "license.xml"); service.save(Gui.HOME_PATH, productCode, customerCode, license, priKeyFile, licenseFile); //??zip? File customerPath = licenseFile.getParentFile(); //???license????? File licensePath = new File(customerPath.getParent(), "license"); if (!licensePath.exists() && !licensePath.isDirectory()) { licensePath.mkdir(); } else { FileUtils.cleanDirectory(licensePath); } //? FileUtils.copyDirectory(customerPath, licensePath); String currentTime = FormatDateTime.formatDateTimeNum(new Date()); ZipUtils.zip(licensePath, new File(licensePath.getParentFile(), customerCode + "-" + currentTime + ".zip")); //license FileUtils.deleteDirectory(licensePath); JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "??"); } catch (Exception e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), e1.getMessage()); } } }); GridBagConstraints gbc_btnSave = new GridBagConstraints(); gbc_btnSave.insets = new Insets(0, 0, 5, 5); gbc_btnSave.gridx = 1; gbc_btnSave.gridy = 7; add(btnSave, gbc_btnSave); //?? initData(); }
From source file:edu.fullerton.viewerplugin.XYPlotter.java
private ChartPanel getPanel(double[][] data) throws WebUtilException { ChartPanel ret = null;/*from ww w . j a v a2 s . c o m*/ try { XYSeries xys; XYSeriesCollection mtds = new XYSeriesCollection(); String mylegend = legend == null || legend.isEmpty() ? "series 1" : legend; xys = new XYSeries(legend); int len = data.length; double minx = Double.MAX_VALUE; double maxx = Double.MIN_VALUE; double miny = Double.MAX_VALUE; double maxy = Double.MIN_VALUE; boolean gotZeroX = false; boolean gotZeroY = false; for (int i = 0; i < len; i++) { double x = data[i][0]; double y = data[i][1]; if (x == 0) { gotZeroX = true; } else { minx = Math.min(minx, x); maxx = Math.max(maxx, x); } if (y == 0) { gotZeroY = true; } else { miny = Math.min(miny, y); maxy = Math.max(maxy, y); } } // this kludge lets us plot a 0 on a log axis double fakeZeroX = 0.; double fakeZeroY = 0.; if (gotZeroX) { if (logXaxis) { fakeZeroX = minx / 10; } else { minx = Math.min(0, minx); maxx = Math.max(0, maxx); } } if (gotZeroY) { if (logYaxis) { fakeZeroY = miny / 10; } else { miny = Math.min(0, miny); maxy = Math.max(0, maxy); } } for (int i = 0; i < len; i++) { double x = data[i][0]; double y = data[i][1]; x = x == 0 ? fakeZeroX : x; y = y == 0 ? fakeZeroY : y; xys.add(x, y); } mtds.addSeries(xys); DefaultXYDataset ds = new DefaultXYDataset(); int exp; if (maxy == 0. && miny == 0.) { miny = -1.; exp = 0; logYaxis = false; } else { maxy = maxy > miny ? maxy : miny * 10; exp = PluginSupport.scaleRange(mtds, miny, maxy); if (!logYaxis && exp > 0) { yLabel += " x 1e-" + Integer.toString(exp); } } JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, ds, PlotOrientation.VERTICAL, true, false, false); org.jfree.chart.plot.XYPlot plot = (org.jfree.chart.plot.XYPlot) chart.getPlot(); if (logYaxis) { LogAxis rangeAxis = new LogAxis(yLabel); double smallest = miny * Math.pow(10, exp); rangeAxis.setSmallestValue(smallest); rangeAxis.setMinorTickCount(9); LogAxisNumberFormat lanf = new LogAxisNumberFormat(); lanf.setExp(exp); rangeAxis.setNumberFormatOverride(lanf); rangeAxis.setRange(smallest, maxy * Math.pow(10, exp)); plot.setRangeAxis(rangeAxis); } if (logXaxis) { LogAxis domainAxis = new LogAxis(xLabel); domainAxis.setMinorTickCount(9); domainAxis.setSmallestValue(minx); domainAxis.setNumberFormatOverride(new LogAxisNumberFormat()); plot.setDomainAxis(domainAxis); } ValueAxis domainAxis = plot.getDomainAxis(); if (fmin != null && fmin > 0) { domainAxis.setLowerBound(fmin); } if (fmax != null && fmax > 0) { domainAxis.setUpperBound(fmax); } plot.setDomainAxis(domainAxis); plot.setDataset(0, mtds); // Set the line thickness XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); BasicStroke str = new BasicStroke(lineThickness); int n = plot.getSeriesCount(); for (int i = 0; i < n; i++) { r.setSeriesStroke(i, str); } if (legend == null || legend.isEmpty()) { chart.removeLegend(); } ret = new ChartPanel(chart); } catch (Exception ex) { throw new WebUtilException("Creating spectrum plot" + ex.getLocalizedMessage()); } return ret; }
From source file:gdt.jgui.entity.contact.JContactEditor.java
public JContactEditor() { GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 100, 0, 0 }; gridBagLayout.rowHeights = new int[] { 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0 }; setLayout(gridBagLayout);//from w ww .j ava 2s.c om JLabel lblTitle = new JLabel("Label"); GridBagConstraints gbc_lblTitle = new GridBagConstraints(); gbc_lblTitle.insets = new Insets(5, 5, 5, 5); gbc_lblTitle.gridx = 0; gbc_lblTitle.gridy = 0; gbc_lblTitle.anchor = GridBagConstraints.NORTHWEST; add(lblTitle, gbc_lblTitle); title = new JTextField(); GridBagConstraints gbc_title = new GridBagConstraints(); gbc_title.insets = new Insets(5, 0, 5, 5); gbc_title.fill = GridBagConstraints.HORIZONTAL; gbc_title.gridx = 1; gbc_title.gridy = 0; add(title, gbc_title); title.setColumns(10); JLabel lblPhone = new JLabel("Phone"); GridBagConstraints gbc_lblphone = new GridBagConstraints(); gbc_lblphone.insets = new Insets(5, 5, 5, 5); gbc_lblphone.gridx = 0; gbc_lblphone.gridy = 1; gbc_lblphone.anchor = GridBagConstraints.NORTHWEST; add(lblPhone, gbc_lblphone); phone = new JTextField(); GridBagConstraints gbc_phone = new GridBagConstraints(); gbc_phone.insets = new Insets(5, 0, 5, 5); gbc_phone.fill = GridBagConstraints.HORIZONTAL; gbc_phone.gridx = 1; gbc_phone.gridy = 1; add(phone, gbc_phone); phone.setColumns(10); JLabel lblEmail = new JLabel("Email"); GridBagConstraints gbc_lblEmail = new GridBagConstraints(); gbc_lblEmail.insets = new Insets(5, 5, 5, 5); gbc_lblEmail.gridx = 0; gbc_lblEmail.gridy = 2; gbc_lblEmail.anchor = GridBagConstraints.NORTHWEST; add(lblEmail, gbc_lblEmail); email = new JTextField(); GridBagConstraints gbc_email = new GridBagConstraints(); gbc_phone.insets = new Insets(5, 0, 5, 5); gbc_email.fill = GridBagConstraints.HORIZONTAL; gbc_email.gridx = 1; gbc_email.gridy = 2; add(email, gbc_email); email.setColumns(10); JPanel panel = new JPanel(); GridBagConstraints gbc_panel = new GridBagConstraints(); gbc_panel.weighty = 1.0; gbc_panel.insets = new Insets(5, 0, 5, 5); gbc_panel.fill = GridBagConstraints.BOTH; gbc_panel.gridx = 0; gbc_panel.gridy = 3; add(panel, gbc_panel); panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); }
From source file:edu.umn.msi.tropix.proteomics.itraqquantitation.impl.Variance.java
static double[][] createVarianceMatrix(final List<ITraqLabel> labels, final Map<ITraqLabel, double[]> intensities, final double[] ds, final int binSize) { final int n = intensities.values().iterator().next().length; final double[] reference = new double[n]; for (int i = 0; i < n; i++) { double intensitiesProduct = 1.0d; for (final ITraqLabel label : labels) { final double intensity = intensities.get(label)[i]; intensitiesProduct *= intensity; }//from w w w . j a v a 2 s . c o m reference[i] = MathUtils.log(2.0, intensitiesProduct); } // final double[] sortedReference = Arrays.copyOf(reference, reference.length); final double[] sortedReference = new double[reference.length]; for (int i = 0; i < reference.length; i++) { sortedReference[i] = reference[i]; } Arrays.sort(sortedReference); final List<ITraqRatio> ratios = ITraqLabels.buildRatios(labels); final int numRatios = ratios.size(); final int numRows = numRatios * n; // Precompute ratios final double[] actualRatios = new double[numRatios]; final double[][] numerators = new double[numRatios][]; final double[][] denominators = new double[numRatios][]; for (int ratioIndex = 0; ratioIndex < numRatios; ratioIndex++) { final ITraqRatio ratio = ratios.get(ratioIndex); final int numeratorIndex = labels.indexOf(ratio.getNumerator()); final int denominatorIndex = labels.indexOf(ratio.getDenominator()); numerators[ratioIndex] = intensities.get(ratio.getNumerator()); denominators[ratioIndex] = intensities.get(ratio.getDenominator()); actualRatios[ratioIndex] = MathUtils.log(2.0, ds[numeratorIndex] / ds[denominatorIndex]); } final double[][] samplePoints = new double[numRows][2]; for (int sortedReferenceIndex = 0; sortedReferenceIndex < n; sortedReferenceIndex++) { final double referenceValue = sortedReference[sortedReferenceIndex]; final int referenceIndex = indexOf(referenceValue, reference); final int rowOffset = sortedReferenceIndex * numRatios; for (int ratioIndex = 0; ratioIndex < numRatios; ratioIndex++) { final double actualRatio = actualRatios[ratioIndex]; final double estimatedRatio = MathUtils.log(2.0, numerators[ratioIndex][referenceIndex] / denominators[ratioIndex][referenceIndex]); final double diff = (estimatedRatio - actualRatio); samplePoints[rowOffset + ratioIndex][0] = referenceValue; samplePoints[rowOffset + ratioIndex][1] = diff * diff; } } final int numBins = numRows / binSize; final double[][] matrixXV = new double[numBins][2]; double maxV = Double.MIN_VALUE; double sumX = 0.0, sumV = 0.0; int curBin = 0; for (int i = 0; i < numRows; i++) { sumX += samplePoints[i][0]; sumV += samplePoints[i][1]; if ((i + 1) % binSize == 0) { final double x = sumX / binSize; final double v = sumV / binSize; final double binWeight = 1 / v; if (!Double.isInfinite(binWeight)) { maxV = Math.max(binWeight, maxV); } matrixXV[curBin][0] = x; matrixXV[curBin][1] = binWeight; curBin++; sumX = 0.0; sumV = 0.0; } } for (int i = 0; i < numBins; i++) { if (Double.isInfinite(matrixXV[i][1])) { matrixXV[i][1] = maxV; } } for (int i = 0; i < numBins - 1; i++) { matrixXV[i][0] = (matrixXV[i][0] + matrixXV[i + 1][0]) / 2.0; } return matrixXV; }
From source file:net.sf.jtmt.clustering.KMeansClusterer.java
/** * Cluster.//from ww w . j a va 2 s. c o m * * @param collection the collection * @return the list */ public List<Cluster> cluster(DocumentCollection collection) { int numDocs = collection.size(); int numClusters = 0; if (initialClusterAssignments == null) { // compute initial cluster assignments IdGenerator idGenerator = new IdGenerator(numDocs); numClusters = (int) Math.floor(Math.sqrt(numDocs)); initialClusterAssignments = new String[numClusters]; for (int i = 0; i < numClusters; i++) { int docId = idGenerator.getNextId(); initialClusterAssignments[i] = collection.getDocumentNameAt(docId); } } else { numClusters = initialClusterAssignments.length; } // build initial clusters List<Cluster> clusters = new ArrayList<Cluster>(); for (int i = 0; i < numClusters; i++) { Cluster cluster = new Cluster("C" + i); cluster.addDocument(initialClusterAssignments[i], collection.getDocument(initialClusterAssignments[i])); clusters.add(cluster); } log.debug("..Initial clusters:" + clusters.toString()); List<Cluster> prevClusters = new ArrayList<Cluster>(); // Repeat until termination conditions are satisfied for (;;) { // For every cluster i, (re-)compute the centroid based on the // current member documents. (We have moved 2.2 above 2.1 because // this needs to be done before every iteration). RealMatrix[] centroids = new RealMatrix[numClusters]; for (int i = 0; i < numClusters; i++) { RealMatrix centroid = clusters.get(i).getCentroid(); centroids[i] = centroid; } // For every document d, find the cluster i whose centroid is // most similar, assign d to cluster i. (If a document is // equally similar from all centroids, then just dump it into // cluster 0). for (int i = 0; i < numDocs; i++) { int bestCluster = 0; double maxSimilarity = Double.MIN_VALUE; RealMatrix document = collection.getDocumentAt(i); String docName = collection.getDocumentNameAt(i); for (int j = 0; j < numClusters; j++) { double similarity = clusters.get(j).getSimilarity(document); if (similarity > maxSimilarity) { bestCluster = j; maxSimilarity = similarity; } } for (Cluster cluster : clusters) { if (cluster.getDocument(docName) != null) { cluster.removeDocument(docName); } } clusters.get(bestCluster).addDocument(docName, document); } log.debug("..Intermediate clusters: " + clusters.toString()); // Check for termination -- minimal or no change to the assignment // of documents to clusters. if (CollectionUtils.isEqualCollection(clusters, prevClusters)) { break; } prevClusters.clear(); prevClusters.addAll(clusters); } // Return list of clusters log.debug("..Final clusters: " + clusters.toString()); return clusters; }
From source file:analysers.FilterValidatedDialog.java
/** * Create the dialog.//from w w w. j av a 2 s . c o m */ public FilterValidatedDialog() { setTitle("Validated Lineages: Export Filter"); setBounds(100, 100, 632, 348); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); GridBagLayout gbl_contentPanel = new GridBagLayout(); gbl_contentPanel.columnWidths = new int[] { 160, 440, 0 }; gbl_contentPanel.rowHeights = new int[] { 1, 28, 28, 28, 0, 0 }; gbl_contentPanel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; contentPanel.setLayout(gbl_contentPanel); { JLabel lblCriterion = new JLabel("Lineage Criterion"); lblCriterion.setFont(new Font("Lucida Grande", Font.BOLD, 13)); GridBagConstraints gbc_lblCriterion = new GridBagConstraints(); gbc_lblCriterion.insets = new Insets(0, 0, 5, 5); gbc_lblCriterion.gridx = 0; gbc_lblCriterion.gridy = 0; contentPanel.add(lblCriterion, gbc_lblCriterion); } { JLabel lblValue = new JLabel("Value"); lblValue.setFont(new Font("Lucida Grande", Font.BOLD, 13)); GridBagConstraints gbc_lblValue = new GridBagConstraints(); gbc_lblValue.insets = new Insets(0, 0, 5, 0); gbc_lblValue.gridx = 1; gbc_lblValue.gridy = 0; contentPanel.add(lblValue, gbc_lblValue); } { lblMinLineageLength = new JLabel("Min. Length (frames)"); GridBagConstraints gbc_lblMinLineageLength = new GridBagConstraints(); gbc_lblMinLineageLength.fill = GridBagConstraints.BOTH; gbc_lblMinLineageLength.insets = new Insets(0, 0, 5, 5); gbc_lblMinLineageLength.gridx = 0; gbc_lblMinLineageLength.gridy = 1; contentPanel.add(lblMinLineageLength, gbc_lblMinLineageLength); } { minLinLen = new JTextField(); GridBagConstraints gbc_minLinLen = new GridBagConstraints(); gbc_minLinLen.anchor = GridBagConstraints.NORTH; gbc_minLinLen.fill = GridBagConstraints.HORIZONTAL; gbc_minLinLen.insets = new Insets(0, 0, 5, 0); gbc_minLinLen.gridx = 1; gbc_minLinLen.gridy = 1; contentPanel.add(minLinLen, gbc_minLinLen); minLinLen.setText("1"); minLinLen.setColumns(3); } { lblStartFrameOf = new JLabel("Max. Start Frame"); GridBagConstraints gbc_lblStartFrameOf = new GridBagConstraints(); gbc_lblStartFrameOf.fill = GridBagConstraints.HORIZONTAL; gbc_lblStartFrameOf.insets = new Insets(0, 0, 5, 5); gbc_lblStartFrameOf.gridx = 0; gbc_lblStartFrameOf.gridy = 2; contentPanel.add(lblStartFrameOf, gbc_lblStartFrameOf); } { startLin = new JTextField(); GridBagConstraints gbc_startLin = new GridBagConstraints(); gbc_startLin.insets = new Insets(0, 0, 5, 0); gbc_startLin.fill = GridBagConstraints.HORIZONTAL; gbc_startLin.gridx = 1; gbc_startLin.gridy = 2; contentPanel.add(startLin, gbc_startLin); startLin.setText("-1"); startLin.setColumns(3); } { JButton btnPreview = new JButton("Preview"); btnPreview.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { preview.setText(makePreview()); } }); GridBagConstraints gbc_btnPreview = new GridBagConstraints(); gbc_btnPreview.insets = new Insets(0, 0, 5, 5); gbc_btnPreview.gridx = 0; gbc_btnPreview.gridy = 3; contentPanel.add(btnPreview, gbc_btnPreview); } { JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.insets = new Insets(0, 0, 5, 0); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 1; gbc_scrollPane.gridy = 3; contentPanel.add(scrollPane, gbc_scrollPane); { preview = new JTextArea(); scrollPane.setViewportView(preview); preview.setEditable(false); preview.setColumns(10); preview.setTabSize(4); } } { JLabel lblOptions = new JLabel("Options"); GridBagConstraints gbc_lblOptions = new GridBagConstraints(); gbc_lblOptions.insets = new Insets(0, 0, 0, 5); gbc_lblOptions.gridx = 0; gbc_lblOptions.gridy = 4; contentPanel.add(lblOptions, gbc_lblOptions); } { JPanel panel = new JPanel(); GridBagConstraints gbc_panel = new GridBagConstraints(); gbc_panel.anchor = GridBagConstraints.NORTH; gbc_panel.fill = GridBagConstraints.HORIZONTAL; gbc_panel.gridx = 1; gbc_panel.gridy = 4; contentPanel.add(panel, gbc_panel); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[] { 69, 169, 162, 0 }; gbl_panel.rowHeights = new int[] { 23, 23, 0 }; gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_panel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; panel.setLayout(gbl_panel); { rdbtnExportMeanIntensity = new JRadioButton("Export Mean Intensity"); rdbtnExportMeanIntensity.setSelected(true); buttonGroup.add(rdbtnExportMeanIntensity); GridBagConstraints gbc_rdbtnExportMeanIntensity = new GridBagConstraints(); gbc_rdbtnExportMeanIntensity.anchor = GridBagConstraints.NORTHWEST; gbc_rdbtnExportMeanIntensity.insets = new Insets(0, 0, 5, 5); gbc_rdbtnExportMeanIntensity.gridx = 1; gbc_rdbtnExportMeanIntensity.gridy = 0; panel.add(rdbtnExportMeanIntensity, gbc_rdbtnExportMeanIntensity); } { rdbtnExportMaxIntensity = new JRadioButton("Export Max Intensity"); buttonGroup.add(rdbtnExportMaxIntensity); GridBagConstraints gbc_rdbtnExportMaxIntensity = new GridBagConstraints(); gbc_rdbtnExportMaxIntensity.anchor = GridBagConstraints.NORTHWEST; gbc_rdbtnExportMaxIntensity.insets = new Insets(0, 0, 5, 0); gbc_rdbtnExportMaxIntensity.gridx = 2; gbc_rdbtnExportMaxIntensity.gridy = 0; panel.add(rdbtnExportMaxIntensity, gbc_rdbtnExportMaxIntensity); } { chckbxExportPositions = new JCheckBox("Export Cell Positions and Areas in CSV"); GridBagConstraints gbc_chckbxExportPositions = new GridBagConstraints(); gbc_chckbxExportPositions.anchor = GridBagConstraints.NORTH; gbc_chckbxExportPositions.gridwidth = 2; gbc_chckbxExportPositions.gridx = 1; gbc_chckbxExportPositions.gridy = 1; panel.add(chckbxExportPositions, gbc_chckbxExportPositions); } } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (validateFields()) { Prefs.set("TrackApp.FilterValidatedDialog.startLin", valStartLin); Prefs.set("TrackApp.FilterValidatedDialog.minLinLen", valMinLinLen); Prefs.set("TrackApp.FilterValidatedDialog.exportMean", doExportMean); Prefs.set("TrackApp.FilterValidatedDialog.exportPositions", doExportPositions); Prefs.savePreferences(); dispose(); } } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } }
From source file:org.um.feri.ears.qualityIndicator.EpsilonBin.java
private double getEpsilon(double[][] normalizedFront1, double[][] normalizedFront2, int method) { int i, j, k;/*from w w w . j ava 2 s . c om*/ double eps, eps_j = 0.0, eps_k = 0.0, eps_temp; if (method == 0) eps = Double.MIN_VALUE; else eps = 0; for (i = 0; i < normalizedFront2.length; i++) { for (j = 0; j < normalizedFront1.length; j++) { for (k = 0; k < numberOfObjectives; k++) { switch (method) { case 0: eps_temp = normalizedFront1[j][k] - normalizedFront2[i][k]; break; default: if ((normalizedFront2[i][k] < 0 && normalizedFront1[j][k] > 0) || (normalizedFront2[i][k] > 0 && normalizedFront1[j][k] < 0) || (normalizedFront2[i][k] == 0 || normalizedFront1[j][k] == 0)) { System.err.println("error in data file"); System.exit(0); } eps_temp = normalizedFront1[j][k] / normalizedFront2[i][k]; break; } if (k == 0) eps_k = eps_temp; else if (eps_k < eps_temp) eps_k = eps_temp; } if (j == 0) eps_j = eps_k; else if (eps_j > eps_k) eps_j = eps_k; } if (i == 0) eps = eps_j; else if (eps < eps_j) eps = eps_j; } return eps; }