mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Fixed issues when creating leaded components using drag and drop with
'Snap to Grid' option switched on using a metric grid spacing (e.g. 1mm)
This commit is contained in:
@@ -32,6 +32,7 @@ import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
/**
|
||||
@@ -258,5 +259,10 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createdIn(Project project) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,5 +196,12 @@ public interface IDIYComponent<T> extends Serializable, Cloneable {
|
||||
* Used only if {@link ComponentDescriptor#enableCache()} is set to true.
|
||||
* @return
|
||||
*/
|
||||
Rectangle2D getCachingBounds();
|
||||
Rectangle2D getCachingBounds();
|
||||
|
||||
/**
|
||||
* Notifies the component that it's being created in the context of the specified project
|
||||
*
|
||||
* @param project
|
||||
*/
|
||||
void createdIn(Project project);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.text.Format;
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public class AbstractMeasure<T extends Enum<? extends Unit>> implements Serializable, Cloneable {
|
||||
public abstract class AbstractMeasure<T extends Enum<? extends Unit>> implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -48,6 +48,13 @@ public class CalcUtils {
|
||||
point.setLocation(x, y);
|
||||
}
|
||||
|
||||
public static Size findClosestMultiplierOf(Size factor, Size target, int step) {
|
||||
Size ret = new Size(0d, factor.getUnit());
|
||||
while (ret.convertToPixels() < target.convertToPixels())
|
||||
ret = new Size(ret.getValue() + factor.getValue() * step, factor.getUnit());
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void snapPointToObjects(Point2D point, Size gridSpacing, IDIYComponent<?> component, List<IDIYComponent<?>> components) {
|
||||
for (IDIYComponent<?> c : components) {
|
||||
if (c == component)
|
||||
|
||||
@@ -260,7 +260,8 @@ public class InstantiationManager {
|
||||
LOG.info("Instatiating component of type: " + componentType.getInstanceClass().getName());
|
||||
|
||||
// Instantiate the component.
|
||||
IDIYComponent<?> component = componentType.getInstanceClass().newInstance();
|
||||
IDIYComponent<?> component = componentType.getInstanceClass().newInstance();
|
||||
component.createdIn(currentProject);
|
||||
|
||||
component.setName(createUniqueName(componentType, currentProject.getComponents()));
|
||||
|
||||
|
||||
@@ -3290,6 +3290,10 @@
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>macOS: two finger click shows the popup menu without deselecting a selected component</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Fixed issues when creating leaded components using drag and drop with 'Snap to Grid' option switched on using a metric grid spacing (e.g. 1mm)</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Do not allow for components like traces, jumpers and wires to be reduced to nothing by dragging connected components</description>
|
||||
@@ -3300,7 +3304,7 @@
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Moving a rigid component (e.g. tube/transistor symbol) which is not snapped to grid makes it snap back to the grid when 'Snap to Grid' is switched on</description>
|
||||
<description>Moving a rigid component (e.g. tube/transistor symbol) which is not snapped to grid makes it snap back to the grid when 'Snap to Grid' option is switched on</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
|
||||
Reference in New Issue
Block a user