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:au.org.ala.delta.intkey.ui.FindInCharactersDialog.java
public FindInCharactersDialog(Intkey intkeyApp, IntkeyContext context) { super(intkeyApp.getMainFrame(), false); setResizable(false);/* w w w . jav a 2 s . c om*/ ResourceMap resourceMap = Application.getInstance().getContext() .getResourceMap(FindInCharactersDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(this); _intkeyApp = intkeyApp; _numMatchedCharacters = 0; _currentMatchedCharacter = -1; _findAction = actionMap.get("findCharacters"); _nextAction = actionMap.get("nextCharacter"); this.setTitle(windowTitle); _pnlMain = new JPanel(); _pnlMain.setBorder(new EmptyBorder(20, 20, 20, 20)); getContentPane().add(_pnlMain, BorderLayout.CENTER); _pnlMain.setLayout(new BorderLayout(0, 0)); _pnlMainTop = new JPanel(); _pnlMain.add(_pnlMainTop, BorderLayout.NORTH); _pnlMainTop.setLayout(new BoxLayout(_pnlMainTop, BoxLayout.Y_AXIS)); _lblEnterSearchString = new JLabel(enterSearchStringCaption); _lblEnterSearchString.setBorder(new EmptyBorder(0, 0, 5, 0)); _pnlMainTop.add(_lblEnterSearchString); _textField = new JTextField(); _pnlMainTop.add(_textField); _textField.setColumns(10); _textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { reset(); } @Override public void insertUpdate(DocumentEvent e) { reset(); } @Override public void changedUpdate(DocumentEvent e) { reset(); } }); _pnlMainBottom = new JPanel(); _pnlMainBottom.setBorder(new EmptyBorder(20, 0, 0, 0)); _pnlMain.add(_pnlMainBottom, BorderLayout.CENTER); _pnlMainBottom.setLayout(new BoxLayout(_pnlMainBottom, BoxLayout.Y_AXIS)); _chckbxSearchStates = new JCheckBox(searchStatesCaption); _chckbxSearchStates.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchStates); _chckbxSearchUsedCharacters = new JCheckBox(searchUsedCharactersCaption); _chckbxSearchUsedCharacters.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchUsedCharacters); _pnlButtons = new JPanel(); _pnlButtons.setBorder(new EmptyBorder(20, 0, 0, 10)); getContentPane().add(_pnlButtons, BorderLayout.EAST); _pnlButtons.setLayout(new BorderLayout(0, 0)); _pnlInnerButtons = new JPanel(); _pnlButtons.add(_pnlInnerButtons, BorderLayout.NORTH); GridBagLayout gbl__pnlInnerButtons = new GridBagLayout(); gbl__pnlInnerButtons.columnWidths = new int[] { 0, 0 }; gbl__pnlInnerButtons.rowHeights = new int[] { 0, 0, 0, 0 }; gbl__pnlInnerButtons.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; gbl__pnlInnerButtons.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; _pnlInnerButtons.setLayout(gbl__pnlInnerButtons); _btnFindNext = new JButton(); _btnFindNext.setAction(_findAction); GridBagConstraints gbc__btnFindNext = new GridBagConstraints(); gbc__btnFindNext.fill = GridBagConstraints.HORIZONTAL; gbc__btnFindNext.insets = new Insets(0, 0, 5, 0); gbc__btnFindNext.gridx = 0; gbc__btnFindNext.gridy = 0; _pnlInnerButtons.add(_btnFindNext, gbc__btnFindNext); _btnPrevious = new JButton(); _btnPrevious.setAction(actionMap.get("previousCharacter")); _btnPrevious.setEnabled(false); GridBagConstraints gbc__btnPrevious = new GridBagConstraints(); gbc__btnPrevious.insets = new Insets(0, 0, 5, 0); gbc__btnPrevious.gridx = 0; gbc__btnPrevious.gridy = 1; _pnlInnerButtons.add(_btnPrevious, gbc__btnPrevious); _btnDone = new JButton(); _btnDone.setAction(actionMap.get("findCharactersDone")); GridBagConstraints gbc__btnDone = new GridBagConstraints(); gbc__btnDone.fill = GridBagConstraints.HORIZONTAL; gbc__btnDone.gridx = 0; gbc__btnDone.gridy = 2; _pnlInnerButtons.add(_btnDone, gbc__btnDone); this.pack(); this.setLocationRelativeTo(_intkeyApp.getMainFrame()); }
From source file:ed.net.lb.LB.java
void _addMonitors() { HttpServer.addGlobalHandler(new WebViews.LBOverview(this)); HttpServer.addGlobalHandler(new WebViews.LBLast(this)); HttpServer.addGlobalHandler(new WebViews.LoadMonitorWebView(this._loadMonitor)); HttpServer.addGlobalHandler(new WebViews.SiteLoadMonitorWebView(this._loadMonitor)); HttpServer.addGlobalHandler(new WebViews.RouterPools(this._router)); HttpServer.addGlobalHandler(new WebViews.RouterServers(this._router)); HttpServer.addGlobalHandler(new WebViews.MappingView(this._router)); HttpServer.addGlobalHandler(new HttpHandler() { public boolean handles(HttpRequest request, Info info) { if (!"/~kill".equals(request.getURI())) return false; if (!"127.0.0.1".equals(request.getPhysicalRemoteAddr())) return false; info.fork = false;//from w w w. jav a 2 s . c o m info.admin = true; return true; } public boolean handle(HttpRequest request, HttpResponse response) { JxpWriter out = response.getJxpWriter(); if (isShutDown()) { out.print("alredy shutdown"); return true; } LB.this.shutdown(); out.print("done"); return true; } public double priority() { return Double.MIN_VALUE; } }); }
From source file:rita.ui.component.DialogSelectEnemies.java
/** * Initialize the contents of the frame. * //from w ww. j av a 2 s .c om * @throws NoEnemiesException */ private void initialize() throws NoEnemiesException { this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.getContentPane().setLayout(new BorderLayout(6, 6)); this.setTitle(Language.get("selectEnemies")); randomMode = new JCheckBox(Language.get("robotsBattleMode.random")); randomMode.setSelected(true); randomMode.addActionListener(new SelectUnselectPositionAction()); icon = new ImageIcon(DialogSelectEnemies.class.getResource("/images/icons/target.jpg")); JPanel panelRobots = new JPanel(); panelRobots.setBorder(new EmptyBorder(0, 12, 12, 0)); panelRobots.setLayout(new BorderLayout(0, 0)); JPanel panelSelectAllNone = new JPanel(); panelSelectAllNone.setBorder(new EmptyBorder(0, 12, 0, 12)); panelRobots.add(panelSelectAllNone, BorderLayout.EAST); this.getContentPane().add(panelRobots, BorderLayout.CENTER); GridBagLayout gbl_panelSelectAllNone = new GridBagLayout(); gbl_panelSelectAllNone.columnWidths = new int[] { 0, 0 }; gbl_panelSelectAllNone.rowHeights = new int[] { 0, 0, 8 }; gbl_panelSelectAllNone.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; gbl_panelSelectAllNone.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; panelSelectAllNone.setLayout(gbl_panelSelectAllNone); JButton btnSelectAll = new JButton(Language.get("selectAllEnemies")); GridBagConstraints gbc_btnSelectAll = new GridBagConstraints(); gbc_btnSelectAll.fill = GridBagConstraints.HORIZONTAL; gbc_btnSelectAll.insets = new Insets(0, 0, 5, 0); gbc_btnSelectAll.gridx = 0; gbc_btnSelectAll.gridy = 0; panelSelectAllNone.add(btnSelectAll, gbc_btnSelectAll); JButton btnSelectNone = new JButton(Language.get("selectNoEnemies")); GridBagConstraints gbc_btnSelectNone = new GridBagConstraints(); gbc_btnSelectNone.fill = GridBagConstraints.HORIZONTAL; gbc_btnSelectNone.gridx = 0; gbc_btnSelectNone.gridy = 1; panelSelectAllNone.add(btnSelectNone, gbc_btnSelectNone); /* * btnInitialPositionsConfig = new * JButton(Language.get("selectRobotsInitialPositions")); * GridBagConstraints gbc_btnInitialPositionsConfig = new * GridBagConstraints(); gbc_btnSelectNone.fill = * GridBagConstraints.HORIZONTAL; gbc_btnSelectNone.gridx = 0; * gbc_btnSelectNone.gridy = 1; * panelSelectAllNone.add(btnInitialPositionsConfig, * gbc_btnInitialPositionsConfig); * btnInitialPositionsConfig.addActionListener(new ActionListener() { * public void actionPerformed(ActionEvent evt) { * selectRobotsInitialPositions(); } }); */ JLabel label = new JLabel(String.format(Language.get("youtRobotAgainst"), HelperEditor.currentRobotName)); label.setBorder(new EmptyBorder(12, 12, 0, 12)); label.setIcon(new ImageIcon(DialogSelectEnemies.class.getResource("/images/icons/compite2.png"))); label.setVerticalAlignment(SwingConstants.TOP); label.setFont(label.getFont().deriveFont(Font.BOLD, 14)); panelSelectRobots = new JPanel(); panelSelectRobots.setLayout(new GridLayout(0, 2)); panelSelectRobots.setAutoscrolls(true); panelRobots.add(label, BorderLayout.NORTH); panelRobots.add(panelSelectRobots, BorderLayout.CENTER); // posicion de mi robot JPanel panelSetMyRobotPosition = new JPanel(); // panelRobots.add(panelSetMyRobotPosition, BorderLayout.PAGE_END); panelSetMyRobotPosition.setLayout(new FlowLayout()); JLabel ownPosition = new JLabel(Language.get("myRobotPosition") + " " + HelperEditor.currentRobotName); ownPosition.setFont(new Font("sansserif", Font.BOLD, 12)); panelSetMyRobotPosition.add(ownPosition); // Posicion de mi robot buttonPos = new JButton(icon); buttonPos.addActionListener(new PosicionRobotAction(HelperEditor.currentRobotName)); // el nombre aqui es solo a // modo informativo buttonPos.setPreferredSize(new Dimension(30, 30)); panelSetMyRobotPosition.add(buttonPos); positionComponents.add(buttonPos); // Matas JPanel panelSelectRoundsNumber = new JPanel(); // panelRobots.add(panelSelectRoundsNumber, BorderLayout.SOUTH); panelSelectRoundsNumber.setLayout(new FlowLayout()); panelSelectRoundsNumber.add(new JLabel(Language.get("selectRoundsNumber"))); // this.roundsNumberTextField = new JTextField( // Integer.toString(Batalla.NUMBER_OF_ROUNDS), 5); this.roundsNumberSpinner = new JSpinner(new SpinnerNumberModel(Batalla.NUMBER_OF_ROUNDS, Batalla.MIN_NUMBER_OF_ROUNDS, Batalla.MAX_NUMBER_OF_ROUNDS, 1)); panelSelectRoundsNumber.add(this.roundsNumberSpinner); JPanel panelSouth = new JPanel(); panelSouth.setLayout(new GridLayout(4, 1)); panelSouth.add(panelSetMyRobotPosition); //this.getContentPane().add(randomMode, BorderLayout.SOUTH); panelSouth.add(randomMode); panelSouth.add(new JSeparator()); panelSouth.add(panelSelectRoundsNumber); panelRobots.add(panelSouth, BorderLayout.SOUTH); JPanel panelOkCancel = new JPanel(); this.getContentPane().add(panelOkCancel, BorderLayout.SOUTH); panelOkCancel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 12)); btnOK = new JButton(Language.get("selectStartBattle")); btnOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { startBattle(panelSelectRobots); } }); // comienza deshabilitado hasta que se seleccione 1 enemigo // btnOK.setEnabled(false); panelOkCancel.add(btnOK); JButton btnCancel = new JButton(Language.get("cancel")); btnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { closeDialog(); } }); panelOkCancel.add(btnCancel); btnSelectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { selectChecks(panelSelectRobots, true); // btnOK.setEnabled(true); } }); btnSelectNone.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { selectChecks(panelSelectRobots, false); // btnOK.setEnabled(false); } }); // TODO Agregar funcionalidad de elegir las posiciones iniciales de los // robots. // TODO Averiguar como pasar las posiciones para que se elijan de manera // random, probar (0,0,0) try { robotNameClicked = new RobotNameClickedEvent(btnOK); addRobotsToPanel(panelSelectRobots); this.setResizable(false); this.pack(); PositionCalc.centerDialog(this); enablePositionOptions(false); this.setVisible(true); } catch (FileNotFoundException e) { throw new NoEnemiesException(e.getMessage()); } }
From source file:javalibs.CSVDataNormalizer.java
private Pair getMaxMinFromCol(String columnName) { double max = Double.MIN_VALUE; double min = Double.MAX_VALUE; for (CSVRecord record : this.allRecords) { double val = NumUtils.getDoubleFromStr(record.get(columnName)); // NOTE: Floating point errors aren't really that important here, don't waste time on // a proper floating point comparison if (val > max) max = val; if (val < min) min = val; }//from w ww . java2 s . c o m return new Pair(max, min); }
From source file:ca.uhn.hl7v2.testpanel.ui.conn.Hl7ConnectionPanelHeader.java
/** * Create the panel./*from ww w .ja v a2 s.c o m*/ */ public Hl7ConnectionPanelHeader() { setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Outbound Message Sender", TitledBorder.CENTER, TitledBorder.TOP, null, new Color(0, 0, 0))); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 138, 0 }; gridBagLayout.rowHeights = new int[] { 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0 }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; setLayout(gridBagLayout); myNameBox = new JTextField(); myNameBox.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent theE) { myIgnoreNameChanges = true; try { myConnection.setNameExplicitly(myNameBox.getText()); } finally { myIgnoreNameChanges = false; } } }); myRememberAsCheckBox = new JCheckBox("Save With Name:"); myRememberAsCheckBox .setToolTipText("If checked, this connection will be saved for the next time you start TestPanel"); myRememberAsCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myConnection.setPersistent(myRememberAsCheckBox.isSelected()); updateRememberAsUi(); } }); GridBagConstraints gbc_RememberAsCheckBox = new GridBagConstraints(); gbc_RememberAsCheckBox.insets = new Insets(0, 0, 5, 5); gbc_RememberAsCheckBox.gridx = 0; gbc_RememberAsCheckBox.gridy = 0; add(myRememberAsCheckBox, gbc_RememberAsCheckBox); GridBagConstraints gbc_NameBox = new GridBagConstraints(); gbc_NameBox.insets = new Insets(0, 0, 5, 0); gbc_NameBox.fill = GridBagConstraints.HORIZONTAL; gbc_NameBox.gridx = 1; gbc_NameBox.gridy = 0; add(myNameBox, gbc_NameBox); myNameBox.setColumns(10); JPanel panel_5 = new JPanel(); GridBagConstraints gbc_panel_5 = new GridBagConstraints(); gbc_panel_5.anchor = GridBagConstraints.WEST; gbc_panel_5.fill = GridBagConstraints.VERTICAL; gbc_panel_5.gridx = 1; gbc_panel_5.gridy = 1; add(panel_5, gbc_panel_5); myStartButton = new JButton("Start"); myStartButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myConnection.start(); } }); panel_5.add(myStartButton); myStopButton = new JButton("Stop"); myStopButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myConnection.stop(); } }); panel_5.add(myStopButton); myStatusLabel = new JLabel("New label"); panel_5.add(myStatusLabel); }
From source file:com.yoncabt.ebr.executor.BaseReport.java
public ReportDefinition loadDefinition(File reportFile, File jsonFile) throws AssertionError, IOException, JSONException { ReportDefinition ret = new ReportDefinition(reportFile); if (!jsonFile.exists()) { ret.setCaption(jsonFile.getName().replace(".ebr.json", "")); return ret; }/*from www . j a v a 2 s .co m*/ String jsonComment = FileUtils.readFileToString(jsonFile, "utf-8"); JSONObject jsonObject = new JSONObject(jsonComment); ret.setCaption(jsonObject.optString("title", "NOT ITTLE")); ret.setDataSource(jsonObject.optString("datasource", "default")); ret.setTextEncoding(jsonObject.optString("text-encoding", "utf-8")); ret.setTextTemplate(jsonObject.optString("text-template", "SUITABLE")); if (jsonObject.has("fields")) { JSONArray fieldsArray = jsonObject.getJSONArray("fields"); for (int i = 0; i < fieldsArray.length(); i++) { JSONObject field = fieldsArray.getJSONObject(i); FieldType fieldType = FieldType.valueOfJSONName(field.getString("type")); switch (fieldType) { case DATE: { ReportParam<Date> rp = new ReportParam<>(Date.class); readCommon(ret, rp, field); if (field.has("default-value")) { rp.setDefaultValue(new Date(field.getLong("default-value"))); } break; } case STRING: { ReportParam<String> rp = new ReportParam<>(String.class); readCommon(ret, rp, field); if (field.has("default-value")) { rp.setDefaultValue(field.getString("default-value")); } break; } case INTEGER: { ReportParam<Integer> rp = new ReportParam<>(Integer.class); readCommon(ret, rp, field); int min = field.has("min") ? field.getInt("min") : Integer.MIN_VALUE; int max = field.has("max") ? field.getInt("max") : Integer.MAX_VALUE; rp.setMax(max); rp.setMin(min); if (field.has("default-value")) { rp.setDefaultValue(field.getInt("default-value")); } break; } case LONG: { ReportParam<Long> rp = new ReportParam<>(Long.class); readCommon(ret, rp, field); long min = field.has("min") ? field.getLong("min") : Long.MIN_VALUE; long max = field.has("max") ? field.getLong("max") : Long.MAX_VALUE; rp.setMax(max); rp.setMin(min); if (field.has("default-value")) { rp.setDefaultValue(field.getLong("default-value")); } break; } case DOUBLE: { ReportParam<Double> rp = new ReportParam<>(Double.class); readCommon(ret, rp, field); double min = field.has("min") ? field.getLong("min") : Double.MIN_VALUE; double max = field.has("max") ? field.getLong("max") : Double.MAX_VALUE; rp.setMax(max); rp.setMin(min); if (field.has("default-value")) { rp.setDefaultValue(field.getDouble("default-value")); } break; } default: { throw new AssertionError(fieldType); } } } } return ret; }
From source file:cmsc105_mp2.Plot.java
public void createGraph(Data d, float window, Double threshold) { XYSeries data = new XYSeries("data"); double min = Double.MAX_VALUE; double max = Double.MIN_VALUE; for (double num : d.plots) { if (max < num) max = num;/*from w ww. j a v a 2 s. c o m*/ if (min > num) min = num; } max += 3; min -= 3; ArrayList<XYSeries> xy = new ArrayList(); ArrayList<Integer> points = new ArrayList(); for (int j = (int) (window / 2); j < d.plots.length - (window / 2); j++) { data.add(j, d.plots[j]); System.out.println(points.size()); if (d.plots[j] > threshold) { points.add(j); } else { if (points.size() >= window) { System.out.println("MIN!"); XYSeries series = new XYSeries("trend"); for (int n : points) { series.add(n, max); } xy.add(series); } points = new ArrayList(); } } if (points.size() >= window) { XYSeries series = new XYSeries("trend"); for (int n : points) { series.add(n, max); } xy.add(series); } XYSeriesCollection my_data_series = new XYSeriesCollection(); my_data_series.addSeries(data); for (XYSeries x : xy) { my_data_series.addSeries(x); } XYSeries thresh = new XYSeries("threshold"); for (int j = 0; j < d.plots.length; j++) { thresh.add(j, threshold); } my_data_series.addSeries(thresh); System.out.println(d.name); JFreeChart XYLineChart = ChartFactory.createXYLineChart(d.name, "Position", "Average", my_data_series, PlotOrientation.VERTICAL, true, true, false); bImage1 = (BufferedImage) XYLineChart.createBufferedImage(600, 300); ImageIcon imageIcon = new ImageIcon(bImage1); jLabel1.setIcon(imageIcon); }
From source file:net.praqma.jenkins.memorymap.MemoryMapBuildAction.java
public void doDrawMemoryMapUsageGraph(StaplerRequest req, StaplerResponse rsp) throws IOException { DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataset = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>(); String members = req.getParameter("categories"); String graphTitle = req.getParameter("title"); int w = Integer.parseInt(req.getParameter("width")); int h = Integer.parseInt(req.getParameter("height")); List<String> memberList = Arrays.asList(members.split(",")); List<List<String>> memberLists = new ArrayList<List<String>>(); for (String s : memberList) { memberLists.add(Arrays.asList(s.split(" "))); }/*from w w w . ja v a 2s.c om*/ List<ValueMarker> markers = new ArrayList<ValueMarker>(); double max = Double.MIN_VALUE; Set<String> drawnMarker = new HashSet<String>(); String scale = getRecorder().scale; for (MemoryMapBuildAction membuild = this; membuild != null; membuild = membuild.getPreviousAction()) { ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(membuild.build); MemoryMapConfigMemory result = membuild.getMemoryMapConfig(); MemoryMapConfigMemory resultBlacklist = new MemoryMapConfigMemory(); for (List<String> list : memberLists) { double value = 0.0d; double maxx = 0.0d; String labelName = ""; for (MemoryMapConfigMemoryItem res : result) { if (list.contains(res.getName()) && !resultBlacklist.contains(res)) { resultBlacklist.add(res); if (labelName.equals("")) { labelName = res.getName(); } else { labelName = String.format("%s+%s", labelName, res.getName()); } if (getRecorder().getShowBytesOnGraph()) { maxx = maxx + HexUtils.byteCount(res.getLength(), getRecorder().getWordSize(), scale); value = value + HexUtils.byteCount(res.getUsed(), getRecorder().getWordSize(), scale); } else { maxx = maxx + HexUtils.wordCount(res.getLength(), getRecorder().getWordSize(), scale); value = value + HexUtils.wordCount(res.getUsed(), getRecorder().getWordSize(), scale); } } else { } if (maxx > max) { max = maxx; } if (value > max) { max = value; } } if (!labelName.equals("")) { dataset.add(value, labelName, label); } boolean makeMarker = true; for (ValueMarker vm : markers) { if (maxx == vm.getValue() && !vm.getLabel().contains(labelName) && !labelName.equals("")) { drawnMarker.add(vm.getLabel().replace("(MAX) - ", "") + " - " + labelName); String s = vm.getLabel().replace("(MAX) - ", ""); vm.setLabel(String.format("%s - %s", vm.getLabel(), labelName)); //this is the size of chars used for setting the offset right double i = vm.getLabel().length() * labelOffset + 40; vm.setLabelOffset(new RectangleInsets(5, i, -20, 5)); makeMarker = false; } } if ((!labelName.equals("")) && (drawnMarker.add(labelName))) { if (makeMarker) { ValueMarker vm = new ValueMarker((double) maxx, Color.BLACK, new BasicStroke(1.2f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f)); vm.setLabel(String.format("(MAX) - %s", labelName)); double i = vm.getLabel().length() * labelOffset + 40; vm.setLabelOffset(new RectangleInsets(5, i, -20, 5)); vm.setLabelAnchor(RectangleAnchor.TOP_LEFT); vm.setPaint(Color.BLACK); vm.setOutlinePaint(Color.BLACK); vm.setAlpha(1.0f); markers.add(vm); } } } } String s = ""; if (scale.equalsIgnoreCase("kilo")) { s = "k"; } else if (scale.equalsIgnoreCase("mega")) { s = "M"; } else if (scale.equalsIgnoreCase("giga")) { s = "G"; } String byteLegend = s + "Bytes"; String wordLegend = s + "Words"; String legend = getRecorder().getShowBytesOnGraph() ? byteLegend : wordLegend; JFreeChart chart = createPairedBarCharts(graphTitle, legend, max * 1.1d, 0d, dataset.build(), markers); chart.setBackgroundPaint(Color.WHITE); chart.getLegend().setPosition(RectangleEdge.BOTTOM); ChartUtil.generateGraph(req, rsp, chart, w, h); }
From source file:HSSFDateUtil.java
/** * Given a double, checks if it is a valid Excel date. * //from w w w. j av a2 s.com * @return true if valid * @param value * the double value */ public static boolean isValidExcelDate(final double value) { return (value > -Double.MIN_VALUE); }
From source file:org.pmad.gmm.MyMixMNDEM.java
/** * Fit a mixture model to the data supplied to the constructor. * * The quality of the fit depends on the concavity of the data provided to * the constructor and the initial mixture provided to this function. If the * data has many local optima, multiple runs of the fitting function with * different initial mixtures may be required to find the optimal solution. * If a SingularMatrixException is encountered, it is possible that another * initialization would work.//from w w w .ja va2 s . c om * * @param initialMixture Model containing initial values of weights and * multivariate normals * @param maxIterations Maximum iterations allowed for fit * @param threshold Convergence threshold computed as difference in * logLikelihoods between successive iterations * @throws SingularMatrixException if any component's covariance matrix is * singular during fitting * @throws NotStrictlyPositiveException if numComponents is less than one * or threshold is less than Double.MIN_VALUE * @throws DimensionMismatchException if initialMixture mean vector and data * number of columns are not equal */ public void fit(final MyMixMND initialMixture, final int maxIterations, final double threshold) throws SingularMatrixException, NotStrictlyPositiveException, DimensionMismatchException { if (maxIterations < 1) { throw new NotStrictlyPositiveException(maxIterations); } if (threshold < Double.MIN_VALUE) { throw new NotStrictlyPositiveException(threshold); } final int n = data.length; // Number of data columns. Jagged data already rejected in constructor, // so we can assume the lengths of each row are equal. final int numCols = data[0].length; final int k = initialMixture.getComponents().size(); final int numMeanColumns = initialMixture.getComponents().get(0).getSecond().getMeans().length; if (numMeanColumns != numCols) { throw new DimensionMismatchException(numMeanColumns, numCols); } int numIterations = 0; double previousLogLikelihood = 0d; logLikelihood = Double.NEGATIVE_INFINITY; // Initialize model to fit to initial mixture. fittedModel = new MyMixMND(initialMixture.getComponents()); while (numIterations++ <= maxIterations && FastMath.abs(previousLogLikelihood - logLikelihood) > threshold) { System.out.println(numIterations); previousLogLikelihood = logLikelihood; double sumLogLikelihood = 0d; // Mixture components final List<Pair<Double, MyMND>> components = fittedModel.getComponents(); // Weight and distribution of each component final double[] weights = new double[k]; final MyMND[] mvns = new MyMND[k]; for (int j = 0; j < k; j++) { weights[j] = components.get(j).getFirst(); mvns[j] = components.get(j).getSecond(); } // E-step: compute the data dependent parameters of the expectation // function. // The percentage of row's total density between a row and a // component final double[][] gamma = new double[n][k]; // Sum of gamma for each component final double[] gammaSums = new double[k]; // for (double d : weights) { // System.out.print(d+" "); // } // System.out.println(); // Sum of gamma times its row for each each component final double[][] gammaDataProdSums = new double[k][numCols]; for (int i = 0; i < n; i++) { final double rowDensity = fittedModel.density(data[i]); sumLogLikelihood += FastMath.log(rowDensity); for (int j = 0; j < k; j++) { gamma[i][j] = weights[j] * mvns[j].density(data[i]); if (rowDensity == 0) { if (gamma[i][j] == 0) { gamma[i][j] = weights[j]; } else { System.err.println("ele"); } } else { gamma[i][j] /= rowDensity; } gammaSums[j] += gamma[i][j]; for (int col = 0; col < numCols; col++) { gammaDataProdSums[j][col] += gamma[i][j] * data[i][col]; } } } if (Utils.hasNaN(gamma)) { System.out.println("gamma has NaN"); } logLikelihood = sumLogLikelihood / n; // M-step: compute the new parameters based on the expectation // function. final double[] newWeights = new double[k]; final double[][] newMeans = new double[k][numCols]; for (int j = 0; j < k; j++) { newWeights[j] = gammaSums[j] / n; for (int col = 0; col < numCols; col++) { newMeans[j][col] = gammaDataProdSums[j][col] / gammaSums[j]; } } // Compute new covariance matrices final RealMatrix[] newCovMats = new RealMatrix[k]; for (int j = 0; j < k; j++) { newCovMats[j] = new Array2DRowRealMatrix(numCols, numCols); } for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { final RealMatrix vec = new Array2DRowRealMatrix(MathArrays.ebeSubtract(data[i], newMeans[j])); final RealMatrix dataCov = vec.multiply(vec.transpose()).scalarMultiply(gamma[i][j]); newCovMats[j] = newCovMats[j].add(dataCov); } } // Converting to arrays for use by fitted model final double[][][] newCovMatArrays = new double[k][numCols][numCols]; for (int j = 0; j < k; j++) { newCovMats[j] = newCovMats[j].scalarMultiply(1d / gammaSums[j]); newCovMatArrays[j] = newCovMats[j].getData(); // if (Utils.hasNaN(newCovMatArrays[j])) { // System.out.println("covmet nan"); // } } // if (Utils.hasNaN(newMeans)) { // System.out.println("neams nan"); // } // Update current model fittedModel = new MyMixMND(newWeights, newMeans, newCovMatArrays); } if (FastMath.abs(previousLogLikelihood - logLikelihood) > threshold) { // Did not converge before the maximum number of iterations // throw new ConvergenceException(); System.out.println("Did not converge"); } }