7 лабораторная(без логгов)

This commit is contained in:
Inohara 2022-12-16 12:06:53 +04:00
parent d9c0fbf63c
commit 441001a425
8 changed files with 63 additions and 37 deletions

View File

@ -7,6 +7,24 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" exported="">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../../Download/apache-log4j-2.19.0-bin/apache-log4j-2.19.0-bin/log4j-api-2.19.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library" exported="">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../../Download/apache-log4j-2.19.0-bin/apache-log4j-2.19.0-bin/log4j-core-2.19.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="log4j-1.2.17" level="project" /> <orderEntry type="library" name="log4j-1.2.17" level="project" />
</component> </component>
</module> </module>

View File

@ -1,8 +0,0 @@
2022-12-14 00:20:19 INFO FormMapWithSetTractorsGeneric:195 - Переход на карту: 1
2022-12-14 00:20:19 INFO FormMapWithSetTractorsGeneric:228 - Добавлена карта: 1
INFO FormMapWithSetTractorsGeneric:195 - Переход на карту: 1 2022-12-14
INFO FormMapWithSetTractorsGeneric:228 - Добавлена карта: 1 2022-12-14
INFO FormMapWithSetTractorsGeneric:195 - Переход на карту: 1 2022-12-14
INFO FormMapWithSetTractorsGeneric:228 - Добавлена карта: 1 2022-12-14
INFO FormMapWithSetTractorsGeneric:195 - Переход на карту: 1 14-12-2022
INFO FormMapWithSetTractorsGeneric:228 - Добавлена карта: 1 14-12-2022

View File

@ -3,7 +3,7 @@
<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="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/> <margin top="0" left="0" bottom="0" right="0"/>
<constraints> <constraints>
<xy x="20" y="20" width="884" height="620"/> <xy x="20" y="20" width="884" height="599"/>
</constraints> </constraints>
<properties/> <properties/>
<border type="none"/> <border type="none"/>

View File

@ -7,7 +7,7 @@ import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.apache.log4j.*; import org.apache.log4j.Logger;
public class FormMapWithSetWarships extends JFrame{ public class FormMapWithSetWarships extends JFrame{
private JPanel mainPanel; private JPanel mainPanel;
private JPanel PictureBox; private JPanel PictureBox;
@ -44,6 +44,11 @@ public class FormMapWithSetWarships extends JFrame{
private Logger _logger; private Logger _logger;
public FormMapWithSetWarships(Logger logger){
this();
this._logger=logger;;
}
public FormMapWithSetWarships(){ public FormMapWithSetWarships(){
InitializeComponent(); InitializeComponent();
} }
@ -74,10 +79,10 @@ public class FormMapWithSetWarships extends JFrame{
} }
private void InitializeComponent(){ private void InitializeComponent(){
_logger = Logger.getLogger("FormMapWithSetTractorsGeneric");
setContentPane(mainPanel); setContentPane(mainPanel);
setTitle("Warship"); setTitle("Warship");
setSize(935, 693); setSize(554, 548);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setVisible(true); setVisible(true);
@ -192,7 +197,7 @@ public class FormMapWithSetWarships extends JFrame{
if(ListBoxMaps.getSelectedIndex() == -1) if(ListBoxMaps.getSelectedIndex() == -1)
return; return;
bufferedImage = _mapsCollection.get(ListBoxMaps.getSelectedValue().toString()).ShowSet(); bufferedImage = _mapsCollection.get(ListBoxMaps.getSelectedValue().toString()).ShowSet();
_logger.log(Level.INFO,"Переход на карту: " + ListBoxMaps.getSelectedValue().toString()); _logger.info("Переход на карту "+ListBoxMaps.getSelectedValue());
repaint(); repaint();
}); });

View File

@ -1,5 +1,7 @@
import org.apache.log4j.*;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
new FormMapWithSetWarships(); new FormMapWithSetWarships(LogManager.getLogger(Main.class));
} }
} }

View File

@ -116,14 +116,15 @@ public class MapWithSetWarshipsGeneric <T extends IDrawingObject,U extends Abstr
private void DrawWarship(Graphics gr) private void DrawWarship(Graphics gr)
{ {
int width = _pictureWidth / _placeSizeWidth; int countInLine = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight; int countInColumn = _pictureHeight / _placeSizeHeight;
int maxDown = (countInColumn - 1) * _placeSizeHeight;
for (int i = 0; i < _setWarships.getCount(); i++) for (int i = 0; i < _setWarships.getCount(); i++)
{ {
if (_setWarships.Get(i) != null) if (_setWarships.Get(i) != null)
{ {
_setWarships.Get(i).SetObject(i % width * _placeSizeWidth, ((height - 1 - i / width) * _placeSizeHeight) + 6, _pictureWidth, _pictureHeight); _setWarships.Get(i).SetObject(i % countInLine * _placeSizeWidth, maxDown - i / countInLine * _placeSizeHeight + 7, _pictureWidth, _pictureHeight);
_setWarships.Get(i).DrawingObject(gr); _setWarships.Get(i).DrawingObject(gr);
} }
} }

View File

@ -21,7 +21,7 @@ public class SetWarshipsGeneric<T extends Object> implements Iterable<T>{
public int Insert(T warship, int position) public int Insert(T warship, int position)
{ {
if (position < 0 || position >= _maxCount) if (position < 0 || position >= _maxCount || getCount() >= _maxCount)
throw new StorageOverflowException(_maxCount); throw new StorageOverflowException(_maxCount);
_places.add(position, warship); _places.add(position, warship);
return position; return position;

View File

@ -1,19 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE log4j:configuration PUBLIC <Configuration status="info">
"-//APACHE//DTD LOG4J 1.2//EN" <Appenders>
"http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd"> <File name="error" fileName="Errors.log" append="true">
<log4j:configuration debug="false"> <PatternLayout>
<Pattern>
<appender name="FileAppender" class="org.apache.log4j.DailyRollingFileAppender"> [%-5level] %msg (%d{dd.MM.yyyy})%n
<param name="File" value="messages"/> </Pattern>
<param name="DatePattern" value="'-'yyyy-MM-dd"/> </PatternLayout>
<param name="Encoding" value="utf-8"/> <ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY"/>
<layout class="org.apache.log4j.PatternLayout"> </File>
<param name="ConversionPattern" value=" %-5p %c{1}:%L - %m %d{dd-MM-yyyy} %n"/> <File name="info" fileName="Infos.log" append="true">
</layout> <PatternLayout>
</appender> <Pattern>
<root> [%-5level] %msg (%d{dd.MM.yyyy})%n
<priority value="INFO"/> </Pattern>
<appender-ref ref="FileAppender"/> </PatternLayout>
</root> <ThresholdFilter level="WARN" onMatch="DENY" onMismatch="ACCEPT"/>
</log4j:configuration> </File>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="info"/>
<AppenderRef ref="error"/>
</Root>
</Loggers>
</Configuration>