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

Method draw

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

Draws this histogram in the drawing panel. @param drawingPanel @param g

(DrawingPanel drawingPanel, Graphics g)

Source from the content-addressed store, hash-verified

357 * @param g
358 */
359 @Override
360 public synchronized void draw(DrawingPanel drawingPanel, Graphics g) {
361 if (bins.size() == 0 || !visible) {
362 return;
363 }
364// Shape oldClip = g.getClip();
365 g = g.create();
366 g.setColor(binFillColor);
367 g.clipRect(0, 0, drawingPanel.getWidth(), drawingPanel.getHeight());
368 for (Iterator<Integer> keys = bins.keySet().iterator(); keys.hasNext();) {
369 Integer binNumber = keys.next();
370 Double d = (bins.get(binNumber));
371 if (d == null) {
372 break;
373 }
374 double occurrences = d.doubleValue();
375 if (normalizedToOne) {
376 occurrences /= sum;
377 }
378 if (binStyle == DRAW_BIN) {
379 drawBin(drawingPanel, g, binNumber.intValue(), occurrences);
380 } else {
381 drawPoint(drawingPanel, g, binNumber.intValue(), occurrences);
382 }
383 }
384// g.setClip(oldClip);
385 g.dispose();
386 }
387
388 /** Clears all data from this histogram and resets min and max values. */
389 public synchronized void clear() {

Callers

nothing calls this directly

Calls 13

drawBinMethod · 0.95
drawPointMethod · 0.95
clipRectMethod · 0.80
doubleValueMethod · 0.80
intValueMethod · 0.80
getWidthMethod · 0.65
getHeightMethod · 0.65
getMethod · 0.65
disposeMethod · 0.65
createMethod · 0.45
setColorMethod · 0.45
hasNextMethod · 0.45

Tested by

no test coverage detected