auto-create pads

This commit is contained in:
bancika
2011-02-23 20:42:40 +00:00
parent abdf02eac8
commit 80e7ebcbe9
7 changed files with 35 additions and 5 deletions
@@ -1,4 +1,8 @@
<map>
<entry>
<string>default.org.diylc.components.passive.TrimmerPotentiometer:Type</string>
<org.diylc.components.passive.TrimmerPotentiometer_-TrimmerType>FLAT_LARGE</org.diylc.components.passive.TrimmerPotentiometer_-TrimmerType>
</entry>
<entry>
<string>lastPath</string>
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop</string>
@@ -25,13 +29,17 @@
</gridColor>
</org.diylc.core.Theme>
</entry>
<entry>
<string>autoCreatePads</string>
<boolean>false</boolean>
</entry>
<entry>
<string>antiAliasing</string>
<boolean>true</boolean>
</entry>
<entry>
<string>snapToGrid</string>
<boolean>false</boolean>
<boolean>true</boolean>
</entry>
<entry>
<string>hiQualityRender</string>
@@ -40,6 +40,8 @@ public class DIYLCStarter {
LOG.error("Could not initialize log4j configuration", e);
}
LOG.debug("Java version: " + System.getProperty("java.runtime.version") + " by " + System.getProperty("java.vm.vendor"));
LOG.info("Starting DIYLC with working directory " + System.getProperty("user.dir"));
try {
@@ -38,6 +38,7 @@ public interface IPlugInPort {
public static final String STICKY_POINTS_KEY = "stickyPoints";
public static final String METRIC_KEY = "metric";
public static final String SNAP_TO_GRID_KEY = "snapToGrid";
public static final String AUTO_PADS_KEY = "autoCreatePads";
/**
* Returns size of the canvas that takes project dimensions into account as
@@ -27,6 +27,7 @@ import org.diylc.common.IComponentFiler;
import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort;
import org.diylc.common.PropertyWrapper;
import org.diylc.components.connectivity.SolderPad;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IView;
import org.diylc.core.Project;
@@ -364,7 +365,7 @@ public class Presenter implements IPlugInPort {
}
IDIYComponent<?> component = instantiationManager.instantiateComponent(
componentTypeSlot, scaledPoint, currentProject);
addComponent(component, componentTypeSlot);
addComponent(component, componentTypeSlot, true);
// Select the new component
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
// selectedComponents);
@@ -402,7 +403,7 @@ public class Presenter implements IPlugInPort {
// On the second click, add the component to the project.
IDIYComponent<?> componentSlot = instantiationManager.getComponentSlot();
componentSlot.setControlPoint(scaledPoint, 1);
addComponent(componentSlot, componentTypeSlot);
addComponent(componentSlot, componentTypeSlot, true);
// Select the new component if it's not locked.
List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>();
if (!isComponentLocked(componentSlot)) {
@@ -835,7 +836,7 @@ public class Presenter implements IPlugInPort {
component.setControlPoint(point, i);
}
addComponent(component, ComponentProcessor.getInstance().extractComponentTypeFrom(
(Class<? extends IDIYComponent<?>>) component.getClass()));
(Class<? extends IDIYComponent<?>>) component.getClass()), false);
}
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
.deepClone(currentProject), "Add");
@@ -1100,7 +1101,8 @@ public class Presenter implements IPlugInPort {
* @param component
* @param componentType
*/
private void addComponent(IDIYComponent<?> component, ComponentType componentType) {
private void addComponent(IDIYComponent<?> component, ComponentType componentType,
boolean canCreatePads) {
int index = 0;
while (index < currentProject.getComponents().size()
&& componentType.getZOrder() >= ComponentProcessor.getInstance()
@@ -1114,6 +1116,17 @@ public class Presenter implements IPlugInPort {
} else {
currentProject.getComponents().add(component);
}
if (canCreatePads
&& ConfigurationManager.getInstance().readBoolean(IPlugInPort.AUTO_PADS_KEY, false)) {
for (int i = 0; i < component.getControlPointCount(); i++) {
if (component.isControlPointSticky(i)) {
SolderPad pad = new SolderPad();
pad.setControlPoint(component.getControlPoint(i), 0);
addComponent(pad, ComponentProcessor.getInstance().extractComponentTypeFrom(
SolderPad.class), false);
}
}
}
}
@Override
@@ -48,6 +48,8 @@ public class ConfigPlugin implements IPlugIn {
"Export Grid", IPlugInPort.EXPORT_GRID_KEY, false), CONFIG_MENU);
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
"Snap to Grid", IPlugInPort.SNAP_TO_GRID_KEY, true), CONFIG_MENU);
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
"Auto-Create Pads", IPlugInPort.AUTO_PADS_KEY, false), CONFIG_MENU);
File themeDir = new File("themes");
if (themeDir.exists()) {
XStream xStream = new XStream(new DomDriver());
@@ -248,6 +248,10 @@
<changeType>NEW_FEATURE</changeType>
<description>Snap to Grid may be turned off</description>
</com.diyfever.gui.update.Change>
<com.diyfever.gui.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Auto-create solder pads</description>
</com.diyfever.gui.update.Change>
</changes>
<url>http://code.google.com/p/diy-layout-creator/downloads/list
</url>