List of usage examples for java.lang Number doubleValue
public abstract double doubleValue();
From source file:cc.redberry.core.number.Numeric.java
/** * Constructs a new {@code Numeric} instance, which {@code double} variable * is taken from {@code value.doubleValue()}. So, this constructor makes <br>{@code * this.value = value.doubleValue();/*from ww w. j a v a 2 s . co m*/ * } * * @param value the value, which double representation to be represented by * the {@code Double}. * @throws NullArgumentException if value is {@code null}. */ public Numeric(final Number value) { checkNotNull(value); this.value = value.doubleValue(); }
From source file:de.unioninvestment.eai.portal.portlet.crud.scripting.domain.container.rest.ValueConverter.java
private Object convertNumberToNumber(Class<?> targetClass, Number number) { if (targetClass.isAssignableFrom(number.getClass())) { return number; } else if (targetClass == Integer.class) { return number.intValue(); } else if (targetClass == Long.class) { return number.longValue(); } else if (targetClass == Double.class) { return number.doubleValue(); } else if (targetClass == BigDecimal.class) { return new BigDecimal(number.toString()); }/*from w ww . ja v a2s .com*/ throw new IllegalArgumentException("Cannot convert to " + targetClass.getSimpleName() + ": " + number + " of type " + number.getClass().getName()); }
From source file:de.codesourcery.flocking.ui.NumberInputField.java
protected String numberToString(Number n) { if (onlyIntValues) { return n == null ? "0" : Long.toString(n.intValue()); }/*from ww w . j a va 2s .c om*/ final DecimalFormat DF = new DecimalFormat("########0.0###"); return n == null ? "0.0" : DF.format(n.doubleValue()); }
From source file:dk.sdu.mmmi.featureous.views.featurecharacterization.FeatureViewChart.java
public FeatureViewChart(List<TraceModel> ftms, final boolean pkg) { this.pkg = pkg; data = new DefaultCategoryDataset(); chart = ChartFactory.createStackedBarChart("Feature characterization", "Feature", "Scattering", data, PlotOrientation.VERTICAL, true, false, false); plot = (CategoryPlot) chart.getPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); xAxis.setMaximumCategoryLabelLines(2); // chart.getLegend().setPosition(RectangleEdge.RIGHT); // chart.getLegend().setVerticalAlignment(VerticalAlignment.TOP); // chart.getLegend().setHorizontalAlignment(HorizontalAlignment.LEFT); LegendItemCollection lic = new LegendItemCollection(); // lic.add(new LegendItem("Infrastructural unit", "", "", "", new Rectangle(10, 10), Color.GREEN)); // lic.add(new LegendItem("Group-feature unit", "", "", "", new Rectangle(10, 10), Color.BLUE)); // lic.add(new LegendItem("Single-feature unit", "", "", "", new Rectangle(10, 10), Color.RED)); plot.setFixedLegendItems(lic);/*from w w w.j a v a 2s . co m*/ // chart.removeLegend(); panel = new ChartPanel(chart); chart.setBackgroundPaint(Color.white); this.ftms = ftms; scattering = new ArrayList<Result>( new StaticScattering(pkg).calculateAndReturnAll(new HashSet<TraceModel>(ftms), null)); Result.sortByName(scattering); for (Result r : scattering) { // OutputUtil.log(r.name + ";" +r.value); } panel.getPopupMenu().setEnabled(false);//add(SVGExporter.createExportAction(chart, panel)); StackedBarRenderer r2 = new StackedBarRenderer() { @Override public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass); double start = plot.getDomainAxis().getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double end = plot.getDomainAxis().getCategoryEnd(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); String compUnit = data.getRowKey(row).toString(); // Calculate y coeffs double posBase = getBase(); for (int i = 0; i < row; i++) { Number val = dataset.getValue(i, column); if (val != null) { posBase = posBase + val.doubleValue(); } } Number value = dataset.getValue(row, column); if (value == null) { return; } double val = value.doubleValue(); double translatedBase = plot.getRangeAxis().valueToJava2D(posBase, dataArea, plot.getRangeAxisEdge()); double translatedValue = plot.getRangeAxis().valueToJava2D(posBase + val, dataArea, plot.getRangeAxisEdge()); if (Controller.getInstance().getTraceSet().getSelectionManager().getSelectedClasses() .contains(compUnit) || Controller.getInstance().getTraceSet().getSelectionManager().getSelectedPkgs() .contains(compUnit)) { g2.setPaint(UIUtils.SELECTION_COLOR); g2.setStroke(new BasicStroke(3f)); Line2D l2d = new Line2D.Double(start, translatedBase, start, translatedValue); g2.draw(l2d); l2d = new Line2D.Double(end, translatedBase, end, translatedValue); g2.draw(l2d); l2d = new Line2D.Double(start, translatedBase, end, translatedBase); g2.draw(l2d); l2d = new Line2D.Double(start, translatedValue, end, translatedValue); g2.draw(l2d); } } }; plot.setRenderer(r2, true); StackedBarRenderer r = (StackedBarRenderer) plot.getRenderer(); r.setDrawBarOutline(true); plot.getRenderer().setOutlineStroke(new BasicStroke(0.1f)); Controller.getInstance().getTraceSet().getSelectionManager().addSelectionListener(this); }
From source file:org.jfree.data.xy.DefaultHighLowDataset.java
/** * Returns the low-value (as a double primitive) for an item within a * series.//w w w .j a va 2 s .com * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The low-value. * * @see #getLow(int, int) */ @Override public double getLowValue(int series, int item) { double result = Double.NaN; Number l = getLow(series, item); if (l != null) { result = l.doubleValue(); } return result; }
From source file:org.jfree.data.xy.DefaultHighLowDataset.java
/** * Returns the high-value (as a double primitive) for an item within a * series.//from w ww.ja va 2 s. c o m * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The high-value. * * @see #getHigh(int, int) */ @Override public double getHighValue(int series, int item) { double result = Double.NaN; Number h = getHigh(series, item); if (h != null) { result = h.doubleValue(); } return result; }
From source file:org.jfree.data.xy.DefaultHighLowDataset.java
/** * Returns the close-value (as a double primitive) for an item within a * series./*from ww w.jav a 2 s .c o m*/ * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The close-value. * * @see #getClose(int, int) */ @Override public double getCloseValue(int series, int item) { double result = Double.NaN; Number c = getClose(series, item); if (c != null) { result = c.doubleValue(); } return result; }
From source file:org.jstockchart.plot.TimeseriesPlot.java
private XYPlot createPricePlot() { Font axisFont = new Font("Arial", 0, 12); Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); PriceArea priceArea = timeseriesArea.getPriceArea(); Color averageColor = new Color(243, 182, 117); priceArea.setAverageColor(averageColor); priceArea.setPriceColor(Color.BLUE); TimeSeriesCollection priceDataset = new TimeSeriesCollection(); priceDataset.addSeries(dataset.getPriceTimeSeries().getTimeSeries()); if (priceArea.isAverageVisible()) { priceDataset.addSeries(dataset.getAverageTimeSeries().getTimeSeries()); }/*from www. j a va2s . c o m*/ CentralValueAxis logicPriceAxis = priceArea.getLogicPriceAxis(); logicPriceAxis.setTickCount(7); CFXNumberAxis priceAxis = new CFXNumberAxis(logicPriceAxis.getLogicTicks()); priceAxis.setShowUD(true); priceAxis.setOpenPrice(logicPriceAxis.getCentralValue().doubleValue()); priceAxis.setTickMarksVisible(false); XYLineAndShapeRenderer priceRenderer = new XYLineAndShapeRenderer(true, false); priceAxis.setUpperBound(logicPriceAxis.getUpperBound()); priceAxis.setLowerBound(logicPriceAxis.getLowerBound()); priceAxis.setAxisLineVisible(false); priceAxis.setTickLabelFont(axisFont); priceRenderer.setSeriesPaint(0, priceArea.getPriceColor()); priceRenderer.setSeriesPaint(1, priceArea.getAverageColor()); CFXNumberAxis rateAxis = new CFXNumberAxis(logicPriceAxis.getRatelogicTicks()); rateAxis.setShowUD(true); rateAxis.setOpenPrice(logicPriceAxis.getCentralValue().doubleValue()); rateAxis.setTickMarksVisible(false); ; rateAxis.setTickLabelFont(axisFont); rateAxis.setAxisLineVisible(false); rateAxis.setUpperBound(logicPriceAxis.getUpperBound()); rateAxis.setLowerBound(logicPriceAxis.getLowerBound()); XYPlot plot = new XYPlot(priceDataset, null, priceAxis, priceRenderer); plot.setBackgroundPaint(priceArea.getBackgroudColor()); plot.setOrientation(priceArea.getOrientation()); plot.setRangeAxisLocation(priceArea.getPriceAxisLocation()); plot.setRangeMinorGridlinesVisible(false); Stroke outLineStroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); Stroke gridLineStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] { 2.0f, 2.0f }, 1.0f); plot.setRangeGridlineStroke(gridLineStroke); plot.setDomainGridlineStroke(gridLineStroke); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); plot.setOutlineVisible(true); plot.setOutlineStroke(outLineStroke); plot.setOutlinePaint(Color.BLACK); if (priceArea.isRateVisible()) { plot.setRangeAxis(1, rateAxis); plot.setRangeAxisLocation(1, priceArea.getRateAxisLocation()); plot.setDataset(1, null); plot.mapDatasetToRangeAxis(1, 1); } if (priceArea.isMarkCentralValue()) { Number centralPrice = logicPriceAxis.getCentralValue(); if (centralPrice != null) { plot.addRangeMarker(new ValueMarker(centralPrice.doubleValue(), priceArea.getCentralPriceColor(), new BasicStroke())); } } return plot; }
From source file:ai.grakn.graql.internal.template.TemplateVisitor.java
@Override public Boolean visitGreaterExpression(GraqlTemplateParser.GreaterExpressionContext ctx) { Object lValue = this.visit(ctx.expr(0)); Object rValue = this.visit(ctx.expr(1)); if (!(lValue instanceof Number) || !(rValue instanceof Number)) { throw GraqlSyntaxException.parsingTemplateError("GREATER THAN", ctx.getText(), originalContext); }//from www. j a v a2s .c o m Number lNumber = (Number) lValue; Number rNumber = (Number) rValue; return lNumber.doubleValue() > rNumber.doubleValue(); }
From source file:ai.grakn.graql.internal.template.TemplateVisitor.java
@Override public Boolean visitGreaterEqExpression(GraqlTemplateParser.GreaterEqExpressionContext ctx) { Object lValue = this.visit(ctx.expr(0)); Object rValue = this.visit(ctx.expr(1)); if (!(lValue instanceof Number) || !(rValue instanceof Number)) { throw GraqlSyntaxException.parsingTemplateError("GREATER THAN EQUALS", ctx.getText(), originalContext); }//ww w .j ava 2 s .c o m Number lNumber = (Number) lValue; Number rNumber = (Number) rValue; return lNumber.doubleValue() >= rNumber.doubleValue(); }