MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / drawPoint

Method drawPoint

src/org/opensourcephysics/display/Histogram.java:812–823  ·  view source on GitHub ↗

Draws a point at the top of a bin. @param drawingPanel @param g @param binNumber @param occurrences

(DrawingPanel drawingPanel, Graphics g, int binNumber, double occurrences)

Source from the content-addressed store, hash-verified

810 * @param occurrences
811 */
812 protected void drawPoint(DrawingPanel drawingPanel, Graphics g, int binNumber, double occurrences) {
813 int px = drawingPanel.xToPix(getLeftMostBinPosition(binNumber)); // leftmost position of bin
814 int py = drawingPanel.yToPix(occurrences);
815 int pointRadius = 2;
816 if (discrete) {
817 g.fillRect(px - pointRadius, py - pointRadius, pointRadius * 2, pointRadius * 2);
818 } else { // continous, draw entire bin
819 int px2 = drawingPanel.xToPix(getRightMostBinPosition(binNumber));
820 int pWidth = px2 - px;
821 g.fillRect(px, py, pWidth, pointRadius * 2);
822 }
823 }
824
825 /**
826 * Draws a filled bin.

Callers 1

drawMethod · 0.95

Calls 5

xToPixMethod · 0.45
yToPixMethod · 0.45
fillRectMethod · 0.45

Tested by

no test coverage detected