mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Added "Label Orientation" property to leaded components that can be used
to force labels to be rendered horizontally instead of following component placement direction
This commit is contained in:
@@ -71,6 +71,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
protected Color leadColor = LEAD_COLOR;
|
||||
protected Display display = Display.NAME;
|
||||
private boolean flipStanding = false;
|
||||
private LabelOriantation labelOriantation = LabelOriantation.Directional;
|
||||
|
||||
protected AbstractLeadedComponent() {
|
||||
super();
|
||||
@@ -235,9 +236,17 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
g2d.rotate(Math.PI, length / 2, width / 2);
|
||||
offset = -offset;
|
||||
}
|
||||
g2d.drawString(label, (int) (length - textRect.getWidth()) / 2 + offset,
|
||||
calculateLabelYCoordinate(shapeRect, textRect, fontMetrics));
|
||||
g2d.setTransform(oldTransform);
|
||||
if (getLabelOriantation() == LabelOriantation.Horizontal) {
|
||||
g2d.setTransform(oldTransform);
|
||||
double x = (points[0].x + points[1].x - length) / 2.0;
|
||||
double y = (points[0].y + points[1].y - width) / 2.0;
|
||||
g2d.drawString(label, (int) (x + (length - textRect.getWidth()) / 2 + offset),
|
||||
(int)(y + calculateLabelYCoordinate(shapeRect, textRect, fontMetrics)));
|
||||
} else {
|
||||
g2d.drawString(label, (int) (length - textRect.getWidth()) / 2 + offset,
|
||||
calculateLabelYCoordinate(shapeRect, textRect, fontMetrics));
|
||||
g2d.setTransform(oldTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,7 +376,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
: getLeadColor();
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Lead color")
|
||||
@EditableProperty(name = "Lead Color")
|
||||
public Color getLeadColor() {
|
||||
if (leadColor == null) {
|
||||
leadColor = LEAD_COLOR_ICON;
|
||||
@@ -457,7 +466,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Label color")
|
||||
@EditableProperty(name = "Label Color")
|
||||
public Color getLabelColor() {
|
||||
return labelColor;
|
||||
}
|
||||
@@ -466,6 +475,17 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
this.labelColor = labelColor;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Label Orientation")
|
||||
public LabelOriantation getLabelOriantation() {
|
||||
if (labelOriantation == null)
|
||||
labelOriantation = LabelOriantation.Directional;
|
||||
return labelOriantation;
|
||||
}
|
||||
|
||||
public void setLabelOriantation(LabelOriantation labelOriantation) {
|
||||
this.labelOriantation = labelOriantation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method with @EditableProperty annotation in child classes where standing mode is
|
||||
* supported
|
||||
@@ -479,4 +499,8 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
public void setFlipStanding(boolean flipStanding) {
|
||||
this.flipStanding = flipStanding;
|
||||
}
|
||||
|
||||
public enum LabelOriantation {
|
||||
Directional, Horizontal
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -200,7 +200,7 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
||||
|
||||
@Override
|
||||
protected int getLabelOffset(int bodyWidth, int labelWidth) {
|
||||
if (value == null || getColorCode() == ResistorColorCode.NONE)
|
||||
if (value == null || getColorCode() == ResistorColorCode.NONE || getLabelOriantation() != AbstractLeadedComponent.LabelOriantation.Directional)
|
||||
return 0;
|
||||
int width = getClosestOdd(getWidth().convertToPixels());
|
||||
Color[] bands = value.getColorCode(colorCode);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -2138,6 +2138,10 @@
|
||||
<releaseDate>2019-01-09 00:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Added "Label Orientation" property to leaded components that can be used to force labels to be rendered horizontally instead of following component placement direction</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>"Jazz Bass Pickup" added</description>
|
||||
|
||||
Reference in New Issue
Block a user