List of usage examples for java.lang Float MAX_VALUE
float MAX_VALUE
To view the source code for java.lang Float MAX_VALUE.
Click Source Link
From source file:org.opencms.ui.components.fileselect.CmsResourceTreeContainer.java
/** * Defines the container properties.<p> *///from w w w . j a va 2 s . c o m protected void defineProperties() { addContainerProperty(CmsResourceTableProperty.PROPERTY_RESOURCE_NAME, String.class, null); addContainerProperty(CmsResourceTableProperty.PROPERTY_STATE, CmsResourceState.class, null); addContainerProperty(CmsResourceTableProperty.PROPERTY_TREE_CAPTION, String.class, null); addContainerProperty(CmsResourceTableProperty.PROPERTY_INSIDE_PROJECT, Boolean.class, Boolean.TRUE); addContainerProperty(CmsResourceTableProperty.PROPERTY_IS_FOLDER, Boolean.class, Boolean.TRUE); addContainerProperty(PROPERTY_RESOURCE, CmsResource.class, null); addContainerProperty(CmsResourceTableProperty.PROPERTY_IN_NAVIGATION, Boolean.class, Boolean.FALSE); addContainerProperty(CmsResourceTableProperty.PROPERTY_NAVIGATION_POSITION, Float.class, Float.valueOf(Float.MAX_VALUE)); addContainerProperty(PROPERTY_SITEMAP_CAPTION, String.class, ""); addContainerProperty(CmsResourceTableProperty.PROPERTY_NAVIGATION_TEXT, CmsResourceTableProperty.PROPERTY_NAVIGATION_TEXT.getColumnType(), ""); }
From source file:org.openmicroscopy.shoola.util.ui.NumericalTextField.java
/** * Sets the type of number to handle./*from ww w .j a v a 2 s.c o m*/ * * @param numberType The value to set. */ public void setNumberType(Class<?> numberType) { if (numberType == null) numberType = Integer.class; this.numberType = numberType; if (numberType.equals(Integer.class) || numberType.equals(Long.class)) accepted = NUMERIC; else accepted = FLOAT; setNegativeAccepted(negativeAccepted); if (numberType.equals(Double.class)) { setMinimum(0.0); setMaximum(Double.MAX_VALUE); } else if (numberType.equals(Float.class)) { setMinimum(0.0); setMaximum(Float.MAX_VALUE); } else if (numberType.equals(Long.class)) { setMinimum(0.0); setMaximum(Long.MAX_VALUE); } }
From source file:com.cohesionforce.dis.ConvertCSV.java
private Vector3Float getRandomFloatV() { Vector3Float vector = new Vector3Float(); vector.setX((float) (1.0 - (rand.nextFloat() * 2.0) * Float.MAX_VALUE)); vector.setY((float) (1.0 - (rand.nextFloat() * 2.0) * Float.MAX_VALUE)); vector.setZ((float) (1.0 - (rand.nextFloat() * 2.0) * Float.MAX_VALUE)); return vector; }
From source file:easyJ.common.validate.GenericTypeValidator.java
/** * Checks if the value can safely be converted to a float primitive. * /*from w w w . j a v a 2 s. co m*/ * @param value * The value validation is being performed on. * @param locale * The locale to use to parse the number (system default if * null) * @return the converted Float value. */ public static Float formatFloat(String value, Locale locale) { Float result = null; if (value != null) { NumberFormat formatter = null; if (locale != null) { formatter = NumberFormat.getInstance(locale); } else { formatter = NumberFormat.getInstance(Locale.getDefault()); } ParsePosition pos = new ParsePosition(0); Number num = formatter.parse(value, pos); // If there was no error and we used the whole string if (pos.getErrorIndex() == -1 && pos.getIndex() == value.length()) { if (num.doubleValue() >= (Float.MAX_VALUE * -1) && num.doubleValue() <= Float.MAX_VALUE) { result = new Float(num.floatValue()); } } } return result; }
From source file:gdsc.core.utils.ConvexHull.java
void calculateBounds(float[] xpoints, float[] ypoints, int npoints) { minX = Float.MAX_VALUE; minY = Float.MAX_VALUE;/*from w ww. j a v a 2 s . c o m*/ maxX = Float.MIN_VALUE; maxY = Float.MIN_VALUE; for (int i = 0; i < npoints; i++) { float x = xpoints[i]; minX = Math.min(minX, x); maxX = Math.max(maxX, x); float y = ypoints[i]; minY = Math.min(minY, y); maxY = Math.max(maxY, y); } int iMinX = (int) Math.floor(minX); int iMinY = (int) Math.floor(minY); bounds = new Rectangle(iMinX, iMinY, (int) (maxX - iMinX + 0.5), (int) (maxY - iMinY + 0.5)); }
From source file:org.red5.io.AbstractIOTest.java
@Test public void testNumberFloat() { log.debug("\ntestNumberFloat"); for (Number n : new Number[] { Float.MIN_VALUE, Float.MIN_NORMAL, Float.MAX_VALUE, rnd.nextFloat(), 666.6666f }) {// w w w . ja v a 2 s.c om Serializer.serialize(out, n); dumpOutput(); Number rn = Deserializer.deserialize(in, Number.class); assertEquals("Deserialized Float should be the same", (Float) n, (Float) rn.floatValue()); resetOutput(); } }
From source file:org.opencms.file.collectors.CmsDefaultResourceCollector.java
/** * Collects all resources in a folder (or subtree) sorted by the NavPos property.<p> * // w w w . j ava 2s. c o m * @param cms the current user's Cms object * @param param the collector's parameter(s) * @param readSubTree if true, collects all resources in the subtree * @return a List of Cms resources found by the collector * @throws CmsException if something goes wrong * */ protected List<CmsResource> allInFolderNavPos(CmsObject cms, String param, boolean readSubTree) throws CmsException { CmsCollectorData data = new CmsCollectorData(param); String foldername = CmsResource.getFolderPath(data.getFileName()); CmsResourceFilter filter = CmsResourceFilter.DEFAULT_FILES.addRequireType(data.getType()) .addExcludeFlags(CmsResource.FLAG_TEMPFILE); List<CmsResource> foundResources = cms.readResources(foldername, filter, readSubTree); // the Cms resources are saved in a map keyed by their nav elements // to save time sorting the resources by the value of their NavPos property CmsJspNavBuilder navBuilder = new CmsJspNavBuilder(cms); Map<CmsJspNavElement, CmsResource> navElementMap = new HashMap<CmsJspNavElement, CmsResource>(); for (int i = 0, n = foundResources.size(); i < n; i++) { CmsResource resource = foundResources.get(i); CmsJspNavElement navElement = navBuilder.getNavigationForResource(cms.getSitePath(resource)); // check if the resource has the NavPos property set or not if ((navElement != null) && (navElement.getNavPosition() != Float.MAX_VALUE)) { navElementMap.put(navElement, resource); } else if (LOG.isInfoEnabled()) { // printing a log messages makes it a little easier to identify // resources having not the NavPos property set LOG.info(Messages.get().getBundle().key(Messages.LOG_RESOURCE_WITHOUT_NAVPROP_1, cms.getSitePath(resource))); } } // all found resources have the NavPos property set // sort the nav. elements, and pull the found Cms resources // from the map in the correct order into a list // only resources with the NavPos property set are used here List<CmsJspNavElement> navElementList = new ArrayList<CmsJspNavElement>(navElementMap.keySet()); List result = new ArrayList<CmsResource>(); Collections.sort(navElementList); for (int i = 0, n = navElementList.size(); i < n; i++) { CmsJspNavElement navElement = navElementList.get(i); result.add(navElementMap.get(navElement)); } return shrinkToFit(result, data.getCount()); }
From source file:edu.cens.loci.provider.LociDbUtils.java
public LociCircleArea getPlacePositionEstimate(long placeId) { ArrayList<LociVisit> visits = getBaseVisits(placeId, Visits.ENTER + " DESC", null); LociLocation placeLoc = null;//from w ww .j a v a 2 s . c o m MyLog.i(LociConfig.D.DB.UTILS, TAG, String.format("[DB] estimating position from %d visits.", visits.size())); // first, check if we have a good location fix near stay time from all visits for (LociVisit visit : visits) { long enter = visit.enter; long exit = visit.exit; placeLoc = getAveragePosition(enter - 30000, exit + 30000, 100); if (placeLoc != null && placeLoc.isValid()) break; } if (placeLoc == null || !placeLoc.isValid()) { float minAccuracy = Float.MAX_VALUE; LociLocation tmpLoc = null; MyLog.i(LociConfig.D.DB.UTILS, TAG, String.format("[DB] estimated positions while staying had low accuracy, try bad accuracy.")); for (LociVisit visit : visits) { tmpLoc = getPlaceLocationEstimationWithBestAccuracy(visit.enter - 30000, visit.exit + 30000); if (tmpLoc != null) MyLog.i(LociConfig.D.DB.UTILS, TAG, String.format(" => lat=%f lon=%f acc=%f", tmpLoc.getLatitude(), tmpLoc.getLongitude(), tmpLoc.getAccuracy())); else MyLog.i(LociConfig.D.DB.UTILS, TAG, String.format(" => no location for this visit..")); if (tmpLoc != null && minAccuracy >= tmpLoc.getAccuracy()) { placeLoc = tmpLoc; minAccuracy = placeLoc.getAccuracy(); } } if (placeLoc != null) MyLog.i(LociConfig.D.DB.UTILS, TAG, String.format(" ++ picked lat=%f lon=%f acc=%f", placeLoc.getLatitude(), placeLoc.getLongitude(), placeLoc.getAccuracy())); else MyLog.i(LociConfig.D.DB.UTILS, TAG, " ++ no location satisfying condition."); } else { MyLog.i(LociConfig.D.DB.UTILS, TAG, "[DB] (1) got an estimate within a stay with good accuracy."); MyLog.i(LociConfig.D.DB.UTILS, TAG, String.format(" ++ picked lat=%f lon=%f acc=%f", placeLoc.getLatitude(), placeLoc.getLongitude(), placeLoc.getAccuracy())); // add to state LociCircleArea circle = new LociCircleArea(); circle.setCenter(placeLoc); circle.setRadius(placeLoc.getAccuracy()); circle.extra = "while staying"; return circle; } // if not, get the closest location fix from stay time if (placeLoc == null || !placeLoc.isValid()) { MyLog.i(LociConfig.D.DB.UTILS, TAG, "[DB] don't have an estimate within a stay, try closest."); long minOffTime = Long.MAX_VALUE; String finalExtra = ""; String extra = ""; long offTime = Long.MAX_VALUE; LociLocation tmpLoc = null; for (LociVisit visit : visits) { LociLocation before = getFirstLocationBeforeOrAfterTime(visit.enter, true); LociLocation after = getFirstLocationBeforeOrAfterTime(visit.exit, false); if (before != null && after != null) { MyLog.i(LociConfig.D.DB.UTILS, TAG, "[DB] has both before and after."); if (Math.abs(before.getTime() - visit.enter) < Math.abs(after.getTime() - visit.exit)) { tmpLoc = before; offTime = visit.enter - before.getTime(); extra = MyDateUtils.humanReadableDuration(offTime, 2) + "before entering"; } else { tmpLoc = after; offTime = after.getTime() - visit.exit; extra = MyDateUtils.humanReadableDuration(offTime, 2) + "after exiting"; } } else if (before != null) { MyLog.i(LociConfig.D.DB.UTILS, TAG, "[DB] has before."); tmpLoc = before; offTime = visit.enter - before.getTime(); extra = MyDateUtils.humanReadableDuration(offTime, 2) + "before entering"; } else if (after != null) { MyLog.i(LociConfig.D.DB.UTILS, TAG, "[DB] has after."); tmpLoc = after; offTime = after.getTime() - visit.exit; extra = MyDateUtils.humanReadableDuration(offTime, 2) + "after exiting"; } else { MyLog.i(LociConfig.D.DB.UTILS, TAG, "[DB] has none."); continue; } MyLog.i(LociConfig.D.DB.UTILS, TAG, String.format("[DB] offtime=%d extra=%s", offTime, extra)); if (offTime < minOffTime) { minOffTime = offTime; finalExtra = extra; placeLoc = tmpLoc; } } if (placeLoc != null && placeLoc.isValid()) { LociCircleArea circle = new LociCircleArea(); circle.setCenter(placeLoc); circle.setRadius(placeLoc.getAccuracy()); circle.extra = finalExtra; MyLog.i(LociConfig.D.DB.UTILS, TAG, "[DB] (3) got an estimate near stay"); MyLog.i(LociConfig.D.DB.UTILS, TAG, String.format(" ++ picked lat=%f lon=%f acc=%f", placeLoc.getLatitude(), placeLoc.getLongitude(), placeLoc.getAccuracy())); return circle; } else { MyLog.i(LociConfig.D.DB.UTILS, TAG, "[DB] has no gps."); } } else { MyLog.i(LociConfig.D.DB.UTILS, TAG, "[DB] (2) got an estimate within a stay with ok accuracy"); // add to state LociCircleArea circle = new LociCircleArea(); circle.setCenter(placeLoc); circle.setRadius(placeLoc.getAccuracy()); circle.extra = "while staying (low accuracy)"; MyLog.i(LociConfig.D.DB.UTILS, TAG, String.format(" ++ picked lat=%f lon=%f acc=%f", placeLoc.getLatitude(), placeLoc.getLongitude(), placeLoc.getAccuracy())); return circle; } //TODO: What should we do when no position? MyLog.i(LociConfig.D.DB.UTILS, TAG, "[DB] (4) no estimate"); LociCircleArea circle = new LociCircleArea(); circle.setCenter(34.06945, -118.443); circle.setRadius(100); circle.extra = "location is not available, default location."; return null; }
From source file:com.chiorichan.event.EventBus.java
public Map<Class<? extends Event>, Set<RegisteredListener>> createRegisteredListeners(Listener listener, final EventCreator plugin) { Validate.notNull(plugin, "Creator can not be null"); Validate.notNull(listener, "Listener can not be null"); Map<Class<? extends Event>, Set<RegisteredListener>> ret = new HashMap<Class<? extends Event>, Set<RegisteredListener>>(); Set<Method> methods; try {/* w w w . jav a 2 s .c o m*/ Method[] publicMethods = listener.getClass().getMethods(); methods = new HashSet<Method>(publicMethods.length, Float.MAX_VALUE); for (Method method : publicMethods) { methods.add(method); } for (Method method : listener.getClass().getDeclaredMethods()) { methods.add(method); } } catch (NoClassDefFoundError e) { Loader.getLogger() .severe("Plugin " + plugin.getDescription().getFullName() + " has failed to register events for " + listener.getClass() + " because " + e.getMessage() + " does not exist."); return ret; } for (final Method method : methods) { final EventHandler eh = method.getAnnotation(EventHandler.class); if (eh == null) continue; final Class<?> checkClass; if (method.getParameterTypes().length != 1 || !Event.class.isAssignableFrom(checkClass = method.getParameterTypes()[0])) { Loader.getLogger() .severe(plugin.getDescription().getFullName() + " attempted to register an invalid EventHandler method signature \"" + method.toGenericString() + "\" in " + listener.getClass()); continue; } final Class<? extends Event> eventClass = checkClass.asSubclass(Event.class); method.setAccessible(true); Set<RegisteredListener> eventSet = ret.get(eventClass); if (eventSet == null) { eventSet = new HashSet<RegisteredListener>(); ret.put(eventClass, eventSet); } for (Class<?> clazz = eventClass; Event.class.isAssignableFrom(clazz); clazz = clazz.getSuperclass()) { // This loop checks for extending deprecated events if (clazz.getAnnotation(Deprecated.class) != null) { Warning warning = clazz.getAnnotation(Warning.class); WarningState warningState = Loader.getInstance().getWarningState(); if (!warningState.printFor(warning)) { break; } Loader.getLogger().log(Level.WARNING, String.format( "\"%s\" has registered a listener for %s on method \"%s\", but the event is Deprecated." + " \"%s\"; please notify the authors %s.", plugin.getDescription().getFullName(), clazz.getName(), method.toGenericString(), (warning != null && warning.reason().length() != 0) ? warning.reason() : "Server performance will be affected", Arrays.toString(plugin.getDescription().getAuthors().toArray())), warningState == WarningState.ON ? new AuthorNagException(null) : null); break; } } EventExecutor executor = new EventExecutor() { public void execute(Listener listener, Event event) throws EventException { try { if (!eventClass.isAssignableFrom(event.getClass())) { return; } method.invoke(listener, event); } catch (InvocationTargetException ex) { throw new EventException(ex.getCause()); } catch (Throwable t) { throw new EventException(t); } } }; if (useTimings) { eventSet.add(new TimedRegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled())); } else { eventSet.add( new RegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled())); } } return ret; }
From source file:com.chiorichan.plugin.loader.JavaPluginLoader.java
public Map<Class<? extends Event>, Set<RegisteredListener>> createRegisteredListeners(Listener listener, final Plugin plugin) { Validate.notNull(plugin, "Plugin can not be null"); Validate.notNull(listener, "Listener can not be null"); boolean useTimings = Loader.getEventBus().useTimings(); Map<Class<? extends Event>, Set<RegisteredListener>> ret = new HashMap<Class<? extends Event>, Set<RegisteredListener>>(); Set<Method> methods; try {/*w w w.j a v a 2 s. c o m*/ Method[] publicMethods = listener.getClass().getMethods(); methods = new HashSet<Method>(publicMethods.length, Float.MAX_VALUE); for (Method method : publicMethods) { methods.add(method); } for (Method method : listener.getClass().getDeclaredMethods()) { methods.add(method); } } catch (NoClassDefFoundError e) { PluginManager.getLogger() .severe("Plugin " + plugin.getDescription().getFullName() + " has failed to register events for " + listener.getClass() + " because " + e.getMessage() + " does not exist."); return ret; } for (final Method method : methods) { final EventHandler eh = method.getAnnotation(EventHandler.class); if (eh == null) continue; final Class<?> checkClass; if (method.getParameterTypes().length != 1 || !Event.class.isAssignableFrom(checkClass = method.getParameterTypes()[0])) { PluginManager.getLogger() .severe(plugin.getDescription().getFullName() + " attempted to register an invalid EventHandler method signature \"" + method.toGenericString() + "\" in " + listener.getClass()); continue; } final Class<? extends Event> eventClass = checkClass.asSubclass(Event.class); method.setAccessible(true); Set<RegisteredListener> eventSet = ret.get(eventClass); if (eventSet == null) { eventSet = new HashSet<RegisteredListener>(); ret.put(eventClass, eventSet); } for (Class<?> clazz = eventClass; Event.class.isAssignableFrom(clazz); clazz = clazz.getSuperclass()) { // This loop checks for extending deprecated events if (clazz.getAnnotation(Deprecated.class) != null) { Warning warning = clazz.getAnnotation(Warning.class); WarningState warningState = Loader.getInstance().getWarningState(); if (!warningState.printFor(warning)) { break; } PluginManager.getLogger().log(Level.WARNING, String.format( "\"%s\" has registered a listener for %s on method \"%s\", but the event is Deprecated." + " \"%s\"; please notify the authors %s.", plugin.getDescription().getFullName(), clazz.getName(), method.toGenericString(), (warning != null && warning.reason().length() != 0) ? warning.reason() : "Server performance will be affected", Arrays.toString(plugin.getDescription().getAuthors().toArray())), warningState == WarningState.ON ? new AuthorNagException(null) : null); break; } } EventExecutor executor = new EventExecutor() { public void execute(Listener listener, Event event) throws EventException { try { if (!eventClass.isAssignableFrom(event.getClass())) { return; } method.invoke(listener, event); } catch (InvocationTargetException ex) { throw new EventException(ex.getCause()); } catch (Throwable t) { throw new EventException(t); } } }; if (useTimings) { eventSet.add(new TimedRegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled())); } else { eventSet.add( new RegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled())); } } return ret; }