centering metadata and Image in EditableCanvas

This commit is contained in:
2026-06-03 14:53:23 +03:00
parent 538ba5f06b
commit 6bf0177927
5 changed files with 77 additions and 39 deletions

View File

@ -23,6 +23,7 @@ public class HitboxRectengleRenderingFunction implements ShapeRenderingFunction
private List<Point> LocalListPointsIso = new ArrayList<Point>();
private List<Point> LocalListPointsCartesian = new ArrayList<Point>();
private float scaleIndex = 1;
Point centeringImage;
public List<Point> getLocalListPointsIso() {
return LocalListPointsIso;
@ -40,7 +41,6 @@ public class HitboxRectengleRenderingFunction implements ShapeRenderingFunction
public void drawing(Graphics2D g) {
scaleIndex = entity.getScaleIndex();
HitboxRectangle nowHitbox = (HitboxRectangle)entity.getHitbox();
int x1,y1,x2,y2;
if(nowHitbox.getListPointsIso().size() == 4) {
drawingLinesFromListPoints(nowHitbox.getListPointsIso(),g);
}
@ -58,13 +58,14 @@ public class HitboxRectengleRenderingFunction implements ShapeRenderingFunction
y1 = (int)listPointsIso.get(i % size).y;
x2 = (int)listPointsIso.get((i+1) % size).x;
y2 = (int)listPointsIso.get((i+1) % size).y;
g.drawLine((int)(x1*scaleIndex), (int)(y1*scaleIndex), (int)(x2*scaleIndex), (int)(y2*scaleIndex));
g.drawLine((int)(x1*scaleIndex+centeringImage.x), (int)(y1*scaleIndex+centeringImage.y), (int)(x2*scaleIndex+centeringImage.x), (int)(y2*scaleIndex+centeringImage.y));
System.out.println("x = "+x1*scaleIndex+centeringImage.x+"|| y = "+y1*scaleIndex+centeringImage.y);
}
x1 = (int)listPointsIso.get(0).x;
y1 = (int)listPointsIso.get(0).y;
x2 = (int)listPointsIso.get(3).x;
y2 = (int)listPointsIso.get(3).y;
g.drawLine((int)(x1*scaleIndex), (int)(y1*scaleIndex), (int)(x2*scaleIndex), (int)(y2*scaleIndex));
g.drawLine((int)(x1*scaleIndex+centeringImage.x), (int)(y1*scaleIndex+centeringImage.y), (int)(x2*scaleIndex+centeringImage.x), (int)(y2*scaleIndex+centeringImage.y));
}
@Override
@ -95,8 +96,11 @@ public class HitboxRectengleRenderingFunction implements ShapeRenderingFunction
@Override
public void mouseMoved(MouseEvent e) {
currentIsoPoint.x = e.getX()/scaleIndex;
currentIsoPoint.y = e.getY()/scaleIndex;
currentIsoPoint.x = (e.getX()-centeringImage.x)/scaleIndex;
currentIsoPoint.y = (e.getY()-centeringImage.y)/scaleIndex;
System.out.println("currentIsoPoint.x = "+currentIsoPoint.x);
System.out.println("currentIsoPoint.y = "+currentIsoPoint.y);
HitboxRectangle nowHitbox = (HitboxRectangle)entity.getHitbox();
if(entity!=null) {
if(firstIsoPoint != null && nowHitbox.getListPointsIso().size() == 0) {
@ -151,6 +155,9 @@ public class HitboxRectengleRenderingFunction implements ShapeRenderingFunction
}
}
public void setCenteringImagePoint(Point p) {
centeringImage = p;
}
@Override
public void functionClearJButton() {
HitboxRectangle nowHitbox = (HitboxRectangle)entity.getHitbox();