List of usage examples for java.lang Double compare
public static int compare(double d1, double d2)
From source file:com.codelanx.codelanxlib.util.Players.java
/** * Returns the closest {@link Player} to a specific {@link Location} * // ww w .j a v a 2 s. c o m * @since 0.1.0 * @version 0.1.0 * * @param loc The {@link Location} representing the origin to search from * @return The closest {@link Player}, or {@code null} if no one is in the * world */ public static Player getClosestPlayer(Location loc) { return loc.getWorld().getPlayers().stream().min((o1, o2) -> { return Double.compare(o1.getLocation().distanceSquared(loc), o2.getLocation().distanceSquared(loc)); }).orElse(null); }
From source file:com.cloudmine.api.db.LocallySavableCMGeoPoint.java
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; LocallySavableCMGeoPoint geoPoint = (LocallySavableCMGeoPoint) o; if (Double.compare(geoPoint.latitude, latitude) != 0) return false; if (Double.compare(geoPoint.longitude, longitude) != 0) return false; return true;/*from w ww . j a v a 2s . c o m*/ }
From source file:io.fouad.jtb.core.beans.InputVenueMessageContent.java
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof InputVenueMessageContent)) return false; InputVenueMessageContent that = (InputVenueMessageContent) o; if (Double.compare(that.latitude, latitude) != 0) return false; if (Double.compare(that.longitude, longitude) != 0) return false; if (title != null ? !title.equals(that.title) : that.title != null) return false; if (address != null ? !address.equals(that.address) : that.address != null) return false; return foursquareId != null ? foursquareId.equals(that.foursquareId) : that.foursquareId == null; }
From source file:org.briljantframework.data.vector.DoubleVector.java
@Override public int compareAt(int a, Vector other, int b) { double va = getAsDoubleAt(a); double vb = other.loc().getAsDouble(b); return !Is.NA(va) && !Is.NA(vb) ? Double.compare(va, vb) : 0; }
From source file:org.stockchart.series.SeriesBase.java
public double[] getMaxMinPrice(double viewMax, double viewMin) { if (!isVisibleOnScreen(viewMax, viewMin)) return null; double max = Double.NaN; double min = Double.NaN; int arrayIndex = convertToArrayIndexZeroBased(viewMin); for (int i = arrayIndex; i < getPointCount(); i++) { AbstractPoint p = getPointAt(i); double[] maxMin = p.getMaxMin(); max = (0 == Double.compare(max, Double.NaN)) ? maxMin[0] : Math.max(maxMin[0], max); min = (0 == Double.compare(min, Double.NaN)) ? maxMin[1] : Math.min(maxMin[1], min); if (convertToScaleIndex(i) > viewMax) break; }//w w w . ja va2s .c om return new double[] { max, min }; }
From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.MapSlideInspectorImpl.java
private void updateCoordinates(double latitude, double longitude) { MapSlide slide = getSlide();//from www.j a va2s . c o m if (slide == null || ((Double.compare(latitude, slide.getLatitude()) == 0) && (Double.compare(longitude, slide.getLongitude()) == 0))) { return; } slide.setLatitude(latitude); slide.setLongitude(longitude); try { slideService.update(slide); onUpdate(); } catch (ServiceException ex) { ErrorDialog.show(root, "Fehler beim ndern der Koordinaten", ""); } map.clear(); map.addMarker(new LatLong(latitude, longitude)); map.center(new LatLong(latitude, longitude)); }
From source file:org.killbill.billing.plugin.avatax.client.model.GetTaxResult.java
@Override public boolean equals(final Object o) { if (this == o) { return true; }//from w ww. ja v a 2 s.c om if (o == null || getClass() != o.getClass()) { return false; } final GetTaxResult that = (GetTaxResult) o; if (Double.compare(that.TotalAmount, TotalAmount) != 0) { return false; } if (Double.compare(that.TotalDiscount, TotalDiscount) != 0) { return false; } if (Double.compare(that.TotalExemption, TotalExemption) != 0) { return false; } if (Double.compare(that.TotalTax, TotalTax) != 0) { return false; } if (Double.compare(that.TotalTaxCalculated, TotalTaxCalculated) != 0) { return false; } if (Double.compare(that.TotalTaxable, TotalTaxable) != 0) { return false; } if (DocCode != null ? !DocCode.equals(that.DocCode) : that.DocCode != null) { return false; } if (DocDate != null ? !DocDate.equals(that.DocDate) : that.DocDate != null) { return false; } if (!Arrays.equals(Messages, that.Messages)) { return false; } if (ResultCode != that.ResultCode) { return false; } if (!Arrays.equals(TaxAddresses, that.TaxAddresses)) { return false; } if (TaxDate != null ? !TaxDate.equals(that.TaxDate) : that.TaxDate != null) { return false; } if (!Arrays.equals(TaxLines, that.TaxLines)) { return false; } if (!Arrays.equals(TaxSummary, that.TaxSummary)) { return false; } if (Timestamp != null ? !Timestamp.equals(that.Timestamp) : that.Timestamp != null) { return false; } return true; }
From source file:fr.gotorennes.remote.RelayParkService.java
public List<RelayPark> getProximityRelayParks(final double latitude, final double longitude) { List<RelayPark> relayParks = loadList(getProximityCommand(latitude, longitude), NODE); if (relayParks != null) { Collections.sort(relayParks, new Comparator<RelayPark>() { @Override//from ww w.j av a2 s . c o m public int compare(RelayPark relayPark1, RelayPark relayPark2) { double distance1 = AbstractMapActivity.getDistance(latitude, longitude, relayPark1.latitude, relayPark1.longitude); double distance2 = AbstractMapActivity.getDistance(latitude, longitude, relayPark2.latitude, relayPark2.longitude); return Double.compare(distance1, distance2); } }); } return relayParks; }
From source file:com.opengamma.analytics.financial.commodity.derivative.CommodityFutureOption.java
@Override public boolean equals(Object obj) { if (this == obj) { return true; }//from www .ja va 2 s . c om if (obj == null) { return false; } if (!(obj instanceof CommodityFutureOption)) { return false; } final CommodityFutureOption<?> other = (CommodityFutureOption<?>) obj; if (!ObjectUtils.equals(_underlying, other._underlying)) { return false; } if (!ObjectUtils.equals(_exerciseType, other._exerciseType)) { return false; } if (Double.compare(_expiry, other._expiry) != 0) { return false; } if (Double.compare(_strike, other._strike) != 0) { return false; } if (_isCall != other._isCall) { return false; } return true; }
From source file:biomine.bmvis2.pipeline.SizeSliderOperation.java
public void updateSizeSlider(VisualGraph visualGraph) { int minCount = targetSize; HashSet<VisualGroupNode> closedGroups = new HashSet<VisualGroupNode>(); HashSet<VisualGroupNode> openGroups = new HashSet<VisualGroupNode>(); for (VisualNode n : visualGraph.getNodes()) { if (n instanceof VisualGroupNode) { closedGroups.add((VisualGroupNode) n); }// w w w .j a v a 2 s . co m VisualGroupNode p = n.getParent(); if (p != null && p.getParent() != null) { openGroups.add(p); openGroups.remove(p.getParent()); } } int curCount = visualGraph.getNodes().size(); final int order = 1; final double depthMult = 0.01; System.out.println("openGroups.size() = " + openGroups.size()); if (curCount > minCount) { // close as many open groups as possible while not going // under minCount nodes // start with nodes with most depth ArrayList<VisualGroupNode> groups = new ArrayList<VisualGroupNode>(openGroups); Collections.sort(groups, new Comparator<VisualGroupNode>() { public int compare(VisualGroupNode o1, VisualGroupNode o2) { return Double.compare((o2.getDepth() - o1.getDepth()) * depthMult // + hider.getNodeGoodness(o1) // - hider.getNodeGoodness(o2) , 0) * order; } }); for (VisualGroupNode toClose : groups) { System.out.println("closing " + toClose); int s = toClose.getChildren().size(); if (curCount - s >= minCount) { toClose.setOpen(false); curCount -= s; } } } else { ArrayList<VisualGroupNode> groups = new ArrayList<VisualGroupNode>(closedGroups); Collections.sort(groups, new Comparator<VisualGroupNode>() { public int compare(VisualGroupNode o1, VisualGroupNode o2) { return Double.compare((o2.getDepth() - o1.getDepth()) * depthMult // + hider.getNodeGoodness(o1) // - hider.getNodeGoodness(o2), , 0) * order * -1; } }); for (VisualGroupNode toOpen : groups) { System.out.println("opening " + toOpen); int s = toOpen.getChildren().size(); toOpen.setOpen(true); for (VisualNode n : toOpen.getChildren()) if (n instanceof VisualGroupNode) ((VisualGroupNode) n).setOpen(false); curCount += s; if (curCount + s >= minCount) break; } } }