mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-13 06:49:36 -04:00
minor refactoring
This commit is contained in:
parent
f076b6a83f
commit
9fd0ca8506
@ -10,7 +10,7 @@ import de.neemann.digital.draw.graphics.text.formatter.GraphicsFormatter;
|
|||||||
import java.awt.font.FontRenderContext;
|
import java.awt.font.FontRenderContext;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
import static de.neemann.digital.draw.graphics.GraphicSwing.isMirror;
|
import static de.neemann.digital.draw.graphics.GraphicSwing.getMirrorYOrientation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to determine the size of shapes or the whole circuit.
|
* This class is used to determine the size of shapes or the whole circuit.
|
||||||
@ -113,8 +113,7 @@ public class GraphicMinMax extends Graphic {
|
|||||||
p = p.sub(width.mul(orientation.getX()).div(2));
|
p = p.sub(width.mul(orientation.getX()).div(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
int oy = orientation.getY();
|
int oy = getMirrorYOrientation(orientation, p1, p2, p3);
|
||||||
if (isMirror(p1, p2, p3)) oy = 2 - oy;
|
|
||||||
if (oy != 0) {
|
if (oy != 0) {
|
||||||
p = p.sub(height.mul(oy).div(2));
|
p = p.sub(height.mul(oy).div(2));
|
||||||
} else
|
} else
|
||||||
|
@ -13,7 +13,7 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import static de.neemann.digital.draw.graphics.GraphicSwing.isMirror;
|
import static de.neemann.digital.draw.graphics.GraphicSwing.getMirrorYOrientation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to create a SVG representation of the circuit.
|
* Used to create a SVG representation of the circuit.
|
||||||
@ -206,8 +206,7 @@ public class GraphicSVG extends Graphic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VectorFloat p = new VectorFloat(p1);
|
VectorFloat p = new VectorFloat(p1);
|
||||||
int oy = orientation.getY();
|
int oy = getMirrorYOrientation(orientation, p1, p2, p3);
|
||||||
if (isMirror(p1, p2, p3)) oy = 2 - oy;
|
|
||||||
switch (oy) {
|
switch (oy) {
|
||||||
case 1:
|
case 1:
|
||||||
p = p.add(new VectorFloat(0, style.getFontSize() / 2f - style.getFontSize() / 8f));
|
p = p.add(new VectorFloat(0, style.getFontSize() / 2f - style.getFontSize() / 8f));
|
||||||
|
@ -130,8 +130,7 @@ public class GraphicSwing extends Graphic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int yoff = 0;
|
int yoff = 0;
|
||||||
int oy = orientation.getY();
|
int oy = getMirrorYOrientation(orientation, p1, p2, p3);
|
||||||
if (isMirror(p1, p2, p3)) oy = 2 - oy;
|
|
||||||
if (oy != 0) {
|
if (oy != 0) {
|
||||||
int height = fragment.getHeight();
|
int height = fragment.getHeight();
|
||||||
yoff += height * oy / 3;
|
yoff += height * oy / 3;
|
||||||
@ -144,10 +143,12 @@ public class GraphicSwing extends Graphic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isMirror(VectorInterface p1, VectorInterface p2, VectorInterface p3) {
|
static int getMirrorYOrientation(Orientation orientation, VectorInterface p1, VectorInterface p2, VectorInterface p3) {
|
||||||
|
int oy = orientation.getY();
|
||||||
VectorInterface d0 = p2.sub(p1).toFloat().getOrthogonal();
|
VectorInterface d0 = p2.sub(p1).toFloat().getOrthogonal();
|
||||||
VectorInterface d1 = p3.sub(p1);
|
VectorInterface d1 = p3.sub(p1);
|
||||||
return d1.getX() * d0.getX() + d1.getY() * d0.getY() < 0;
|
if (d1.getX() * d0.getX() + d1.getY() * d0.getY() < 0) oy = 2 - oy;
|
||||||
|
return oy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user