mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12: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 java.util.Arrays;
|
||||||
|
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
|
import org.diylc.core.Project;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -258,5 +259,10 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
|||||||
@Override
|
@Override
|
||||||
public Rectangle2D getCachingBounds() {
|
public Rectangle2D getCachingBounds() {
|
||||||
return null;
|
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.
|
* Used only if {@link ComponentDescriptor#enableCache()} is set to true.
|
||||||
* @return
|
* @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>
|
* @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;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,13 @@ public class CalcUtils {
|
|||||||
point.setLocation(x, y);
|
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) {
|
public static void snapPointToObjects(Point2D point, Size gridSpacing, IDIYComponent<?> component, List<IDIYComponent<?>> components) {
|
||||||
for (IDIYComponent<?> c : components) {
|
for (IDIYComponent<?> c : components) {
|
||||||
if (c == component)
|
if (c == component)
|
||||||
|
|||||||
@@ -260,7 +260,8 @@ public class InstantiationManager {
|
|||||||
LOG.info("Instatiating component of type: " + componentType.getInstanceClass().getName());
|
LOG.info("Instatiating component of type: " + componentType.getInstanceClass().getName());
|
||||||
|
|
||||||
// Instantiate the component.
|
// Instantiate the component.
|
||||||
IDIYComponent<?> component = componentType.getInstanceClass().newInstance();
|
IDIYComponent<?> component = componentType.getInstanceClass().newInstance();
|
||||||
|
component.createdIn(currentProject);
|
||||||
|
|
||||||
component.setName(createUniqueName(componentType, currentProject.getComponents()));
|
component.setName(createUniqueName(componentType, currentProject.getComponents()));
|
||||||
|
|
||||||
|
|||||||
@@ -3290,6 +3290,10 @@
|
|||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>macOS: two finger click shows the popup menu without deselecting a selected component</description>
|
<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>
|
||||||
|
<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>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Do not allow for components like traces, jumpers and wires to be reduced to nothing by dragging connected components</description>
|
<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>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<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>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
|||||||
Binary file not shown.
@@ -52,6 +52,7 @@ import org.diylc.core.annotations.EditableProperty;
|
|||||||
import org.diylc.core.annotations.PositiveNonZeroMeasureValidator;
|
import org.diylc.core.annotations.PositiveNonZeroMeasureValidator;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.presenter.CalcUtils;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,6 +103,13 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
}
|
}
|
||||||
points[2] = calculateLabelPosition(points[0], points[1]);
|
points[2] = calculateLabelPosition(points[0], points[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createdIn(Project project) {
|
||||||
|
double targetSize = CalcUtils.findClosestMultiplierOf(project.getGridSpacing(), DEFAULT_SIZE, 2).convertToPixels();
|
||||||
|
points[0]= new Point2D.Double(-targetSize / 2, 0);
|
||||||
|
points[1] = new Point2D.Double(targetSize / 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean IsCopperArea() {
|
protected boolean IsCopperArea() {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user