57 lines
2.5 KiB
Java
57 lines
2.5 KiB
Java
import java.awt.*;
|
|
|
|
public class DrawingDecks implements IDecksDrawing{
|
|
private NumberOfDecks numDecks;
|
|
public NumberOfDecks getProperty(){
|
|
return numDecks;
|
|
}
|
|
public void setNumDecks(int nDecks){
|
|
switch(nDecks){
|
|
case 1:
|
|
numDecks = NumberOfDecks.Deck_1;
|
|
break;
|
|
case 2:
|
|
numDecks = NumberOfDecks.Deck_2;
|
|
break;
|
|
case 3:
|
|
numDecks = NumberOfDecks.Deck_3;
|
|
break;
|
|
default:
|
|
numDecks = NumberOfDecks.Deck_1;
|
|
System.out.println("Что-то пошло не так, количество палуб неверное" + Integer.toString(nDecks) + "сделаем вид, будто она одна");
|
|
break;
|
|
}
|
|
}
|
|
public void DrawDeck(int _startPosX, int _startPosY,Color bodyColor, Graphics2D g){
|
|
if(numDecks == NumberOfDecks.Deck_1){
|
|
g.setPaint(bodyColor);
|
|
// заполнение борта
|
|
int x[] = {_startPosX+ 20, _startPosX+40, _startPosX+110, _startPosX+130, _startPosX+ 20};
|
|
int y[] = {_startPosY+65,_startPosY+85, _startPosY+85, _startPosY+65, _startPosY+65};
|
|
g.fillPolygon(x, y, 5);
|
|
|
|
//борт корабля контур
|
|
g.setPaint(Color.BLACK);
|
|
int _x[] = {_startPosX+ 20, _startPosX+40, _startPosX+110, _startPosX+130, _startPosX+ 20};
|
|
int _y[] = {_startPosY+65,_startPosY+85, _startPosY+85, _startPosY+65, _startPosY+65};
|
|
g.drawPolyline(_x, _y, 5);
|
|
|
|
//рисунок на борту
|
|
g.drawLine(_startPosX + 43, _startPosY + 80, _startPosX + 47, _startPosY + 80);
|
|
g.drawLine(_startPosX + 45, _startPosY + 70, _startPosX + 45, _startPosY + 80);
|
|
g.drawLine(_startPosX + 40, _startPosY + 75, _startPosX + 50, _startPosY + 75);
|
|
|
|
}
|
|
if(numDecks == NumberOfDecks.Deck_2){
|
|
g.setPaint(Color.BLACK);
|
|
g.drawLine(_startPosX + 120, _startPosY + 75, _startPosX+ 55, _startPosY + 75);
|
|
}
|
|
if(numDecks == NumberOfDecks.Deck_3){
|
|
g.setPaint(Color.BLACK);
|
|
g.drawLine(_startPosX + 120, _startPosY + 75, _startPosX+ 55, _startPosY + 75);
|
|
g.drawLine(_startPosX + 125, _startPosY + 70, _startPosX+ 50, _startPosY + 70);
|
|
}
|
|
}
|
|
|
|
}
|