List of usage examples for java.lang Number doubleValue
public abstract double doubleValue();
From source file:org.ietr.preesm.mapper.ui.MyGanttRenderer.java
/** * Draws the tasks/subtasks for one item. * /*w w w . ja v a2 s .c o m*/ * @param g2 * the graphics device. * @param state * the renderer state. * @param dataArea * the data plot area. * @param plot * the plot. * @param domainAxis * the domain axis. * @param rangeAxis * the range axis. * @param dataset * the data. * @param row * the row index (zero-based). * @param column * the column index (zero-based). */ @Override protected void drawTasks(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, GanttCategoryDataset dataset, int row, int column) { int count = dataset.getSubIntervalCount(row, column); if (count == 0) { drawTask(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column); } for (int subinterval = 0; subinterval < count; subinterval++) { RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); // value 0 Number value0 = dataset.getStartValue(row, column, subinterval); if (value0 == null) { return; } double translatedValue0 = rangeAxis.valueToJava2D(value0.doubleValue(), dataArea, rangeAxisLocation); // value 1 Number value1 = dataset.getEndValue(row, column, subinterval); if (value1 == null) { return; } double translatedValue1 = rangeAxis.valueToJava2D(value1.doubleValue(), dataArea, rangeAxisLocation); if (translatedValue1 < translatedValue0) { double temp = translatedValue1; translatedValue1 = translatedValue0; translatedValue0 = temp; } double rectStart = calculateBarW0(plot, plot.getOrientation(), dataArea, domainAxis, state, row, column); double rectLength = Math.abs(translatedValue1 - translatedValue0); double rectBreadth = state.getBarWidth(); // DRAW THE BARS... RoundRectangle2D bar = null; bar = new RoundRectangle2D.Double(translatedValue0, rectStart, rectLength, rectBreadth, 10.0, 10.0); /* Paint seriesPaint = */getItemPaint(row, column); if (((TaskSeriesCollection) dataset).getSeriesCount() > 0) if (((TaskSeriesCollection) dataset).getSeries(0).getItemCount() > column) if (((TaskSeriesCollection) dataset).getSeries(0).get(column).getSubtaskCount() > subinterval) { g2.setPaint(getRandomBrightColor(((TaskSeriesCollection) dataset).getSeries(0).get(column) .getSubtask(subinterval).getDescription())); } g2.fill(bar); if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { g2.setStroke(getItemStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(bar); } // Displaying the tooltip inside the bar if enough space is // available if (getToolTipGenerator(row, column) != null) { // Getting the string to display String tip = getToolTipGenerator(row, column).generateToolTip(dataset, subinterval, column); // Truncting the string if it is too long String subtip = ""; if (rectLength > 0) { double percent = (g2.getFontMetrics().getStringBounds(tip, g2).getWidth() + 10) / rectLength; if (percent > 1.0) { subtip = tip.substring(0, (int) (tip.length() / percent)); } else if (percent > 0) { subtip = tip; } // Setting font and color Font font = new Font("Garamond", Font.BOLD, 12); g2.setFont(font); g2.setColor(Color.WHITE); // Testing width and displaying if (!subtip.isEmpty()) { g2.drawString(subtip, (int) translatedValue0 + 5, (int) rectStart + g2.getFontMetrics().getHeight()); } } } // collect entity and tool tip information... if (state.getInfo() != null) { EntityCollection entities = state.getEntityCollection(); if (entities != null) { String tip = null; if (getToolTipGenerator(row, column) != null) { tip = getToolTipGenerator(row, column).generateToolTip(dataset, subinterval, column); } String url = null; if (getItemURLGenerator(row, column) != null) { url = getItemURLGenerator(row, column).generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(bar, tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); } } } }
From source file:org.jfree.chart.demo.SampleXYSymbolicDataset.java
/** * Returns the x-value (as a double primitive) for an item within a series. * /*from ww w. j a va 2 s . c o m*/ * @param series * the series (zero-based index). * @param item * the item (zero-based index). * @return The x-value. */ public double getX(int series, int item) { double result = Double.NaN; Number x = getXValue(series, item); if (x != null) { result = x.doubleValue(); } return result; }
From source file:org.jfree.chart.demo.SampleXYSymbolicDataset.java
/** * Returns the y-value (as a double primitive) for an item within a series. * // w w w. ja v a2 s .co m * @param series * the series (zero-based index). * @param item * the item (zero-based index). * @return The y-value. */ public double getY(int series, int item) { double result = Double.NaN; Number y = getYValue(series, item); if (y != null) { result = y.doubleValue(); } return result; }
From source file:io.coala.random.impl.RandomDistributionFactoryImpl.java
@Override public RandomNumberDistribution<Integer> getBinomial(final RandomNumberStream rng, final Number trials, final Number p) { final IntegerDistribution dist = new BinomialDistribution( RandomNumberStream.Util.asCommonsRandomGenerator(rng), trials.intValue(), p.doubleValue()); return new RandomNumberDistribution<Integer>() { @Override//from w ww . j a v a 2 s .c o m public Integer draw() { return dist.sample(); } }; }
From source file:edu.uci.ics.jung.algorithms.scoring.DistanceCentralityScorer.java
/** * Calculates the score for the specified vertex. Returns {@code null} if * there are missing distances and such are not ignored by this instance. */// w w w. j a v a 2 s . c o m public Double getVertexScore(V v) { Double value = output.get(v); if (value != null) { if (value < 0) return null; return value; } Map<V, Number> v_distances = new HashMap<V, Number>(distance.getDistanceMap(v)); if (ignore_self_distances) v_distances.remove(v); // if we don't ignore missing distances and there aren't enough // distances, output null (shortcut) if (!ignore_missing) { int num_dests = graph.getVertexCount() - (ignore_self_distances ? 1 : 0); if (v_distances.size() != num_dests) { output.put(v, -1.0); return null; } } Double sum = 0.0; for (V w : graph.getVertices()) { if (w.equals(v) && ignore_self_distances) continue; Number w_distance = v_distances.get(w); if (w_distance == null) if (ignore_missing) continue; else { output.put(v, -1.0); return null; } else sum += w_distance.doubleValue(); } value = sum; if (averaging) value /= v_distances.size(); double score = value == 0 ? Double.POSITIVE_INFINITY : 1.0 / value; output.put(v, score); return score; }
From source file:main.java.edu.isistan.genCom.redSocial.RedSocial.java
/** * Returns the degree of reachability by getting the distances of every pair of vertices in the network when a vertices set is removed * network//from w w w .j a v a 2s .c o m * * Degree of reachability by Borgatti * * @param comission * Nodes to be removed * @return List of distances */ public List<Double> getDegreeOfReachability(List<Investigador> comission) { List<Double> distancias = new ArrayList<>(); try { RedSocial reduced = null; reduced = (RedSocial) this.clone(); Set<Investigador> invSet = new HashSet<>(getNodos()); invSet.removeAll(comission); reduced.reducirA(invSet); UnweightedShortestPath<Investigador, String> uWSP = new UnweightedShortestPath(reduced.getRed()); List<Investigador> nodos = reduced.getNodos(); for (int i = 0; i < nodos.size(); i++) { Investigador inv1 = nodos.get(i); for (int j = 0; j < i; j++) { Investigador inv2 = nodos.get(j); Number dist = uWSP.getDistance(inv1, inv2); Double d = dist != null ? dist.doubleValue() : Double.POSITIVE_INFINITY; distancias.add(d); } } } catch (CloneNotSupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return distancias; }
From source file:io.coala.random.impl.RandomDistributionFactoryImpl.java
@Override public RandomNumberDistribution<Integer> getPoisson(final RandomNumberStream rng, final Number alpha, final Number beta) { final IntegerDistribution dist = new BinomialDistribution( RandomNumberStream.Util.asCommonsRandomGenerator(rng), alpha.intValue(), beta.doubleValue()); return new RandomNumberDistribution<Integer>() { @Override/* www .j a v a2s . c o m*/ public Integer draw() { return dist.sample(); } }; }
From source file:com.isentropy.accumulo.test.AccumuloMapTest.java
public void testFixedPointSerde(Connector c) throws AccumuloException, AccumuloSecurityException { AccumuloSortedMap asm = new AccumuloSortedMap(c, "testfp" + Util.randomHexString(10)); SerDe s = new FixedPointSerde(); byte zero = 0; asm.setKeySerde(s).setValueSerde(s); asm.put(-2, "minus two"); asm.put(-1.5f, "minus one point 5"); asm.put(-1, "minus one"); asm.put(zero, "zero"); asm.put(1l, "one"); asm.put(2, "two"); asm.put(1.4, "one point 4"); asm.put("a", "A"); asm.put("aa", "AA"); asm.put("b", "bbb"); asm.put("abb", "Abb"); byte[] byteKey = "bytes".getBytes(); asm.put(byteKey, "bytessss".getBytes()); AccumuloSortedMap<Number, Object> numbers = asm.subMap(-3, 3); assertTrue(numbers.size() == 7);//from w w w . j a va 2s . c o m Iterator<Number> it = numbers.keySet().iterator(); assertTrue(it.next().equals(-2l)); assertTrue(it.next().equals(-1.5)); Double prev = null; for (Number n : numbers.keySet()) { double d = n.doubleValue(); if (prev != null && prev > d) fail(); prev = d; } }
From source file:org.pentaho.plugin.jfreereport.reportcharts.backport.StackedAreaRenderer.java
/** * Calculates the stacked values (one positive and one negative) of all series up to, but not including, * <code>series</code> for the specified item. It returns [0.0, 0.0] if <code>series</code> is the first series. * * @param dataset the dataset (<code>null</code> not permitted). * @param series the series index./*from w w w . ja v a 2 s . c o m*/ * @param index the item index. * @return An array containing the cumulative negative and positive values for all series values up to but excluding * <code>series</code> for <code>index</code>. */ protected double[] getStackValues(final CategoryDataset dataset, final int series, final int index) { final double[] result = new double[2]; double total = 0.0; if (this.renderAsPercentages) { total = DataUtilities.calculateColumnTotal(dataset, index); } for (int i = 0; i < series; i++) { if (isSeriesVisible(i)) { double v = 0.0; final Number n = dataset.getValue(i, index); if (n != null) { v = n.doubleValue(); if (this.renderAsPercentages) { v = v / total; } } if (!Double.isNaN(v)) { if (v >= 0.0) { result[1] += v; } else { result[0] += v; } } } } return result; }
From source file:io.coala.time.AbstractInstant.java
/** @see Instant#minus(Number, TimeUnit) */ @Override//from w w w . j a va 2 s . c o m public THIS minus(final Number value, final TimeUnit unit) { return plus(-value.doubleValue(), unit); }