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

Method draw

src/test/TextLayoutTest.java:24–40  ·  view source on GitHub ↗
(DrawingPanel panel, Graphics g)

Source from the content-addressed store, hash-verified

22 ArrayData griddata = new ArrayData(numpts, numpts, 3);
23 GrayscalePlot grayscalePlot = new GrayscalePlot(griddata) {
24 @Override
25 public void draw(DrawingPanel panel, Graphics g) {
26
27 setRandomVals();
28 super.draw(panel, g);
29 g.setColor(Color.blue);
30 String str = "" + textLayoutFont.getSize2D();
31 TextLayout tl = new TextLayout(str, textLayoutFont);
32 System.out.println("TLT.tl " + tl.getBounds());
33 System.out.println("TLT.fs " + textLayoutFont.getStringBounds(str, ((Graphics2D)g).getFontRenderContext()));
34 float w = (float) tl.getBounds().getWidth();
35 float h = (float) tl.getBounds().getHeight();
36 h = 0;
37 System.out.println("TLT.draw w=" + w + " h=" + h);
38 tl.draw(g, (103-w/2) , (112 - h/2));
39
40 }
41 };
42 PlottingPanel plottingPanel = new PlottingPanel("x", "t", null);
43 DrawingFrame drawingFrame = new DrawingFrame(plottingPanel);

Callers

nothing calls this directly

Calls 10

setRandomValsMethod · 0.95
getBoundsMethod · 0.95
drawMethod · 0.95
getStringBoundsMethod · 0.80
getFontRenderContextMethod · 0.80
drawMethod · 0.65
printlnMethod · 0.65
getWidthMethod · 0.65
getHeightMethod · 0.65
setColorMethod · 0.45

Tested by

no test coverage detected