From cc09c59fe526a1850c8e758e13662cff243cf58a Mon Sep 17 00:00:00 2001 From: Bane Stojkovic Date: Sun, 14 Jun 2026 10:05:15 +0200 Subject: [PATCH] Fixed scaling for 'Image' and 'SVG Image' components; it was showing as undefined --- .../chatbot/service/ChatbotService.java | 4 +- .../diylc-core/src/main/resources/update.xml | 16 ++++++++ .../java/org/diylc/components/misc/Image.java | 41 +++++++++++-------- .../org/diylc/components/misc/SVGImage.java | 41 +++++++++++-------- 4 files changed, 64 insertions(+), 38 deletions(-) diff --git a/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/ChatbotService.java b/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/ChatbotService.java index edcddf40c..4bd55cd83 100644 --- a/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/ChatbotService.java +++ b/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/ChatbotService.java @@ -109,8 +109,8 @@ public class ChatbotService { private IChatbotAPI getService() { if (service == null) { - String serviceUrl = - ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api/v1/ai"); + String serviceUrl = System.getProperty("org.diylc.cloud.baseUrl", + ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api/v1")) + "/ai"; ProxyFactory factory = new ProxyFactory(new PhpFlatProxy()); service = factory.createProxy(IChatbotAPI.class, serviceUrl); } diff --git a/diylc/diylc-core/src/main/resources/update.xml b/diylc/diylc-core/src/main/resources/update.xml index 0efe40193..e8d3f5c26 100644 --- a/diylc/diylc-core/src/main/resources/update.xml +++ b/diylc/diylc-core/src/main/resources/update.xml @@ -420,5 +420,21 @@ https://github.com/bancika/diy-layout-creator/releases + + + 5 + 15 + 0 + + 2026-06-13 00:00:00.000 CET + + + + BUG_FIX + Fixed scaling for 'Image' and 'SVG Image' components; it was showing as undefined + + + https://github.com/bancika/diy-layout-creator/releases + diff --git a/diylc/diylc-library/src/main/java/org/diylc/components/misc/Image.java b/diylc/diylc-library/src/main/java/org/diylc/components/misc/Image.java index d58df5198..70fb2bdae 100644 --- a/diylc/diylc-library/src/main/java/org/diylc/components/misc/Image.java +++ b/diylc/diylc-library/src/main/java/org/diylc/components/misc/Image.java @@ -39,6 +39,7 @@ import com.thoughtworks.xstream.annotations.XStreamConverter; import org.diylc.awt.ImageUtils; import org.diylc.common.ObjectCache; import org.diylc.common.Orientation; +import org.diylc.common.Percentage; import org.diylc.components.AbstractTransparentComponent; import org.diylc.components.transform.ImageTransformer; import org.diylc.core.ComponentState; @@ -46,12 +47,7 @@ import org.diylc.core.IDIYComponent; import org.diylc.core.IDrawingObserver; import org.diylc.core.Project; import org.diylc.core.VisibilityPolicy; -import org.diylc.core.annotations.BinaryType; -import org.diylc.core.annotations.BomPolicy; -import org.diylc.core.annotations.ByteArrayProperty; -import org.diylc.core.annotations.ComponentDescriptor; -import org.diylc.core.annotations.EditableProperty; -import org.diylc.core.annotations.PercentEditor; +import org.diylc.core.annotations.*; @ComponentDescriptor(name = "Image", author = "Branislav Stojkovic", category = "Misc", description = "User defined image", instanceNamePrefix = "Img", zOrder = IDIYComponent.COMPONENT, @@ -63,7 +59,6 @@ public class Image extends AbstractTransparentComponent { private static final long serialVersionUID = 1L; public static String DEFAULT_TEXT = "Double click to edit text"; private static ImageIcon ICON; - private static byte DEFAULT_SCALE = 25; private Point2D.Double point = new Point2D.Double(0, 0); private Point2D.Double secondPoint = null; @@ -90,8 +85,11 @@ public class Image extends AbstractTransparentComponent { @Deprecated private ImageIcon image; private byte[] data; + @Deprecated private Byte scale; - private byte newScale = DEFAULT_SCALE; + @Deprecated + private Byte newScale; + private Percentage scalePercent = new Percentage(100); private ImageSizingMode sizingMode = ImageSizingMode.Scale; private transient ImageIcon imageIcon; @@ -116,7 +114,7 @@ public class Image extends AbstractTransparentComponent { double scaleY; ImageIcon imageIcon = getImage(); if (getSizingMode() == ImageSizingMode.Scale) { - scaleX = scaleY = 1d * getScale() / DEFAULT_SCALE; + scaleX = scaleY = 1d * getScale().getValue() / 100d; } else { Point2D secondPoint = getControlPoint(1); scaleX = 1d * Math.abs(point.getX() - secondPoint.getX()) / imageIcon.getIconWidth(); @@ -240,17 +238,24 @@ public class Image extends AbstractTransparentComponent { } @PercentEditor(minValue = 1, maxValue = 1000) - @EditableProperty(defaultable = false) - public byte getScale() { - if (scale != null) { - newScale = (byte) (scale / 2); - scale = null; + @EditableProperty(name = "Scale", defaultable = false) + public Percentage getScale() { + if (scalePercent == null) { + if (newScale != null) { + scalePercent = new Percentage(newScale * 4); + newScale = null; + } else if (scale != null) { + scalePercent = new Percentage(scale * 2); + scale = null; + } else { + scalePercent = new Percentage(100); + } } - return newScale; + return scalePercent; } - public void setScale(byte scale) { - this.newScale = scale; + public void setScale(Percentage scale) { + this.scalePercent = scale; } @Override @@ -293,7 +298,7 @@ public class Image extends AbstractTransparentComponent { if (getSizingMode() == ImageSizingMode.TwoPoints) { finalSecondPoint = secondPoint; } else { - double scale = 1d * getScale() / DEFAULT_SCALE; + double scale = 1d * getScale().getValue() / 100d; ImageIcon iconImage = getImage(); finalSecondPoint = new Point2D.Double(point.getX() + iconImage.getIconWidth() * scale, point.getY() + iconImage.getIconHeight() * scale); diff --git a/diylc/diylc-library/src/main/java/org/diylc/components/misc/SVGImage.java b/diylc/diylc-library/src/main/java/org/diylc/components/misc/SVGImage.java index f8d9a8ed6..552855b2b 100644 --- a/diylc/diylc-library/src/main/java/org/diylc/components/misc/SVGImage.java +++ b/diylc/diylc-library/src/main/java/org/diylc/components/misc/SVGImage.java @@ -37,6 +37,7 @@ import com.kitfox.svg.SVGUniverse; import org.diylc.common.ObjectCache; import org.diylc.common.Orientation; +import org.diylc.common.Percentage; import org.diylc.components.AbstractTransparentComponent; import org.diylc.components.transform.ImageTransformer; import org.diylc.core.ComponentState; @@ -44,12 +45,7 @@ import org.diylc.core.IDIYComponent; import org.diylc.core.IDrawingObserver; import org.diylc.core.Project; import org.diylc.core.VisibilityPolicy; -import org.diylc.core.annotations.BinaryType; -import org.diylc.core.annotations.BomPolicy; -import org.diylc.core.annotations.ByteArrayProperty; -import org.diylc.core.annotations.ComponentDescriptor; -import org.diylc.core.annotations.EditableProperty; -import org.diylc.core.annotations.PercentEditor; +import org.diylc.core.annotations.*; @ComponentDescriptor(name = "SVG Image", author = "Branislav Stojkovic", category = "Misc", description = "Scalable Vector Graphics", instanceNamePrefix = "Svg", @@ -61,7 +57,6 @@ public class SVGImage extends AbstractTransparentComponent { private static final long serialVersionUID = 1L; public static String DEFAULT_TEXT = "Double click to edit text"; - private static byte DEFAULT_SCALE = 25; private Point2D.Double point = new Point2D.Double(0, 0); private Point2D.Double secondPoint = null; @@ -74,8 +69,11 @@ public class SVGImage extends AbstractTransparentComponent { } private byte[] data; + @Deprecated private Byte scale; - private byte newScale = DEFAULT_SCALE; + @Deprecated + private Byte newScale; + private Percentage scalePercent = new Percentage(100); private ImageSizingMode sizingMode = ImageSizingMode.Scale; private transient SVGDiagram svgDiagram; @@ -95,7 +93,7 @@ public class SVGImage extends AbstractTransparentComponent { double scaleY; SVGDiagram svgDiagram = getSvgDiagram(); if (getSizingMode() == ImageSizingMode.Scale) { - scaleX = scaleY = 1d * getScale() / DEFAULT_SCALE; + scaleX = scaleY = 1d * getScale().getValue() / 100d; } else { Point2D secondPoint = getControlPoint(1); scaleX = 1d * Math.abs(point.getX() - secondPoint.getX()) / svgDiagram.getWidth(); @@ -226,18 +224,25 @@ public class SVGImage extends AbstractTransparentComponent { this.svgDiagram = null; } - @PercentEditor(minValue = 0, maxValue = 1000) - @EditableProperty(defaultable = false) - public byte getScale() { - if (scale != null) { - newScale = (byte) (scale / 2); - scale = null; + @PercentEditor(minValue = 1, maxValue = 1000) + @EditableProperty(name = "Scale", defaultable = false) + public Percentage getScale() { + if (scalePercent == null) { + if (newScale != null) { + scalePercent = new Percentage(newScale * 4); + newScale = null; + } else if (scale != null) { + scalePercent = new Percentage(scale * 2); + scale = null; + } else { + scalePercent = new Percentage(100); + } } - return newScale; + return scalePercent; } - public void setScale(byte scale) { - this.newScale = scale; + public void setScale(Percentage scale) { + this.scalePercent = scale; } @Override