org.game.Juzzle
Class PuzzlePanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--org.game.Juzzle.PuzzlePanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable

public class PuzzlePanel
extends javax.swing.JPanel
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

this panel paints the pieces of the puzzle

See Also:
PuzzlePanel, PuzzlePartList, Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  boolean antialiasing
          antialiasing on/off
protected  java.awt.image.BufferedImage bimage
          reference to the image
protected  ControlPanel controlPanel
          reference to the ControlPanel to set sthe solved pieces count
protected static java.awt.Cursor CURSOR_DEFAULT
          cursor normal
protected static java.awt.Cursor CURSOR_HAND
          cursor while dragging
protected  boolean dragModus1
          drag modus 1 mean that the user clicks the mouse button and then move the piece and clicks again to release.


drag modus 2 mean that the user press the mouse button and then drag the piece and release the button.


protected  boolean dragModus2
          drag modus 1 mean that the user clicks the mouse button and then move the piece and clicks again to release.


drag modus 2 mean that the user press the mouse button and then drag the piece and release the button.


protected  boolean endMessagePrinted
          needed to show only one time per game the win message
protected  java.awt.Point lastDragLocation
          last drag location for difference calculation
protected  boolean outline
          outline on/off
protected static java.awt.Color outlineColor
          outline color
protected static int PAINT_EXTEND
          thicknes of the outline for the piece for repaint rect
protected static int PAINT_SHADOW
          thicknes of the shadow while dragging and for repaint rect
protected  IPuzzlePartList puzzlePartList
          reference to the pieces list model
protected  java.awt.Rectangle repaintRect1
          source rect to repaint
protected  java.awt.Rectangle repaintRect2
          target rect to repaint
protected  boolean shadow
          shadow on/off
protected static java.awt.Color shadowColor
          shadow color
protected  int x_parts
          x division
protected  int y_parts
          y division
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, 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
 
Constructor Summary
PuzzlePanel(ControlPanel controlPanel)
          simply constructor
 
Method Summary
 void emptyGame()
          clear all variables
 void mouseClicked(java.awt.event.MouseEvent e)
          from MouseListener
 void mouseDragged(java.awt.event.MouseEvent e)
          from MouseMotionListener
 void mouseEntered(java.awt.event.MouseEvent e)
          from MouseListener, not used
 void mouseExited(java.awt.event.MouseEvent e)
          from MouseListener, not used
 void mouseMoved(java.awt.event.MouseEvent e)
          from MouseMotionListener
 void mousePressed(java.awt.event.MouseEvent e)
          from MouseListener
 void mouseReleased(java.awt.event.MouseEvent e)
          from MouseListener
 void paintComponent(java.awt.Graphics g)
          overwrite paintComponent to paint the pieces
 void resetGame()
          reset the current game
 void setAntialiasing(boolean b)
          set antialiasing on/off
 void setGame(java.awt.image.BufferedImage bimage, int x_parts, int y_parts)
          set the new parameters to play the game
 void setOutline(boolean b)
          set outline on/off
 void setShadow(boolean b)
          set shadow on/off
protected  void startDragging(java.awt.event.MouseEvent e)
          if the user clicks one of the parts, start dragging
protected  void stopDragging(java.awt.event.MouseEvent e)
          the user put the piece on the desctop back
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PAINT_EXTEND

protected static final int PAINT_EXTEND
thicknes of the outline for the piece for repaint rect

PAINT_SHADOW

protected static final int PAINT_SHADOW
thicknes of the shadow while dragging and for repaint rect

CURSOR_HAND

protected static final java.awt.Cursor CURSOR_HAND
cursor while dragging

CURSOR_DEFAULT

protected static final java.awt.Cursor CURSOR_DEFAULT
cursor normal

outlineColor

protected static final java.awt.Color outlineColor
outline color

shadowColor

protected static final java.awt.Color shadowColor
shadow color

bimage

protected java.awt.image.BufferedImage bimage
reference to the image

x_parts

protected int x_parts
x division

y_parts

protected int y_parts
y division

controlPanel

protected ControlPanel controlPanel
reference to the ControlPanel to set sthe solved pieces count
See Also:
ControlPanel

dragModus1

protected boolean dragModus1
drag modus 1 mean that the user clicks the mouse button and then move the piece and clicks again to release.


drag modus 2 mean that the user press the mouse button and then drag the piece and release the button.



dragModus2

protected boolean dragModus2
drag modus 1 mean that the user clicks the mouse button and then move the piece and clicks again to release.


drag modus 2 mean that the user press the mouse button and then drag the piece and release the button.



lastDragLocation

protected java.awt.Point lastDragLocation
last drag location for difference calculation

repaintRect1

protected java.awt.Rectangle repaintRect1
source rect to repaint

repaintRect2

protected java.awt.Rectangle repaintRect2
target rect to repaint

endMessagePrinted

protected boolean endMessagePrinted
needed to show only one time per game the win message

puzzlePartList

protected IPuzzlePartList puzzlePartList
reference to the pieces list model
See Also:
IPuzzlePartList

antialiasing

protected boolean antialiasing
antialiasing on/off

outline

protected boolean outline
outline on/off

shadow

protected boolean shadow
shadow on/off
Constructor Detail

PuzzlePanel

public PuzzlePanel(ControlPanel controlPanel)
simply constructor
Parameters:
controlPanel - the reference to the ControlPanel
Method Detail

resetGame

public void resetGame()
reset the current game

emptyGame

public void emptyGame()
clear all variables

setGame

public void setGame(java.awt.image.BufferedImage bimage,
                    int x_parts,
                    int y_parts)
set the new parameters to play the game

setAntialiasing

public void setAntialiasing(boolean b)
set antialiasing on/off

setOutline

public void setOutline(boolean b)
set outline on/off

setShadow

public void setShadow(boolean b)
set shadow on/off

paintComponent

public void paintComponent(java.awt.Graphics g)
overwrite paintComponent to paint the pieces
Overrides:
paintComponent in class javax.swing.JComponent

startDragging

protected void startDragging(java.awt.event.MouseEvent e)
if the user clicks one of the parts, start dragging

stopDragging

protected void stopDragging(java.awt.event.MouseEvent e)
the user put the piece on the desctop back

mouseClicked

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

mouseEntered

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

mouseExited

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

mousePressed

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

mouseReleased

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

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
from MouseMotionListener
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
from MouseMotionListener
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener