commit 5 lab

This commit is contained in:
ekallin 2023-12-05 12:45:47 +04:00
parent 2e31988a1b
commit ac846959df
2 changed files with 57 additions and 30 deletions

View File

@ -13,7 +13,7 @@
</properties>
<border type="none"/>
<children>
<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">
<grid id="4a7b" binding="groupBoxObjectParameters" layout-manager="GridLayoutManager" row-count="10" 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="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">
@ -36,7 +36,7 @@
<grid id="b49a8" binding="groupBoxColors" layout-manager="GridLayoutManager" row-count="2" 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="2" row-span="6" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<grid row="0" column="3" row-span="6" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="210" height="200"/>
<preferred-size width="210" height="200"/>
<maximum-size width="210" height="200"/>
@ -201,7 +201,7 @@
</component>
<component id="4c1bf" class="javax.swing.JLabel" binding="lableSimpleObject">
<constraints>
<grid row="6" 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="6" column="3" 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="Простой"/>
@ -209,7 +209,7 @@
</component>
<component id="cc241" class="javax.swing.JLabel" binding="labelModifiedObject">
<constraints>
<grid row="6" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="6" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-2133636"/>
@ -224,14 +224,6 @@
<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>
<component id="f2170" class="javax.swing.JLabel" binding="labelCountWheels">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
@ -246,6 +238,30 @@
</constraints>
<properties/>
</component>
<component id="bddf7" class="javax.swing.JLabel" binding="labelBlackWheels">
<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>
<component id="e6296" class="javax.swing.JLabel" binding="labelEmptyWheels">
<constraints>
<grid row="7" column="3" 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>
<component id="f3cc8" class="javax.swing.JLabel" binding="labelRainbowWheels">
<constraints>
<grid row="7" column="4" 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">

View File

@ -41,9 +41,11 @@ public class FormLocomotiveConfig{
private JPanel violetPanel;
private JPanel panelBodyColor;
private JPanel panelAdditionalColor;
private JLabel labelWheels;
private JLabel labelBlackWheels;
private JLabel labelCountWheels;
private JSpinner numericUpDownWheels;
private JLabel labelEmptyWheels;
private JLabel labelRainbowWheels;
public Canvas canvas;
public JPanel getPictureBoxObject(){
@ -154,9 +156,17 @@ public class FormLocomotiveConfig{
labelModifiedObject.addMouseListener(new LabelMouseAdapter());
labelModifiedObject.setBorder(br);
labelWheels.setTransferHandler(new LabelTransferHandler());
labelWheels.addMouseListener(new LabelMouseAdapter());
labelWheels.setBorder(br);
labelBlackWheels.setTransferHandler(new LabelTransferHandler());
labelBlackWheels.addMouseListener(new LabelMouseAdapter());
labelBlackWheels.setBorder(br);
labelEmptyWheels.setTransferHandler(new LabelTransferHandler());
labelEmptyWheels.addMouseListener(new LabelMouseAdapter());
labelEmptyWheels.setBorder(br);
labelRainbowWheels.setTransferHandler((new LabelTransferHandler()));
labelRainbowWheels.addMouseListener(new LabelMouseAdapter());
labelRainbowWheels.setBorder(br);
redPanel.setTransferHandler(new PanelTransferHandler());
redPanel.addMouseListener(new PanelMouseAdapter());
@ -271,24 +281,25 @@ public class FormLocomotiveConfig{
break;
}
int wheelsCount = (int)numericUpDownWheels.getValue();
IDrawingWheels iDrawingWheels;
String dataWheels = (String) support.getTransferable().getTransferData(DataFlavor.stringFlavor);
switch (dataWheels){
case "Колеса добавить?...":
Random rnd;
rnd = new Random();
IDrawingWheels iDrawingWheels;
int wheelsChoice = rnd.nextInt(0, 3);
int wheelsCount = (int)numericUpDownWheels.getValue();
if (wheelsChoice == 0) {
iDrawingWheels = new DrawingWheel();
} else if (wheelsChoice == 1) {
iDrawingWheels = new DrawingEmptyWheels();
} else {
iDrawingWheels = new DrawingWheelsBlueCrom();
}
case "Черные колеса":
iDrawingWheels = new DrawingWheel();
iDrawingWheels.SetWheelsCount(wheelsCount);
_loco._drawingWheels = iDrawingWheels;
break;
case "Пустые колеса":
iDrawingWheels = new DrawingEmptyWheels();
iDrawingWheels.SetWheelsCount(wheelsCount);
_loco._drawingWheels = iDrawingWheels;
break;
case "Радужные колеса":
iDrawingWheels = new DrawingWheelsBlueCrom();
iDrawingWheels.SetWheelsCount(wheelsCount);
_loco._drawingWheels = iDrawingWheels;
break;
}
pictureBoxObject.repaint();
return true;