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

Method draw

src/csm/ch03/Projectile.java:83–94  ·  view source on GitHub ↗

Draws the projectile. Required for Drawable interface. @param drawingPanel @param g

(DrawingPanel drawingPanel, Graphics g)

Source from the content-addressed store, hash-verified

81 * @param g
82 */
83 @Override
84public void draw(DrawingPanel drawingPanel, Graphics g) {
85 int xpix = drawingPanel.xToPix(state[0]);
86 int ypix = drawingPanel.yToPix(state[2]);
87 g.setColor(Color.red);
88 g.fillOval(xpix-pixRadius, ypix-pixRadius, 2*pixRadius, 2*pixRadius);
89 g.setColor(Color.green);
90 int xmin = drawingPanel.xToPix(-100);
91 int xmax = drawingPanel.xToPix(100);
92 int y0 = drawingPanel.yToPix(0);
93 g.drawLine(xmin, y0, xmax, y0); // draw a line to represent the ground
94 }
95}
96
97/*

Callers

nothing calls this directly

Calls 5

fillOvalMethod · 0.80
drawLineMethod · 0.80
xToPixMethod · 0.45
yToPixMethod · 0.45
setColorMethod · 0.45

Tested by

no test coverage detected