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

Method draw

src/org/opensourcephysics/display/axes/XAxis.java:45–71  ·  view source on GitHub ↗

Draws the axis in the drawing panel. @param drawingPanel @param g

(DrawingPanel drawingPanel, Graphics g)

Source from the content-addressed store, hash-verified

43 * @param g
44 */
45 @Override
46public void draw(DrawingPanel drawingPanel, Graphics g) {
47 int pixLoc = drawingPanel.yToPix(location);
48 if(pixLoc<1) {
49 location = drawingPanel.getYMin();
50 }
51 if(pixLoc>drawingPanel.getHeight()-1) {
52 location = drawingPanel.getYMax();
53 }
54 Graphics2D g2 = (Graphics2D) g.create();
55// Shape clipShape = g2.getClip();
56 // unclip needed here?
57 g2.clipRect(0, 0, drawingPanel.getWidth(), drawingPanel.getHeight());
58 switch(locationType) {
59 case DRAW_AT_LOCATION :
60 case DRAW_IN_DISPLAY :
61 drawInsideDisplay(drawingPanel, g);
62 break;
63 case DRAW_IN_GUTTER :
64 drawInsideGutter(drawingPanel, g);
65 break;
66 default :
67 drawInsideDisplay(drawingPanel, g);
68 break;
69 }
70 g2.dispose();// BH 2020.02.26//setClip(clipShape);
71 }
72
73 private void drawInsideDisplay(DrawingPanel drawingPanel, Graphics g) {
74 Color foreground = drawingPanel.getForeground();

Callers

nothing calls this directly

Calls 10

drawInsideDisplayMethod · 0.95
drawInsideGutterMethod · 0.95
clipRectMethod · 0.80
getYMinMethod · 0.65
getHeightMethod · 0.65
getYMaxMethod · 0.65
getWidthMethod · 0.65
disposeMethod · 0.65
yToPixMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected