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

Method paintPlayerName

src/Graphwar/GraphPlane.java:660–696  ·  view source on GitHub ↗
(Graphics g, int x, int y, Player player)

Source from the content-addressed store, hash-verified

658 }
659
660 private void paintPlayerName(Graphics g, int x, int y, Player player)
661 {
662 int border = 3;
663 int nameLength = player.getNameLength();
664
665 int borderX = x-nameLength/2-border;
666 int borderY = y-15-2*Constants.SOLDIER_RADIUS;
667 int textX = x-nameLength/2;
668 int textY = y-2-2*Constants.SOLDIER_RADIUS;
669
670 if(borderY < 0)
671 {
672 borderY = y-2+2*Constants.SOLDIER_RADIUS;
673 textY = y+11+2*Constants.SOLDIER_RADIUS;
674 }
675
676 if(borderX < 0)
677 {
678 textX = textX - borderX;
679 borderX = 0;
680 }
681
682 if(borderX + nameLength+2*border > Constants.PLANE_LENGTH)
683 {
684 textX = (textX - borderX) + Constants.PLANE_LENGTH - nameLength-2*border;
685 borderX = Constants.PLANE_LENGTH - nameLength-2*border;
686 }
687
688 g.setColor(transparentWhite);
689 g.fillRoundRect(borderX, borderY, nameLength+2*border, 15, 7, 7);
690
691 g.setColor(player.getColor());
692 g.drawRoundRect(borderX, borderY, nameLength+2*border, 15, 7, 7);
693
694 g.setColor(Color.BLACK);
695 g.drawString(player.getName(), textX, textY);
696 }
697
698 private void drawPlayersNames(Graphics g, boolean reversed)
699 {

Callers 1

drawPlayersNamesMethod · 0.95

Calls 3

getNameLengthMethod · 0.80
getColorMethod · 0.80
getNameMethod · 0.45

Tested by

no test coverage detected