Example usage for java.lang Double floatValue

List of usage examples for java.lang Double floatValue

Introduction

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

Prototype

public float floatValue() 

Source Link

Document

Returns the value of this Double as a float after a narrowing primitive conversion.

Usage

From source file:org.pentaho.di.core.injection.NullNumberConverter.java

@Override
public int number2intPrimitive(final Double v) {
    return v == null ? -1 : Math.round(v.floatValue());
}

From source file:com.sarm.aussiepayslipgenerator.service.PaySlipServiceImpl.java

@Override
public Integer roundOff(Double value) {
    logger.debug(" rounding off value as float to Int " + Math.round(value.floatValue()));

    //Autoboxing//from   w w w  .  j a  v a  2s  . c  om
    return (Integer) Math.round(value.floatValue());
}

From source file:io.sanfran.wikiTrends.extraction.plots.PlotTimeSeries.java

public PlotTimeSeries(String title, TimeSeriesCollection data, List<Double> width, List<Color> colors) {
    super(title);
    seriesWidth = new ArrayList<Float>();
    for (Double i : width) {
        seriesWidth.add(i.floatValue());
    }/*from www. j  a va  2  s .c  o  m*/
    seriesColor = colors;

    ChartPanel chartPanel = (ChartPanel) createPanel(data, title);
    chartPanel.setPreferredSize(new java.awt.Dimension(1024, 768));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
}

From source file:org.apache.hadoop.hive.ql.udf.UDFToFloat.java

public Float evaluate(Double i) {
    if (i == null) {
        return null;
    } else {/*from w w w.  j  a v  a  2s. com*/
        return Float.valueOf(i.floatValue());
    }
}

From source file:com.norconex.collector.http.data.store.impl.mongo.MongoCrawlDataSerializer.java

@Override
public ICrawlData fromDBObject(DBObject dbObject) {
    ICrawlData superData = super.fromDBObject(dbObject);
    if (superData == null) {
        return null;
    }//  w w  w . j  a  va  2s .co m
    HttpCrawlData data = new HttpCrawlData(superData);
    data.setDepth((Integer) dbObject.get(FIELD_DEPTH));
    data.setSitemapLastMod((Long) dbObject.get(FIELD_SITEMAP_LAST_MOD));
    data.setSitemapChangeFreq((String) dbObject.get(FIELD_SITEMAP_CHANGE_FREQ));
    Double val = (Double) dbObject.get(FIELD_SITEMAP_PRIORITY);
    if (val != null) {
        data.setSitemapPriority(val.floatValue());
    }
    data.setOriginalReference((String) dbObject.get(FIELD_ORIGINAL_REFERENCE));
    data.setReferrerReference((String) dbObject.get(FIELD_REFERRER_REFERENCE));
    data.setReferrerLinkTag((String) dbObject.get(FIELD_REFERRER_LINK_TAG));
    data.setReferrerLinkText((String) dbObject.get(FIELD_REFERRER_LINK_TEXT));
    data.setReferrerLinkTitle((String) dbObject.get(FIELD_REFERRER_LINK_TITLE));

    BasicDBList dbRefUrls = (BasicDBList) dbObject.get(FIELD_REFERENCED_URLS);
    if (dbRefUrls != null) {
        data.setReferencedUrls(dbRefUrls.toArray(ArrayUtils.EMPTY_STRING_ARRAY));
    }
    return data;
}

From source file:ru.histone.v2.BaseTest.java

protected Object getObjectValue(Object value) {
    if (isDouble(value)) {
        Double v = (Double) value;
        if (v % 1 == 0 && v <= Integer.MAX_VALUE) {
            return v.longValue();
        } else {// ww w.ja  v a 2s . co m
            return v.floatValue();
        }
    } else {
        return value;
    }
}

From source file:edu.umn.msi.tropix.webgui.server.messages.MessageJobsEventHandlerImpl.java

public void handleEvent(final EventBase event) {
    LOG.trace("Handling job update : " + event.toString());
    if (event instanceof ObjectAddedEvent) {
        final ObjectAddedMessage message = new ObjectAddedMessage();
        message.setDestinationId(((ObjectAddedEvent) event).getDestinationId());
        message.setObjectId(((ObjectAddedEvent) event).getObjectId());
        messagePusher.push(event.getUserId(), message);
    } else {// w  w  w .ja va2 s  .  c o  m
        final ProgressMessage message = new ProgressMessage();
        message.setWorkflowId(event.getWorkflowId());
        message.setName(event.getJobName());
        message.setId(event.getJobId());
        if (event instanceof CompletionEvent) {
            message.setStep("Complete");
            message.setPercent(1.0f);
            message.setJobStatus(ProgressMessage.JOB_COMPLETE);
        } else if (event instanceof FailureEvent) {
            message.setStep("Failed");
            message.setPercent(0.0f);
            message.setJobStatus(ProgressMessage.JOB_FAILED);
        } else if (event instanceof WorkflowEvent) {
            final WorkflowEvent workflowEvent = (WorkflowEvent) event;
            message.setStep(workflowEvent.getStep());
            message.setStepStatus("Executing");
        } else if (event instanceof GridStatusEvent) {
            final Status status = ((GridStatusEvent) event).getStatus();
            final QueueStage stage = QueueStage.fromStatusUpdateList(status);
            String step = "Queued with status " + stage.toString();
            if (stage.equals(QueueStage.PENDING) && status.getQueuePosition() != null) {
                final QueuePosition pos = status.getQueuePosition();
                step = step + " (" + pos.getValue() + " / " + pos.getQueueSize() + ")";
            }
            message.setStep(step);
            final Double percentComplete = StatusUtils.getPercentComplete(status);
            if (percentComplete != null && stage.equals(QueueStage.RUNNING)) {
                message.setPercent(percentComplete.floatValue());
            } else {
                message.setStepStatus("Executing");
            }
        }
        this.messagePusher.push(event.getUserId(), message);
    }
}

