mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
auto-create component framework improvement
This commit is contained in:
@@ -11,7 +11,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.AutoCreateTag;
|
||||
import org.diylc.core.annotations.AutoCreator;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -20,12 +20,13 @@ import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@AutoCreator(creatorClass = SolderPadAutoCreator.class)
|
||||
@ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic",
|
||||
description = "Copper solder pad, round or square", instanceNamePrefix = "Pad", stretchable = false,
|
||||
zOrder = IDIYComponent.TRACE + 0.1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, autoCreateTag = AutoCreateTag.SOLDER_PAD)
|
||||
zOrder = IDIYComponent.TRACE + 0.1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false)
|
||||
public class SolderPad extends AbstractComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Size SIZE = new Size(0.09d, SizeUnit.in);
|
||||
public static Size HOLE_SIZE = new Size(0.8d, SizeUnit.mm);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.diylc.components.connectivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.IAutoCreator;
|
||||
|
||||
public class SolderPadAutoCreator implements IAutoCreator {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(SolderPadAutoCreator.class);
|
||||
|
||||
public static final String AUTO_PADS_KEY = "autoCreatePads";
|
||||
|
||||
@Override
|
||||
public List<IDIYComponent<?>> createIfNeeded(IDIYComponent<?> lastAdded) {
|
||||
if (ConfigurationManager.getInstance().readBoolean(AUTO_PADS_KEY, false)
|
||||
&& !(lastAdded.getClass().equals(SolderPad.class))) {
|
||||
List<IDIYComponent<?>> res = new ArrayList<IDIYComponent<?>>();
|
||||
for (int i = 0; i < lastAdded.getControlPointCount(); i++) {
|
||||
if (lastAdded.isControlPointSticky(i)) {
|
||||
try {
|
||||
SolderPad pad = new SolderPad();
|
||||
// instantiationManager.instantiateComponent(padType, null,
|
||||
// component.getControlPoint(i), currentProject)
|
||||
// .get(0);
|
||||
pad.setControlPoint(lastAdded.getControlPoint(i), 0);
|
||||
res.add(pad);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Could not auto-create solder pad", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user