List of usage examples for java.lang Number doubleValue
public abstract double doubleValue();
From source file:org.jfree.chart.demo.CompassDemo.java
/** * Updates the data.//from ww w . j a va 2 s. c o m * * @param value the value. */ public void adjustData(final double value) { final Number val = this.compassData.getValue(); double newVal = value; if (val != null) { newVal += val.doubleValue(); } if (newVal > 360) { newVal = 0; } if (newVal < 0) { newVal = 360; } this.compassData.setValue(new Double(newVal)); }
From source file:jgnash.ui.commodity.SecurityItemLabelGenerator.java
/** * Generates a tooltip text item for a particular item within a series. * * @param dataset the dataset./*from www. j a va 2 s .c o m*/ * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The tooltip text. */ @Override public String generateToolTip(final XYDataset dataset, final int series, final int item) { String result = null; if (dataset instanceof OHLCDataset) { OHLCDataset d = (OHLCDataset) dataset; Number close = d.getClose(series, item); Number x = d.getX(series, item); if (x != null) { Date date = new Date(x.longValue()); result = dateLabel + " " + dateFormatter.format(date); if (close != null) { result = result + " " + closeLabel + " " + numberFormatter.format(close.doubleValue()); } } } return result; }
From source file:org.jfree.data.xy.XYBarDataset.java
/** * Returns the starting X value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value./*from ww w.ja v a 2s. c o m*/ */ @Override public Number getStartX(int series, int item) { Number result = null; Number xnum = this.underlying.getX(series, item); if (xnum != null) { result = xnum.doubleValue() - this.barWidth / 2.0; } return result; }
From source file:org.jfree.data.xy.XYBarDataset.java
/** * Returns the ending X value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value.//from w w w. j a v a2 s . co m */ @Override public Number getEndX(int series, int item) { Number result = null; Number xnum = this.underlying.getX(series, item); if (xnum != null) { result = xnum.doubleValue() + this.barWidth / 2.0; } return result; }
From source file:de.micromata.mgc.javafx.launcher.gui.AbstractMainWindow.java
@Override public void initializeWithModel() { Thread currentThread = Thread.currentThread(); currentThread.setUncaughtExceptionHandler(model.getUncaughtExceptionHandler()); addCss();/*from w w w . j a v a 2 s .c om*/ LauncherLocalSettingsConfigModel config = MgcLauncher.getLauncherConfig(); if (config.isEnableLF5() == false) { launchMenu.setVisible(false); } if (SystemService.get().getOsType() != OsType.Windows) { hideWindowMenu.setVisible(false); } stage.setOnCloseRequest(event -> { if (SystemService.get().getOsType() != OsType.Windows) { event.consume(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(model.getTranslateService().translate("mgc.launcher.gui.quitconfirmation.title")); alert.setHeaderText( model.getTranslateService().translate("mgc.launcher.gui.quitconfirmation.header")); alert.setContentText( model.getTranslateService().translate("mgc.launcher.gui.quitconfirmation.message")); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { closeApplication(null); } } }); startServerButton.setOnAction(e -> { startServer(); }); stopServerButton.setOnAction(e -> { stopServer(); }); stopServerButton.setDisable(true); boolean runnin = MgcLauncher.get().getApplication().isRunning(); startServerButton.setDisable(runnin); stopServerButton.setDisable(runnin == false); openBrowser.setDisable(runnin == false); addStartServerEventHandler(); addStopServerEventHandler(); openBrowser.setOnAction(e -> { launchBrowser(); }); loggingPane.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { loggingController.adjustWidth(newSceneWidth.doubleValue()); } }); loggingPane.heightProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { loggingController.adjustHeight(newSceneWidth.doubleValue()); } }); loggingController.adjustHeight(loggingPane.getHeight()); loggingController.adjustWidth(loggingPane.getWidth()); MgcEventRegistries.getEventInstanceRegistry() .registerListener(new MgcApplicationStartStopToEventListener()); String helpUrl = getModel().getApplicationInfo().getHelpUrl(); if (StringUtils.isBlank(helpUrl) == true) { helpButton.setVisible(false); } else { helpButton.setOnAction(event -> { SystemService.get().openUrlInBrowser(helpUrl); }); } FXEvents.get().addEventHandler(this, stopServerButton, MgcLauncherEvent.APP_STARTED, event -> { if (config.isStartBrowserOnStartup() == true) { launchBrowser(); } }); }
From source file:edu.uci.ics.jung.algorithms.importance.AbstractRanker.java
public double getEdgeRankScore(E e) { Number rankScore = edgeRankScores.get(getRankScoreKey()).get(e); if (rankScore != null) { return rankScore.doubleValue(); } else {/* w w w . j a v a 2 s .c o m*/ throw new RuntimeException("setRemoveRankScoresOnFinalize(false) must be called before evaluate()."); } }
From source file:dk.sdu.mmmi.featureous.views.codecharacterization.TanglingViewChart.java
public TanglingViewChart(boolean pkg, boolean sortByValue) { this.sortByValue = sortByValue; this.pkg = pkg; data = new DefaultKeyedValues2DDataset(); String title = "Computational unit characterization"; jchart = ChartFactory.createStackedBarChart(title, (pkg) ? "Package" : "Class", "Tangling", data, PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) jchart.getPlot(); // 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 ww w . j av a 2s. c o m // chart.removeLegend(); plot.setDomainAxis(new SparselyLabeledCategoryAxis(20)); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); xAxis.setLabel((pkg) ? "Package" : "Class"); // xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 5, 5)); // xAxis.setMaximumCategoryLabelLines(1); xAxis.setLowerMargin(0); xAxis.setCategoryMargin(0); xAxis.setUpperMargin(0); // xAxis.setMaximumCategoryLabelWidthRatio(20f); jchart.setBackgroundPaint(Color.white); StackedBarRenderer renderer = 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); } } }; renderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset cd, int i, int i1) { String key = data.getRowKey(i).toString(); // key = key.substring(0, key.length()-1); return "<html>" + i + " - " + key + "<br>" + Double.toString(cd.getValue(i, i1).doubleValue()) + "</hmtl>"; } }); plot.setRenderer(renderer); panel = new ChartPanel(jchart); panel.getPopupMenu().setEnabled(false);//add(SVGExporter.createExportAction(chart, panel)); createView(); Controller.getInstance().getTraceSet().getSelectionManager().addSelectionListener(this); }
From source file:org.jfree.data.statistics.DefaultMultiValueCategoryDataset.java
/** * Adds a list of values to the dataset (<code>null</code> and Double.NaN * items are automatically removed) and sends a {@link DatasetChangeEvent} * to all registered listeners.//from ww w.j a va 2 s. c o m * * @param values a list of values (<code>null</code> not permitted). * @param rowKey the row key (<code>null</code> not permitted). * @param columnKey the column key (<code>null</code> not permitted). */ public void add(List values, Comparable rowKey, Comparable columnKey) { ParamChecks.nullNotPermitted(values, "values"); ParamChecks.nullNotPermitted(rowKey, "rowKey"); ParamChecks.nullNotPermitted(columnKey, "columnKey"); List vlist = new ArrayList(values.size()); Iterator iterator = values.listIterator(); while (iterator.hasNext()) { Object obj = iterator.next(); if (obj instanceof Number) { Number n = (Number) obj; double v = n.doubleValue(); if (!Double.isNaN(v)) { vlist.add(n); } } } Collections.sort(vlist); this.data.addObject(vlist, rowKey, columnKey); if (vlist.size() > 0) { double maxval = Double.NEGATIVE_INFINITY; double minval = Double.POSITIVE_INFINITY; for (int i = 0; i < vlist.size(); i++) { Number n = (Number) vlist.get(i); double v = n.doubleValue(); minval = Math.min(minval, v); maxval = Math.max(maxval, v); } // update the cached range values... if (this.maximumRangeValue == null) { this.maximumRangeValue = new Double(maxval); } else if (maxval > this.maximumRangeValue.doubleValue()) { this.maximumRangeValue = new Double(maxval); } if (this.minimumRangeValue == null) { this.minimumRangeValue = new Double(minval); } else if (minval < this.minimumRangeValue.doubleValue()) { this.minimumRangeValue = new Double(minval); } this.rangeBounds = new Range(this.minimumRangeValue.doubleValue(), this.maximumRangeValue.doubleValue()); } fireDatasetChanged(); }
From source file:edu.uci.ics.jung.algorithms.importance.AbstractRanker.java
/** * Given an edge or node, returns the corresponding rank score. This is a default * implementation of getRankScore which assumes the decorations are of type MutableDouble. * This method only returns legal values if <code>setRemoveRankScoresOnFinalize(false)</code> was called * prior to <code>evaluate()</code>. * @return the rank score value/*from w w w . j ava2s . c om*/ */ public double getVertexRankScore(V v) { Number rankScore = vertexRankScores.get(getRankScoreKey()).get(v); if (rankScore != null) { return rankScore.doubleValue(); } else { throw new RuntimeException("setRemoveRankScoresOnFinalize(false) must be called before evaluate()."); } }
From source file:org.pentaho.plugin.jfreereport.reportcharts.RadarChartExpression.java
private double computeMaxValue(final DefaultCategoryDataset defaultDataset) { final int rows = defaultDataset.getRowCount(); final int columns = defaultDataset.getColumnCount(); double maxdata = 0.01; for (int r = 0; r < rows; r++) { for (int cc = 0; cc < columns; cc++) { final Number value = defaultDataset.getValue(r, cc); if (value == null) { continue; }// w w w.j a va2s.c o m if (value.doubleValue() > maxdata) { maxdata = value.doubleValue(); } } } return maxdata; }