From source file:net.solarnetwork.node.power.impl.OutbackMX60PowerDatumDataSource.java

/**
 * Parse an Outback Mate serial data string into a PowerDatum object.
 * //from w  w  w . j  a  v a2 s . c  o  m
 * <p>
 * The string data format looks like
 * {@code D,00,00,00,016,129,00,00,000,00,511,000,000,046}. See the
 * <em>Mate Serial Communications Guide</em> for details.
 * </p>
 * 
 * @param data
 *        the serial data string
 * @return a PowerDatum instance
 */
@SuppressWarnings("deprecation")
private PowerDatum getPowerDatumInstance(String data) {

    // split data on comma
    String[] frame = data.split(",");
    if (frame.length < 14) {
        if (log.isWarnEnabled()) {
            log.warn("Expected 14 data elements, but got " + frame.length);
        }
        return null;
    }

    PowerDatum pd = new PowerDatum();

    Double d = getFrameDouble(frame, FRAME_IDX_PV_AMPS);
    if (d != null) {
        pd.setPvAmps(d.floatValue());
    }

    d = getFrameDouble(frame, FRAME_IDX_PV_VOLTS);
    if (d != null) {
        pd.setPvVolts(d.floatValue());
    }

    d = getFrameDouble(frame, FRAME_IDX_DC_AMPS);
    if (d != null) {
        pd.setDcOutputAmps(d.floatValue());
    }

    d = getFrameDouble(frame, FRAME_IDX_BAT_VOLTS);
    if (d != null) {
        pd.setBatteryVolts(d.floatValue() * BAT_VOLTS_MULTIPLIER);
    }

    d = getFrameDouble(frame, FRAME_IDX_KWATT_HOURS);
    if (d != null) {
        pd.setKWattHoursToday(d * KWATT_HOURS_MULTIPLIER);
    }

    return pd;
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.masterDegree.commons.candidate.WriteCandidateEnrolments.java

protected void run(Set<String> selectedCurricularCoursesIDs, String candidateID, Double credits,
        String givenCreditsRemarks) throws FenixServiceException {

    MasterDegreeCandidate masterDegreeCandidate = FenixFramework.getDomainObject(candidateID);
    if (masterDegreeCandidate == null) {
        throw new NonExistingServiceException();
    }/* ww w.  j a  v a  2s.  c o m*/

    masterDegreeCandidate.setGivenCredits(credits);

    if (credits.floatValue() != 0) {
        masterDegreeCandidate.setGivenCreditsRemarks(givenCreditsRemarks);
    }

    Collection<CandidateEnrolment> candidateEnrolments = masterDegreeCandidate.getCandidateEnrolmentsSet();
    List<String> candidateEnrolmentsCurricularCoursesIDs = (List<String>) CollectionUtils
            .collect(candidateEnrolments, new Transformer() {
                @Override
                public Object transform(Object arg0) {
                    CandidateEnrolment candidateEnrolment = (CandidateEnrolment) arg0;
                    return candidateEnrolment.getCurricularCourse().getExternalId();
                }
            });

    Collection<String> curricularCoursesToEnroll = CollectionUtils.subtract(selectedCurricularCoursesIDs,
            candidateEnrolmentsCurricularCoursesIDs);

    final Collection<Integer> curricularCoursesToDelete = CollectionUtils
            .subtract(candidateEnrolmentsCurricularCoursesIDs, selectedCurricularCoursesIDs);

    Collection<CandidateEnrolment> candidateEnrollmentsToDelete = CollectionUtils.select(candidateEnrolments,
            new Predicate() {
                @Override
                public boolean evaluate(Object arg0) {
                    CandidateEnrolment candidateEnrolment = (CandidateEnrolment) arg0;
                    return (curricularCoursesToDelete
                            .contains(candidateEnrolment.getCurricularCourse().getExternalId()));
                }
            });

    writeFilteredEnrollments(masterDegreeCandidate, curricularCoursesToEnroll);

    for (CandidateEnrolment candidateEnrolmentToDelete : candidateEnrollmentsToDelete) {
        candidateEnrolmentToDelete.delete();
    }
}

From source file:org.goko.core.gcode.rs274ngcv3.jogl.renderer.RS274GCodeRenderer.java

/** (inheritDoc)
 * @see org.goko.tools.viewer.jogl.service.AbstractCoreJoglRenderer#render(javax.media.opengl.GL3, com.jogamp.opengl.util.PMVMatrix)
 */// w w w . ja  v a 2  s  . com
@Override
public void render(GL3 gl, PMVMatrix modelViewMatrix) throws GkException {
    if (fourAxisControllerAdapter == null) {
        super.render(gl, modelViewMatrix);
    } else {
        // We have to render using the 4th axis
        float angle = 0;
        Double realAngle = fourAxisControllerAdapter.getA().doubleValue(AngleUnit.DEGREE_ANGLE);
        if (realAngle != null) {
            angle = realAngle.floatValue();
        }
        Vector3f rotationAxis = JoglViewerPreference.getInstance().getRotaryAxisDirectionVector();
        modelViewMatrix.glRotatef(-angle, rotationAxis.x, rotationAxis.y, rotationAxis.z);
        super.render(gl, modelViewMatrix);
        modelViewMatrix.glRotatef(angle, rotationAxis.x, rotationAxis.y, rotationAxis.z);
    }
}