New architecture of classes for switching the drawing modes of hitboxes/Dravboxes of entities
This commit is contained in:
5
src/gui/CircleRenderingFunction.java
Normal file
5
src/gui/CircleRenderingFunction.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package gui;
|
||||||
|
|
||||||
|
public class CircleRenderingFunction implements ShapeRenderingFunction {
|
||||||
|
|
||||||
|
}
|
||||||
@ -150,7 +150,9 @@ public class DrawboxEditor extends Editable {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void clearPoints(){
|
||||||
|
|
||||||
|
}
|
||||||
// эта штука очищает точки при нажатии универскальной кнопки очистки в Main GUI. Это следует рефакторнуть и вместо передачи события сюда,
|
// эта штука очищает точки при нажатии универскальной кнопки очистки в Main GUI. Это следует рефакторнуть и вместо передачи события сюда,
|
||||||
// обрабатывать его прямо в Main GUI(лямбдой) вызывая отсюда только метод в духе clearPoints()
|
// обрабатывать его прямо в Main GUI(лямбдой) вызывая отсюда только метод в духе clearPoints()
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public abstract class Editable extends JPanel implements MouseListener, MouseMot
|
|||||||
protected Entity entity;
|
protected Entity entity;
|
||||||
protected String selectedEntityName;
|
protected String selectedEntityName;
|
||||||
protected BufferedImage image;
|
protected BufferedImage image;
|
||||||
JPanel drawPanel;
|
EditableCanvas canvas;
|
||||||
|
|
||||||
private static Logger logger = Logger.getLogger("gui.Editable");
|
private static Logger logger = Logger.getLogger("gui.Editable");
|
||||||
|
|
||||||
|
|||||||
7
src/gui/EditableCanvas.java
Normal file
7
src/gui/EditableCanvas.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package gui;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
public class EditableCanvas extends JPanel {
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,47 +0,0 @@
|
|||||||
package gui;
|
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
public class HitboxCircleEditor extends Editable {
|
|
||||||
|
|
||||||
HitboxCircleEditor(ListGUI listGUI) {
|
|
||||||
super(listGUI);
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawing(Graphics2D g) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveDataInEntity() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseMoved(MouseEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -10,12 +10,12 @@ import model.Hitbox;
|
|||||||
import model.Point;
|
import model.Point;
|
||||||
|
|
||||||
|
|
||||||
public class HitboxRectangleEditor extends Editable {
|
public class HitboxEditor extends Editable {
|
||||||
Point firstIsoPoint = null;
|
Point firstIsoPoint = null;
|
||||||
Point currentIsoPoint = new Point(0,0);
|
Point currentIsoPoint = new Point(0,0);
|
||||||
Point firstCartesianPoint = new Point(0,0), currentCartesianPoint = new Point(0,0);
|
Point firstCartesianPoint = new Point(0,0), currentCartesianPoint = new Point(0,0);
|
||||||
|
|
||||||
HitboxRectangleEditor(ListGUI listGUI) {
|
HitboxEditor(ListGUI listGUI) {
|
||||||
super(listGUI);
|
super(listGUI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,48 +0,0 @@
|
|||||||
package gui;
|
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
public class HitboxPoligonEditor extends Editable {
|
|
||||||
|
|
||||||
HitboxPoligonEditor(ListGUI listGUI) {
|
|
||||||
super(listGUI);
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawing(Graphics2D g) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveDataInEntity() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseMoved(MouseEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -27,7 +27,8 @@ public class MainGUI extends JFrame{
|
|||||||
JButton clearLinesJButton;
|
JButton clearLinesJButton;
|
||||||
public static JTabbedPane editorPane;
|
public static JTabbedPane editorPane;
|
||||||
DrawboxEditor drawBoxPanel;
|
DrawboxEditor drawBoxPanel;
|
||||||
HitboxRectangleEditor hitboxRectanglePanel;
|
HitboxEditor hitboxPanel;
|
||||||
|
|
||||||
|
|
||||||
public MainGUI() {
|
public MainGUI() {
|
||||||
|
|
||||||
@ -41,9 +42,9 @@ public class MainGUI extends JFrame{
|
|||||||
list.setVisible(true);
|
list.setVisible(true);
|
||||||
|
|
||||||
drawBoxPanel = new DrawboxEditor(list);
|
drawBoxPanel = new DrawboxEditor(list);
|
||||||
hitboxRectanglePanel = new HitboxRectangleEditor(list);
|
hitboxPanel = new HitboxEditor(list);
|
||||||
list.registerJListListener(drawBoxPanel);
|
list.registerJListListener(drawBoxPanel);
|
||||||
list.registerJListListener(hitboxRectanglePanel);
|
list.registerJListListener(hitboxPanel);
|
||||||
|
|
||||||
OpenXMLFileButtonListener = new OpenXMLFileButtonListener(list);
|
OpenXMLFileButtonListener = new OpenXMLFileButtonListener(list);
|
||||||
|
|
||||||
@ -59,17 +60,17 @@ public class MainGUI extends JFrame{
|
|||||||
add(TopButtonBar,BorderLayout.NORTH);
|
add(TopButtonBar,BorderLayout.NORTH);
|
||||||
|
|
||||||
clearLinesJButton.addActionListener(drawBoxPanel);
|
clearLinesJButton.addActionListener(drawBoxPanel);
|
||||||
clearLinesJButton.addActionListener(hitboxRectanglePanel);
|
clearLinesJButton.addActionListener(hitboxPanel);
|
||||||
|
|
||||||
|
|
||||||
editorPane = new JTabbedPane();
|
editorPane = new JTabbedPane();
|
||||||
editorPane.setVisible(true);
|
editorPane.setVisible(true);
|
||||||
add(editorPane,BorderLayout.CENTER);
|
add(editorPane,BorderLayout.CENTER);
|
||||||
|
|
||||||
editorPane.addTab("Hitbox", hitboxRectanglePanel);
|
editorPane.addTab("Hitbox", hitboxPanel);
|
||||||
editorPane.addTab("Drawbox", drawBoxPanel);
|
editorPane.addTab("Drawbox", drawBoxPanel);
|
||||||
repaint();
|
repaint();
|
||||||
drawBoxPanel.subscribe(Project.getInstance()); // подписка: Project получит данные ввиде обьекта Event, содержащий аднные drawbox при отрисовке последней точки из 4-х.
|
drawBoxPanel.subscribe(Project.getInstance()); // подписка: Project получит данные ввиде обьекта Event, содержащий данные drawbox при отрисовке последней точки из 4-х.
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
5
src/gui/RectengleRenderingFunction.java
Normal file
5
src/gui/RectengleRenderingFunction.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package gui;
|
||||||
|
|
||||||
|
public class RectengleRenderingFunction implements ShapeRenderingFunction {
|
||||||
|
|
||||||
|
}
|
||||||
5
src/gui/ShapeRenderingFunction.java
Normal file
5
src/gui/ShapeRenderingFunction.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package gui;
|
||||||
|
|
||||||
|
public interface ShapeRenderingFunction {
|
||||||
|
|
||||||
|
}
|
||||||
@ -74,8 +74,8 @@ public class Entity {
|
|||||||
public void PrintEntity() {
|
public void PrintEntity() {
|
||||||
System.out.println("---------------------");
|
System.out.println("---------------------");
|
||||||
System.out.println("Name: "+thisName);
|
System.out.println("Name: "+thisName);
|
||||||
this.thisDrawbox.printToConsole();
|
thisDrawbox.printToConsole();
|
||||||
this.thisHitbox.printToConsole();
|
thisHitbox.printToConsole();
|
||||||
System.out.println("---------------------");
|
System.out.println("---------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user