Draws a filled bin. @param drawingPanel @param g @param binNumber @param occurrences
(DrawingPanel drawingPanel, Graphics g, int binNumber, double occurrences)
| 831 | * @param occurrences |
| 832 | */ |
| 833 | protected void drawBin(DrawingPanel drawingPanel, Graphics g, int binNumber, double occurrences) { |
| 834 | if (adjustForWidth) { |
| 835 | occurrences = occurrences / getBinWidth(); |
| 836 | } |
| 837 | if (logScale) { |
| 838 | occurrences = Math.max(0, Math.log(occurrences)); |
| 839 | } |
| 840 | int binlx = drawingPanel.xToPix(getLeftMostBinPosition(binNumber)); |
| 841 | if (discrete) { |
| 842 | if (binEdgeColor != null) { |
| 843 | g.setColor(binEdgeColor); |
| 844 | g.drawLine(binlx, drawingPanel.yToPix(YMIN), binlx, drawingPanel.yToPix(occurrences)); |
| 845 | } |
| 846 | } else { // continous, draw entire bin |
| 847 | int binrx = drawingPanel.xToPix(getRightMostBinPosition(binNumber)); |
| 848 | int pWidth = binrx - binlx; |
| 849 | double pHeight = drawingPanel.getYPixPerUnit() * occurrences; |
| 850 | java.awt.geom.Rectangle2D.Double rect = new java.awt.geom.Rectangle2D.Double(binlx, |
| 851 | drawingPanel.yToPix(occurrences), pWidth, pHeight); |
| 852 | Graphics2D g2 = (Graphics2D) g; |
| 853 | if (binFillColor != null) { |
| 854 | g.setColor(binFillColor); |
| 855 | g2.fill(rect); |
| 856 | } |
| 857 | if (binEdgeColor != null) { |
| 858 | g.setColor(binEdgeColor); |
| 859 | g2.draw(rect); |
| 860 | } |
| 861 | } |
| 862 | } |
| 863 | |
| 864 | /** |
| 865 | * Gets an array containing the bin centers. |
no test coverage detected