Package org.refcodes.checkerboard
Class AbstractPlayer<P extends Player<P,S>,S>
- java.lang.Object
-
- org.refcodes.observer.AbstractObservable<PlayerObserver<P,S>,PlayerEvent<P>>
-
- org.refcodes.checkerboard.AbstractPlayer<P,S>
-
- Type Parameters:
P
- the generic typeS
- the generic type
- All Implemented Interfaces:
Player<P,S>
,org.refcodes.graphical.DraggableAccessor
,org.refcodes.graphical.DraggableAccessor.DraggableBuilder<P>
,org.refcodes.graphical.DraggableAccessor.DraggableMutator
,org.refcodes.graphical.DraggableAccessor.DraggableProperty
,org.refcodes.graphical.Position
,org.refcodes.graphical.Position.PositionBuilder<P>
,org.refcodes.graphical.Position.PositionMutator
,org.refcodes.graphical.Position.PositionProperty
,org.refcodes.graphical.PosXAccessor
,org.refcodes.graphical.PosXAccessor.PosXBuilder<P>
,org.refcodes.graphical.PosXAccessor.PosXMutator
,org.refcodes.graphical.PosXAccessor.PosXProperty
,org.refcodes.graphical.PosYAccessor
,org.refcodes.graphical.PosYAccessor.PosYBuilder<P>
,org.refcodes.graphical.PosYAccessor.PosYMutator
,org.refcodes.graphical.PosYAccessor.PosYProperty
,org.refcodes.graphical.VisibleAccessor
,org.refcodes.graphical.VisibleAccessor.VisibleBuilder<P>
,org.refcodes.graphical.VisibleAccessor.VisibleMutator
,org.refcodes.graphical.VisibleAccessor.VisibleProperty
,org.refcodes.mixin.StatusAccessor<P>
,org.refcodes.mixin.StatusAccessor.StatusBuilder<P,S>
,org.refcodes.mixin.StatusAccessor.StatusMutator<P>
,org.refcodes.mixin.StatusAccessor.StatusProperty<P>
,org.refcodes.observer.Observable<P>
- Direct Known Subclasses:
TaitoImpl
public abstract class AbstractPlayer<P extends Player<P,S>,S> extends org.refcodes.observer.AbstractObservable<PlayerObserver<P,S>,PlayerEvent<P>> implements Player<P,S>
The Class AbstractPlayer.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.Disposable
org.refcodes.mixin.Disposable.Disposedable
-
Nested classes/interfaces inherited from interface org.refcodes.graphical.DraggableAccessor
org.refcodes.graphical.DraggableAccessor.DraggableBuilder<B extends org.refcodes.graphical.DraggableAccessor.DraggableBuilder<B>>, org.refcodes.graphical.DraggableAccessor.DraggableMutator, org.refcodes.graphical.DraggableAccessor.DraggableProperty
-
Nested classes/interfaces inherited from interface org.refcodes.graphical.Position
org.refcodes.graphical.Position.PositionBuilder<B extends org.refcodes.graphical.Position.PositionBuilder<B>>, org.refcodes.graphical.Position.PositionMutator, org.refcodes.graphical.Position.PositionProperty, org.refcodes.graphical.Position.PositionPropertyBuilder
-
Nested classes/interfaces inherited from interface org.refcodes.graphical.PosXAccessor
org.refcodes.graphical.PosXAccessor.PosXBuilder<B extends org.refcodes.graphical.PosXAccessor.PosXBuilder<B>>, org.refcodes.graphical.PosXAccessor.PosXMutator, org.refcodes.graphical.PosXAccessor.PosXProperty
-
Nested classes/interfaces inherited from interface org.refcodes.graphical.PosYAccessor
org.refcodes.graphical.PosYAccessor.PosYBuilder<B extends org.refcodes.graphical.PosYAccessor.PosYBuilder<B>>, org.refcodes.graphical.PosYAccessor.PosYMutator, org.refcodes.graphical.PosYAccessor.PosYProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.StatusAccessor
org.refcodes.mixin.StatusAccessor.StatusBuilder<S extends java.lang.Object,B extends org.refcodes.mixin.StatusAccessor.StatusBuilder<S,B>>, org.refcodes.mixin.StatusAccessor.StatusMutator<S extends java.lang.Object>, org.refcodes.mixin.StatusAccessor.StatusProperty<S extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.refcodes.graphical.VisibleAccessor
org.refcodes.graphical.VisibleAccessor.VisibleBuilder<B extends org.refcodes.graphical.VisibleAccessor.VisibleBuilder<B>>, org.refcodes.graphical.VisibleAccessor.VisibleMutator, org.refcodes.graphical.VisibleAccessor.VisibleProperty
-
-
Constructor Summary
Constructors Constructor Description AbstractPlayer()
Empty constructor.AbstractPlayer(int aPosX, int aPosY)
Instantiates a new abstract player.AbstractPlayer(org.refcodes.graphical.Position aPosition)
Instantiates a new abstract player.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
click()
Selects ("clicks") the player.void
draggable()
protected boolean
fireEvent(PlayerEvent<P> aEvent, PlayerObserver<P,S> aObserver, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy)
Fire event.int
getPositionX()
int
getPositionY()
S
getStatus()
void
hide()
boolean
isDraggable()
boolean
isVisible()
void
setDraggable(boolean isDraggable)
Sets the draggable.void
setPosition(int aPosX, int aPosY)
Sets the position.void
setPosition(org.refcodes.graphical.Position aPosition)
void
setPositionX(int aPosX)
Sets the position X.void
setPositionY(int aPosY)
Sets the position Y.void
setStatus(S aState)
Sets the state.void
setVisible(boolean isVisible)
Sets the visible.void
show()
void
stationary()
java.lang.String
toString()
P
withDraggable()
With draggable.P
withDraggable(boolean isDraggable)
With draggable.P
withHide()
With hide.P
withPosition(int aPosX, int aPosY)
With position.P
withPosition(org.refcodes.graphical.Position aPosition)
With position.P
withPositionX(int aPosX)
With position X.P
withPositionY(int aPosY)
With position Y.P
withShow()
With show.P
withStationary()
With stationary.P
withStatus(S aState)
With state.P
withVisible(boolean isVisible)
With visible.-
Methods inherited from class org.refcodes.observer.AbstractObservable
clear, dispose, doHandleEventListenerException, fireEvent, getThreadPriority, hasObserverSubscription, isEmpty, isObserversActive, observers, setObserversActive, setThreadPriority, size, subscribeObserver, unsubscribeObserver
-
Methods inherited from interface org.refcodes.mixin.Loggable
alert, alert, critical, critical, debug, error, info, notice, panic, trace, warn, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.refcodes.observer.Observable
hasObserverSubscription, subscribeObserver, unsubscribeObserver
-
Methods inherited from interface org.refcodes.checkerboard.Player
blink, moveDown, moveLeft, moveRight, moveUp, onChangePosition, onClicked, onDraggabilityChanged, onPositionChanged, onStateChanged, onVisibilityChanged
-
-
-
-
Constructor Detail
-
AbstractPlayer
public AbstractPlayer()
Empty constructor. Make sure you set the coordinates e.g. by callingsetPosition(int, int)
or the like after construction. You may also directly construct with coordinates by usingAbstractPlayer(Position)
orAbstractPlayer(int, int)
.
-
AbstractPlayer
public AbstractPlayer(int aPosX, int aPosY)
Instantiates a new abstract player.- Parameters:
aPosX
- the pos XaPosY
- the pos Y
-
AbstractPlayer
public AbstractPlayer(org.refcodes.graphical.Position aPosition)
Instantiates a new abstract player.- Parameters:
aPosition
- the position
-
-
Method Detail
-
click
public void click()
Selects ("clicks") the player.
-
withPosition
public P withPosition(int aPosX, int aPosY) throws org.refcodes.exception.VetoException.VetoRuntimeException
With position.
-
withPosition
public P withPosition(org.refcodes.graphical.Position aPosition) throws org.refcodes.exception.VetoException.VetoRuntimeException
With position.
-
setPosition
public void setPosition(int aPosX, int aPosY) throws org.refcodes.exception.VetoException.VetoRuntimeException
Sets the position.- Specified by:
setPosition
in interfaceorg.refcodes.graphical.Position.PositionMutator
- Parameters:
aPosX
- the pos XaPosY
- the pos Y- Throws:
org.refcodes.exception.VetoException.VetoRuntimeException
- the veto runtime exception
-
setPosition
public void setPosition(org.refcodes.graphical.Position aPosition) throws org.refcodes.exception.VetoException.VetoRuntimeException
- Specified by:
setPosition
in interfaceorg.refcodes.graphical.Position.PositionMutator
- Throws:
org.refcodes.exception.VetoException.VetoRuntimeException
-
withPositionY
public P withPositionY(int aPosY) throws org.refcodes.exception.VetoException.VetoRuntimeException
With position Y.
-
setPositionY
public void setPositionY(int aPosY) throws org.refcodes.exception.VetoException.VetoRuntimeException
Sets the position Y.- Specified by:
setPositionY
in interfaceorg.refcodes.graphical.PosYAccessor.PosYMutator
- Parameters:
aPosY
- the new position Y- Throws:
org.refcodes.exception.VetoException.VetoRuntimeException
- the veto runtime exception
-
withPositionX
public P withPositionX(int aPosX) throws org.refcodes.exception.VetoException.VetoRuntimeException
With position X.
-
setStatus
public void setStatus(S aState)
Sets the state.
-
setPositionX
public void setPositionX(int aPosX)
Sets the position X.- Specified by:
setPositionX
in interfaceorg.refcodes.graphical.PosXAccessor.PosXMutator
- Parameters:
aPosX
- the new position X
-
setVisible
public void setVisible(boolean isVisible)
Sets the visible.- Specified by:
setVisible
in interfaceorg.refcodes.graphical.VisibleAccessor.VisibleMutator
- Parameters:
isVisible
- the new visible
-
withShow
public P withShow()
With show.
-
withHide
public P withHide()
With hide.
-
withVisible
public P withVisible(boolean isVisible)
With visible.
-
show
public void show()
- Specified by:
show
in interfaceorg.refcodes.graphical.VisibleAccessor.VisibleMutator
-
hide
public void hide()
- Specified by:
hide
in interfaceorg.refcodes.graphical.VisibleAccessor.VisibleMutator
-
isVisible
public boolean isVisible()
- Specified by:
isVisible
in interfaceorg.refcodes.graphical.VisibleAccessor
-
setDraggable
public void setDraggable(boolean isDraggable)
Sets the draggable.- Specified by:
setDraggable
in interfaceorg.refcodes.graphical.DraggableAccessor.DraggableMutator
- Parameters:
isDraggable
- the new draggable
-
withDraggable
public P withDraggable()
With draggable.
-
withStationary
public P withStationary()
With stationary.
-
withDraggable
public P withDraggable(boolean isDraggable)
With draggable.
-
draggable
public void draggable()
- Specified by:
draggable
in interfaceorg.refcodes.graphical.DraggableAccessor.DraggableMutator
-
stationary
public void stationary()
- Specified by:
stationary
in interfaceorg.refcodes.graphical.DraggableAccessor.DraggableMutator
-
isDraggable
public boolean isDraggable()
- Specified by:
isDraggable
in interfaceorg.refcodes.graphical.DraggableAccessor
-
getPositionX
public int getPositionX()
- Specified by:
getPositionX
in interfaceorg.refcodes.graphical.PosXAccessor
-
getPositionY
public int getPositionY()
- Specified by:
getPositionY
in interfaceorg.refcodes.graphical.PosYAccessor
-
getStatus
public S getStatus()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
fireEvent
protected boolean fireEvent(PlayerEvent<P> aEvent, PlayerObserver<P,S> aObserver, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) throws org.refcodes.exception.VetoException
Fire event.- Specified by:
fireEvent
in classorg.refcodes.observer.AbstractObservable<PlayerObserver<P extends Player<P,S>,S>,PlayerEvent<P extends Player<P,S>>>
- Parameters:
aEvent
- the eventaObserver
- the observeraExecutionStrategy
- the execution strategy- Returns:
- true, if successful
- Throws:
org.refcodes.exception.VetoException
- the veto exception
-
-