Beispiel #1
0
  public void StaticObjNew(StaticObj so) {
    Graphics2D g = radarArea.backImage.createGraphics();
    g.setColor(so_color);

    if (so instanceof Beacon) {
      g.drawOval(
          convPos(so.pos.x) - grid_size / 6,
          convPos(so.pos.y) - grid_size / 6,
          grid_size / 3,
          grid_size / 3);
      JLabel sol = new JLabel(Integer.toString(so.id));
      sol.setForeground(so_text_color);
      sol.setBounds(
          convPos(so.pos.x) + grid_size / 6, convPos(so.pos.y), grid_size / 3, grid_size / 2);
      radarArea.add(sol, new Integer(1));
    }

    if (so instanceof Airfield) {
      int xa[] = new int[3], ya[] = new int[3];
      int l1 = grid_size / 2, l2 = grid_size / 6;
      xa[0] = convPos(so.pos.x);
      ya[0] = convPos(so.pos.y);
      xa[1] = convPos(so.pos.x) - l1 * so.dir.x - l2 * so.dir.y;
      ya[1] = convPos(so.pos.y) - l1 * so.dir.y + l2 * so.dir.x;
      xa[2] = convPos(so.pos.x) - l1 * so.dir.x + l2 * so.dir.y;
      ya[2] = convPos(so.pos.y) - l1 * so.dir.y - l2 * so.dir.x;
      g.drawPolygon(xa, ya, 3);
      JLabel sol = new JLabel(Integer.toString(so.id));
      sol.setForeground(so_text_color);
      sol.setBounds(
          convPos(so.pos.x) + grid_size / 6, convPos(so.pos.y), grid_size / 3, grid_size / 2);
      radarArea.add(sol, new Integer(1));
    }

    if (so instanceof Exit) {
      g.drawRect(
          convPos(so.pos.x) - grid_size / 6,
          convPos(so.pos.y) - grid_size / 6,
          grid_size / 3,
          grid_size / 3);
      JLabel sol = new JLabel(Integer.toString(so.id));
      sol.setForeground(so_text_color);
      sol.setBounds(
          convPos(so.pos.x) + grid_size / 6, convPos(so.pos.y), grid_size / 3, grid_size / 2);
      radarArea.add(sol, new Integer(1));
    }

    if (so instanceof Line) {
      g.setColor(line_color);
      g.drawLine(
          convPos(((Line) so).pos.x),
          convPos(((Line) so).pos.y),
          convPos(((Line) so).second_end.x),
          convPos(((Line) so).second_end.y));
    }

    radarArea.backIcon = new ImageIcon(radarArea.backImage);
    radarArea.back.setIcon(radarArea.backIcon);
  }
Beispiel #2
0
  public void PlaneRemove(Plane p) {
    char id = p.getIdChar();
    UIPlane uiplane = null;
    synchronized (this) {
      uiplane = (UIPlane) (planes.get((Object) (new Character(id))));
    }
    if (uiplane == null) return;

    if (uiplane.radar_label != null) radarArea.remove(uiplane.radar_label);
    if (uiplane.info_label != null) infoArea.remove(uiplane.info_label);
    synchronized (this) {
      planes.remove((Object) (new Character(id)));
    }

    radarArea.repaint();
    infoArea.repaint();
  }
