Example usage for java.lang Double compare

List of usage examples for java.lang Double compare

Introduction

In this page you can find the example usage for java.lang Double compare.

Prototype

public static int compare(double d1, double d2) 

Source Link

Document

Compares the two specified double values.

Usage

From source file:Navigation.Vertex.java

public int compareTo(Vertex other) {
    return Double.compare(minDistance, other.minDistance);
}

From source file:com.opengamma.analytics.financial.model.interestrate.curve.ForwardCurveYieldImplied.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }/*from  w  ww .  j  a  va2 s .  c om*/
    if (!super.equals(obj)) {
        return false;
    }
    if (!(obj instanceof ForwardCurveYieldImplied)) {
        return false;
    }
    final ForwardCurveYieldImplied other = (ForwardCurveYieldImplied) obj;
    if (Double.compare(_spot, other._spot) != 0) {
        return false;
    }
    if (!ObjectUtils.equals(_costOfCarryCurve, other._costOfCarryCurve)) {
        return false;
    }
    if (!ObjectUtils.equals(_riskFreeCurve, other._riskFreeCurve)) {
        return false;
    }
    return true;
}

From source file:edu.umich.robot.soar.StopCommand.java

@Override
boolean isComplete() {
    double[] vel = Misc.toPrimitiveDoubleArray(output.getPose().getVel());
    return Double.compare(LinAlg.magnitude(vel), TOLERANCE) < 0;
}

From source file:com.thoughtworks.go.server.service.support.ServerStatusService.java

@Autowired
public ServerStatusService(SecurityService securityService, ServerInfoProvider... providerArray)
        throws IOException {
    this.securityService = securityService;

    providers.addAll(Arrays.asList(providerArray));
    Collections.sort(providers, new Comparator<ServerInfoProvider>() {
        @Override//from   w ww.jav a  2  s . c  o m
        public int compare(ServerInfoProvider oneProvider, ServerInfoProvider anotherProvider) {
            return Double.compare(oneProvider.priority(), anotherProvider.priority());
        }
    });
}

From source file:org.gitools.analysis.clustering.kmeans.Cluster.java

@Override
public int compareTo(Cluster o) {

    if (o == null) {
        return 1;
    }//w ww. j a v  a  2 s. c  o m

    return -1 * Double.compare(weight, o.getWeight());
}

From source file:com.alibaba.jstorm.ui.tags.CpuTag.java

@Override
public void doTag() throws JspException {
    JspWriter out = getJspContext().getOut();
    try {/* w  w  w  .j ava 2s  .co m*/
        if (!StringUtils.isBlank(ratio)) {
            double value = JStormUtils.parseDouble(ratio);
            double danger_threshold = workers * 100;
            double warn_threshold = danger_threshold * THRESHOLD;
            String status_success = "success";
            String status_warning = "warning";
            String status_danger = "danger";

            StringBuilder sb = new StringBuilder();
            sb.append("<div class='progress cpu-ratio-bar'>");
            if (Double.compare(value, warn_threshold) <= 0) {
                double width = value / danger_threshold * 100;
                appendBar(sb, width, value, status_success);
            } else if (Double.compare(value, danger_threshold) <= 0) {
                double width1 = THRESHOLD * 100;
                double width2 = (value - warn_threshold) / danger_threshold * 100;
                appendBar(sb, width1, value, status_success);
                appendBar(sb, width2, value, status_warning);
            } else {
                double width1 = danger_threshold / value * 100;
                double width2 = 100 - width1;
                appendBar(sb, width1, value, status_success);
                appendBar(sb, width2, value, status_danger);
            }
            sb.append("</div>");
            out.write(sb.toString());
        }

    } catch (IOException e) {
        throw new JspException("Error: " + e.getMessage());
    }
}

From source file:org.jberet.support.io.StockTrade2.java

@Override
public boolean equals(final Object o) {
    if (this == o)
        return true;
    if (!(o instanceof StockTrade2))
        return false;

    final StockTrade2 that = (StockTrade2) o;

    if (Double.compare(that.close, close) != 0)
        return false;
    if (Double.compare(that.high, high) != 0)
        return false;
    if (Double.compare(that.low, low) != 0)
        return false;
    if (Double.compare(that.open, open) != 0)
        return false;
    if (Double.compare(that.volume, volume) != 0)
        return false;
    if (!date.equals(that.date))
        return false;
    if (!time.equals(that.time))
        return false;

    return true;/*from   w w  w  . j  av  a2  s. c o  m*/
}

From source file:org.jberet.support.io.Cape.java

@Override
public boolean equals(final Object o) {
    if (this == o)
        return true;
    if (!(o instanceof Cape))
        return false;

    final Cape cape1 = (Cape) o;

    if (Double.compare(cape1.cpi, cpi) != 0)
        return false;
    if (Double.compare(cape1.date, date) != 0)
        return false;
    if (Double.compare(cape1.dateFraction, dateFraction) != 0)
        return false;
    if (Double.compare(cape1.dividend, dividend) != 0)
        return false;
    if (Double.compare(cape1.earnings, earnings) != 0)
        return false;
    if (Double.compare(cape1.longInterestRate, longInterestRate) != 0)
        return false;
    if (Double.compare(cape1.realDividend, realDividend) != 0)
        return false;
    if (Double.compare(cape1.realEarnings, realEarnings) != 0)
        return false;
    if (Double.compare(cape1.realPrice, realPrice) != 0)
        return false;
    if (Double.compare(cape1.sp, sp) != 0)
        return false;
    if (cape != null ? !cape.equals(cape1.cape) : cape1.cape != null)
        return false;

    return true;// w w w . j  a  v  a  2  s . c o  m
}

From source file:net.mintern.primitive.pair.DoublePair.java

/**
 * Compares the pair based on the left element followed by the right element.
 *
 * @param other  the other pair, not null
 * @return negative if this is less, zero if equal, positive if greater
 *//*w  w w  .  j  a  v a  2  s.  co  m*/
@Override
public int compareTo(DoublePair other) {
    int cmp = Double.compare(getLeft(), other.getLeft());
    return cmp != 0 ? cmp : Double.compare(getRight(), other.getRight());
}

From source file:com.igormaznitsa.mindmap.swing.panel.utils.ScalableIcon.java

public synchronized Image getImage(final double scale) {
    if (Double.compare(this.currentScaleFactor, scale) != 0) {
        this.scaledCachedImage = null;
    }/*  www . j a  va 2 s. co  m*/

    if (this.scaledCachedImage == null) {
        this.currentScaleFactor = scale;

        final int imgw = this.baseImage.getWidth(null);
        final int imgh = this.baseImage.getHeight(null);
        final int scaledW = (int) Math.round(imgw * this.baseScaleX * scale);
        final int scaledH = (int) Math.round(imgh * this.baseScaleY * scale);

        final BufferedImage img = new BufferedImage(scaledW, scaledH, BufferedImage.TYPE_INT_ARGB);
        final Graphics2D g = (Graphics2D) img.getGraphics();

        g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
                RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);

        g.drawImage(this.baseImage, 0, 0, scaledW, scaledH, null);
        g.dispose();

        this.scaledCachedImage = img;
    }
    return this.scaledCachedImage;
}