diff --git a/diylc/diylc-core/src/org/diylc/components/AbstractLeadedComponent.java b/diylc/diylc-core/src/org/diylc/components/AbstractLeadedComponent.java index 9dd8c536..3e5a49cc 100644 --- a/diylc/diylc-core/src/org/diylc/components/AbstractLeadedComponent.java +++ b/diylc/diylc-core/src/org/diylc/components/AbstractLeadedComponent.java @@ -71,6 +71,7 @@ public abstract class AbstractLeadedComponent 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 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 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 extends AbstractTransparentComp this.display = display; } - @EditableProperty(name = "Label color") + @EditableProperty(name = "Label Color") public Color getLabelColor() { return labelColor; } @@ -465,6 +474,17 @@ public abstract class AbstractLeadedComponent extends AbstractTransparentComp public void setLabelColor(Color labelColor) { 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 @@ -479,4 +499,8 @@ public abstract class AbstractLeadedComponent extends AbstractTransparentComp public void setFlipStanding(boolean flipStanding) { this.flipStanding = flipStanding; } + + public enum LabelOriantation { + Directional, Horizontal + } } diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar index a68e7f96..b95dba76 100644 Binary files a/diylc/diylc-library/lib/diylc-core.jar and b/diylc/diylc-library/lib/diylc-core.jar differ diff --git a/diylc/diylc-library/src/org/diylc/components/passive/Resistor.java b/diylc/diylc-library/src/org/diylc/components/passive/Resistor.java index be7eb36c..3379165e 100644 --- a/diylc/diylc-library/src/org/diylc/components/passive/Resistor.java +++ b/diylc/diylc-library/src/org/diylc/components/passive/Resistor.java @@ -200,7 +200,7 @@ public class Resistor extends AbstractLeadedComponent { @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); diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar index a68e7f96..b95dba76 100644 Binary files a/diylc/diylc-swing/lib/diylc-core.jar and b/diylc/diylc-swing/lib/diylc-core.jar differ diff --git a/diylc/diylc-swing/library/main.jar b/diylc/diylc-swing/library/main.jar index 75a9dbc6..d31657b4 100644 Binary files a/diylc/diylc-swing/library/main.jar and b/diylc/diylc-swing/library/main.jar differ diff --git a/diylc/diylc-swing/update.xml b/diylc/diylc-swing/update.xml index 17233ff0..102fa6e4 100644 --- a/diylc/diylc-swing/update.xml +++ b/diylc/diylc-swing/update.xml @@ -2138,6 +2138,10 @@ 2019-01-09 00:00:00.000 CET + + NEW_FEATURE + Added "Label Orientation" property to leaded components that can be used to force labels to be rendered horizontally instead of following component placement direction + NEW_FEATURE "Jazz Bass Pickup" added