List of usage examples for java.lang Integer floatValue
public float floatValue()
From source file:ConversionUtil.java
public static byte[] convertToByteArray(Object object) throws Exception { byte[] returnArray = null; Class clazz = object.getClass(); String clazzName = clazz.getName(); if (clazz.equals(Integer.class)) { Integer aValue = (Integer) object; int intValue = aValue.intValue(); returnArray = convertToByteArray(intValue); } else if (clazz.equals(String.class)) { String aValue = (String) object; returnArray = convertToByteArray(aValue); } else if (clazz.equals(Byte.class)) { Byte aValue = (Byte) object; byte byteValue = aValue.byteValue(); returnArray = convertToByteArray(byteValue); } else if (clazz.equals(Long.class)) { Long aValue = (Long) object; long longValue = aValue.longValue(); returnArray = convertToByteArray(longValue); } else if (clazz.equals(Short.class)) { Short aValue = (Short) object; short shortValue = aValue.shortValue(); returnArray = convertToByteArray(shortValue); } else if (clazz.equals(Boolean.class)) { Boolean aValue = (Boolean) object; boolean booleanValue = aValue.booleanValue(); returnArray = convertToByteArray(booleanValue); } else if (clazz.equals(Character.class)) { Character aValue = (Character) object; char charValue = aValue.charValue(); returnArray = convertToByteArray(charValue); } else if (clazz.equals(Float.class)) { Float aValue = (Float) object; float floatValue = aValue.floatValue(); returnArray = convertToByteArray(floatValue); } else if (clazz.equals(Double.class)) { Double aValue = (Double) object; double doubleValue = aValue.doubleValue(); returnArray = convertToByteArray(doubleValue); } else {/* w w w. jav a2 s . c o m*/ throw new Exception("Cannot convert object of type " + clazzName); } return returnArray; }
From source file:com.intuit.tank.api.model.v1.datafile.DataFileDescriptorTest.java
/** * Run the Integer getId() method test./*from ww w.ja va 2 s .c om*/ * * @throws Exception * * @generatedBy CodePro at 12/15/14 3:00 PM */ @Test public void testGetId_1() throws Exception { DataFileDescriptor fixture = new DataFileDescriptor(); fixture.setComments(""); fixture.setCreator(""); fixture.setName(""); fixture.setDataUrl(""); fixture.setId(new Integer(1)); fixture.setCreated(new Date()); fixture.setModified(new Date()); Integer result = fixture.getId(); assertNotNull(result); assertEquals("1", result.toString()); assertEquals((byte) 1, result.byteValue()); assertEquals((short) 1, result.shortValue()); assertEquals(1, result.intValue()); assertEquals(1L, result.longValue()); assertEquals(1.0f, result.floatValue(), 1.0f); assertEquals(1.0, result.doubleValue(), 1.0); }
From source file:org.webical.web.component.event.EventForm.java
/** * Stores all the event instances/*w w w . ja v a 2s .co m*/ */ private void alterAllEventInstances() { if (overruleCalendarTimeZone && !eventWrapper.getEvent().isAllDay()) { //Display dtstart and dtend in user timezone Integer offSetCalendar = eventWrapper.getEvent().getCalendar().getOffSetFrom(); if (offSetCalendar != null) { float difference = offSetUser.floatValue() - offSetCalendar.floatValue(); if (eventWrapper.getEvent().getDtStart() != null) { eventWrapper.getEvent() .setDtStart(CalendarUtils.addHours(eventWrapper.getEvent().getDtStart(), -difference)); } if (eventWrapper.getEvent().getDtEnd() != null) { eventWrapper.getEvent() .setDtEnd(CalendarUtils.addHours(eventWrapper.getEvent().getDtEnd(), -difference)); } } } eventWrapper.storeRecurrence(); /*if(eventWrapper.getFrequency() != null && eventWrapper.getInterval() != null) { if(eventWrapper.getCount() == null){ RecurrenceUtil.setRecurrenceRule(storeEvent, new Recurrence(eventWrapper.getFrequency(), eventWrapper.getInterval(), eventWrapper.getUntil())); } else { RecurrenceUtil.setRecurrenceRule(storeEvent, new Recurrence(eventWrapper.getFrequency(), eventWrapper.getCount(), eventWrapper.getInterval(), eventWrapper.getUntil())); } } else { //Clear the recurrence RecurrenceUtil.clearRecurrence(storeEvent); }*/ //Refresh the event calendar, or else there is a lazilyexception /*Calendar storeCalendar; try { storeCalendar = calendarManager.getCalendarForEvent(storeEvent); } catch (WebicalException e1) { throw new WebicalWebAplicationException(e1); }*/ //Save the event /* try { //If the is a gCalendar than put this remove this event from its series if (excludeFromRange) { oldEvent.getExDate().add(date.getTime()); eventManager.storeEvent(oldEvent); } eventManager.storeEvent(storeEvent); if (log.isDebugEnabled()) { log.debug("Event saved: " + storeEvent.getSummary() + " for calendar: " + storeEvent.getCalendar().getName()); } //Change back to the list EventAddEditPanel.this.onAction(new FormFinishedAction(null)); } catch (WebicalException e) { if (e.getCause().getClass() == UpdateConflictException.class) { if (log.isDebugEnabled()) { log.debug("update exception"); } eventSelectionListener.eventUpdateandDeleteException(storeEvent, storeCalendar, true); } else if (e.getCause().getClass() == DeleteConflictException.class) { if (log.isDebugEnabled()) { log.debug("delete exception"); } eventSelectionListener.eventUpdateandDeleteException(storeEvent, storeCalendar, false); } else { error("Could not store the event"); throw new WebicalWebAplicationException("Event could not be saved: " + storeEvent.getSummary(), e); } } */ // Store the event if (editForm && oldEvent.getCalendar().getCalendarId() != eventWrapper.getCalendar().getCalendarId()) { log.info("Change Event Calendar " + eventWrapper.getCalendar().getName()); EventForm.this.onAction(new RemoveEventAction(oldEvent)); eventWrapper.setEventId(null); eventWrapper.setUid(null); EventForm.this.onAction(new StoreEventAction(eventWrapper.getEvent())); } else { EventForm.this.onAction(new StoreEventAction(eventWrapper.getEvent())); } }
From source file:org.etudes.mneme.tool.FormatListDecorationDelegate.java
/** * {@inheritDoc}//from w ww .j a v a 2s . c o m */ public String format(Context context, Object value) { Object o = context.get("submission"); if (!(o instanceof Submission)) return value.toString(); Submission submission = (Submission) o; String rv = null; // see if we are blocked by an access advisor boolean blocked = false; if (this.accessAdvisor != null) { blocked = this.accessAdvisor.denyAccess("sakai.mneme", submission.getAssessment().getContext(), submission.getAssessment().getId(), submission.getUserId()); } // check mastery level boolean belowMastery = false; String masteryPoints = null; if (this.masteryAdvisor != null) { belowMastery = this.masteryAdvisor.failedToMaster("sakai.mneme", submission.getAssessment().getContext(), submission.getAssessment().getId(), submission.getUserId()); if (belowMastery) { Integer masteryPercent = this.masteryAdvisor.masteryLevelPercent("sakai.mneme", submission.getAssessment().getContext(), submission.getAssessment().getId(), submission.getUserId()); if (masteryPercent != null) { masteryPoints = FormatScoreDelegate.formatScore( Float.valueOf(submission.getAssessment().getParts().getTotalPoints().floatValue() * (masteryPercent.floatValue() / 100.0f))); } } } // get the status AssessmentSubmissionStatus status = submission.getAssessmentSubmissionStatus(); // non-user submission status, 0 points, not answered Boolean nonUserZeroEmpty = ((submission.getCompletionStatus() != SubmissionCompletionStatus.userFinished) && ((!submission.getIsReleased()) || (submission.getTotalScore() == null) || (submission.getTotalScore() == 0.0)) && (submission.getIsUnanswered())); switch (status) { case future: { rv = "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + "/icons/future.gif\" alt=\"" + context.getMessages().getString("format-list-decoration-future") + "\" title=\"" + context.getMessages().getString("format-list-decoration-future") + "\" /><br /><span style=\"font-size:smaller\">" + context.getMessages().getString("format-list-decoration-future") + "</span>"; break; } case hiddenTillOpen: { rv = "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + "/icons/future.gif\" alt=\"" + context.getMessages().getString("format-list-decoration-future") + "\" title=\"" + context.getMessages().getString("format-list-decoration-future") + "\" /><br /><span style=\"font-size:smaller\">" + context.getMessages().getString("format-list-decoration-future") + "</span>"; break; } case ready: { if (!blocked) { rv = "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + "/icons/begin.gif\" alt=\"" + context.getMessages().getString("format-list-decoration-todo") + "\" title=\"" + context.getMessages().getString("format-list-decoration-todo") + "\" /><br /><span style=\"font-size:smaller\">" + context.getMessages().getString("format-list-decoration-todo") + "</span>"; } break; } case overdueReady: { if (!blocked) { rv = "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + "/icons/exit.gif\" alt=\"" + context.getMessages().getString("format-list-decoration-inprogress") + "\" title=\"" + context.getMessages().getString("format-list-decoration-inprogress") + "\" />" + "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + "/icons/warning.png\" alt=\"" + context.getMessages().getString("format-list-decoration-urgent") + "\" title=\"" + context.getMessages().getString("format-list-decoration-urgent") + "\" />" + "<br /><span style=\"font-size:smaller\">" + context.getMessages().getString("format-list-decoration-overdue-ready") + "</span>"; } break; } case inProgressAlert: { if (!blocked) { rv = "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + "/icons/exit.gif\" alt=\"" + context.getMessages().getString("format-list-decoration-inprogress") + "\" title=\"" + context.getMessages().getString("format-list-decoration-inprogress") + "\" />" + "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + "/icons/warning.png\" alt=\"" + context.getMessages().getString("format-list-decoration-urgent") + "\" title=\"" + context.getMessages().getString("format-list-decoration-urgent") + "\" />" + "<br /><span style=\"font-size:smaller\">" + context.getMessages().getString("format-list-decoration-inprogress-urgent") + "</span>"; } break; } case inProgress: { if (!blocked) { rv = "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + "/icons/exit.gif\" alt=\"" + context.getMessages().getString("format-list-decoration-inprogress") + "\" title=\"" + context.getMessages().getString("format-list-decoration-inprogress") + "\" /><br /><span style=\"font-size:smaller\">" + context.getMessages().getString("format-list-decoration-inprogress") + "</span>"; } break; } case completeReady: { String icon = "/icons/finish.gif"; String msgSelector = "format-list-decoration-complete"; String repeatMsgSelector = "format-list-decoration-complete-repeat"; if (nonUserZeroEmpty) { icon = "/icons/missed-try-again.png"; msgSelector = "format-list-decoration-missed"; repeatMsgSelector = "format-list-decoration-missed-repeat"; } String repeatMsg = context.getMessages().getString(repeatMsgSelector); if (belowMastery && (!nonUserZeroEmpty)) { icon = "/icons/not-mastered.png"; Object[] args = new Object[1]; args[0] = masteryPoints; msgSelector = "format-list-decoration-submitted"; String selector = "format-list-decoration-complete-repeat-mastery"; if ((!submission.getIsReleased()) || submission.getHasUnscoredAnswers() || submission.getHasUngradedSiblings()) { selector = "format-list-decoration-complete-repeat-mastery-pending"; } repeatMsg = context.getMessages().getFormattedMessage(selector, args); } if (!blocked) { rv = "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + icon + "\" alt=\"" + context.getMessages().getString(msgSelector) + "\" title=\"" + context.getMessages().getString(msgSelector) + "\" />" + "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + "/icons/begin.gif\" alt=\"" + context.getMessages().getString("format-list-decoration-repeat") + "\" title=\"" + context.getMessages().getString("format-list-decoration-repeat") + "\" />" + "<br /><span style=\"font-size:smaller\">" + repeatMsg + "</span>"; } break; } case overdueCompleteReady: { String icon = "/icons/finish.gif"; String msgSelector = "format-list-decoration-complete"; if (nonUserZeroEmpty) { icon = "/icons/missed-try-again.png"; msgSelector = "format-list-decoration-missed"; } String repeatMsg = context.getMessages().getString("format-list-decoration-complete-repeat-overdue"); if (belowMastery && (!nonUserZeroEmpty)) { icon = "/icons/not-mastered.png"; Object[] args = new Object[1]; args[0] = masteryPoints; msgSelector = "format-list-decoration-submitted"; String selector = "format-list-decoration-complete-repeat-overdue-mastery"; if ((!submission.getIsReleased()) || submission.getHasUnscoredAnswers() || submission.getHasUngradedSiblings()) { selector = "format-list-decoration-complete-repeat-overdue-mastery-pending"; } repeatMsg = context.getMessages().getFormattedMessage(selector, args); } if (!blocked) { rv = "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + icon + "\" alt=\"" + context.getMessages().getString(msgSelector) + "\" title=\"" + context.getMessages().getString(msgSelector) + "\" />" + "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + "/icons/begin.gif\" alt=\"" + context.getMessages().getString("format-list-decoration-repeat") + "\" title=\"" + context.getMessages().getString("format-list-decoration-repeat") + "\" />" + "<br /><span style=\"font-size:smaller\">" + repeatMsg + "</span>"; } break; } case complete: { String icon = "/icons/finish.gif"; String msgSelector = "format-list-decoration-complete"; String detailSelector = "format-list-decoration-complete"; Object[] args = new Object[1]; args[0] = masteryPoints; if (nonUserZeroEmpty) { icon = "/icons/exclamation.png"; msgSelector = "format-list-decoration-missed"; detailSelector = "format-list-decoration-missed"; } else if (belowMastery) { msgSelector = "format-list-decoration-submitted"; icon = "/icons/not-mastered.png"; if ((!submission.getIsReleased()) || submission.getHasUnscoredAnswers() || submission.getHasUngradedSiblings()) { detailSelector = "format-list-decoration-complete-not-mastered-pending"; } else { detailSelector = "format-list-decoration-complete-not-mastered"; } } String msg = context.getMessages().getFormattedMessage(msgSelector, args); String detail = context.getMessages().getFormattedMessage(detailSelector, args); rv = "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + icon + "\" alt=\"" + msg + "\" title=\"" + msg + "\" /><br /><span style=\"font-size:smaller\">" + detail + "</span>"; break; } case over: { rv = "<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + "/icons/cancel.gif\" alt=\"" + context.getMessages().getString("format-list-decoration-overdue") + "\" title=\"" + context.getMessages().getString("format-list-decoration-overdue") + "\" /><br /><span style=\"font-size:smaller\">" + context.getMessages().getString("format-list-decoration-overdue") + "</span>"; break; } } return rv; }
From source file:org.gytheio.content.transform.ffmpeg.FfmpegContentTransformerWorker.java
/** * Gets the ffmpeg command string for the transform options * provided//w w w.j av a 2 s. c o m * <p> * Note: The current implementation assumes a 4:3 aspect ratio in the source * and that the <code>imageResizeOptions</code> given signify max width and * heights. * <p> * TODO: Future implementations should examine the source for the aspect ratio to * correctly create the thumbnail. * * @param options transformation options * @param sourceFile * @return String the ffmpeg command options */ protected String getTargetResizeCommandOptions(TransformationOptions options, File sourceFile) { if (options == null) { return null; } ImageResizeOptions imageResizeOptions = null; if (options instanceof ImageTransformationOptions) { imageResizeOptions = ((ImageTransformationOptions) options).getResizeOptions(); } if (options instanceof VideoTransformationOptions) { imageResizeOptions = ((VideoTransformationOptions) options).getResizeOptions(); } if (imageResizeOptions == null) { return null; } float aspectRatio = 1.3333f; // default try { String sourceDetails = getDetails(sourceFile); String sourceResolution = getResolution(sourceDetails); if (sourceResolution != null) { Integer sourceWidth = new Integer(sourceResolution.split("x")[0]); Integer sourceHeight = new Integer(sourceResolution.split("x")[1]); aspectRatio = sourceWidth.floatValue() / sourceHeight.floatValue(); } } catch (Exception e) { logger.warn("Could not get file details: " + e.getMessage()); } StringBuilder builder = new StringBuilder(32); int width = imageResizeOptions.getWidth(); int height = imageResizeOptions.getHeight(); if (imageResizeOptions.isMaintainAspectRatio()) { // Could use ffmpeg's scale features here but this seems easier if (imageResizeOptions.getWidth() > 0 && imageResizeOptions.getHeight() > 0) { if (imageResizeOptions.getWidth() <= imageResizeOptions.getHeight()) { width = imageResizeOptions.getWidth(); height = Math.round(width * (1 / aspectRatio)); } else if (imageResizeOptions.getWidth() > imageResizeOptions.getHeight()) { height = imageResizeOptions.getHeight(); width = Math.round(height * aspectRatio); } } else if (!isFilterSupported()) { if (imageResizeOptions.getHeight() < 0) { width = imageResizeOptions.getWidth(); height = Math.round(width * (1 / aspectRatio)); } else { height = imageResizeOptions.getHeight(); width = Math.round(height * aspectRatio); } } if (height > 0 && (height % 2) != 0) { height = height - 1; } if (width > 0 && (width % 2) != 0) { width = width + 1; } } if (isFilterSupported()) { builder.append(CMD_OPT_SCALE); builder.append(CMD_OPT_PARAM_ASSIGNMENT); builder.append(width); builder.append(":"); builder.append(height); } else { builder.append(CMD_OPT_SIZE); builder.append(CMD_OPT_ASSIGNMENT); builder.append(width); builder.append("x"); builder.append(height); } return builder.toString(); }
From source file:org.tdar.core.bean.resource.InformationResource.java
public void setDate(Integer dateCreated) { this.date = dateCreated; if (dateCreated != null) { this.dateNormalized = Math.round(dateCreated.floatValue() / 10f) * 10; } else {/* ww w .j a va2 s. co m*/ this.dateNormalized = null; } }
From source file:shuffle.fwk.ShuffleController.java
@Override public Integer scaleBorderThickness(int given) { Integer borderScale = getPreferencesManager().getIntegerValue(KEY_BORDER_SCALING); Integer ret = given;/*from w ww .j av a2 s .c o m*/ if (borderScale != null && borderScale != 100 && borderScale >= 1 && borderScale <= 10000) { float scale = borderScale.floatValue() * ret.floatValue() / 100.0f; ret = Math.round(scale); } return ret; }
From source file:shuffle.fwk.ShuffleController.java
@Override public Font scaleFont(Font givenFont) { Font retFont = givenFont;/* w ww . j av a2 s . c om*/ Integer menuFontOverride = getPreferencesManager().getIntegerValue(KEY_FONT_SIZE_SCALING); if (menuFontOverride != null && menuFontOverride != 100 && menuFontOverride > 0 && menuFontOverride < 10000) { float scale = menuFontOverride.floatValue() / 100.0f; float adjustedSize = retFont.getSize2D() * scale; retFont = retFont.deriveFont(adjustedSize); } return retFont; }
From source file:org.gradoop.flink.datagen.transactions.foodbroker.config.FoodBrokerConfig.java
/** * Calculates and returns integer value of the loaded key. * * @param influencingMasterDataQuality list of influencing master data quality * @param node the transactional data node * @param key the key to load from//from ww w .j ava2s .co m * @param higherIsBetterDefault default value to define that a higher value is better or not * @return integer value */ public Integer getIntRangeConfigurationValue(List<Float> influencingMasterDataQuality, String node, String key, boolean higherIsBetterDefault) { Integer min = 0; Integer max = 0; Integer startValue; Integer value; Random random = new Random(); Boolean higherIsBetter = getHigherIsBetter(node, key, higherIsBetterDefault); Float influence = getInfluence(node, key, 0.0f); // load the min and max values for the node and key combination try { min = getTransactionalNodes().getJSONObject(node).getInt(key + "Min"); max = getTransactionalNodes().getJSONObject(node).getInt(key + "Max"); } catch (JSONException e) { e.printStackTrace(); } // generate a random value to start with startValue = 1 + random.nextInt((max - min) + 1) + min; // get the result value depending on the start value value = getValue(influencingMasterDataQuality, higherIsBetter, influence, startValue.floatValue()) .intValue(); // keep result in boundaries if (value < min) { value = min; } else if (value > max) { value = max; } return value; }
From source file:shuffle.fwk.ShuffleController.java
/** * Creates a ShuffleController with the given configuration paths for the primary configuration * (which tells other managers where to get their configurations). If there are none passed, then * "config/main.txt" is assumed.//from w ww .j a v a 2s. c om * * @param configPaths * The paths as Strings */ public ShuffleController(String... configPaths) { if (configPaths.length > 0 && configPaths[0] != null) { factory = new ConfigFactory(configPaths[0]); } else { factory = new ConfigFactory(); } Integer menuFontOverride = getPreferencesManager().getIntegerValue(KEY_FONT_SIZE_SCALING); if (menuFontOverride != null && menuFontOverride != 100 && menuFontOverride >= 1 && menuFontOverride <= 10000) { float scale = menuFontOverride.floatValue() / 100.0f; try { // This is the cleanest and most bug-free way to do this hack. Set<Object> allKeys = new HashSet<Object>(); allKeys.add("JMenu.font"); // Yes we're not supposed to use this, but it is the only one that works with Nimbus LAF allKeys.addAll(UIManager.getLookAndFeelDefaults().keySet()); Object value = UIManager.get("defaultFont"); if (value != null && value instanceof FontUIResource) { FontUIResource fromFont = (javax.swing.plaf.FontUIResource) value; FontUIResource toFont = new FontUIResource(fromFont.deriveFont(fromFont.getSize() * scale)); // This one is necessary UIManager.getLookAndFeel().getDefaults().put("defaultFont", toFont); // And this one allows other LAF to be used in the future UIManager.getDefaults().put("defaultFont", toFont); } // Needed for Nimbus's JTable row height adjustment Object tableFontValue = UIManager.getLookAndFeel().getDefaults().get("Table.font"); Number bestRowHeight = null; if (tableFontValue != null && tableFontValue instanceof FontUIResource) { FontUIResource fromFont = (FontUIResource) tableFontValue; bestRowHeight = fromFont.getSize(); } Object rowHeightValue = UIManager.getLookAndFeel().getDefaults().get("Table.rowHeight"); if (rowHeightValue != null && rowHeightValue instanceof Number) { Number rowHeight = (Number) rowHeightValue; rowHeight = rowHeight.doubleValue() * scale; if (bestRowHeight == null || bestRowHeight.intValue() < rowHeight.intValue()) { bestRowHeight = rowHeight; } } if (bestRowHeight != null) { bestRowHeight = bestRowHeight.doubleValue() * (4.0 / 3.0); } if (bestRowHeight != null && bestRowHeight.intValue() > 0) { UIManager.getLookAndFeel().getDefaults().put("Table.rowHeight", bestRowHeight.intValue()); } } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); LOG.log(Level.SEVERE, "Cannot override menu font sizes!", e); } } try { setModel(new ShuffleModel(this)); setView(new ShuffleView(this)); getModel().checkLocaleConfig(); loadFrame(); } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); LOG.log(Level.SEVERE, "Failure on start:", e); } }