mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-13 02:32:09 +10:00
Fixed scaling for 'Image' and 'SVG Image' components; it was showing as undefined
This commit is contained in:
+2
-2
@@ -109,8 +109,8 @@ public class ChatbotService {
|
|||||||
|
|
||||||
private IChatbotAPI getService() {
|
private IChatbotAPI getService() {
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
String serviceUrl =
|
String serviceUrl = System.getProperty("org.diylc.cloud.baseUrl",
|
||||||
ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api/v1/ai");
|
ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api/v1")) + "/ai";
|
||||||
ProxyFactory factory = new ProxyFactory(new PhpFlatProxy());
|
ProxyFactory factory = new ProxyFactory(new PhpFlatProxy());
|
||||||
service = factory.createProxy(IChatbotAPI.class, serviceUrl);
|
service = factory.createProxy(IChatbotAPI.class, serviceUrl);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -420,5 +420,21 @@
|
|||||||
</changes>
|
</changes>
|
||||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
</org.diylc.appframework.update.Version>
|
</org.diylc.appframework.update.Version>
|
||||||
|
<org.diylc.appframework.update.Version>
|
||||||
|
<versionNumber>
|
||||||
|
<major>5</major>
|
||||||
|
<minor>15</minor>
|
||||||
|
<build>0</build>
|
||||||
|
</versionNumber>
|
||||||
|
<releaseDate>2026-06-13 00:00:00.000 CET</releaseDate>
|
||||||
|
<name></name>
|
||||||
|
<changes>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>BUG_FIX</changeType>
|
||||||
|
<description>Fixed scaling for 'Image' and 'SVG Image' components; it was showing as undefined</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
|
</changes>
|
||||||
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
|
</org.diylc.appframework.update.Version>
|
||||||
</a>
|
</a>
|
||||||
</java.util.Arrays_-ArrayList>
|
</java.util.Arrays_-ArrayList>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import com.thoughtworks.xstream.annotations.XStreamConverter;
|
|||||||
import org.diylc.awt.ImageUtils;
|
import org.diylc.awt.ImageUtils;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
|
import org.diylc.common.Percentage;
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
import org.diylc.components.transform.ImageTransformer;
|
import org.diylc.components.transform.ImageTransformer;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
@@ -46,12 +47,7 @@ import org.diylc.core.IDIYComponent;
|
|||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
import org.diylc.core.VisibilityPolicy;
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.BinaryType;
|
import org.diylc.core.annotations.*;
|
||||||
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;
|
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Image", author = "Branislav Stojkovic", category = "Misc",
|
@ComponentDescriptor(name = "Image", author = "Branislav Stojkovic", category = "Misc",
|
||||||
description = "User defined image", instanceNamePrefix = "Img", zOrder = IDIYComponent.COMPONENT,
|
description = "User defined image", instanceNamePrefix = "Img", zOrder = IDIYComponent.COMPONENT,
|
||||||
@@ -63,7 +59,6 @@ public class Image extends AbstractTransparentComponent<Void> {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
public static String DEFAULT_TEXT = "Double click to edit text";
|
public static String DEFAULT_TEXT = "Double click to edit text";
|
||||||
private static ImageIcon ICON;
|
private static ImageIcon ICON;
|
||||||
private static byte DEFAULT_SCALE = 25;
|
|
||||||
|
|
||||||
private Point2D.Double point = new Point2D.Double(0, 0);
|
private Point2D.Double point = new Point2D.Double(0, 0);
|
||||||
private Point2D.Double secondPoint = null;
|
private Point2D.Double secondPoint = null;
|
||||||
@@ -90,8 +85,11 @@ public class Image extends AbstractTransparentComponent<Void> {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
private ImageIcon image;
|
private ImageIcon image;
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
|
@Deprecated
|
||||||
private Byte scale;
|
private Byte scale;
|
||||||
private byte newScale = DEFAULT_SCALE;
|
@Deprecated
|
||||||
|
private Byte newScale;
|
||||||
|
private Percentage scalePercent = new Percentage(100);
|
||||||
private ImageSizingMode sizingMode = ImageSizingMode.Scale;
|
private ImageSizingMode sizingMode = ImageSizingMode.Scale;
|
||||||
|
|
||||||
private transient ImageIcon imageIcon;
|
private transient ImageIcon imageIcon;
|
||||||
@@ -116,7 +114,7 @@ public class Image extends AbstractTransparentComponent<Void> {
|
|||||||
double scaleY;
|
double scaleY;
|
||||||
ImageIcon imageIcon = getImage();
|
ImageIcon imageIcon = getImage();
|
||||||
if (getSizingMode() == ImageSizingMode.Scale) {
|
if (getSizingMode() == ImageSizingMode.Scale) {
|
||||||
scaleX = scaleY = 1d * getScale() / DEFAULT_SCALE;
|
scaleX = scaleY = 1d * getScale().getValue() / 100d;
|
||||||
} else {
|
} else {
|
||||||
Point2D secondPoint = getControlPoint(1);
|
Point2D secondPoint = getControlPoint(1);
|
||||||
scaleX = 1d * Math.abs(point.getX() - secondPoint.getX()) / imageIcon.getIconWidth();
|
scaleX = 1d * Math.abs(point.getX() - secondPoint.getX()) / imageIcon.getIconWidth();
|
||||||
@@ -240,17 +238,24 @@ public class Image extends AbstractTransparentComponent<Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PercentEditor(minValue = 1, maxValue = 1000)
|
@PercentEditor(minValue = 1, maxValue = 1000)
|
||||||
@EditableProperty(defaultable = false)
|
@EditableProperty(name = "Scale", defaultable = false)
|
||||||
public byte getScale() {
|
public Percentage getScale() {
|
||||||
if (scale != null) {
|
if (scalePercent == null) {
|
||||||
newScale = (byte) (scale / 2);
|
if (newScale != null) {
|
||||||
|
scalePercent = new Percentage(newScale * 4);
|
||||||
|
newScale = null;
|
||||||
|
} else if (scale != null) {
|
||||||
|
scalePercent = new Percentage(scale * 2);
|
||||||
scale = null;
|
scale = null;
|
||||||
|
} else {
|
||||||
|
scalePercent = new Percentage(100);
|
||||||
}
|
}
|
||||||
return newScale;
|
}
|
||||||
|
return scalePercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScale(byte scale) {
|
public void setScale(Percentage scale) {
|
||||||
this.newScale = scale;
|
this.scalePercent = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -293,7 +298,7 @@ public class Image extends AbstractTransparentComponent<Void> {
|
|||||||
if (getSizingMode() == ImageSizingMode.TwoPoints) {
|
if (getSizingMode() == ImageSizingMode.TwoPoints) {
|
||||||
finalSecondPoint = secondPoint;
|
finalSecondPoint = secondPoint;
|
||||||
} else {
|
} else {
|
||||||
double scale = 1d * getScale() / DEFAULT_SCALE;
|
double scale = 1d * getScale().getValue() / 100d;
|
||||||
ImageIcon iconImage = getImage();
|
ImageIcon iconImage = getImage();
|
||||||
finalSecondPoint = new Point2D.Double(point.getX() + iconImage.getIconWidth() * scale,
|
finalSecondPoint = new Point2D.Double(point.getX() + iconImage.getIconWidth() * scale,
|
||||||
point.getY() + iconImage.getIconHeight() * scale);
|
point.getY() + iconImage.getIconHeight() * scale);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.kitfox.svg.SVGUniverse;
|
|||||||
|
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
|
import org.diylc.common.Percentage;
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
import org.diylc.components.transform.ImageTransformer;
|
import org.diylc.components.transform.ImageTransformer;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
@@ -44,12 +45,7 @@ import org.diylc.core.IDIYComponent;
|
|||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
import org.diylc.core.VisibilityPolicy;
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.BinaryType;
|
import org.diylc.core.annotations.*;
|
||||||
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;
|
|
||||||
|
|
||||||
@ComponentDescriptor(name = "SVG Image", author = "Branislav Stojkovic", category = "Misc",
|
@ComponentDescriptor(name = "SVG Image", author = "Branislav Stojkovic", category = "Misc",
|
||||||
description = "Scalable Vector Graphics", instanceNamePrefix = "Svg",
|
description = "Scalable Vector Graphics", instanceNamePrefix = "Svg",
|
||||||
@@ -61,7 +57,6 @@ public class SVGImage extends AbstractTransparentComponent<Void> {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
public static String DEFAULT_TEXT = "Double click to edit text";
|
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 point = new Point2D.Double(0, 0);
|
||||||
private Point2D.Double secondPoint = null;
|
private Point2D.Double secondPoint = null;
|
||||||
@@ -74,8 +69,11 @@ public class SVGImage extends AbstractTransparentComponent<Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
|
@Deprecated
|
||||||
private Byte scale;
|
private Byte scale;
|
||||||
private byte newScale = DEFAULT_SCALE;
|
@Deprecated
|
||||||
|
private Byte newScale;
|
||||||
|
private Percentage scalePercent = new Percentage(100);
|
||||||
private ImageSizingMode sizingMode = ImageSizingMode.Scale;
|
private ImageSizingMode sizingMode = ImageSizingMode.Scale;
|
||||||
private transient SVGDiagram svgDiagram;
|
private transient SVGDiagram svgDiagram;
|
||||||
|
|
||||||
@@ -95,7 +93,7 @@ public class SVGImage extends AbstractTransparentComponent<Void> {
|
|||||||
double scaleY;
|
double scaleY;
|
||||||
SVGDiagram svgDiagram = getSvgDiagram();
|
SVGDiagram svgDiagram = getSvgDiagram();
|
||||||
if (getSizingMode() == ImageSizingMode.Scale) {
|
if (getSizingMode() == ImageSizingMode.Scale) {
|
||||||
scaleX = scaleY = 1d * getScale() / DEFAULT_SCALE;
|
scaleX = scaleY = 1d * getScale().getValue() / 100d;
|
||||||
} else {
|
} else {
|
||||||
Point2D secondPoint = getControlPoint(1);
|
Point2D secondPoint = getControlPoint(1);
|
||||||
scaleX = 1d * Math.abs(point.getX() - secondPoint.getX()) / svgDiagram.getWidth();
|
scaleX = 1d * Math.abs(point.getX() - secondPoint.getX()) / svgDiagram.getWidth();
|
||||||
@@ -226,18 +224,25 @@ public class SVGImage extends AbstractTransparentComponent<Void> {
|
|||||||
this.svgDiagram = null;
|
this.svgDiagram = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PercentEditor(minValue = 0, maxValue = 1000)
|
@PercentEditor(minValue = 1, maxValue = 1000)
|
||||||
@EditableProperty(defaultable = false)
|
@EditableProperty(name = "Scale", defaultable = false)
|
||||||
public byte getScale() {
|
public Percentage getScale() {
|
||||||
if (scale != null) {
|
if (scalePercent == null) {
|
||||||
newScale = (byte) (scale / 2);
|
if (newScale != null) {
|
||||||
|
scalePercent = new Percentage(newScale * 4);
|
||||||
|
newScale = null;
|
||||||
|
} else if (scale != null) {
|
||||||
|
scalePercent = new Percentage(scale * 2);
|
||||||
scale = null;
|
scale = null;
|
||||||
|
} else {
|
||||||
|
scalePercent = new Percentage(100);
|
||||||
}
|
}
|
||||||
return newScale;
|
}
|
||||||
|
return scalePercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScale(byte scale) {
|
public void setScale(Percentage scale) {
|
||||||
this.newScale = scale;
|
this.scalePercent = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user