Module org.refcodes.checkerboard
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.Disposable
,org.refcodes.mixin.StatusAccessor<S>
,org.refcodes.mixin.StatusAccessor.StatusBuilder<S,
,P> org.refcodes.mixin.StatusAccessor.StatusMutator<S>
,org.refcodes.mixin.StatusAccessor.StatusProperty<S>
,org.refcodes.observer.Observable<PlayerObserver<P,
S>>
- Direct Known Subclasses:
Meeple
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.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
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 Object,
B extends org.refcodes.mixin.StatusAccessor.StatusBuilder<S, B>>, org.refcodes.mixin.StatusAccessor.StatusMutator<S extends Object>, org.refcodes.mixin.StatusAccessor.StatusProperty<S extends 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
ConstructorsConstructorDescriptionEmpty constructor.AbstractPlayer
(int aPosX, int aPosY) Instantiates a new abstract player.AbstractPlayer
(org.refcodes.graphical.Position aPosition) Instantiates a new abstract player. -
Method Summary
Modifier and TypeMethodDescriptionvoid
click()
Selects ("clicks") the player.void
protected boolean
fireEvent
(PlayerEvent<P> aEvent, PlayerObserver<P, S> aObserver, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Fire event.int
int
void
hide()
boolean
boolean
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
Sets the state.void
setVisible
(boolean isVisible) Sets the visible.void
show()
void
toString()
With draggable.withDraggable
(boolean isDraggable) With draggable.withHide()
With hide.withPosition
(int aPosX, int aPosY) With position.withPosition
(org.refcodes.graphical.Position aPosition) With position.withPositionX
(int aPosX) With position X.withPositionY
(int aPosY) With position Y.withShow()
With show.With stationary.withStatus
(S aState) With state.withVisible
(boolean isVisible) With visible.Methods inherited from class org.refcodes.observer.AbstractObservable
clear, dispose, doHandleEventListenerException, fireEvent, getThreadPriority, hasObserver, isEmpty, isObserversActive, observers, setObserversActive, setThreadPriority, size, subscribeObserver, unsubscribeObserver
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.refcodes.graphical.DraggableAccessor.DraggableProperty
letDraggable
Methods inherited from interface org.refcodes.observer.Observable
hasObserver, subscribeObserver, unsubscribeObserver
Methods inherited from interface org.refcodes.checkerboard.Player
blink, moveDown, moveLeft, moveRight, moveUp, onChangePosition, onClicked, onDraggabilityChanged, onPositionChanged, onStateChanged, onVisibilityChanged
Methods inherited from interface org.refcodes.graphical.Position
toAddTo, toSubFrom
Methods inherited from interface org.refcodes.graphical.Position.PositionProperty
addTo, letPosition, letPosition, subFrom
Methods inherited from interface org.refcodes.graphical.PosXAccessor.PosXProperty
letPositionX
Methods inherited from interface org.refcodes.graphical.PosYAccessor.PosYProperty
letPositionY
Methods inherited from interface org.refcodes.mixin.StatusAccessor.StatusProperty
letStatus
Methods inherited from interface org.refcodes.graphical.VisibleAccessor.VisibleProperty
letVisible
-
Constructor Details
-
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 Details
-
click
public void click()Selects ("clicks") the player. -
withPosition
With position. -
withPosition
With position. -
setPosition
public void setPosition(int aPosX, int aPosY) 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) - Specified by:
setPosition
in interfaceorg.refcodes.graphical.Position.PositionMutator
-
withPositionY
With position Y. -
setPositionY
public void setPositionY(int aPosY) 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
With position X. -
setStatus
Sets the state. -
withStatus
With 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
With show. -
withHide
With hide. -
withVisible
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
With draggable. -
withStationary
With stationary. -
withDraggable
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
-
toString
-
fireEvent
protected boolean fireEvent(PlayerEvent<P> aEvent, PlayerObserver<P, S> aObserver, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) throws org.refcodes.exception.VetoExceptionFire 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
-