Beispiel #3
0
  public void PlaneUpdate(Plane p) {
    if (ATC.debug_flag) System.out.println("p.u.1");
    char id = p.getIdChar();
    UIPlane uiplane = null;
    synchronized (this) {
      uiplane = (UIPlane) (planes.get((Object) (new Character(id))));
    }
    if (ATC.debug_flag) System.out.println("p.u.1 il=" + uiplane.info_label);
    if (uiplane == null) return;
    if (ATC.debug_flag) System.out.println("p.u.2");

    if (p.takeoff_flag) {
      if (uiplane.radar_label == null) {
        if (ATC.debug_flag) System.out.println("p.u.3");
        uiplane.radar_label = new JLabel(getPlaneText(p), dirToPlaneIcon(p.dir), JLabel.CENTER);
        uiplane.radar_label.setVerticalTextPosition(JLabel.TOP);
        uiplane.radar_label.setHorizontalTextPosition(JLabel.CENTER);
        uiplane.radar_label.setIconTextGap(text_gap);
        uiplane.radar_label.setForeground(text_color);
        radarArea.add(uiplane.radar_label, new Integer(2));
        if (ATC.debug_flag) System.out.println("p.u.4");
      } else {
        if (ATC.debug_flag) System.out.println("p.u.5");
        uiplane.radar_label.setText(getPlaneText(p));
        uiplane.radar_label.setIcon(dirToPlaneIcon(p.dir));
        if (ATC.debug_flag) System.out.println("p.u.6");
      }

      uiplane.radar_label.setBounds(
          convPos(p.pos.x) - plane_width / 2,
          convPos(p.pos.y) - plane_height + icon_size / 2,
          plane_width,
          plane_height);
      if (ATC.debug_flag) System.out.println("p.u.7");
    }

    uiplane.info_label.setText(getPlaneInfoText(p));
    if (ATC.debug_flag) System.out.println("p.u.8");
    infoArea.validate();

    if (ATC.debug_flag) System.out.println("p.u.9");
  }
Beispiel #4
0
  public void initUI(int x, int y) {
    setVisible(true);

    loadIcons();

    dx = x;
    dy = y;
    text_height = getFontMetrics(getFont()).getHeight();
    plane_width = icon_size;
    plane_height = icon_size + text_height + text_gap;
    radar_area_width = grid_size * dx;
    radar_area_height = grid_size * dy;

    getContentPane().setLayout(new BorderLayout());

    radarArea = new RadarPane();
    radarArea.setMinimumSize(new Dimension(radar_area_width, radar_area_height));
    radarArea.setPreferredSize(new Dimension(radar_area_width, radar_area_height));
    getContentPane().add(radarArea, BorderLayout.CENTER);

    radarArea.backImage =
        new BufferedImage(radar_area_width, radar_area_height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = radarArea.backImage.createGraphics();
    g.setBackground(back_color);
    g.setColor(rim_color);
    g.fillRect(0, 0, radar_area_width, radar_area_height);
    g.setColor(back_color);
    g.fillRect(convPos(0), convPos(0), radar_area_width - grid_size, radar_area_height - grid_size);
    g.setColor(line_color);
    int i, j;
    for (i = 0; i < dx; i++)
      for (j = 0; j < dy; j++) g.draw(new Rectangle(convPos(i) - 1, convPos(j) - 1, 1, 1));

    radarArea.backIcon = new ImageIcon(radarArea.backImage);
    radarArea.back = new JLabel(radarArea.backIcon);
    radarArea.back.setBounds(0, 0, radar_area_width, radar_area_height);
    radarArea.add(radarArea.back, new Integer(0));

    infoArea = new JPanel();
    infoArea.setMinimumSize(new Dimension(info_area_width, radar_area_height));
    infoArea.setPreferredSize(new Dimension(info_area_width, radar_area_height));
    infoArea.setLayout(new GridLayout(27, 1));
    infoTopLine = new Label(" ");
    infoArea.add(infoTopLine);
    getContentPane().add(infoArea, BorderLayout.EAST);

    inputArea = new JLabel("          ");
    getContentPane().add(inputArea, BorderLayout.SOUTH);

    controlArea = new JPanel();
    newButton = new JButton("New");
    newButton.setActionCommand("New");
    newButton.addActionListener(this);
    newButton.setEnabled(false);
    newButton.setFocusable(false);
    exitButton = new JButton("Exit");
    exitButton.setActionCommand("Exit");
    exitButton.addActionListener(this);
    exitButton.setFocusable(false);
    controlArea.add(newButton);
    controlArea.add(exitButton);
    getContentPane().add(controlArea, BorderLayout.NORTH);

    pack();
  }