List of usage examples for java.lang Double MAX_VALUE
double MAX_VALUE
To view the source code for java.lang Double MAX_VALUE.
Click Source Link
From source file:org.pentaho.platform.uifoundation.chart.DialWidgetDefinition.java
/** * TODO PROBLEM HERE! If you use this constructor, the XML schema for the chart attributes is different than if * you use the constructor with the arguments public DialWidgetDefinition( Document document, double value, int * width, int height, IPentahoSession session). This constructor expects the chart attribute nodes to be children * of the <chart-attributes> node, whereas the latter constructor expects the attributes to be children of a * <dial> node. This does not help us with our parity situation, and should be deprecated and reconciled. * /*w w w . j a va 2 s.c om*/ * @param data * @param byRow * @param chartAttributes * @param width * @param height * @param session */ public DialWidgetDefinition(final IPentahoResultSet data, final boolean byRow, final Node chartAttributes, final int width, final int height, final IPentahoSession session) { this(0.0, Double.MIN_VALUE, Double.MAX_VALUE, false); attributes = chartAttributes; if (data != null) { if (byRow) { setDataByRow(data); } else { setDataByColumn(data); } } // set legend font setLegendFont(chartAttributes.selectSingleNode(ChartDefinition.LEGEND_FONT_NODE_NAME)); // set legend border visible setLegendBorderVisible(chartAttributes.selectSingleNode(ChartDefinition.DISPLAY_LEGEND_BORDER_NODE_NAME)); // set the alfa layers Node backgroundAlphaNode = chartAttributes.selectSingleNode(ChartDefinition.BACKGROUND_ALPHA_NODE_NAME); Node foregroundAlphaNode = chartAttributes.selectSingleNode(ChartDefinition.FOREGROUND_ALPHA_NODE_NAME); if (backgroundAlphaNode != null) { setBackgroundAlpha(chartAttributes.selectSingleNode(ChartDefinition.BACKGROUND_ALPHA_NODE_NAME)); } if (foregroundAlphaNode != null) { setForegroundAlpha(chartAttributes.selectSingleNode(ChartDefinition.FOREGROUND_ALPHA_NODE_NAME)); } DialWidgetDefinition.createDial(this, chartAttributes, width, height, session); }
From source file:exploration.rendezvous.MultiPointRendezvousStrategy.java
@Override public void processExplorerCheckDueReturnToRV() { //Here we can recalc where we can meet relay (could be, that from our location, it's better to meet relay //at another point, i.e. change our part of the RV location pair. if (settings.replanOurMeetingPoint) { RendezvousAgentData rvd = agent.getRendezvousAgentData(); int origMeetingTime = rvd.getParentRendezvous().getTimeMeeting(); int origWaitingTime = rvd.getParentRendezvous().getTimeWait(); Point relayPoint = rvd.getParentRendezvous().getParentLocation(); Point explorerPoint = rvd.getParentRendezvous().getChildLocation(); Rendezvous origParentsRV = rvd.getParentRendezvous().parentsRVLocation; //Do same as sampling method, except we already have explorer point //need to find nearest point to base's comms range System.out.print(SimConstants.INDENT + "Generating random points ... "); generatedPoints = SampleEnvironmentPoints(agent, settings.SamplePointDensity); NearRVPoint relayRVPoint = new NearRVPoint(relayPoint.x, relayPoint.y); NearRVPoint explorerRVPoint = new NearRVPoint(explorerPoint.x, explorerPoint.y); generatedPoints.add(explorerRVPoint); generatedPoints.add(relayRVPoint); System.out.print(SimConstants.INDENT + "Finding commlinks ... "); connectionsToBase = FindCommLinks(generatedPoints, agent); int pathsCalculated = 0; double minDistToExplorer = Double.MAX_VALUE; NearRVPoint bestRVPoint = explorerRVPoint; for (CommLink link : relayRVPoint.commLinks) { NearRVPoint connectedPoint = link.getRemotePoint(); double dist = agent.calculatePath(connectedPoint.getLocation(), agent.getLocation(), false, false) .getLength();/*ww w . j a v a 2s .com*/ if (dist < minDistToExplorer) { bestRVPoint = connectedPoint; minDistToExplorer = dist; } } //End method. Now just set the found points as RV. NearRVPoint childPoint = bestRVPoint; NearRVPoint parentPoint = relayRVPoint; Rendezvous meetingLocation = new Rendezvous(childPoint); meetingLocation.setParentLocation(parentPoint); /*Rendezvous parentsMeetingLocation = new Rendezvous(parentPoint.parentPoint); Point baseLocation = agent.getTeammate(agent.getParentTeammate().getParent()).getLocation(); System.out.println(" base location: " + baseLocation); parentsMeetingLocation.setParentLocation(agent.getTeammate(agent.getParentTeammate().getParent()).getLocation());*/ meetingLocation.parentsRVLocation = origParentsRV; rvd.setParentRendezvous(meetingLocation); //Rendezvous backupRV = new Rendezvous(childPoint); //rvd.setParentBackupRendezvous(backupRV); //calculate timings rvd.getParentRendezvous().setTimeMeeting(origMeetingTime); rvd.getParentRendezvous().setTimeWait(origWaitingTime); //calculateParentTimeToBackupRV(); displayData.setGeneratedPoints(generatedPoints); System.out.print(SimConstants.INDENT + "Re-evaluating explorer's meeting point complete " + rvd.getParentRendezvous().getChildLocation().x + "," + rvd.getParentRendezvous().getChildLocation().y + ". "); if (rvd.getParentRendezvous().parentsRVLocation.getChildLocation() == null) { System.err.println("!!! ParentPoint is null!"); } } }
From source file:MediaControl.java
public MediaControl(final MediaPlayer mp) { this.mp = mp; setStyle("-fx-background-color: #bfc2c7;"); mediaView = new MediaView(mp); Pane mvPane = new Pane() { };//w ww .j a v a 2 s. c o m mvPane.getChildren().add(mediaView); mvPane.setStyle("-fx-background-color: black;"); setCenter(mvPane); mediaBar = new HBox(); mediaBar.setAlignment(Pos.CENTER); mediaBar.setPadding(new Insets(5, 10, 5, 10)); BorderPane.setAlignment(mediaBar, Pos.CENTER); final Button playButton = new Button(">"); playButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { Status status = mp.getStatus(); if (status == Status.UNKNOWN || status == Status.HALTED) { // don't do anything in these states return; } if (status == Status.PAUSED || status == Status.READY || status == Status.STOPPED) { // rewind the movie if we're sitting at the end if (atEndOfMedia) { mp.seek(mp.getStartTime()); atEndOfMedia = false; } mp.play(); } else { mp.pause(); } } }); mp.currentTimeProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { updateValues(); } }); mp.setOnPlaying(new Runnable() { public void run() { if (stopRequested) { mp.pause(); stopRequested = false; } else { playButton.setText("||"); } } }); mp.setOnPaused(new Runnable() { public void run() { System.out.println("onPaused"); playButton.setText(">"); } }); mp.setOnReady(new Runnable() { public void run() { duration = mp.getMedia().getDuration(); updateValues(); } }); mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1); mp.setOnEndOfMedia(new Runnable() { public void run() { if (!repeat) { playButton.setText(">"); stopRequested = true; atEndOfMedia = true; } } }); mediaBar.getChildren().add(playButton); // Add spacer Label spacer = new Label(" "); mediaBar.getChildren().add(spacer); // Add Time label Label timeLabel = new Label("Time: "); mediaBar.getChildren().add(timeLabel); // Add time slider timeSlider = new Slider(); HBox.setHgrow(timeSlider, Priority.ALWAYS); timeSlider.setMinWidth(50); timeSlider.setMaxWidth(Double.MAX_VALUE); timeSlider.valueProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { if (timeSlider.isValueChanging()) { // multiply duration by percentage calculated by slider position mp.seek(duration.multiply(timeSlider.getValue() / 100.0)); } } }); mediaBar.getChildren().add(timeSlider); // Add Play label playTime = new Label(); playTime.setPrefWidth(130); playTime.setMinWidth(50); mediaBar.getChildren().add(playTime); // Add the volume label Label volumeLabel = new Label("Vol: "); mediaBar.getChildren().add(volumeLabel); // Add Volume slider volumeSlider = new Slider(); volumeSlider.setPrefWidth(70); volumeSlider.setMaxWidth(Region.USE_PREF_SIZE); volumeSlider.setMinWidth(30); volumeSlider.valueProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { if (volumeSlider.isValueChanging()) { mp.setVolume(volumeSlider.getValue() / 100.0); } } }); mediaBar.getChildren().add(volumeSlider); setBottom(mediaBar); }
From source file:mulavito.gui.components.LayerViewer.java
/** * @return the extent of the graph according to its vertices' location *//* w w w .jav a 2 s .c om*/ public void updateGraphBoundsCache() { double minX = Double.MAX_VALUE; double minY = Double.MAX_VALUE; double maxX = -Double.MAX_VALUE; double maxY = -Double.MAX_VALUE; for (V v : getGraphLayout().getGraph().getVertices()) { Point2D p = getGraphLayout().transform(v); minX = Math.min(minX, p.getX()); minY = Math.min(minY, p.getY()); maxX = Math.max(maxX, p.getX()); maxY = Math.max(maxY, p.getY()); } // no point if (minX > maxX || minY > maxY) minX = maxX = minY = maxY = 0; if (graphBoundsCache == null) graphBoundsCache = new Rectangle2D.Double(); graphBoundsCache.setRect(minX, minY, maxX - minX, maxY - minY); double excess = Math.max(Math.max(graphBoundsCache.width * 0.1, graphBoundsCache.height * 0.1), 10); // include the given excess graphBoundsCache.setRect(graphBoundsCache.x - excess, graphBoundsCache.y - excess, graphBoundsCache.width + 2 * excess, graphBoundsCache.height + 2 * excess); }
From source file:com.cdd.bao.editor.EditSchema.java
public EditSchema(Stage stage) { this.stage = stage; if (MainApplication.icon != null) stage.getIcons().add(MainApplication.icon); menuBar = new MenuBar(); menuBar.setUseSystemMenuBar(true);/*w ww . java 2 s. c om*/ menuBar.getMenus().add(menuFile = new Menu("_File")); menuBar.getMenus().add(menuEdit = new Menu("_Edit")); menuBar.getMenus().add(menuValue = new Menu("_Value")); menuBar.getMenus().add(menuView = new Menu("Vie_w")); createMenuItems(); treeRoot = new TreeItem<>(new Branch(this)); treeView = new TreeView<>(treeRoot); treeView.setEditable(true); treeView.setCellFactory(p -> new HierarchyTreeCell()); treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldVal, newVal) -> { if (oldVal != null) pullDetail(oldVal); if (newVal != null) pushDetail(newVal); }); treeView.focusedProperty() .addListener((val, oldValue, newValue) -> Platform.runLater(() -> maybeUpdateTree())); detail = new DetailPane(this); StackPane sp1 = new StackPane(), sp2 = new StackPane(); sp1.getChildren().add(treeView); sp2.getChildren().add(detail); splitter = new SplitPane(); splitter.setOrientation(Orientation.HORIZONTAL); splitter.getItems().addAll(sp1, sp2); splitter.setDividerPositions(0.4, 1.0); progBar = new ProgressBar(); progBar.setMaxWidth(Double.MAX_VALUE); root = new BorderPane(); root.setTop(menuBar); root.setCenter(splitter); root.setBottom(progBar); BorderPane.setMargin(progBar, new Insets(2, 2, 2, 2)); Scene scene = new Scene(root, 1000, 800, Color.WHITE); stage.setScene(scene); treeView.setShowRoot(false); treeRoot.getChildren().add(treeTemplate = new TreeItem<>(new Branch(this, "Template"))); treeRoot.getChildren().add(treeAssays = new TreeItem<>(new Branch(this, "Assays"))); treeTemplate.setExpanded(true); treeAssays.setExpanded(true); rebuildTree(); Platform.runLater(() -> treeView.getFocusModel().focus(treeView.getSelectionModel().getSelectedIndex())); // for some reason it defaults to not the first item stage.setOnCloseRequest(event -> { if (!confirmClose()) event.consume(); }); updateTitle(); // loading begins in a background thread, and is updated with a status bar Vocabulary.Listener listener = new Vocabulary.Listener() { public void vocabLoadingProgress(Vocabulary vocab, float progress) { Platform.runLater(() -> { progBar.setProgress(progress); if (vocab.isLoaded()) root.getChildren().remove(progBar); }); } public void vocabLoadingException(Exception ex) { ex.printStackTrace(); } }; Vocabulary.globalInstance(listener); }
From source file:ai.susi.mind.SusiTransfer.java
/** * A conclusion from choices is done by the application of a function on the choice set. * This may be done by i.e. counting the number of choices or extracting a maximum element. * @param choices the given set of json objects from the data object of a SusiThought * @returnan array of json objects which are the extraction of given choices according to the given mapping */// w w w. ja v a2 s . c o m public JSONArray conclude(JSONArray choices) { JSONArray a = new JSONArray(); if (this.selectionMapping != null && this.selectionMapping.size() == 1) { // test if this has an aggregation key: AVG, COUNT, MAX, MIN, SUM final String aggregator = this.selectionMapping.keySet().iterator().next(); final String aggregator_as = this.selectionMapping.get(aggregator); if (aggregator.startsWith("COUNT(") && aggregator.endsWith(")")) { // TODO: there should be a special pattern for this to make it more efficient return a.put(new JSONObject().put(aggregator_as, choices.length())); } if (aggregator.startsWith("MAX(") && aggregator.endsWith(")")) { final AtomicDouble max = new AtomicDouble(Double.MIN_VALUE); String c = aggregator.substring(4, aggregator.length() - 1); choices.forEach(json -> max.set(Math.max(max.get(), ((JSONObject) json).getDouble(c)))); return a.put(new JSONObject().put(aggregator_as, max.get())); } if (aggregator.startsWith("MIN(") && aggregator.endsWith(")")) { final AtomicDouble min = new AtomicDouble(Double.MAX_VALUE); String c = aggregator.substring(4, aggregator.length() - 1); choices.forEach(json -> min.set(Math.min(min.get(), ((JSONObject) json).getDouble(c)))); return a.put(new JSONObject().put(aggregator_as, min.get())); } if (aggregator.startsWith("SUM(") && aggregator.endsWith(")")) { final AtomicDouble sum = new AtomicDouble(0.0d); String c = aggregator.substring(4, aggregator.length() - 1); choices.forEach(json -> sum.addAndGet(((JSONObject) json).getDouble(c))); return a.put(new JSONObject().put(aggregator_as, sum.get())); } if (aggregator.startsWith("AVG(") && aggregator.endsWith(")")) { final AtomicDouble sum = new AtomicDouble(0.0d); String c = aggregator.substring(4, aggregator.length() - 1); choices.forEach(json -> sum.addAndGet(((JSONObject) json).getDouble(c))); return a.put(new JSONObject().put(aggregator_as, sum.get() / choices.length())); } } if (this.selectionMapping != null && this.selectionMapping.size() == 2) { Iterator<String> ci = this.selectionMapping.keySet().iterator(); String aggregator = ci.next(); String column = ci.next(); if (column.indexOf('(') >= 0) { String s = aggregator; aggregator = column; column = s; } final String aggregator_as = this.selectionMapping.get(aggregator); final String column_as = this.selectionMapping.get(column); final String column_final = column; if (aggregator.startsWith("PERCENT(") && aggregator.endsWith(")")) { final AtomicDouble sum = new AtomicDouble(0.0d); String c = aggregator.substring(8, aggregator.length() - 1); choices.forEach(json -> sum.addAndGet(((JSONObject) json).getDouble(c))); choices.forEach(json -> a.put( new JSONObject().put(aggregator_as, 100.0d * ((JSONObject) json).getDouble(c) / sum.get()) .put(column_as, ((JSONObject) json).get(column_final)))); return a; } } // this.selectionMapping == null -> extract everything for (Object json : choices) { JSONObject extraction = this.extract((JSONObject) json); if (extraction.length() > 0) a.put(extraction); } return a; }
From source file:ch.epfl.lsir.xin.algorithm.core.MatrixFactorization.java
/** * This function learns a matrix factorization model using Stochastic Gradient Descent * *///from w w w . j a v a2 s . c o m public void buildSGD() { double preError = Double.MAX_VALUE; for (int i = 0; i < this.Iterations; i++) { System.out.println("Iteration: " + i); ArrayList<MatrixEntry2D> entries = this.ratingMatrix.getValidEntries(); double error = 0; //overall error of this iteration while (entries.size() > 0) { //find a random entry int r = new Random().nextInt(entries.size()); MatrixEntry2D entry = entries.get(r); double prediction = predict(entry.getRowIndex(), entry.getColumnIndex(), false); if (prediction > this.maxRating) prediction = this.maxRating; if (prediction < this.minRating) prediction = this.minRating; double difference = entry.getValue() - prediction; for (int l = 0; l < this.latentFactors; l++) { double tempU = this.userMatrix.get(entry.getRowIndex(), l) + this.learningRate * ( /*2 **/ difference * this.itemMatrix.get(entry.getColumnIndex(), l) - this.regUser * this.userMatrix.get(entry.getRowIndex(), l)); double tempI = this.itemMatrix.get(entry.getColumnIndex(), l) + this.learningRate * ( /*2 **/ difference * this.userMatrix.get(entry.getRowIndex(), l) - this.regItem * this.itemMatrix.get(entry.getColumnIndex(), l)); this.userMatrix.set(entry.getRowIndex(), l, tempU); this.itemMatrix.set(entry.getColumnIndex(), l, tempI); } //one rating is only processed once in an iteration entries.remove(r); } //error entries = this.ratingMatrix.getValidEntries(); for (int k = 0; k < entries.size(); k++) { MatrixEntry2D entry = entries.get(k); double prediction = predict(entry.getRowIndex(), entry.getColumnIndex(), false); if (prediction > this.maxRating) prediction = this.maxRating; if (prediction < this.minRating) prediction = this.minRating; error = error + Math.abs(entry.getValue() - prediction); // for( int j = 0 ; j < this.latentFactors ; j++ ) // { // error = error + this.regUser/2 * Math.pow(this.userMatrix.get(entry.getRowIndex(), j), 2) + // this.regItem/2 * Math.pow(this.itemMatrix.get(entry.getColumnIndex(), j), 2); // } } this.logger.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " Iteration " + i + " : Error ~ " + error); this.logger.flush(); //check for convergence if (Math.abs(error - preError) <= this.convergence && error <= preError) { logger.println("The algorithm convergences."); this.logger.flush(); break; } // learning rate update strategy updateLearningRate(error, preError); preError = error; logger.flush(); } }
From source file:edu.stanford.cfuller.imageanalysistools.filter.ConvolutionFilter.java
public void inverseTransform(WritableImage orig, int z, Complex[][] transformed) { Complex[][] colMajorImage = transformed; double[][] rowImage = new double[colMajorImage[0].length][colMajorImage.length]; FastFourierTransformer fft = new org.apache.commons.math3.transform.FastFourierTransformer( org.apache.commons.math3.transform.DftNormalization.STANDARD); for (int c = 0; c < colMajorImage.length; c++) { colMajorImage[c] = fft.transform(colMajorImage[c], org.apache.commons.math3.transform.TransformType.INVERSE); }/*from ww w . j a va 2 s . c o m*/ Complex[] tempRow = new Complex[rowImage.length]; //also calculate min/max values double newMin = Double.MAX_VALUE; double newMax = 0; for (int r = 0; r < rowImage.length; r++) { for (int c = 0; c < colMajorImage.length; c++) { tempRow[c] = colMajorImage[c][r]; } Complex[] transformedRow = fft.transform(tempRow, org.apache.commons.math3.transform.TransformType.INVERSE); for (int c = 0; c < colMajorImage.length; c++) { rowImage[r][c] = transformedRow[c].abs(); if (rowImage[r][c] < newMin) newMin = rowImage[r][c]; if (rowImage[r][c] > newMax) newMax = rowImage[r][c]; } } //rescale values to same min/max as before Histogram h = new Histogram(orig); double oldMin = h.getMinValue(); double oldMax = h.getMaxValue(); double scaleFactor = (oldMax - oldMin) / (newMax - newMin); ImageCoordinate minCoord = ImageCoordinate.createCoordXYZCT(0, 0, z, 0, 0); ImageCoordinate maxCoord = ImageCoordinate.cloneCoord(orig.getDimensionSizes()); maxCoord.set(ImageCoordinate.Z, z + 1); orig.setBoxOfInterest(minCoord, maxCoord); scaleFactor = 1; oldMin = 0; for (ImageCoordinate ic : orig) { orig.setValue(ic, (float) ((rowImage[ic.get(ImageCoordinate.Y)][ic.get(ImageCoordinate.X)] - newMin) * scaleFactor + oldMin)); } orig.clearBoxOfInterest(); minCoord.recycle(); maxCoord.recycle(); }
From source file:cz.lbenda.dataman.db.sql.SQLEditorController.java
@SuppressWarnings("unchecked") public SQLEditorController(Consumer<Object> menuItemConsumer, Scene scene, ObjectProperty<DbConfig> dbConfigProperty, NodeShower nodeShower) { node.setMaxHeight(Double.MAX_VALUE); node.setMaxHeight(Double.MAX_VALUE); this.nodeShower = nodeShower; textEditor.setScene(scene);//from w ww . j av a2s. c o m textEditor.changeHighlighter(new HighlighterSQL()); nodeShower.addNode(webView, msgConsoleTitle, false); CodeArea ca = textEditor.createCodeArea(); ca.setMaxHeight(Double.MAX_VALUE); ca.setMaxWidth(Double.MAX_VALUE); AnchorPane.setTopAnchor(ca, 0.0); AnchorPane.setBottomAnchor(ca, 0.0); AnchorPane.setLeftAnchor(ca, 0.0); AnchorPane.setRightAnchor(ca, 0.0); node.getChildren().add(ca); menuItemConsumer .accept(new SQLRunHandler(dbConfigProperty, this, handler -> nodeShower.focusNode(webView))); menuItemConsumer .accept(new SQLRunAllHandler(dbConfigProperty, this, handler -> nodeShower.focusNode(webView))); menuItemConsumer.accept(new OpenFileHandler(this)); menuItemConsumer.accept(new SaveFileHandler(this)); menuItemConsumer.accept(new SaveAsFileHandler(this)); menuItemConsumer.accept(new StopOnFirstErrorOptions(stopOnFirstError)); }
From source file:com.thinkbiganalytics.spark.validation.HCatDataTypeTest.java
@Test public void testIsValueConvertibleToBigDecimal() throws Exception { HCatDataType type = HCatDataType.getDataTypes().get("decimal"); assertTrue(type.isValueConvertibleToType("0")); assertTrue(type.isValueConvertibleToType(Double.MAX_VALUE + "")); assertTrue(type.isValueConvertibleToType("12712")); assertTrue(type.isValueConvertibleToType("-12812")); assertTrue(type.isValueConvertibleToType("-12812.204154")); assertTrue(type.isValueConvertibleToType("-12812.1234")); assertTrue(type.isValueConvertibleToType("-128.12E8")); assertTrue(type.isValueConvertibleToType(null)); assertTrue(type.isValueConvertibleToType("")); assertFalse(type.isValueConvertibleToType("No number")); }