private void setupHistogram(final RangeFilter rangeFilter, final Range range) { histogram.clear(); for (Object value : values) { histogram.addData(value); } histogram.sortData(); double rangeLowerBound = 0.0; double rangeUpperBound = 0.0; if (range.getRangeType().equals(Integer.class)) { rangeLowerBound = ((Integer) range.getLowerBound()).doubleValue(); rangeUpperBound = ((Integer) range.getUpperBound()).doubleValue(); } else if (range.getRangeType().equals(Float.class)) { rangeLowerBound = ((Float) range.getLowerBound()).doubleValue(); rangeUpperBound = ((Float) range.getUpperBound()).doubleValue(); } else if (range.getRangeType().equals(Double.class)) { rangeLowerBound = ((Double) range.getLowerBound()); rangeUpperBound = ((Double) range.getUpperBound()); } else if (range.getRangeType().equals(Long.class)) { rangeLowerBound = ((Long) range.getLowerBound()).doubleValue(); rangeUpperBound = ((Long) range.getUpperBound()).doubleValue(); } histogram.setLowerBound(rangeLowerBound); histogram.setUpperBound(rangeUpperBound); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { revalidate(); repaint(); } }); }
private RichTooltip buildTooltip() { if (histogram.countValues() == 0) { return null; } NumberFormat formatter = DecimalFormat.getNumberInstance(); formatter.setMaximumFractionDigits(3); String average = formatter.format(histogram.getAverage()); String averageInRange = formatter.format(histogram.getAverageInRange()); RichTooltip richTooltip = new RichTooltip(); richTooltip.setTitle("Statistics (In-Range)"); richTooltip.addDescriptionSection( "<html><b># of Values:</b> " + histogram.countValues() + " (" + histogram.countInRange() + ")"); richTooltip.addDescriptionSection( "<html><b>Average:</b> " + average + " (" + averageInRange + ")"); richTooltip.addDescriptionSection( "<html><b>Median:</b> " + histogram.getMedian() + " (" + histogram.getMedianInRange() + ")"); return richTooltip; }
public RangePanel() { initComponents(); histogram = new JQuickHistogram(); histogramPanel.add(histogram.getPanel()); histogram.setConstraintHeight(30); }