mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
better default label position on schematic symbols
This commit is contained in:
Binary file not shown.
@@ -98,6 +98,8 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// This will happen if components do not have any shape.
|
// This will happen if components do not have any shape.
|
||||||
}
|
}
|
||||||
|
if (newPoints != null)
|
||||||
|
newPoints[2] = calculateLabelPosition(newPoints[0], newPoints[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean IsCopperArea() {
|
protected boolean IsCopperArea() {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ package org.diylc.components;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
|
import java.awt.Point;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
import org.diylc.common.LabelPosition;
|
import org.diylc.common.LabelPosition;
|
||||||
@@ -70,6 +71,15 @@ public abstract class AbstractSchematicLeadedSymbol<T> extends AbstractLeadedCom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Point calculateLabelPosition(Point point1, Point point2) {
|
||||||
|
double x = (point1.x + point2.x) / 2.0;
|
||||||
|
double y = (point1.y + point2.y) / 2.0;
|
||||||
|
double theta = Math.atan2(point2.y - point1.y, point2.x - point2.x) - Math.PI / 2;
|
||||||
|
double r = width.convertToPixels() / 2 + LABEL_FONT.getSize() / 2;
|
||||||
|
return new Point((int) (x + Math.cos(theta) * r), (int) (y + Math.sin(theta) * r));
|
||||||
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Label Position")
|
@EditableProperty(name = "Label Position")
|
||||||
public LabelPosition getLabelPosition() {
|
public LabelPosition getLabelPosition() {
|
||||||
return labelPosition;
|
return labelPosition;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user