some changes
This commit is contained in:
parent
d9410fa68b
commit
c222fcb356
@ -14,4 +14,8 @@ public class EntityElectricLocomotive extends EntityLocomotive {
|
||||
SeifBatteries = seifBatteries;
|
||||
}
|
||||
|
||||
public void SetAdditionalColor(Color color){
|
||||
AdditionalColor = color;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ public class FormDopClassParameters {
|
||||
rnd = new Random();
|
||||
EntityLocomotive entityLocomotive;
|
||||
Color color = new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
|
||||
|
||||
if (rnd.nextBoolean()) {
|
||||
entityLocomotive = new EntityLocomotive(
|
||||
rnd.nextInt(100, 300),
|
||||
|
@ -1,22 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ProjectElectricLocomotive.FormLocomotiveConfig">
|
||||
<grid id="27dc6" binding="MainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="MainPanel" layout-manager="GridLayoutManager" row-count="4" 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>
|
||||
<xy x="20" y="20" width="980" height="500"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<maximumSize width="900" height="400"/>
|
||||
<minimumSize width="900" height="400"/>
|
||||
<preferredSize width="900" height="400"/>
|
||||
<maximumSize width="900" height="500"/>
|
||||
<minimumSize width="900" height="500"/>
|
||||
<preferredSize width="900" height="500"/>
|
||||
<requestFocusEnabled value="true"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="4a7b" binding="groupBoxObjectParameters" layout-manager="GridLayoutManager" row-count="11" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="4a7b" binding="groupBoxObjectParameters" layout-manager="GridLayoutManager" row-count="10" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="3" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<grid row="1" column="0" row-span="3" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="600" height="400"/>
|
||||
<preferred-size width="600" height="400"/>
|
||||
<maximum-size width="600" height="400"/>
|
||||
@ -48,7 +48,7 @@
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="b01e9" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="b01e9" binding="violetPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" 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="3" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
@ -63,7 +63,7 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="f87f2" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="f87f2" binding="orangePanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
@ -78,7 +78,7 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="b9af1" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="b9af1" binding="yellowPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
@ -93,7 +93,7 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="31fc0" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="31fc0" binding="ligthBluePanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" 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="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
@ -108,7 +108,7 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="15de0" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="15de0" binding="melissePanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" 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="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
@ -123,7 +123,7 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="dd90a" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="dd90a" binding="bluePanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" 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="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
@ -138,7 +138,7 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="9944c" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="9944c" binding="redPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
@ -154,7 +154,7 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="6d24f" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="6d24f" binding="ligthGreenPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
@ -224,11 +224,19 @@
|
||||
<text value="Признак наличия рогов"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="bddf7" class="javax.swing.JLabel" binding="labelWheels">
|
||||
<constraints>
|
||||
<grid row="7" 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="Колеса добавить?..."/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="8989b" class="javax.swing.JButton" binding="buttonOk">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Добавить"/>
|
||||
@ -236,16 +244,16 @@
|
||||
</component>
|
||||
<component id="1efca" class="javax.swing.JButton" binding="buttonClose">
|
||||
<constraints>
|
||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Отмена"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="11089" binding="pictureBoxObject" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="11089" binding="pictureBoxObject" custom-create="true" layout-manager="GridLayoutManager" row-count="1" column-count="1" 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="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="300" height="300"/>
|
||||
<preferred-size width="300" height="300"/>
|
||||
<maximum-size width="300" height="300"/>
|
||||
@ -255,22 +263,50 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<component id="cedac" class="javax.swing.JLabel" binding="labelColor">
|
||||
<grid id="41a80" binding="panelBodyColor" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<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"/>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="60" height="30"/>
|
||||
<preferred-size width="60" height="30"/>
|
||||
<maximum-size width="60" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Цвет"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7dbfb" class="javax.swing.JLabel" binding="labelDopColor">
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="9cd35" class="javax.swing.JLabel" binding="labelColor">
|
||||
<constraints>
|
||||
<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="Цвет"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="b6d99" binding="panelAdditionalColor" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<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"/>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="60" height="30"/>
|
||||
<preferred-size width="60" height="30"/>
|
||||
<maximum-size width="60" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Доп. Цвет"/>
|
||||
</properties>
|
||||
</component>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="a349b" class="javax.swing.JLabel" binding="labelDopColor">
|
||||
<constraints>
|
||||
<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="Доп. Цвет"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
@ -11,6 +11,7 @@ import java.awt.event.MouseEvent;
|
||||
import javax.swing.border.Border;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
public class FormLocomotiveConfig{
|
||||
|
||||
@ -30,7 +31,19 @@ public class FormLocomotiveConfig{
|
||||
private JButton buttonClose;
|
||||
private JLabel labelColor;
|
||||
private JLabel labelDopColor;
|
||||
public JPanel pictureBoxObject;
|
||||
public JComponent pictureBoxObject;
|
||||
private JPanel redPanel;
|
||||
private JPanel orangePanel;
|
||||
private JPanel yellowPanel;
|
||||
private JPanel ligthGreenPanel;
|
||||
private JPanel melissePanel;
|
||||
private JPanel ligthBluePanel;
|
||||
private JPanel bluePanel;
|
||||
private JPanel violetPanel;
|
||||
private JPanel panelBodyColor;
|
||||
private JPanel panelAdditionalColor;
|
||||
private JLabel labelWheels;
|
||||
public Canvas canvas;
|
||||
|
||||
|
||||
public JPanel getPictureBoxObject(){
|
||||
@ -66,19 +79,19 @@ public class FormLocomotiveConfig{
|
||||
// }
|
||||
// };
|
||||
|
||||
// private class Canvas extends JComponent{
|
||||
// public Canvas(){
|
||||
// }
|
||||
// public void paintComponent (Graphics g){
|
||||
// if ( == null){
|
||||
// return;
|
||||
// }
|
||||
// super.paintComponents (g) ;
|
||||
// Graphics2D g2d = (Graphics2D)g;
|
||||
// _train.DrawTransport(g2d);
|
||||
// super.repaint();
|
||||
// }
|
||||
// }
|
||||
private class Canvas extends JComponent{
|
||||
public Canvas(){
|
||||
}
|
||||
public void paintComponent (Graphics g){
|
||||
if (_loco == null){
|
||||
return;
|
||||
}
|
||||
super.paintComponents (g) ;
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
_loco.DrawTransport(g2d);
|
||||
super.repaint();
|
||||
}
|
||||
}
|
||||
//класс для перетаскивания типа объекта
|
||||
private class LabelTransferHandler extends TransferHandler {
|
||||
@Override
|
||||
@ -207,7 +220,7 @@ public class FormLocomotiveConfig{
|
||||
|
||||
public FormLocomotiveConfig()
|
||||
{
|
||||
Border br = BorderFactory.createLineBorder(Color.cyan);
|
||||
Border br = BorderFactory.createLineBorder(Color.BLACK);
|
||||
|
||||
SpinnerModel numSpeed = new SpinnerNumberModel(100, 100, 1000, 1);
|
||||
numericUpDownSpeed = new JSpinner(numSpeed);
|
||||
@ -223,6 +236,33 @@ public class FormLocomotiveConfig{
|
||||
labelModifiedObject.addMouseListener(new LabelMouseAdapter());
|
||||
labelModifiedObject.setBorder(br);
|
||||
|
||||
// labelWheels.setTransferHandler(new LabelTransferHandler());
|
||||
labelWheels.addMouseListener(new LabelMouseAdapter());
|
||||
|
||||
redPanel.setTransferHandler(new PanelTransferHandler());
|
||||
redPanel.addMouseListener(new PanelMouseAdapter());
|
||||
|
||||
orangePanel.setTransferHandler(new PanelTransferHandler());
|
||||
orangePanel.addMouseListener(new PanelMouseAdapter());
|
||||
|
||||
yellowPanel.setTransferHandler(new PanelTransferHandler());
|
||||
yellowPanel.addMouseListener(new PanelMouseAdapter());
|
||||
|
||||
ligthGreenPanel.setTransferHandler(new PanelTransferHandler());
|
||||
ligthGreenPanel.addMouseListener(new PanelMouseAdapter());
|
||||
|
||||
melissePanel.setTransferHandler(new PanelTransferHandler());
|
||||
melissePanel.addMouseListener(new PanelMouseAdapter());
|
||||
|
||||
ligthBluePanel.setTransferHandler(new PanelTransferHandler());
|
||||
ligthBluePanel.addMouseListener(new PanelMouseAdapter());
|
||||
|
||||
bluePanel.setTransferHandler(new PanelTransferHandler());
|
||||
bluePanel.addMouseListener(new PanelMouseAdapter());
|
||||
|
||||
violetPanel.setTransferHandler(new PanelTransferHandler());
|
||||
violetPanel.addMouseListener(new PanelMouseAdapter());
|
||||
|
||||
labelColor.setBorder(br);
|
||||
labelColor.setTransferHandler(
|
||||
new TransferHandler(){
|
||||
@ -233,6 +273,12 @@ public class FormLocomotiveConfig{
|
||||
Color color = (Color) support.getTransferable().getTransferData(ColorTransferable.colorDataFlavor);
|
||||
if(_loco == null) return false;
|
||||
_loco.EntityLocomotive.SetBodyColor(color);
|
||||
|
||||
panelBodyColor.setBackground(color);
|
||||
|
||||
Border border = BorderFactory.createLineBorder(color);
|
||||
|
||||
labelColor.setBorder(border);
|
||||
return true;
|
||||
}
|
||||
catch(UnsupportedFlavorException | IOException e){
|
||||
@ -252,10 +298,13 @@ public class FormLocomotiveConfig{
|
||||
{
|
||||
try{
|
||||
Color color = (Color) support.getTransferable().getTransferData(ColorTransferable.colorDataFlavor);
|
||||
panelAdditionalColor.setBackground(color);
|
||||
Border border = BorderFactory.createLineBorder(color);
|
||||
labelDopColor.setBorder(border);
|
||||
if(_loco == null) return false;
|
||||
if(!(_loco instanceof DrawingLocomotive))
|
||||
return false;
|
||||
((EntityElectricLocomotive)_loco.EntityLocomotive).SetBodyColor(color);
|
||||
((EntityElectricLocomotive)_loco.EntityLocomotive).SetAdditionalColor(color);
|
||||
return true;
|
||||
}
|
||||
catch(UnsupportedFlavorException | IOException e){
|
||||
@ -267,11 +316,121 @@ public class FormLocomotiveConfig{
|
||||
}
|
||||
);
|
||||
|
||||
labelWheels.setBorder(br);
|
||||
labelWheels.setTransferHandler(
|
||||
new TransferHandler(){
|
||||
@Override
|
||||
public boolean canImport(TransferHandler.TransferSupport support) {
|
||||
return support.isDataFlavorSupported(WheelTransferable.wheelDrawingDataFlavor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean importData(TransferHandler.TransferSupport support){
|
||||
if(canImport(support)) {
|
||||
try {
|
||||
Random rnd = new Random();
|
||||
IDrawingWheels wheels = (IDrawingWheels) support.getTransferable().getTransferData(WheelTransferable.wheelDrawingDataFlavor);
|
||||
if (_loco == null) return false;
|
||||
|
||||
int wheelsChoice = rnd.nextInt(0, 3);
|
||||
|
||||
wheels.SetWheelsCount(/*rnd.nextInt(2, 5)*/ wheelsChoice);
|
||||
|
||||
if (wheelsChoice == 0) {
|
||||
wheels = new DrawingWheel();
|
||||
} else if (wheelsChoice == 1) {
|
||||
wheels = new DrawingEmptyWheels();
|
||||
} else {
|
||||
wheels = new DrawingWheelsBlueCrom();
|
||||
}
|
||||
_loco._drawingWheels = wheels;
|
||||
pictureBoxObject.repaint();
|
||||
return true;
|
||||
} catch (UnsupportedFlavorException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
canvas = new Canvas();
|
||||
pictureBoxObject.setTransferHandler(
|
||||
new TransferHandler(){
|
||||
@Override
|
||||
public boolean canImport(TransferHandler.TransferSupport support) {
|
||||
return support.isDataFlavorSupported(DataFlavor.stringFlavor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean importData(TransferHandler.TransferSupport support) {
|
||||
if (canImport(support)) {
|
||||
try {
|
||||
Random rnd;
|
||||
String data = (String) support.getTransferable().getTransferData(DataFlavor.stringFlavor);
|
||||
switch (data) {
|
||||
case "Простой":
|
||||
_loco = new DrawingLocomotive(
|
||||
(int)numericUpDownSpeed.getValue(),
|
||||
(int)numericUpDownWeight.getValue(),
|
||||
Color.WHITE,/* (int)numericWheelNum.getValue(),*/ /*CanvasWidth,CanvasHeight*/
|
||||
// pictureBoxObject.getWidth(),
|
||||
// pictureBoxObject.getHeight()
|
||||
300,300
|
||||
);
|
||||
|
||||
// rnd = new Random();
|
||||
// IDrawingWheels iDrawingWheels;
|
||||
// int wheelsChoice = rnd.nextInt(0, 3);
|
||||
// if (wheelsChoice == 0) {
|
||||
// iDrawingWheels = new DrawingWheel();
|
||||
// } else if (wheelsChoice == 1) {
|
||||
// iDrawingWheels = new DrawingEmptyWheels();
|
||||
// } else {
|
||||
// iDrawingWheels = new DrawingWheelsBlueCrom();
|
||||
// }
|
||||
// iDrawingWheels.SetWheelsCount(rnd.nextInt(2, 5));
|
||||
|
||||
break;
|
||||
case "Сложный":
|
||||
_loco = new DrawingElectricLocomotive(
|
||||
(int)numericUpDownSpeed.getValue(),
|
||||
(int)numericUpDownWeight.getValue(),
|
||||
Color.WHITE, /*(int)numericWheelNum.getValue(),*/
|
||||
Color.BLACK,
|
||||
checkBoxHorns.isSelected(),
|
||||
checkBoxSeifBatteries.isSelected(), /*checkBoxLocoLine.isSelected(),*/
|
||||
pictureBoxObject.getWidth(),
|
||||
pictureBoxObject.getHeight()
|
||||
);
|
||||
break;
|
||||
}
|
||||
pictureBoxObject.repaint();
|
||||
// Draw();
|
||||
return true;
|
||||
} catch (UnsupportedFlavorException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
// lableSimpleObject.addMouseListener(ml);
|
||||
// labelModifiedObject.setTransferHandler(new TransferHandler("rar"));
|
||||
|
||||
public void Draw() {
|
||||
pictureBoxObject.repaint();
|
||||
}
|
||||
|
||||
private void createUIComponents(){
|
||||
pictureBoxObject = new Canvas();
|
||||
pictureBoxObject.setBounds(new Rectangle(300, 300));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user