Morozov V.S. LabWork01_Hard #1
@ -1,22 +1,24 @@
|
||||
import java.awt.*;
|
||||
|
||||
import java.util.Random;
|
||||
class DrawingEntityPlain
|
||||
{
|
||||
public EntityAirPlane Airplane;
|
||||
|
||||
public DrawingPorthole drawingPortholes = new DrawingPorthole();
|
||||
private float _startPosX;
|
||||
private float _startPosY;
|
||||
|
||||
private int _pictureWidth = -1;
|
||||
private int _pictureHeight = -1;
|
||||
|
||||
private int _AirplaneWidth = 120;
|
||||
private int _AirplaneHeight = 60;
|
||||
private int _AirplaneWidth = 240;
|
||||
private int _AirplaneHeight = 120;
|
||||
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Airplane = new EntityAirPlane();
|
||||
Airplane.Init(speed, weight, bodyColor);
|
||||
drawingPortholes.Init(rnd.nextInt(1, 35),Airplane.BodyColor);
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
@ -79,29 +81,30 @@ class DrawingEntityPlain
|
||||
}
|
||||
|
||||
|
||||
g.drawRect( (int)_startPosX, (int)_startPosY, 20, 30);
|
||||
g.drawRect( (int)_startPosX, (int)_startPosY + 30, 100, 30);
|
||||
g.drawRect( (int)_startPosX+100, (int)_startPosY + 40, 20, 15);
|
||||
g.drawRect( (int)_startPosX, (int)_startPosY, 40, 60);
|
||||
g.drawRect( (int)_startPosX, (int)_startPosY + 60, 200, 60);
|
||||
g.drawRect( (int)_startPosX+100, (int)_startPosY + 80, 40, 30);
|
||||
//koleso1
|
||||
g.drawRect( (int)_startPosX + 30, (int)_startPosY + 60, 5, 10);
|
||||
g.drawOval( (int)_startPosX+28,(int) _startPosY+70, 9, 9);
|
||||
g.drawRect( (int)_startPosX + 60, (int)_startPosY + 120, 10, 20);
|
||||
g.drawOval( (int)_startPosX+56,(int) _startPosY+140, 18, 18);
|
||||
//koleso2
|
||||
g.drawRect( (int)_startPosX + 80, (int)_startPosY + 60, 5, 10);
|
||||
g.drawOval( (int)_startPosX + 78, (int)_startPosY + 70, 9, 9);
|
||||
g.drawRect( (int)_startPosX + 160, (int)_startPosY + 120, 10, 20);
|
||||
g.drawOval( (int)_startPosX + 156, (int)_startPosY + 140, 18, 18);
|
||||
|
||||
//Korpys
|
||||
g.setPaint(Airplane.BodyColor);
|
||||
g.fillRect((int)_startPosX+3, (int)_startPosY + 33, 94, 24);
|
||||
g.fillRect( (int)_startPosX+1, (int)_startPosY+1, 19, 29);
|
||||
g.fillRect((int)_startPosX+6, (int)_startPosY + 66, 188, 48);
|
||||
g.fillRect( (int)_startPosX+2, (int)_startPosY+2, 38, 58);
|
||||
|
||||
//krilya
|
||||
g.setPaint(Color.black);
|
||||
g.fillRect((int)_startPosX + 30, (int)_startPosY + 40, 40, 8);
|
||||
g.fillRect((int)_startPosX + 60, (int)_startPosY + 80, 80, 16);
|
||||
|
||||
//cabina
|
||||
g.setPaint(Color.blue);
|
||||
g.fillRect( (int)_startPosX + 101, (int)_startPosY + 41, 19, 14);
|
||||
g.fillRect( (int)_startPosX + 202, (int)_startPosY + 82, 38, 28);
|
||||
|
||||
drawingPortholes.draw(g, (int)_startPosX+6, (int)_startPosY+70);
|
||||
}
|
||||
|
||||
public void ChangeBorders(int width, int height)
|
||||
|
40
RadarAirplane/src/DrawingPorthole.java
Normal file
40
RadarAirplane/src/DrawingPorthole.java
Normal file
@ -0,0 +1,40 @@
|
||||
import java.awt.*;
|
||||
|
||||
public class DrawingPorthole {
|
||||
|
||||
private Porthole PortholeCount;
|
||||
|
||||
Color color;
|
||||
|
||||
public void Init(int count, Color bodyColor) {
|
||||
if(count <= 10) PortholeCount = Porthole.Ten;
|
||||
else if(count >= 30) PortholeCount = Porthole.Twenty;
|
||||
else PortholeCount = Porthole.Thirty;
|
||||
color = bodyColor;
|
||||
|
||||
}
|
||||
|
||||
public void draw(Graphics2D g, int startPosX, int startPosY) {
|
||||
g.setPaint(Color.white);
|
||||
int count = 0;
|
||||
int i = -1;
|
||||
int j = 0;
|
||||
while(true)
|
||||
{
|
||||
if(i==15) {
|
||||
i = 0;
|
||||
j=30;
|
||||
}
|
||||
else i++;
|
||||
if(PortholeCount == Porthole.Ten && count==10) break;
|
||||
else if(PortholeCount == Porthole.Twenty && count==20) break;
|
||||
else if(PortholeCount == Porthole.Thirty && count==30) break;
|
||||
g.drawOval(startPosX+i*12 , startPosY + j, 10, 10);
|
||||
g.fillOval(startPosX+i*12, startPosY + j, 10, 10);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="FormAirPlane">
|
||||
<grid id="27dc6" binding="mainPanel" layout-manager="GridBagLayout">
|
||||
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="7" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="745" height="400"/>
|
||||
</constraints>
|
||||
@ -10,106 +11,122 @@
|
||||
<grid id="c3c1c" binding="DrawPlace" layout-manager="CardLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="7" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="2.0" weighty="2.0"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<component id="df504" class="javax.swing.JButton" binding="createButton">
|
||||
<grid id="7cdea" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="создание"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="e091d" layout-manager="GridBagLayout">
|
||||
<constraints>
|
||||
<grid row="1" column="3" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="2.0" weighty="0.0"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="7" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="-1" height="20"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<hspacer id="323b6">
|
||||
<component id="5d314" class="javax.swing.JLabel" binding="weightLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<vspacer id="cc4bd">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="5bf4f" class="javax.swing.JButton" binding="upButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="up"/>
|
||||
<text value="Вес: "/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b31a8" class="javax.swing.JButton" binding="downButton" default-binding="true">
|
||||
<component id="fa09a" class="javax.swing.JLabel" binding="speedLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="down"/>
|
||||
<text value="Скорость: "/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="1d949" class="javax.swing.JButton" binding="leftButton" default-binding="true">
|
||||
<component id="9494b" class="javax.swing.JLabel" binding="colorLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="left"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="527d2" class="javax.swing.JButton" binding="rightButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="right"/>
|
||||
<text value="Цвет"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="fa09a" class="javax.swing.JLabel" binding="speedLabel">
|
||||
<grid id="b5cf" layout-manager="GridLayoutManager" row-count="2" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="7" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Скорость: "/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5d314" class="javax.swing.JLabel" binding="weightLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Вес: "/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="9494b" class="javax.swing.JLabel" binding="colorLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="5" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="0.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Цвет"/>
|
||||
</properties>
|
||||
</component>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<hspacer id="eb27d">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="df504" class="javax.swing.JButton" binding="createButton">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="создание"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b31a8" class="javax.swing.JButton" binding="downButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="30" height="30"/>
|
||||
<preferred-size width="30" height="30"/>
|
||||
<maximum-size width="30" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<icon value="Resources/down.png"/>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="1d949" class="javax.swing.JButton" binding="leftButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="30" height="30"/>
|
||||
<preferred-size width="30" height="30"/>
|
||||
<maximum-size width="30" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<icon value="Resources/left.png"/>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="527d2" class="javax.swing.JButton" binding="rightButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="30" height="30"/>
|
||||
<preferred-size width="30" height="30"/>
|
||||
<maximum-size width="30" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<icon value="Resources/right.png"/>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5bf4f" class="javax.swing.JButton" binding="upButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="30" height="30"/>
|
||||
<preferred-size width="30" height="30"/>
|
||||
<maximum-size width="30" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<icon value="Resources/up.png"/>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
</form>
|
||||
|
5
RadarAirplane/src/Porthole.java
Normal file
5
RadarAirplane/src/Porthole.java
Normal file
@ -0,0 +1,5 @@
|
||||
public enum Porthole {
|
||||
Ten,
|
||||
Twenty,
|
||||
Thirty
|
||||
}
|
Loading…
Reference in New Issue
Block a user