public class ChessBoard extends Object implements com.google.gwt.event.dom.client.MouseDownHandler, com.google.gwt.event.dom.client.MouseUpHandler, com.google.gwt.event.dom.client.MouseMoveHandler
Constructor and Description |
---|
ChessBoard(com.alonsoruibal.chess.Board board,
org.vectomatic.dom.svg.OMSVGSVGElement svgElt,
Main main) |
Modifier and Type | Method and Description |
---|---|
void |
addPiece(char piece,
String algebraic)
Adds a new piece to the chessboard.
|
String |
getAlgebraic(com.google.gwt.event.dom.client.MouseEvent<?> event)
Returns the algebraic corresponding to a mouse event, or null if
there is no square
|
org.vectomatic.dom.svg.OMSVGPoint |
getLocalCoordinates(com.google.gwt.event.dom.client.MouseEvent<?> e) |
char |
getPiece(String algebraic)
Returns the piece at the specified position
|
int |
getX(int index) |
int |
getY(int index) |
void |
onMouseDown(com.google.gwt.event.dom.client.MouseDownEvent event) |
void |
onMouseMove(com.google.gwt.event.dom.client.MouseMoveEvent event) |
void |
onMouseUp(com.google.gwt.event.dom.client.MouseUpEvent event) |
void |
removePiece(String algebraic)
Removes a piece from the chessboard at the specified position
|
void |
update(boolean force)
Update the chessboard
|
public ChessBoard(com.alonsoruibal.chess.Board board, org.vectomatic.dom.svg.OMSVGSVGElement svgElt, Main main)
public void addPiece(char piece, String algebraic)
piece
- The piece to addalgebraic
- The positionpublic void removePiece(String algebraic)
algebraic
- The positionpublic char getPiece(String algebraic)
algebraic
- The positionpublic void update(boolean force)
force
- Force the recomputation of possible movespublic void onMouseDown(com.google.gwt.event.dom.client.MouseDownEvent event)
onMouseDown
in interface com.google.gwt.event.dom.client.MouseDownHandler
public void onMouseUp(com.google.gwt.event.dom.client.MouseUpEvent event)
onMouseUp
in interface com.google.gwt.event.dom.client.MouseUpHandler
public void onMouseMove(com.google.gwt.event.dom.client.MouseMoveEvent event)
onMouseMove
in interface com.google.gwt.event.dom.client.MouseMoveHandler
public org.vectomatic.dom.svg.OMSVGPoint getLocalCoordinates(com.google.gwt.event.dom.client.MouseEvent<?> e)
public int getX(int index)
public int getY(int index)
public String getAlgebraic(com.google.gwt.event.dom.client.MouseEvent<?> event)
event
- The mouse eventCopyright © 2017. All Rights Reserved.