diff --git a/diylc/diylc-core/src/org/diylc/components/AbstractLeadedComponent.java b/diylc/diylc-core/src/org/diylc/components/AbstractLeadedComponent.java index 72976aec..f30fd32f 100644 --- a/diylc/diylc-core/src/org/diylc/components/AbstractLeadedComponent.java +++ b/diylc/diylc-core/src/org/diylc/components/AbstractLeadedComponent.java @@ -258,7 +258,7 @@ public abstract class AbstractLeadedComponent extends AbstractTransparentComp } Rectangle2D textRect = fontMetrics.getStringBounds(label, g2d); // Don't offset in outline mode. - int offset = outlineMode ? 0 : getLabelOffset((int) length, (int) width); + int offset = outlineMode ? 0 : getLabelOffset((int) length, (int) textRect.getWidth()); // Adjust label angle if needed to make sure that it's readable. if ((theta >= Math.PI / 2 && theta <= Math.PI) || (theta < -Math.PI / 2 && theta > -Math.PI)) { g2d.rotate(Math.PI, length / 2, width / 2); diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar index 81f34ce0..6a2ac23d 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 3879e1e8..44b861a4 100644 --- a/diylc/diylc-library/src/org/diylc/components/passive/Resistor.java +++ b/diylc/diylc-library/src/org/diylc/components/passive/Resistor.java @@ -154,10 +154,10 @@ public class Resistor extends AbstractLeadedComponent { if (colorCode == ResistorColorCode.NONE || outlineMode || value == null) { return; } + int width = getClosestOdd(getWidth().convertToPixels()); if (shape == ResistorShape.Standard) { - int width = getClosestOdd(getWidth().convertToPixels()); - Color[] bands = value.getColorCode(colorCode); int x = width + FIRST_BAND; + Color[] bands = value.getColorCode(colorCode); g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2)); for (int i = 0; i < bands.length; i++) { g2d.setColor(bands[i]); @@ -165,9 +165,9 @@ public class Resistor extends AbstractLeadedComponent { x += BAND_SPACING; } } else { + int x = -FIRST_BAND; int height = getClosestOdd(getWidth().convertToPixels()); Color[] bands = value.getColorCode(colorCode); - int x = FIRST_BAND; g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2)); for (int i = 0; i < bands.length; i++) { g2d.setColor(bands[i]); @@ -183,11 +183,11 @@ public class Resistor extends AbstractLeadedComponent { return 0; int width = getClosestOdd(getWidth().convertToPixels()); Color[] bands = value.getColorCode(colorCode); - int bandArea = width + FIRST_BAND + BAND_SPACING * (bands.length - 1); - // Only offset the label if overlapping with the band area. - if (labelWidth > bodyWidth - 2 * bandArea) - return BAND_SPACING * (bands.length - 1); - return 0; + int bandArea = + shape == ResistorShape.Standard ? width + FIRST_BAND + BAND_SPACING * (bands.length - 1) : -FIRST_BAND + + BAND_SPACING * (bands.length - 1); + + return (bodyWidth - bandArea - labelWidth) / 2; } @EditableProperty(name = "Reverse (standing)") diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar index 81f34ce0..6a2ac23d 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 14a76785..00905213 100644 Binary files a/diylc/diylc-swing/library/main.jar and b/diylc/diylc-swing/library/main.jar differ