diff --git a/diylc/diylc-core/src/org/diylc/components/AbstractComponent.java b/diylc/diylc-core/src/org/diylc/components/AbstractComponent.java index f8fba088..7ccc7450 100644 --- a/diylc/diylc-core/src/org/diylc/components/AbstractComponent.java +++ b/diylc/diylc-core/src/org/diylc/components/AbstractComponent.java @@ -160,9 +160,9 @@ public abstract class AbstractComponent implements IDIYComponent { @SuppressWarnings("unchecked") public IDIYComponent clone() throws CloneNotSupportedException { try { - // Instantiate object of the same type - AbstractComponent newInstance = (AbstractComponent) this.getClass().getConstructors()[0].newInstance(); + // Instantiate object of the same type Class clazz = this.getClass(); + AbstractComponent newInstance = (AbstractComponent) clazz.newInstance(); while (AbstractComponent.class.isAssignableFrom(clazz)) { Field[] fields = clazz.getDeclaredFields(); clazz = clazz.getSuperclass(); @@ -180,8 +180,9 @@ public abstract class AbstractComponent implements IDIYComponent { && value.getClass().getComponentType().isAssignableFrom(Point2D.class)) { Object newArray = Array.newInstance(value.getClass().getComponentType(), Array.getLength(value)); for (int i = 0; i < Array.getLength(value); i++) { - Point2D p = (Point2D) Array.get(value, i); - Array.set(newArray, i, new Point2D.Double(p.getX(), p.getY())); + Point2D p = (Point2D) Array.get(value, i); + if (p != null) + Array.set(newArray, i, new Point2D.Double(p.getX(), p.getY())); } value = newArray; } diff --git a/diylc/diylc-core/src/org/diylc/core/annotations/Defaults.java b/diylc/diylc-core/src/org/diylc/core/annotations/Defaults.java deleted file mode 100644 index 7a7311e2..00000000 --- a/diylc/diylc-core/src/org/diylc/core/annotations/Defaults.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - - DIY Layout Creator (DIYLC). - Copyright (c) 2009-2018 held jointly by the individual authors. - - This file is part of DIYLC. - - DIYLC is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - DIYLC is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DIYLC. If not, see . - -*/ -package org.diylc.core.annotations; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public final class Defaults { - private Defaults() {} - - private static final Map, Object> DEFAULTS; - - static { - // Only add to this map via put(Map, Class, T) - Map, Object> map = new HashMap, Object>(); - put(map, boolean.class, false); - put(map, Boolean.class, false); - put(map, char.class, '\0'); - put(map, byte.class, (byte) 0); - put(map, Byte.class, (byte) 0); - put(map, short.class, (short) 0); - put(map, Short.class, (short) 0); - put(map, int.class, 0); - put(map, Integer.class, 0); - put(map, long.class, 0L); - put(map, Long.class, 0L); - put(map, float.class, 0f); - put(map, Float.class, 0f); - put(map, double.class, 0d); - put(map, Double.class, 0d); - DEFAULTS = Collections.unmodifiableMap(map); - } - - private static void put(Map, Object> map, Class type, T value) { - map.put(type, value); - } - - /** - * Returns the default value of {@code type} as defined by JLS --- {@code 0} for numbers, - * {@code false} for {@code boolean} and {@code '\0'} for {@code char}. For non-primitive types - * and {@code void}, {@code null} is returned. - * - * @throws Exception - */ - @SuppressWarnings("unchecked") - public static T defaultValue(Class type) throws Exception { - // Primitives.wrap(type).cast(...) would avoid the warning, but we can't use that from here - // the put method enforces this key-value relationship - T t = (T) DEFAULTS.get(type); - if (t == null) { - return (T) type.getConstructors()[0].newInstance(); - } - return t; - } -} diff --git a/diylc/diylc-core/src/org/diylc/presenter/update.xml b/diylc/diylc-core/src/org/diylc/presenter/update.xml index 96bc6c26..b6fa703b 100644 --- a/diylc/diylc-core/src/org/diylc/presenter/update.xml +++ b/diylc/diylc-core/src/org/diylc/presenter/update.xml @@ -4154,6 +4154,10 @@ 2022-11-11 00:00:00.000 CET + + BUG_FIX + Fixed an issue that would cause capacitors to fail when creating, editing, moving or deleting + NEW_FEATURE Added standard models in the drop down menu of the component toolbar