MCPcopy Create free account
hub / github.com/catabriga/graphwar / drawFunctionImage

Method drawFunctionImage

src/Graphwar/GraphPlane.java:303–350  ·  view source on GitHub ↗
(Graphics g, boolean reversed)

Source from the content-addressed store, hash-verified

301 }
302
303 private void drawFunctionImage(Graphics g, boolean reversed)
304 {
305 int numDrawSteps = graphwar.getGameData().getCurrentFunctionPosition();
306
307 GeneralPath path = new GeneralPath();
308
309 Graphics2D g2d = (Graphics2D)g;
310 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
311
312 Color playerColor = graphwar.getGameData().getCurrentTurnPlayer().getColor();
313 g2d.setColor(playerColor);
314 //g2d.setStroke(new BasicStroke(1.0f));
315
316 Function function = graphwar.getGameData().getFunction();
317
318 double x = convertX(function.getX(lastStepDrawn));
319 double y = convertY(function.getY(lastStepDrawn));
320
321 if(reversed)
322 {
323 x = Constants.PLANE_LENGTH-x;
324 }
325
326 path.moveTo(x,y);
327
328 for(int i=lastStepDrawn; i<numDrawSteps; i++)
329 {
330 x = convertX(function.getX(i));
331 y = convertY(function.getY(i));
332
333 if(reversed)
334 {
335 x = Constants.PLANE_LENGTH-x;
336 }
337
338 path.lineTo(x,y);
339 //path.curve
340 }
341 lastStepDrawn = numDrawSteps-1;
342
343 if(lastStepDrawn < 0)
344 {
345 lastStepDrawn = 0;
346 }
347
348 g2d.draw(path);
349
350 }
351
352 private void drawFunction(Graphics g, boolean terrainReversed)
353 {

Callers 1

drawFunctionMethod · 0.95

Calls 9

convertXMethod · 0.95
getXMethod · 0.95
convertYMethod · 0.95
getYMethod · 0.95
getGameDataMethod · 0.80
getColorMethod · 0.80
getCurrentTurnPlayerMethod · 0.80
getFunctionMethod · 0.45

Tested by

no test coverage detected