Class FPanelCarte

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class FPanelCarte extends FPanel
Map panel.
It can draw map.
Mouse listener part is in FPanelSup.java.
Author:
Hydrolien
See Also:
  • Field Details

    • xCase

      private int xCase
    • yCase

      private int yCase
    • xTemp

      private int xTemp
    • yTemp

      private int yTemp
    • idCurentFere

      private int idCurentFere
    • lookedCCase

      private CCase lookedCCase
    • hashMapMovingObjectSurCarteAid

      private Map<Integer,fr.formiko.usual.Point> hashMapMovingObjectSurCarteAid
    • hashMapMovingObjectSurCarteAidRotation

      private Map<Integer,fr.formiko.usual.Point> hashMapMovingObjectSurCarteAidRotation
    • imageSizeComparator

      private static Comparator<Creature> imageSizeComparator
    • iconImage

      private BufferedImage iconImage
    • bladeImage

      private BufferedImage bladeImage
    • tBiState

      private BufferedImage[] tBiState
    • TRANSPARENCY

      private int TRANSPARENCY
  • Constructor Details

    • FPanelCarte

      public FPanelCarte()
  • Method Details

    • build

      public void build()
      Build methode.
    • getTailleDUneCase

      public int getTailleDUneCase()
    • getTailleIcon

      public int getTailleIcon()
    • setTailleDUneCase

      public void setTailleDUneCase(int x, boolean updateMap)
      Update Case size.
      Parameters:
      x - new value for Case size
      updateMap - if true update the map to
    • setTailleDUneCase

      public void setTailleDUneCase(int x)
      Update Case size & map.
      Parameters:
      x - new value for Case size
    • getXCase

      public int getXCase()
    • setXCase

      public void setXCase(int x)
    • getYCase

      public int getYCase()
    • setYCase

      public void setYCase(int y)
    • setIdCurentFere

      public void setIdCurentFere(int x)
    • getLookedCCase

      public CCase getLookedCCase()
    • setLookedCCase

      public void setLookedCCase(CCase cc)
    • setLigne

      public void setLigne(Graphics2D g)
    • setSize

      public void setSize(int x, int y)
      setSize sould never be used. Use updateSize insted.
      Overrides:
      setSize in class Component
    • actualiserCarte

      public void actualiserCarte()
      Do the 3 steps that are need to set FPanelCarte to a new size.
    • getTBIState

      public BufferedImage[] getTBIState()
    • paintComponent

      public void paintComponent(Graphics g2)
      Main paint function for Map.
      It print 1 by 1: map with only Case, grids, all map element Case by Case, the mark for all game as playingAnt mark.
      Overrides:
      paintComponent in class FPanel
    • dessinerGrille

      public void dessinerGrille(Graphics g)
      Draw grid.
    • drawBlades

      public void drawBlades(Graphics g, GCase gc)
    • peintImagePourCase

      public void peintImagePourCase(Case c, Graphics2D g)
    • peintImagePourCase

      public void peintImagePourCase(GCase gc, int x, int y, Graphics2D g)
    • peintCaseNuageuse

      public boolean peintCaseNuageuse(int x, int y, Graphics g, int xT, int yT)
      Draw cloud Case.
    • drawPlayingAnt

      private void drawPlayingAnt(Graphics g)
      Draw the mark for playingAnt.
    • drawMovingPath

      private void drawMovingPath(Graphics g)
      Draw the path from playingAnt to the looked case.
    • drawWhiteCircle

      private void drawWhiteCircle(Graphics g, CCase cc, int toPrint)
      Draw a white circle on giving Case.
      Parameters:
      g - graphics where to draw
      cc - CCase where to draw
    • drawCircle

      private void drawCircle(Graphics g, CCase cc, Color col)
      Draw a colored circle on a giving Case.
      Parameters:
      g - graphics where to draw
      cc - CCase where to draw
      col - Color to use
    • drawWhiteLine

      private void drawWhiteLine(Graphics g, CCase from, CCase to, boolean drawOnFrom, boolean drawOnTo)
      Draw a white line on giving Case.
      Parameters:
      g - graphics where to draw
      from - CCase where to start draw
      to - CCase where to end draw
    • drawLine

      private void drawLine(Graphics g, CCase from, CCase to, Color col, boolean drawOnFrom, boolean drawOnTo)
      Draw a colored line on a giving Case.
      Parameters:
      g - graphics where to draw
      from - CCase where to start draw
      to - CCase where to end draw
      col - Color to use
    • drawLine

      private void drawLine(Graphics g, CCase from, CCase to, Color col)
      Draw a colored line on a giving Case.
      Parameters:
      g - graphics where to draw
      from - CCase where to start draw
      to - CCase where to end draw
      col - Color to use
    • getPointFromCase

      public fr.formiko.usual.Point getPointFromCase(int x, int y, boolean centered)
      Return the coordinates on screen for Case with x & y.
      Parameters:
      x - the x of the Case.
      y - the y of the Case.
      centered - True return the coordinates of the center of the case. False return left top coordinates.
    • peintImagePourCase

      public void peintImagePourCase(Case c, int x, int y, Graphics2D g)
      Draw a Case.
    • needToDraw

      public static boolean needToDraw(Creature cr)
      Return true if we need to draw Creature depending of the Options.
    • gcSortedByImageSize

      public static fr.formiko.usual.structures.listes.Liste<Creature> gcSortedByImageSize(GCreature gc)
      Return a Liste<Creature> sorted by image size.
      It is used to print smaler creature on top, so that we can see every Creature.
    • addMovingObject

      public void addMovingObject(int id, fr.formiko.usual.Point location, fr.formiko.usual.Point rotation)
      Add a curent moving object. It modify location and rotation of the object. location and rotation are save in 2 hashmap.
      Parameters:
      id - the id of the object
      location - the modification of the location of the object as a Point
      rotation - the modification of the rotation in the x value of a Point
    • getMovingObjectLocation

      public fr.formiko.usual.Point getMovingObjectLocation(int id)
    • getMovingObjectRotation

      public fr.formiko.usual.Point getMovingObjectRotation(int id)
    • removeMovingObject

      public void removeMovingObject(int id)
    • drawImageCentered

      private void drawImageCentered(Graphics g, BufferedImage image, int xT, int yT, int caseSize)
      draw an image centered.
      Parameters:
      g - Graphics element were to draw.
      image - the image to draw.
      xT - the x of the Case were to draw.
      yT - the y of the Case were to draw.
      caseSize - size of the Case
    • drawImageCentered

      private void drawImageCentered(Graphics g, BufferedImage image, int xT, int yT)
      draw an image centered for a Case.
      Parameters:
      g - Graphics element were to draw.
      image - the image to draw.
      xT - the x of the Case were to draw.
      yT - the y of the Case were to draw.
    • drawImage

      public void drawImage(Graphics gTemp, BufferedImage im, int x, int y)
      draw an image.
      Parameters:
      gTemp - Graphics element were to draw.
      im - the image to draw.
      x - the x ere to draw.
      y - the y were to draw.
    • isSombre

      private boolean isSombre(int x, int y)
      return true if case in x,y is sombre.
    • needToDrawAnthillColor

      private boolean needToDrawAnthillColor(Case c, int x, int y)
      return true if we need to draw the color of the anthill.
    • calculerXYTemp

      public void calculerXYTemp(int xT, int yT, int k, Case c)
      fonction that place ObjetSurCarteAId on the same Case.
      It modify FPanelCarte value xTemp and yTemp.
    • drawRondOuRect

      public void drawRondOuRect(int x, int y, int tailleDUneCase, Graphics2D g, Fourmiliere fere, int tailleDuCercle)
      Draw an anthill mark.
    • drawRond

      public void drawRond(int x, int y, int r, Graphics2D g, Fourmiliere fere, int tailleDuCercle)
      Draw a circle as an anthill mark.
    • drawIcon

      public void drawIcon(Graphics g, BufferedImage iconImage, int xT, int yT, int xOffset)
      Draw an icon.
      Parameters:
      g - the Graphics where to draw
      iconImage - the icon image to draw
      xT - x value to use
      yT - y value to use
      xOffset - offset in x
    • drawListIcons

      public void drawListIcons(Graphics g, fr.formiko.usual.structures.listes.Liste<BufferedImage> list, int xT, int yT, int xOffset)
      Draw an icons list.
      Parameters:
      g - the Graphics where to draw
      list - the list of icon image to draw
      xT - x value to use
      yT - y value to use
      xOffset - offset in x
    • doSlice

      private BufferedImage doSlice(int angle, BufferedImage biIn, int k, boolean replaceColorByImage)
      Do a slice of angle from a BufferedImage.
      Parameters:
      angle - the angle of the slice
      biIn - the BufferedImage in
      k - offset in angle (k * the angle)
      replaceColorByImage - if true we replace font color by the image in
      Returns:
      a slice of the BufferedImage in
    • getIconId

      public static int getIconId(Creature cr, Fourmi fi)
      Return an icon id.
      Parameters:
      cr - the Creature that we represent by the icon
      fi - the Creature that whant to know how to see the other Creature
      Returns:
      the icone id corresponding to the relation from the ant to the Creature.
    • getIconImage

      public static BufferedImage getIconImage(Creature cr, Fourmi fi)
      Return an icon image.
      Parameters:
      cr - the Creature that we represent by the icon
      fi - the Creature that whant to know how to see the other Creature
      Returns:
      the icone image corresponding to the relation from the ant to the Creature
    • getIconImage

      public BufferedImage getIconImage(int id)
      Return an icon image.
      Parameters:
      id - the id of the icon
      Returns:
      the icone image corresponding to the id
    • getStatesIconsImages

      public fr.formiko.usual.structures.listes.Liste<BufferedImage> getStatesIconsImages(Creature cr)
      Return the states icons images.
      Parameters:
      cr - the Creature that we whant to print icons states
    • getStateIconImage

      public BufferedImage getStateIconImage(Color col, BufferedImage icon)
      Return a state icon image.
      A colored round containing an icon image.
    • getDir

      public int getDir(ObjetSurCarteAId obj)
    • updateSize

      public void updateSize()
    • isCaseVisible

      public boolean isCaseVisible(Case c)
      Tool to save performances by drawing only visible Case.
      Parameters:
      c - Case to check return true if case is visible
    • isCaseVisible

      public static boolean isCaseVisible(Case c, int minX, int minY, int maxX, int maxY, int caseSize)
      Tool to save performances by drawing only visible Case.
      Parameters:
      c - Case to check return true if case is visible
    • nbrPrintableCase

      public int nbrPrintableCase(boolean inX)
      Tool to calculate the number of printable case on this Panel.
      It depend of the size of the panel and of the size of the Case.
      Parameters:
      inX - true if we check x (width)
      Returns:
      number of printable Case
    • iniTBiState

      public void iniTBiState()