add setCount in DrawingEngines
This commit is contained in:
parent
685b97e188
commit
f25feff68b
@ -2,14 +2,14 @@ import javax.swing.*;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class Canvas extends JComponent {
|
public class Canvas extends JComponent {
|
||||||
FormAircraft form;
|
Form form;
|
||||||
public Canvas(FormAircraft form) {
|
public Canvas(Form form) {
|
||||||
this.form = form;
|
this.form = form;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
form.draw(g2);
|
form.Draw(g2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,14 @@ public class DrawingEngines {
|
|||||||
private Color color;
|
private Color color;
|
||||||
|
|
||||||
public void Init(int count, Color bodyColor) {
|
public void Init(int count, Color bodyColor) {
|
||||||
|
setCount(count);
|
||||||
|
color = bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCount(int count) {
|
||||||
if(count <= 2) enginesCount = EnginesCount.Two;
|
if(count <= 2) enginesCount = EnginesCount.Two;
|
||||||
else if(count >= 6) enginesCount = EnginesCount.Six;
|
else if(count >= 6) enginesCount = EnginesCount.Six;
|
||||||
else enginesCount = EnginesCount.Four;
|
else enginesCount = EnginesCount.Four;
|
||||||
|
|
||||||
color = bodyColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics2D g, int startPosX, int startPosY) {
|
public void draw(Graphics2D g, int startPosX, int startPosY) {
|
||||||
|
5
Form.java
Normal file
5
Form.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public interface Form {
|
||||||
|
void Draw(Graphics2D g);
|
||||||
|
}
|
@ -5,7 +5,7 @@ import java.awt.event.ComponentAdapter;
|
|||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class FormAircraft {
|
public class FormAircraft implements Form {
|
||||||
private JButton createButton;
|
private JButton createButton;
|
||||||
private JButton upButton;
|
private JButton upButton;
|
||||||
private JButton rightButton;
|
private JButton rightButton;
|
||||||
@ -88,7 +88,8 @@ public class FormAircraft {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics2D g) {
|
@Override
|
||||||
|
public void Draw(Graphics2D g) {
|
||||||
if(_airFighter == null) return;
|
if(_airFighter == null) return;
|
||||||
_airFighter.DrawTransport(g);
|
_airFighter.DrawTransport(g);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user