Esempio n. 1
0
  public void paintComponent(Graphics comp) {
    if (m_Image == null) {
      Cursor currentCursor = getCursor();
      try {
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        Dimension size = m_WorldMap.getMapSize();
        m_Image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = (Graphics2D) m_Image.getGraphics();
        g.setClip(0, 0, size.width, size.height);
        m_WorldMap.draw(g, 0, 0, getDrawMode());
      } finally {
        setCursor(currentCursor);
      }
    }

    Graphics2D g2D = (Graphics2D) comp;
    g2D.drawImage(m_Image, null, 0, 0);

    boolean ShowHexNeighbours = true;
    if (m_CurrentSegment != -1) m_WorldMap.HighlightSegment(comp, m_CurrentSegment, true);
    if (m_CurrentSector != -1)
      m_WorldMap.HighlightSector(g2D, m_CurrentSector, true, ShowHexNeighbours);
    if (m_CurrentPath != null)
      m_WorldMap.HighlightPath(g2D, m_CurrentPath, true, ShowHexNeighbours);
  }
Esempio n. 2
0
  public void mouseClicked(MouseEvent evt) {
    int x = evt.getX();
    int y = evt.getY();

    if (evt.getButton() == MouseEvent.BUTTON1) {
      m_CurrentPath = null;

      m_CurrentSegment = m_WorldMap.GetSelectedSegment(x, y);
      m_CurrentSector = m_WorldMap.GetSelectedSector(x, y);

      repaint();
    } else if (evt.getButton() == MouseEvent.BUTTON3) {
      int Sector = m_WorldMap.GetSelectedSector(x, y);
      m_CurrentPath = m_WorldMap.GetSectorPath(m_CurrentSector, Sector);
      repaint();
    }
  }
Esempio n. 3
0
  public void init(SolarSystemDetails details, int hexSize, WorldMapRenderer.DrawMode drawMode) {
    m_DrawMode = drawMode;
    this.m_WorldMap = new WorldMapRenderer(details, hexSize);
    this.setSize(m_WorldMap.getMapSize());
    this.invalidate();
    this.repaint();

    addMouseListener(this);
  }
Esempio n. 4
0
 public Dimension getSize() {
   return m_WorldMap.getMapSize();
 }
Esempio n. 5
0
 public Dimension getPreferredSize() {
   return m_WorldMap.getMapSize();
 }