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

Method draw

src/org/opensourcephysics/display/axes/YAxis.java:49–75  ·  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

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

Callers

nothing calls this directly

Calls 10

drawInsideDisplayMethod · 0.95
drawInsideGutterMethod · 0.95
clipRectMethod · 0.80
getXMinMethod · 0.65
getWidthMethod · 0.65
getXMaxMethod · 0.65
getHeightMethod · 0.65
disposeMethod · 0.65
xToPixMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected