net.sf.magicproject.zone
Class MZone

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by net.sf.magicproject.zone.MZone
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible
Direct Known Subclasses:
DelayedBuffer, ExpandableZone, Hand, Play, Side, Stack, TriggeredBuffer

public abstract class MZone
extends javax.swing.JPanel
implements java.awt.event.MouseListener

A zone is a cards container.

Since:
0.2c, 0.3 feature "reverseImage" implemented, 0.4 you can now change wallpaper/color of this MZone and setting, 0.52 "enableReverse" option are saved., 0.71 visibility of cards can be set. Cards come into this zone returned or not immediatly
Author:
Fabrice Daugan
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 MCard dragAndDropComponent
          The d&d component.
 java.awt.Point mousePoint
          The d&d starting point
 javax.swing.JScrollPane superPanel
          the parent scrollpane
 Visibility visibility
          Indicates all cards of this zone are returned or not.
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Method Summary
 void add(MCard card, int position)
          Add a card to this panel.
 void addBottom(MCard card)
          Add a card at the bottom of this panel.
 void addTop(MCard card)
          Add a card at the top of this panel.
 void checkAllCardsOf(Test test, java.util.List<Targetable> list, Ability ability)
          Checks all cards corresponding to this constraints
 int countAllCardsOf(Test test, Ability ability)
          Checks all cards corresponding to the specified constraints including attached cards.
 int countAllCardsOf(Test test, Ability ability, int limit, boolean canBePreempted)
          Checks all cards corresponding to the specified constraints including attached cards.
 void disHighLight()
          Dishighlight only this component, not the components of this zone.
 void disHighLightAll()
          Dishighlight all cards of this zone manager
 MCard getBottom()
          return the first card (bottom)
 MCard getCard(int index)
          return the card at index
 int getCardCount()
          return the number of cards in this panel
 int getControllerIdPlayer()
          Return idplayer of controller of this zone.
 Pair<java.lang.Integer,java.lang.Integer> getRealIndexOf(MCard card)
          Return the index of the specified card within this zone
 MCard getTop()
          return the last card (top)
 int getZoneId()
          Returnn the zone identifiant
 java.lang.String getZoneName()
          This function returns the result of Component#getName() This will return the untranslated name of this zone.
 void highLight(java.awt.Color color)
          Highlight only this component, not the components of this zone.
 boolean isMustBePainted(MCard card)
          Return true if the given card should be painted entirely.
 boolean isMustBePaintedReversed(MCard card)
          Return true if the given card should be painted as reversed card.
 boolean isSamePosition(MCard card, int position)
          Indicates wether this card suits to the specified position code.
 boolean isShared()
          Is this zone is shared with all players.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
          is called when you click on me
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paintComponent(java.awt.Graphics g)
           
 void readWallPaperConfiguration(java.io.InputStream inputStream)
          Set the new wallpaper for the current game.
 void remove(AbstractCard card)
          Add a card to this panel.
 void removeAll()
           
 void reset()
          Remove all cards of this zone
 void setVisibility(Visibility visibility)
          Set the visibility of this zone.
 void shuffle()
          Shuffle the zone
 boolean startDragAndDrop(MCard card, java.awt.Point mousePoint)
          Start the drag and drop managment for the given card.
 java.lang.String toString()
          return the translated name of this zone
 void updatePanel()
          update this panel in fonction of it's components
 void updateReversed()
          Update the "reversed" state of this component.
 void writeWallPaperConfiguration(java.io.OutputStream out)
          Send the wallpaper configuration over the given output stream.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

visibility

public Visibility visibility
Indicates all cards of this zone are returned or not. All cards comming into this zone would be returned or not depending this flag.

Since:
0.80 cards are hidden by default, 0.90 use Visibility class instead of boolean

superPanel

public final javax.swing.JScrollPane superPanel
the parent scrollpane


mousePoint

public java.awt.Point mousePoint
The d&d starting point


dragAndDropComponent

public MCard dragAndDropComponent
The d&d component.

Method Detail

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

getCard

public final MCard getCard(int index)
return the card at index

Parameters:
index - is the index where is the element
Returns:
the card at the specified index

getTop

public MCard getTop()
return the last card (top)

Returns:
the last card

getBottom

public MCard getBottom()
return the first card (bottom)

Returns:
the first card

isSamePosition

public final boolean isSamePosition(MCard card,
                                    int position)
Indicates wether this card suits to the specified position code.

Parameters:
card - is the card to locate.
position - the matching position code
Returns:
true if this card suits to the specified position code.
See Also:
IdPositions.ON_THE_BOTTOM, IdPositions.ON_THE_TOP

getRealIndexOf

public Pair<java.lang.Integer,java.lang.Integer> getRealIndexOf(MCard card)
Return the index of the specified card within this zone

Parameters:
card - the card to search
Returns:
the found index

toString

public java.lang.String toString()
return the translated name of this zone

Overrides:
toString in class java.awt.Component
Returns:
the name of this panel

getZoneName

public java.lang.String getZoneName()
This function returns the result of Component#getName() This will return the untranslated name of this zone. The toString()method returns the tanslated name of this zone

Returns:
the result of Component#getName()
See Also:
toString()

readWallPaperConfiguration

public void readWallPaperConfiguration(java.io.InputStream inputStream)
                                throws java.io.IOException
Set the new wallpaper for the current game.

Parameters:
inputStream - the input Stream containing the wallpaper configuration.
Throws:
java.io.IOException - If some other I/O error occurs

writeWallPaperConfiguration

public void writeWallPaperConfiguration(java.io.OutputStream out)
                                 throws java.io.IOException
Send the wallpaper configuration over the given output stream.

Parameters:
out - the output Stream containing the wallpaper configuration.
Throws:
java.io.IOException - If some other I/O error occurs

removeAll

public void removeAll()
Overrides:
removeAll in class java.awt.Container

updatePanel

public void updatePanel()
update this panel in fonction of it's components


shuffle

public void shuffle()
Shuffle the zone


mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

updateReversed

public void updateReversed()
Update the "reversed" state of this component.


mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
is called when you click on me

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - is the mouse event

remove

public void remove(AbstractCard card)
Add a card to this panel. If tag 'returnedCards' is true, this card comes returned into this zone.

Parameters:
card - the card to add to this zone.

getCardCount

public int getCardCount()
return the number of cards in this panel

Returns:
the number of cards in this panel

countAllCardsOf

public int countAllCardsOf(Test test,
                           Ability ability)
Checks all cards corresponding to the specified constraints including attached cards.

Parameters:
test - applied to count valid cards
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
Returns:
amount of card matching with the specified test

countAllCardsOf

public int countAllCardsOf(Test test,
                           Ability ability,
                           int limit,
                           boolean canBePreempted)
Checks all cards corresponding to the specified constraints including attached cards.

Parameters:
test - applied to count valid cards
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.
limit - is the desired count.
canBePreempted - true if the valid targets can be derterminated before runtime.
Returns:
amount of cards matching with the specified test. Highest value is limit.

checkAllCardsOf

public void checkAllCardsOf(Test test,
                            java.util.List<Targetable> list,
                            Ability ability)
Checks all cards corresponding to this constraints

Parameters:
test - applied to count valid cards
list - the list containing the founded cards
ability - is the ability owning this test. The card component of this ability should correspond to the card owning this test too.

disHighLightAll

public void disHighLightAll()
Dishighlight all cards of this zone manager


disHighLight

public void disHighLight()
Dishighlight only this component, not the components of this zone.


highLight

public void highLight(java.awt.Color color)
Highlight only this component, not the components of this zone. Use instead the specific highlight color of the desired zone.

Parameters:
color - the color of highlight.

reset

public void reset()
Remove all cards of this zone


setVisibility

public void setVisibility(Visibility visibility)
Set the visibility of this zone.

Parameters:
visibility - the new visibility for this zone.

addBottom

public void addBottom(MCard card)
Add a card at the bottom of this panel. If tag 'returnedCards' is true, this card comes returned into this zone.

Parameters:
card - the card to add to this zone.

addTop

public void addTop(MCard card)
Add a card at the top of this panel. If tag 'returnedCards' is true, this card comes returned into this zone. Be carrefull, you can use this function only if the specified component is not yet in this container.

Parameters:
card - the card to add to this zone.

add

public void add(MCard card,
                int position)
Add a card to this panel. If tag 'returnedCards' is true, this card comes returned into this zone.

Parameters:
card - the card to add to this zone.
position - the position index of insertion.

getControllerIdPlayer

public int getControllerIdPlayer()
Return idplayer of controller of this zone.

Returns:
idplayer of controller of this zone.

getZoneId

public final int getZoneId()
Returnn the zone identifiant

Returns:
the zone identifiant

startDragAndDrop

public boolean startDragAndDrop(MCard card,
                                java.awt.Point mousePoint)
Start the drag and drop managment for the given card.

Parameters:
card - The d&d component.
mousePoint - The d&d starting point.
Returns:
true if the drag and drop is managed by this zone.

isMustBePaintedReversed

public boolean isMustBePaintedReversed(MCard card)
Return true if the given card should be painted as reversed card.

Parameters:
card - the card to draw.
Returns:
true if the given card should be painted as reversed card.

isMustBePainted

public boolean isMustBePainted(MCard card)
Return true if the given card should be painted entirely.

Parameters:
card - the card to draw.
Returns:
true if the given card should be painted entirely.

isShared

public boolean isShared()
Is this zone is shared with all players.

Returns:
true if this zone is shared with all players.


Copyright © 2003-2007 Magic-Project. All Rights Reserved.