List of usage examples for java.text NumberFormat getInstance
public static final NumberFormat getInstance()
From source file:com.alibaba.druid.benckmark.pool.Case3.java
private void p0(final DataSource dataSource, String name, int threadCount) throws Exception { final AtomicInteger count = new AtomicInteger(); final AtomicInteger errorCount = new AtomicInteger(); final CountDownLatch startLatch = new CountDownLatch(1); final CountDownLatch endLatch = new CountDownLatch(threadCount); for (int i = 0; i < threadCount; ++i) { Thread thread = new Thread() { public void run() { try { startLatch.await();/*from www . j a v a 2 s .c o m*/ for (int i = 0; i < LOOP_COUNT; ++i) { Connection conn = dataSource.getConnection(); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql); while (rs.next()) { rs.getInt(1); } rs.close(); stmt.close(); conn.close(); count.incrementAndGet(); } } catch (Throwable ex) { errorCount.incrementAndGet(); ex.printStackTrace(); } finally { endLatch.countDown(); } } }; thread.start(); } long startMillis = System.currentTimeMillis(); long startYGC = TestUtil.getYoungGC(); long startFullGC = TestUtil.getFullGC(); startLatch.countDown(); endLatch.await(); long millis = System.currentTimeMillis() - startMillis; long ygc = TestUtil.getYoungGC() - startYGC; long fullGC = TestUtil.getFullGC() - startFullGC; Assert.assertEquals(LOOP_COUNT * threadCount, count.get()); Thread.sleep(1); System.out.println("thread " + threadCount + " " + name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC); }
From source file:v800_trainer.JUebersicht.java
public JPanel Update_Uebersicht(JCicloTronic JTronicHandle) { int i;//from ww w . ja v a 2 s . co m Day xTime[]; Today = new GregorianCalendar(); double y1Werte[]; double y2Werte[]; double y3Werte[]; double y4Werte[]; double y5Werte[]; double y6Werte[]; double y7Werte[]; double y8Werte[]; double y9Werte[]; double y10Werte[]; double SummeZeit = 0; double Summekm = 0; double Summehm = 0; double SummeZeit12Mon = 0; double Summekm12Mon = 0; double Summehm12Mon = 0; int AnzahlJahre = 0; int Selektiert = 0; int SelektiertVergl = 0; int Jahr; int Linecount = 0; boolean Vergleich = false; XYItemRenderer renderer; XYBarRenderer rendererb; JFreeChart chart; AnzahlJahre = JTronicHandle.Auswahl_bersicht.getItemCount(); Selektiert = JTronicHandle.Auswahl_bersicht.getSelectedIndex(); SelektiertVergl = JTronicHandle.JahrVergleich.getSelectedIndex(); if (SelektiertVergl == 0 || Selektiert == SelektiertVergl - 1) Vergleich = false; else Vergleich = true; xTime = new Day[366]; y1Werte = new double[366]; y2Werte = new double[366]; y3Werte = new double[366]; y4Werte = new double[366]; y5Werte = new double[366]; y6Werte = new double[366]; y7Werte = new double[366]; y8Werte = new double[366]; y9Werte = new double[366]; y10Werte = new double[366]; TimeSeries dataset; dataset = new TimeSeries("dummy"); dataset.add(new Day(1, 1, 1900), 1); TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); chart = ChartFactory.createTimeSeriesChart( "Jahresbersicht " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString(), "Zeit", "", dataset1, true, true, true); XYToolTipGenerator ToolTip = new StandardXYToolTipGenerator("{0}: ({1}, {2})", (DateFormat) new SimpleDateFormat("dd.MM"), NumberFormat.getInstance()); if (SelektiertVergl != 0) chart.addSubtitle(new TextTitle( "Vergleich mit Jahr " + JTronicHandle.JahrVergleich.getSelectedItem().toString())); chart.setBackgroundPaint(Color.white); JTronicHandle.applyChartTheme(chart); XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairLockedOnData(false); plot.setDomainCrosshairLockedOnData(false); if (!JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { DateAxis MyAxis = new DateAxis(); MyAxis = (DateAxis) plot.getDomainAxis(); MyAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); MyAxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); plot.setDomainGridlinesVisible(false); } plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.getRangeAxis().setFixedDimension(15.0); plot.getDomainAxis().setTickLabelInsets(new RectangleInsets(2.0, 1.0, 2.0, 1.0)); Jahr = Integer.parseInt(JTronicHandle.Auswahl_bersicht.getSelectedItem().toString()); for (i = 0; i < 366; i++) { SummeZeit12Mon += (double) Zeit[Selektiert + 1][i]; Summekm12Mon += (double) kmJahr[Selektiert + 1][i]; Summehm12Mon += (double) HmJahr[Selektiert + 1][i]; } y4Werte[0] = SummeZeit12Mon; y5Werte[0] = Summekm12Mon; y6Werte[0] = Summehm12Mon; xTime[0] = new Day(31, 12, Jahr - 1); for (i = 1; i < 366; i++) { try { xTime[i] = new Day(xTime[i - 1].next().getStart()); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Exception GregorianCalender " + e, "Achtung!", JOptionPane.ERROR_MESSAGE); } if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { SummeZeit += (double) Zeit[Selektiert][i]; Summekm += (double) kmJahr[Selektiert][i]; Summehm += (double) HmJahr[Selektiert][i]; y1Werte[i] = SummeZeit; y2Werte[i] = Summekm; y3Werte[i] = Summehm; y4Werte[i] = y4Werte[i - 1] - (double) Zeit[Selektiert + 1][i] + (double) Zeit[Selektiert][i]; y5Werte[i] = y5Werte[i - 1] - (double) kmJahr[Selektiert + 1][i] + (double) kmJahr[Selektiert][i]; y6Werte[i] = y6Werte[i - 1] - (double) HmJahr[Selektiert + 1][i] + (double) HmJahr[Selektiert][i]; } else { Day n = new Day(1, xTime[i].getMonth(), xTime[i].getYear()); try { Kalender = new GregorianCalendar(xTime[i].getYear(), xTime[i].getMonth() - 1, 1); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Exception GregorianCalender " + e, "Achtung!", JOptionPane.ERROR_MESSAGE); } int j = (int) Kalender.get(Kalender.DAY_OF_YEAR); for (int m = 0; m < 6; m++) { y1Werte[j + m + 1] += (double) Zeit[Selektiert][i]; y2Werte[j + m + 11] += (double) kmJahr[Selektiert][i]; y3Werte[j + m + 21] += (double) HmJahr[Selektiert][i]; } } } dataset = new TimeSeries("Trainingszeit " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString()); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y1Werte[i]); } dataset1 = new TimeSeriesCollection(dataset); NumberAxis axis = new NumberAxis(); try { axis = (NumberAxis) plot.getRangeAxis().clone(); } catch (Exception e) { } axis.setLabel("Stunden"); axis.setAutoRangeIncludesZero(true); axis.setLabelPaint(Color.BLACK); axis.setTickLabelPaint(Color.BLACK); plot.setRangeAxis(0, axis); plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setDrawBarOutline(false); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; dataset = new TimeSeries( "Trainingskilometer " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString()); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y2Werte[i]); } TimeSeriesCollection dataset2 = new TimeSeriesCollection(dataset); NumberAxis axis2 = new NumberAxis(); try { axis2 = (NumberAxis) plot.getRangeAxis().clone(); } catch (Exception e) { } ; axis2.setLabel("Kilometer"); axis2.setAutoRangeIncludesZero(true); axis2.setLabelPaint(Color.BLACK); axis2.setTickLabelPaint(Color.BLACK); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); plot.setDataset(Linecount, dataset2); plot.mapDatasetToRangeAxis(Linecount, 1); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setDrawBarOutline(false); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; dataset = new TimeSeries( "Trainingshhenmeter " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString()); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y3Werte[i]); } TimeSeriesCollection dataset3 = new TimeSeriesCollection(dataset); NumberAxis axis3 = new NumberAxis("Hhenmeter"); try { axis3 = (NumberAxis) plot.getRangeAxis().clone(); } catch (Exception e) { } ; axis3.setLabel("Hhenmeter"); axis3.setAutoRangeIncludesZero(true); axis3.setLabelPaint(Color.BLACK); axis3.setTickLabelPaint(Color.BLACK); plot.setRangeAxis(2, axis3); plot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(Linecount, dataset3); plot.mapDatasetToRangeAxis(Linecount, 2); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setDrawBarOutline(false); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; if (Vergleich == true) { SummeZeit = 0; Summekm = 0; Summehm = 0; SummeZeit12Mon = 0; Summekm12Mon = 0; Summehm12Mon = 0; for (i = 0; i < 366; i++) { SummeZeit12Mon += (double) Zeit[SelektiertVergl - 1][i]; Summekm12Mon += (double) kmJahr[SelektiertVergl - 1][i]; Summehm12Mon += (double) HmJahr[SelektiertVergl - 1][i]; } y4Werte[0] = SummeZeit12Mon; y5Werte[0] = Summekm12Mon; y6Werte[0] = Summehm12Mon; for (i = 1; i < 366; i++) { try { } catch (Exception e) { JOptionPane.showMessageDialog(null, "Exception GregorianCalender " + e, "Achtung!", JOptionPane.ERROR_MESSAGE); } ; if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { SummeZeit += (double) Zeit[SelektiertVergl - 1][i]; Summekm += (double) kmJahr[SelektiertVergl - 1][i]; Summehm += (double) HmJahr[SelektiertVergl - 1][i]; y7Werte[i] = SummeZeit; y8Werte[i] = Summekm; y9Werte[i] = Summehm; y4Werte[i] = y4Werte[i - 1] - (double) Zeit[SelektiertVergl - 1][i] + (double) Zeit[Selektiert][i]; y5Werte[i] = y5Werte[i - 1] - (double) kmJahr[SelektiertVergl - 1][i] + (double) kmJahr[Selektiert][i]; y6Werte[i] = y6Werte[i - 1] - (double) HmJahr[SelektiertVergl - 1][i] + (double) HmJahr[Selektiert][i]; } else { Day n = new Day(1, xTime[i].getMonth(), xTime[i].getYear()); try { Kalender = new GregorianCalendar(xTime[i].getYear(), xTime[i].getMonth() - 1, 1); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Exception GregorianCalender " + e, "Achtung!", JOptionPane.ERROR_MESSAGE); } int j = (int) Kalender.get(Kalender.DAY_OF_YEAR); for (int m = 0; m < 5; m++) { y7Werte[j + m + 4] += (double) Zeit[SelektiertVergl - 1][i]; y8Werte[j + m + 14] += (double) kmJahr[SelektiertVergl - 1][i]; y9Werte[j + m + 24] += (double) HmJahr[SelektiertVergl - 1][i]; } } } if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { dataset = new TimeSeries("Trainingszeit ber 12 Monate "); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y4Werte[i]); } TimeSeriesCollection dataset4 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset4); plot.mapDatasetToRangeAxis(Linecount, 0); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; dataset = new TimeSeries("Trainingskilometer ber 12 Monate "); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y5Werte[i]); } TimeSeriesCollection dataset5 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset5); plot.mapDatasetToRangeAxis(Linecount, 1); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setGradientPaintTransformer(null); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; dataset = new TimeSeries("Trainingshhenmeter ber 12 Monate "); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y6Werte[i]); } TimeSeriesCollection dataset6 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset6); plot.mapDatasetToRangeAxis(Linecount, 2); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setGradientPaintTransformer(null); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } } Linecount++; dataset = new TimeSeries("Trainingszeit " + JTronicHandle.JahrVergleich.getSelectedItem().toString()); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y7Werte[i]); } TimeSeriesCollection dataset7 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset7); plot.mapDatasetToRangeAxis(Linecount, 0); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setGradientPaintTransformer(null); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; dataset = new TimeSeries( "Trainingskilometer " + JTronicHandle.JahrVergleich.getSelectedItem().toString()); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y8Werte[i]); } TimeSeriesCollection dataset8 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset8); plot.mapDatasetToRangeAxis(Linecount, 1); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setGradientPaintTransformer(null); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; dataset = new TimeSeries( "Trainingshhenmeter " + JTronicHandle.JahrVergleich.getSelectedItem().toString()); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y9Werte[i]); } TimeSeriesCollection dataset9 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset9); plot.mapDatasetToRangeAxis(Linecount, 2); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setGradientPaintTransformer(null); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } } if (!JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { double max = axis.getRange().getUpperBound(); for (i = 0; i < 12; i++) { try { Kalender = new GregorianCalendar(Integer.parseInt(DataProperty.getProperty("Jahr", "0")), i, 1); } catch (Exception e) { JOptionPane.showMessageDialog(null, "JUebersicht\nException GregorianCalender " + e, "Achtung!", JOptionPane.ERROR_MESSAGE); } y10Werte[Kalender.get(Kalender.DAY_OF_YEAR)] = max; y10Werte[Kalender.get(Kalender.DAY_OF_YEAR) + 1] = 0; } dataset = new TimeSeries(""); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y10Werte[i]); } TimeSeriesCollection dataset10 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount + 1, dataset10); plot.mapDatasetToRangeAxis(Linecount + 1, 0); renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, Color.white); plot.setRenderer(Linecount + 1, renderer); plot.getDomainAxis().setAutoRange(false); axis.setRange(0, max); } if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { axis2.setRange(0, axis2.getRange().getUpperBound() * 1.5); axis3.setRange(0, axis3.getRange().getUpperBound() * 2); plot.setDomainCrosshairValue( (double) new GregorianCalendar(Jahr, Today.get(Today.MONTH), Today.get(Today.DAY_OF_MONTH)) .getTimeInMillis()); } chart.setPadding(padding); ChartPanel Panel = new ChartPanel(chart); Panel.setDismissDelay(100000); return Panel; }
From source file:chibi.gemmaanalysis.OutlierDetectionTestCli.java
/*** Write results to the output file; file name must be given as argument ***/ private void writeResultsToFileBasic(BufferedWriter bw, ExpressionExperiment ee, OutlierDetectionTestDetails testDetails) { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(4);/*from w w w . j a v a2 s. c om*/ try { // Get information about the experiment: ee = this.eeService.thawLite(ee); System.out.println("Writing results to file for " + ee.getShortName()); bw.write(ee.getShortName()); bw.write("\t" + getPlatforms(ee)); bw.write("\t" + testDetails.getNumExpFactors()); if (useRegression) { bw.write("\t" + testDetails.getNumSigFactors()); } bw.write("\t" + ee.getBioAssays().size()); bw.write("\t" + testDetails.getNumOutliers()); // Get information about each of the outliers: for (OutlierDetails outlier : testDetails.getOutliers()) { bw.write("\t" + outlier.getBioAssay().getName()); bw.write("\t" + nf.format(outlier.getThresholdCorrelation())); bw.write("\t" + nf.format(outlier.getScore())); } bw.write("\tlast threshold: " + nf.format(testDetails.getLastThreshold())); if (useRegression) { for (ExperimentalFactor factor : testDetails.getSignificantFactors()) { bw.write("\t" + factor.getName()); } } bw.newLine(); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:ca.liquidlabs.android.speedtestvisualizer.activities.MapperActivity.java
/** * Adds all the parsed speedtest markers to the map. This task is processor * intensive, stalls the main thread if there is lots of data. But * unfortunately, this has to be done in UI thread. *//*from www.j av a 2 s . co m*/ private void addMarkersToMap() { Builder mapBoundsBuilder = new LatLngBounds.Builder(); int currentTotalRecordCount = 0; // Use parsed data to create map markers for (SpeedTestRecord speedTestRecord : mCsvListData) { if (FILTER_SELECTED == FILTER_TYPE_CELL && !speedTestRecord.getConnectionType().isCell()) { continue; // do not add non-cell items } else if (FILTER_SELECTED == FILTER_TYPE_WIFI && !speedTestRecord.getConnectionType().isWifi()) { continue; // do not add non-wifi items } /* * Build string array to concatenate and send info (doing it in dumb * old way, rather than passing serialized data). NOTE: Must be * retrieved in same order */ String snippetMultiInfo[] = { speedTestRecord.getConnectionType().toString(), NumberFormat.getInstance().format(speedTestRecord.getDownload()) + " " + SPEED_UNIT, NumberFormat.getInstance().format(speedTestRecord.getUpload()) + " " + SPEED_UNIT }; mMap.addMarker( new MarkerOptions().position(speedTestRecord.getLatLng()).title(speedTestRecord.getDate()) .snippet(StringUtils.join(snippetMultiInfo, AppConstants.TEXT_SEPARATOR)) .icon(BitmapDescriptorFactory.defaultMarker(speedTestRecord.getMarkerColorHue()))); // also build the maps bounds area mapBoundsBuilder.include(speedTestRecord.getLatLng()); // Update the count for selected filter currentTotalRecordCount++; } if (currentTotalRecordCount > 0) { // apply bounds if anything was added this.applyMapCameraBounds(mapBoundsBuilder.build()); } }
From source file:SoundBug.java
public void init() { // set up a NumFormat object to print out float with only 3 fraction // digits//from w w w .j a v a 2 s .c o m nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(3); setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); canvas = null; canvas = new Canvas3D(config); add("Center", canvas); // Create a simple scene and attach it to the virtual universe BranchGroup scene = createSceneGraph(); u = new SimpleUniverse(canvas); // set up sound u.getViewer().createAudioDevice(); // get the view view = u.getViewer().getView(); // Get the viewing platform ViewingPlatform viewingPlatform = u.getViewingPlatform(); // Move the viewing platform back to enclose the -4 -> 4 range double viewRadius = 4.0; // want to be able to see circle // of viewRadius size around origin // get the field of view double fov = u.getViewer().getView().getFieldOfView(); // calc view distance to make circle view in fov float viewDistance = (float) (viewRadius / Math.tan(fov / 2.0)); tmpVector.set(0.0f, 0.0f, viewDistance);// setup offset tmpTrans.set(tmpVector); // set trans to translate // move the view platform viewingPlatform.getViewPlatformTransform().setTransform(tmpTrans); // add an orbit behavior to move the viewing platform OrbitBehavior orbit = new OrbitBehavior(canvas, OrbitBehavior.STOP_ZOOM); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); orbit.setSchedulingBounds(bounds); viewingPlatform.setViewPlatformBehavior(orbit); u.addBranchGraph(scene); add("South", soundPanel()); }
From source file:io.plaidapp.ui.PlayerActivity.java
void bindPlayer() { if (player == null) return;/* www.j av a 2 s . com*/ final Resources res = getResources(); final NumberFormat nf = NumberFormat.getInstance(); Glide.with(this).load(player.getHighQualityAvatarUrl()).placeholder(R.drawable.avatar_placeholder) .transform(circleTransform).into(avatar); playerName.setText(player.name.toLowerCase()); if (!TextUtils.isEmpty(player.bio)) { DribbbleUtils.parseAndSetText(bio, player.bio); } else { bio.setVisibility(View.GONE); } shotCount .setText(res.getQuantityString(R.plurals.shots, player.shots_count, nf.format(player.shots_count))); if (player.shots_count == 0) { shotCount.setCompoundDrawablesRelativeWithIntrinsicBounds(null, getDrawable(R.drawable.avd_no_shots), null, null); } setFollowerCount(player.followers_count); likesCount .setText(res.getQuantityString(R.plurals.likes, player.likes_count, nf.format(player.likes_count))); // load the users shots dataManager = new PlayerShotsDataManager(this, player) { @Override public void onDataLoaded(List<Shot> data) { if (data != null && data.size() > 0) { if (adapter.getDataItemCount() == 0) { loading.setVisibility(View.GONE); ViewUtils.setPaddingTop(shots, likesCount.getBottom()); } adapter.addAndResort(data); } } }; adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this)); shots.setAdapter(adapter); shots.setItemAnimator(new SlideInItemAnimator()); shots.setVisibility(View.VISIBLE); layoutManager = new GridLayoutManager(this, columns); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return adapter.getItemColumnSpan(position); } }); shots.setLayoutManager(layoutManager); shots.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) { @Override public void onLoadMore() { dataManager.loadData(); } }); shots.setHasFixedSize(true); // forward on any clicks above the first item in the grid (i.e. in the paddingTop) // to 'pass through' to the view behind shots.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { final int firstVisible = layoutManager.findFirstVisibleItemPosition(); if (firstVisible > 0) return false; // if no data loaded then pass through if (adapter.getDataItemCount() == 0) { return container.dispatchTouchEvent(event); } final RecyclerView.ViewHolder vh = shots.findViewHolderForAdapterPosition(0); if (vh == null) return false; final int firstTop = vh.itemView.getTop(); if (event.getY() < firstTop) { return container.dispatchTouchEvent(event); } return false; } }); // check if following if (dataManager.getDribbblePrefs().isLoggedIn()) { if (player.id == dataManager.getDribbblePrefs().getUserId()) { TransitionManager.beginDelayedTransition(container); follow.setVisibility(View.GONE); ViewUtils.setPaddingTop(shots, container.getHeight() - follow.getHeight() - ((ViewGroup.MarginLayoutParams) follow.getLayoutParams()).bottomMargin); } else { final Call<Void> followingCall = dataManager.getDribbbleApi().following(player.id); followingCall.enqueue(new Callback<Void>() { @Override public void onResponse(Call<Void> call, Response<Void> response) { following = response.isSuccessful(); if (!following) return; TransitionManager.beginDelayedTransition(container); follow.setText(R.string.following); follow.setActivated(true); } @Override public void onFailure(Call<Void> call, Throwable t) { } }); } } if (player.shots_count > 0) { dataManager.loadData(); // kick off initial load } else { loading.setVisibility(View.GONE); } }
From source file:com.skilrock.lms.web.accMgmt.common.AgentPaymentSubmit.java
public String agentPayment() throws Exception { logger.info("REQUEST_CASH_PAYMENT_SUBMIT-" + this); HttpSession session = null;/*from www . j a va 2 s. c o m*/ UserInfoBean userBean = null, agentInfoBean = null; String[] denoType = null; Connection con = null; try { session = getRequest().getSession(); userBean = (UserInfoBean) session.getAttribute("USER_INFO"); agentInfoBean = CommonMethods.fetchUserData(orgId); logger.info( "REQUEST_CASH_PAYMENT_SUBMIT-" + request.getAttribute("AUDIT_ID") + ":" + userBean.getUserId()); String currencySymbol = (String) ServletActionContext.getServletContext() .getAttribute("CURRENCY_SYMBOL"); logger.info("user_id is-" + userBean.getUserId()); ServletContext sc = ServletActionContext.getServletContext(); String isCREnable = (String) sc.getAttribute("IS_CASH_REGISTER"); if (totalAmount != cashAmnt) { throw new LMSException(LMSErrors.CASH_PAYMENT_INVALIDATE_DATA_ERROR_CODE, LMSErrors.CASH_PAYMENT_INVALIDATE_DATA_ERROR_MESSAGE); } if ("ACTIVE".equalsIgnoreCase(isCREnable)) { CashRegisterHelper drawerHelper = new CashRegisterHelper(); List<String> denoList = drawerHelper.getReceivedDenoList(); denoType = (String[]) denoList.toArray(new String[denoList.size()]); } con = DBConnect.getConnection(); con.setAutoCommit(false); int retOrgId = Integer.parseInt(retOrgName); int agentId = agentInfoBean.getUserId(); AgentPaymentSubmitHelper helper = new AgentPaymentSubmitHelper(); String autoGeneRecieptNoAndId = helper.submitCashAgentAmt(orgId, "AGENT", totalAmount, userBean.getUserId(), userBean.getUserOrgId(), userBean.getUserType(), denoType, multiples, retDenoType, retMultiples, con); if (orgType.equalsIgnoreCase("RETAILER")) { RetailerPaymentSubmitHelper retailerPaymentSubmit = new RetailerPaymentSubmitHelper(); autoGeneRecieptNoAndId = retailerPaymentSubmit.retailerCashPaySubmit(retOrgId, "RETAILER", retOrgId, totalAmount, agentId, orgId, "AGENT", con); } con.commit(); String[] autoGeneReceipt = autoGeneRecieptNoAndId.split("#"); String autoGeneRecieptNo = autoGeneReceipt[0]; int id = Integer.parseInt(autoGeneReceipt[1]); java.util.Date d = new java.util.Date(); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); String generationTime = sdf.format(d.getTime()); logger.info("Generation time:" + generationTime); boolean isThermalRcptRequired = "true".equals((String) ServletActionContext.getServletContext() .getAttribute("IS_CASH_RCPT_ON_THERMAL_PRINTER")); if (isThermalRcptRequired) { NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); String amountCash = nf.format(totalAmount); String data = "data=0|txType=RECEIPT|address=" + CommonMethods.getOrgAddress(String.valueOf(userBean.getUserOrgId())) + "|genTime=" + generationTime + "|mode=Voucher|voucherNo=" + autoGeneRecieptNo + "|txDate=" + sdf.format(d.getTime()) + "|amount=" + amountCash + "|orgName=" + agentNameValue + "|ctr=200|parentOrgName=" + userBean.getOrgName() + "|curSymbol=" + currencySymbol; session.setAttribute("APP_DATA", data); } session.setAttribute("totalPay", totalAmount); session.setAttribute("orgName", agentNameValue); session.setAttribute("Receipt_Id", autoGeneRecieptNo); GraphReportHelper graphReportHelper = new GraphReportHelper(); if ("AGENT".equalsIgnoreCase(orgType)) { String parentOrgName = null; int userOrgID = 0; parentOrgName = userBean.getOrgName(); userOrgID = userBean.getUserOrgId(); graphReportHelper.createTextReportBO(id, parentOrgName, userOrgID, (String) session.getAttribute("ROOT_PATH")); } else { graphReportHelper.createTextReportAgent(id, (String) session.getAttribute("ROOT_PATH"), orgId, agentInfoBean.getOrgName()); } } catch (LMSException le) { logger.info("RESPONSE_CASH_PAYMENT_SUBMIT-: ErrorCode:" + le.getErrorCode() + " ErrorMessage:" + le.getErrorMessage()); request.setAttribute("LMS_EXCEPTION", le.getErrorMessage()); return "applicationException"; } catch (Exception e) { logger.error("Exception", e); logger.info("RESPONSE_CASH_PAYMENT_SUBMIT-: ErrorCode:" + LMSErrors.GENERAL_EXCEPTION_ERROR_CODE + " ErrorMessage:" + LMSErrors.GENERAL_EXCEPTION_ERROR_MESSAGE); request.setAttribute("LMS_EXCEPTION", LMSErrors.GENERAL_EXCEPTION_ERROR_MESSAGE); return "applicationException"; } finally { try { if (con != null) { con.close(); } } catch (SQLException e) { e.printStackTrace(); } } return SUCCESS; }
From source file:com.predic8.membrane.core.interceptor.apimanagement.ApiManagementConfiguration.java
private Map<String, Policy> parsePolicies(Map<String, Object> yaml) { Map<String, Policy> result = new HashMap<String, Policy>(); Object policies = yaml.get("policies"); if (policies == null) { log.warn("\"policies\" keyword not found"); return result; }/*from ww w . j a va 2 s. c o m*/ List<Object> yamlPolicies = (List<Object>) policies; for (Object yamlPolicyObj : yamlPolicies) { if (yamlPolicyObj == null) { continue; } LinkedHashMap<String, Object> yamlPolicy = (LinkedHashMap<String, Object>) yamlPolicyObj; for (Object polObj : yamlPolicy.values()) { if (polObj == null) { continue; } LinkedHashMap<String, Object> yamlPolicyDef = (LinkedHashMap<String, Object>) polObj; Policy policy = new Policy(); Object name = yamlPolicyDef.get("id"); if (name == null) { log.warn("Policy object found, but no \"id\" field"); continue; } String policyName = (String) name; policy.setName(policyName); Object serviceProxiesObj = yamlPolicyDef.get("serviceProxy"); if (serviceProxiesObj == null) { log.warn("Policy object found, but no service proxies specified "); continue; } List<String> serviceProxyNames = (List<String>) serviceProxiesObj; for (String sp : serviceProxyNames) { policy.getServiceProxies().add(sp); } //Optionals like rateLimit/quota etc. follow Object rateLimitObj = yamlPolicyDef.get("rateLimit"); if (rateLimitObj != null) { LinkedHashMap<String, Object> rateLimitData = (LinkedHashMap<String, Object>) rateLimitObj; RateLimit rateLimit = new RateLimit(); int requests = -1; Object requestsObj = rateLimitData.get("requests"); if (requestsObj == null) { log.warn("RateLimit object found, but request field is empty"); requests = RateLimit.REQUESTS_DEFAULT; } else { try { requests = Integer.parseInt((String) requestsObj); } catch (NumberFormatException ignored) { // there is an entry, but its not a number ( maybe empty quotes ) requests = RateLimit.REQUESTS_DEFAULT; } } int interval = -1; Object intervalObj = rateLimitData.get("interval"); if (intervalObj == null) { log.warn( "RateLimit object found, but interval field is empty. Setting default: \" + RateLimit.INTERVAL_DEFAULT"); interval = RateLimit.INTERVAL_DEFAULT; } else { try { interval = Integer.parseInt((String) intervalObj); } catch (NumberFormatException ignored) { interval = RateLimit.INTERVAL_DEFAULT; } } rateLimit.setRequests(requests); rateLimit.setInterval(interval); policy.setRateLimit(rateLimit); } Object quotaObj = yamlPolicyDef.get("quota"); if (quotaObj != null) { LinkedHashMap<String, Object> quota = (LinkedHashMap<String, Object>) quotaObj; Object quotaSizeObj = quota.get("size"); long quotaNumber = 0; String quotaSymbolString = ""; if (quotaSizeObj == null) { log.warn("Quota object found, but size field is empty"); quotaNumber = Quota.SIZE_DEFAULT; } else { try { String quotaString = (String) quotaSizeObj; quotaNumber = ((Number) NumberFormat.getInstance().parse(quotaString)).intValue(); quotaSymbolString = quotaString.replaceFirst(Long.toString(quotaNumber), "") .toLowerCase(); } catch (ParseException ignored) { quotaNumber = Quota.SIZE_DEFAULT; } } if (quotaSymbolString.length() > 0) { char quotaSymbol = quotaSymbolString.charAt(0); switch (quotaSymbol) { case 'g': quotaNumber *= 1024; case 'm': quotaNumber *= 1024; case 'k': quotaNumber *= 1024; case 'b': default: } } Object quotaIntervalObj = quota.get("interval"); int quotaInterval = 0; if (quotaIntervalObj == null) { log.warn("Quota object found, but interval field is empty"); quotaInterval = Quota.INTERVAL_DEFAULT; } else { try { quotaInterval = Integer.parseInt((String) quotaIntervalObj); } catch (NumberFormatException ignored) { quotaInterval = Quota.INTERVAL_DEFAULT; } } Quota q = new Quota(); q.setSize(quotaNumber); q.setInterval(quotaInterval); policy.setQuota(q); } result.put(policyName, policy); } } return result; }
From source file:javacommon.excel.ExcelReader.java
/** * ???//from w w w.j av a 2s . com * * @param c ? * @return */ private String getCellStringValue(Cell c) { if (c == null) { return ""; } String value = null; NumberFormat nf = NumberFormat.getInstance(); nf.setGroupingUsed(false); nf.setMaximumFractionDigits(12); switch (c.getCellType()) { case Cell.CELL_TYPE_BOOLEAN: value = String.valueOf(c.getBooleanCellValue()); break; case Cell.CELL_TYPE_NUMERIC: if (DateUtil.isCellDateFormatted(c)) { return DateFormatUtils.ISO_DATE_FORMAT.format(c.getDateCellValue()); } else if ("@".equals(c.getCellStyle().getDataFormatString())) { value = nf.format(c.getNumericCellValue()); } else if ("General".equals(c.getCellStyle().getDataFormatString())) { value = nf.format(c.getNumericCellValue()); } else if (ArrayUtils.contains(ExcelConstants.DATE_PATTERNS, c.getCellStyle().getDataFormatString())) { value = DateFormatUtils.format(HSSFDateUtil.getJavaDate(c.getNumericCellValue()), c.getCellStyle().getDataFormatString()); } else { value = nf.format(c.getNumericCellValue()); } break; case Cell.CELL_TYPE_STRING: value = c.getStringCellValue(); break; case Cell.CELL_TYPE_FORMULA: value = c.getCellFormula(); break; } return value == null ? "" : value.trim(); }
From source file:de.thischwa.pmcms.tool.connection.ftp.FtpTransfer.java
/** * Just a wrapper to {@link #uploadToCurrentDir(String, InputStream)}. *///from w w w. jav a 2s . c o m private void uploadToCurrentDir(UploadObject uploadObject) { progressSetSubTaskMessage(String.format("Upload file: %s (%sKB)", uploadObject.getName(), NumberFormat.getInstance().format(uploadObject.getBytes() / 1024))); uploadToCurrentDir(uploadObject.getName(), uploadObject.getInputStream()); }