com.github.cschen1205.navigator.gui.SonarPanel Maven / Gradle / Ivy
package com.github.cschen1205.navigator.gui;
import com.github.cschen1205.navigator.minefield.env.MineField;
import javax.swing.*;
import java.awt.*;
/**
* Created by chen0469 on 10/2/2015 0002.
*/
public class SonarPanel extends JPanel {
private int bearing;
private double[] sonar;
private double range;
private int numSonar=5;
private int radius;
private Color fore_color;
private boolean sonar_mode;
public SonarPanel(boolean mode, Color c, MineField m )
{
sonar_mode = mode;
fore_color = c;
sonar = new double[numSonar];
}
public void readSonar(int vehicleId, MineField m ) {
if( sonar_mode )
sonar = m.getSonar ( vehicleId );
else
sonar = m.getAVSonar ( vehicleId );
repaint();
}
public boolean get_sonar_mode()
{
return( sonar_mode );
}
protected void paintComponent(Graphics g) {
int r;
super.paintComponent(g);
g.setColor (Color.black);
for (int i=0; i