done scaling

This commit is contained in:
2026-06-01 12:18:45 +03:00
parent 669d26f595
commit 538ba5f06b
7 changed files with 70 additions and 34 deletions

View File

@ -22,12 +22,15 @@ public class DrawboxRectengleRenderingFunction implements ShapeRenderingFunction
private List<EntityDrawboxChangedListener> listeners = new ArrayList<>();
Entity entity;
Logger logger = Logger.getLogger("gui.DrawboxRectangleEditor");
private float scaleIndex = 1;
public DrawboxRectengleRenderingFunction() {
}
@Override
public void drawing(Graphics2D g) {
scaleIndex = entity.getScaleIndex();
Drawbox drawbox = entity.getDrawbox();
drawboxPoints = drawbox.getDrawboxlistPoints();
basePoints = drawbox.getbaseListPoints();
@ -39,13 +42,13 @@ public class DrawboxRectengleRenderingFunction implements ShapeRenderingFunction
if(drawboxPoints.size() >= 1 && drawboxPoints.size() < 4) {
Point lastPoint = drawboxPoints.get(drawboxPoints.size()-1);
g.drawLine((int)lastPoint.x, (int)lastPoint.y, (int)currentPoint.x, (int)currentPoint.y);
g.drawLine((int)(lastPoint.x*scaleIndex), (int)(lastPoint.y*scaleIndex), (int)(currentPoint.x*scaleIndex), (int)(currentPoint.y*scaleIndex));
for(int i = 0; i < drawboxPoints.size()-1;i++) {
int x1 = (int)drawboxPoints.get(i).x;
int y1 = (int)drawboxPoints.get(i).y;
int x2 = (int)drawboxPoints.get(i+1).x;
int y2 = (int)drawboxPoints.get(i+1).y;
g.drawLine(x1, y1, x2, y2);
g.drawLine((int)(x1*scaleIndex), (int)(y1*scaleIndex), (int)(x2*scaleIndex), (int)(y2*scaleIndex));
}
} else {
for(int i = 0; i < drawboxPoints.size();i++) {
@ -53,7 +56,7 @@ public class DrawboxRectengleRenderingFunction implements ShapeRenderingFunction
int y1 = (int)drawboxPoints.get(i % drawboxPoints.size()).y;
int x2 = (int)drawboxPoints.get((i+1) % drawboxPoints.size()).x;
int y2 = (int)drawboxPoints.get((i+1) % drawboxPoints.size()).y;
g.drawLine(x1, y1, x2, y2);
g.drawLine((int)(x1*scaleIndex), (int)(y1*scaleIndex), (int)(x2*scaleIndex), (int)(y2*scaleIndex));
}
// ОТРИСОВКА ОСНОВАНИЯ
g.setColor(Color.BLUE);
@ -62,7 +65,7 @@ public class DrawboxRectengleRenderingFunction implements ShapeRenderingFunction
int y1 = (int)basePoints.get(i).y;
int x2 = (int)basePoints.get(i+1).x;
int y2 = (int)basePoints.get(i+1).y;
g.drawLine(x1, y1+3, x2, y2+3);
g.drawLine((int)(x1*scaleIndex), (int)(y1*scaleIndex), (int)(x2*scaleIndex), (int)(y2*scaleIndex));
}
}
@ -71,7 +74,7 @@ public class DrawboxRectengleRenderingFunction implements ShapeRenderingFunction
@Override
public void mousePressed(MouseEvent e) {
if(drawboxPoints.size() < 4) {
Point p = new Point(e.getX(), e.getY());
Point p = new Point(currentPoint.x, currentPoint.y);
drawboxPoints.add(p);
if(drawboxPoints.size() == 4) {
sortingDrawboxPoints();
@ -88,8 +91,8 @@ public class DrawboxRectengleRenderingFunction implements ShapeRenderingFunction
@Override
public void mouseMoved(MouseEvent e) {
currentPoint.x = e.getX();
currentPoint.y = e.getY();
currentPoint.x = e.getX()/scaleIndex;
currentPoint.y = e.getY()/scaleIndex;
}
/*Точки должны идти в определенном порядке: