Package fr.formiko.views.gui2d
Class FPanelCarte
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
fr.formiko.views.gui2d.FPanel
fr.formiko.views.gui2d.FPanelCarte
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible
Map panel.
It can draw map.
Mouse listener part is in FPanelSup.java.
It can draw map.
Mouse listener part is in FPanelSup.java.
- Author:
- Hydrolien
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class fr.formiko.views.gui2d.FPanel
FPanel.BListenerNested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BufferedImageprivate BufferedImageprivate intprivate static Comparator<Creature>private CCaseprivate BufferedImage[]private intprivate intprivate intprivate intprivate intFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDo the 3 steps that are need to set FPanelCarte to a new size.voidaddMovingObject(int id, fr.formiko.usual.Point location, fr.formiko.usual.Point rotation) Add a curent moving object.voidbuild()Build methode.voidcalculerXYTemp(int xT, int yT, int k, Case c) fonction that place ObjetSurCarteAId on the same Case.voidDraw grid.private BufferedImagedoSlice(int angle, BufferedImage biIn, int k, boolean replaceColorByImage) Do a slice of angle from a BufferedImage.voiddrawBlades(Graphics g, GCase gc) private voiddrawCircle(Graphics g, CCase cc, Color col) Draw a colored circle on a giving Case.voiddrawIcon(Graphics g, BufferedImage iconImage, int xT, int yT, int xOffset) Draw an icon.voiddrawImage(Graphics gTemp, BufferedImage im, int x, int y) draw an image.private voiddrawImageCentered(Graphics g, BufferedImage image, int xT, int yT) draw an image centered for a Case.private voiddrawImageCentered(Graphics g, BufferedImage image, int xT, int yT, int caseSize) draw an image centered.private voidDraw a colored line on a giving Case.private voidDraw a colored line on a giving Case.voiddrawListIcons(Graphics g, fr.formiko.usual.structures.listes.Liste<BufferedImage> list, int xT, int yT, int xOffset) Draw an icons list.private voidDraw the path from playingAnt to the looked case.private voidDraw the mark for playingAnt.voiddrawRond(int x, int y, int r, Graphics2D g, Fourmiliere fere, int tailleDuCercle) Draw a circle as an anthill mark.voiddrawRondOuRect(int x, int y, int tailleDUneCase, Graphics2D g, Fourmiliere fere, int tailleDuCercle) Draw an anthill mark.private voiddrawWhiteCircle(Graphics g, CCase cc, int toPrint) Draw a white circle on giving Case.private voiddrawWhiteLine(Graphics g, CCase from, CCase to, boolean drawOnFrom, boolean drawOnTo) Draw a white line on giving Case.static fr.formiko.usual.structures.listes.Liste<Creature>Return a Liste<Creature> sorted by image size.intgetDir(ObjetSurCarteAId obj) static intReturn an icon id.getIconImage(int id) Return an icon image.static BufferedImagegetIconImage(Creature cr, Fourmi fi) Return an icon image.fr.formiko.usual.PointgetMovingObjectLocation(int id) fr.formiko.usual.PointgetMovingObjectRotation(int id) fr.formiko.usual.PointgetPointFromCase(int x, int y, boolean centered) Return the coordinates on screen for Case with x & y.getStateIconImage(Color col, BufferedImage icon) Return a state icon image.fr.formiko.usual.structures.listes.Liste<BufferedImage>Return the states icons images.intintintgetXCase()intgetYCase()voidbooleanTool to save performances by drawing only visible Case.static booleanisCaseVisible(Case c, int minX, int minY, int maxX, int maxY, int caseSize) Tool to save performances by drawing only visible Case.private booleanisSombre(int x, int y) return true if case in x,y is sombre.intnbrPrintableCase(boolean inX) Tool to calculate the number of printable case on this Panel.static booleanneedToDraw(Creature cr) Return true if we need to draw Creature depending of the Options.private booleanneedToDrawAnthillColor(Case c, int x, int y) return true if we need to draw the color of the anthill.voidMain paint function for Map.booleanpeintCaseNuageuse(int x, int y, Graphics g, int xT, int yT) Draw cloud Case.voidpeintImagePourCase(Case c, int x, int y, Graphics2D g) Draw a Case.voidpeintImagePourCase(Case c, Graphics2D g) voidpeintImagePourCase(GCase gc, int x, int y, Graphics2D g) voidremoveMovingObject(int id) voidsetIdCurentFere(int x) voidvoidsetLookedCCase(CCase cc) voidsetSize(int x, int y) setSize sould never be used.voidsetTailleDUneCase(int x) Update Case size & map.voidsetTailleDUneCase(int x, boolean updateMap) Update Case size.voidsetXCase(int x) voidsetYCase(int y) voidMethods inherited from class fr.formiko.views.gui2d.FPanel
doAction, getBListener, getData, getView, remove, toStringMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
xCase
private int xCase -
yCase
private int yCase -
xTemp
private int xTemp -
yTemp
private int yTemp -
idCurentFere
private int idCurentFere -
lookedCCase
-
hashMapMovingObjectSurCarteAid
-
hashMapMovingObjectSurCarteAidRotation
-
imageSizeComparator
-
iconImage
-
bladeImage
-
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 sizeupdateMap- 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
-
setLookedCCase
-
setLigne
-
setSize
public void setSize(int x, int y) setSize sould never be used. Use updateSize insted. -
actualiserCarte
public void actualiserCarte()Do the 3 steps that are need to set FPanelCarte to a new size. -
getTBIState
-
paintComponent
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:
paintComponentin classFPanel
-
dessinerGrille
Draw grid. -
drawBlades
-
peintImagePourCase
-
peintImagePourCase
-
peintCaseNuageuse
Draw cloud Case. -
drawPlayingAnt
Draw the mark for playingAnt. -
drawMovingPath
Draw the path from playingAnt to the looked case. -
drawWhiteCircle
Draw a white circle on giving Case.- Parameters:
g- graphics where to drawcc- CCase where to draw
-
drawCircle
Draw a colored circle on a giving Case.- Parameters:
g- graphics where to drawcc- CCase where to drawcol- Color to use
-
drawWhiteLine
Draw a white line on giving Case.- Parameters:
g- graphics where to drawfrom- CCase where to start drawto- 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 drawfrom- CCase where to start drawto- CCase where to end drawcol- Color to use
-
drawLine
Draw a colored line on a giving Case.- Parameters:
g- graphics where to drawfrom- CCase where to start drawto- CCase where to end drawcol- 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
Draw a Case. -
needToDraw
Return true if we need to draw Creature depending of the Options. -
gcSortedByImageSize
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 objectlocation- the modification of the location of the object as a Pointrotation- 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
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
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
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
return true if we need to draw the color of the anthill. -
calculerXYTemp
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
Draw a circle as an anthill mark. -
drawIcon
Draw an icon.- Parameters:
g- the Graphics where to drawiconImage- the icon image to drawxT- x value to useyT- y value to usexOffset- 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 drawlist- the list of icon image to drawxT- x value to useyT- y value to usexOffset- offset in x
-
doSlice
Do a slice of angle from a BufferedImage.- Parameters:
angle- the angle of the slicebiIn- the BufferedImage ink- 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
Return an icon id.- Parameters:
cr- the Creature that we represent by the iconfi- 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
Return an icon image.- Parameters:
cr- the Creature that we represent by the iconfi- 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
Return an icon image.- Parameters:
id- the id of the icon- Returns:
- the icone image corresponding to the id
-
getStatesIconsImages
Return the states icons images.- Parameters:
cr- the Creature that we whant to print icons states
-
getStateIconImage
Return a state icon image.
A colored round containing an icon image. -
getDir
-
updateSize
public void updateSize() -
isCaseVisible
Tool to save performances by drawing only visible Case.- Parameters:
c- Case to check return true if case is visible
-
isCaseVisible
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()
-