cleanup component area map on loading

fixed lead area mapping bug
This commit is contained in:
bancika
2011-01-31 22:05:05 +00:00
parent 12ca93e2c9
commit b96bad2688
7 changed files with 28 additions and 5 deletions
@@ -1,15 +1,15 @@
<map> <map>
<entry> <entry>
<string>lastPath</string> <string>metric</string>
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop\oldFiles</string> <boolean>true</boolean>
</entry> </entry>
<entry> <entry>
<string>zoom</string> <string>zoom</string>
<double>1.0</double> <double>1.0</double>
</entry> </entry>
<entry> <entry>
<string>metric</string> <string>lastPath</string>
<boolean>true</boolean> <string>C:\Documents and Settings\Branislav Stojkovic\Desktop\oldFiles</string>
</entry> </entry>
<entry> <entry>
<string>showTemplatesAtStartup</string> <string>showTemplatesAtStartup</string>
@@ -63,6 +63,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
IDrawingObserver drawingObserver) { IDrawingObserver drawingObserver) {
double distance = points[0].distance(points[1]); double distance = points[0].distance(points[1]);
Shape shape = getBodyShape(); Shape shape = getBodyShape();
// If there's no body, just draw the line connecting the ending points.
if (shape == null) { if (shape == null) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(getLeadThickness())); g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(getLeadThickness()));
g2d.setColor(shouldShadeLeads() ? getLeadColor(componentState).darker() g2d.setColor(shouldShadeLeads() ? getLeadColor(componentState).darker()
@@ -313,6 +313,10 @@ public class DrawingManager {
public Area getComponentArea(IDIYComponent<?> component) { public Area getComponentArea(IDIYComponent<?> component) {
return componentAreaMap.get(component); return componentAreaMap.get(component);
} }
public void clearComponentAreaMap() {
componentAreaMap.clear();
}
public List<IDIYComponent<?>> findComponentsAt(Point point, Project project) { public List<IDIYComponent<?>> findComponentsAt(Point point, Project project) {
List<IDIYComponent<?>> components = new ArrayList<IDIYComponent<?>>(); List<IDIYComponent<?>> components = new ArrayList<IDIYComponent<?>>();
@@ -179,6 +179,7 @@ class G2DWrapper extends Graphics2D implements IDrawingObserver {
width, thickness); width, thickness);
Area area = new Area(rect); Area area = new Area(rect);
area.transform(AffineTransform.getRotateInstance(theta, midX, midY)); area.transform(AffineTransform.getRotateInstance(theta, midX, midY));
area.transform(currentTx);
appendShape(area); appendShape(area);
// Set the prev point to line end // Set the prev point to line end
prevPoint = nextPoint; prevPoint = nextPoint;
@@ -180,6 +180,7 @@ public class Presenter implements IPlugInPort {
public void loadProject(Project project, boolean freshStart) { public void loadProject(Project project, boolean freshStart) {
LOG.info(String.format("loadProject(%s, %s)", project.getTitle(), freshStart)); LOG.info(String.format("loadProject(%s, %s)", project.getTitle(), freshStart));
this.currentProject = project; this.currentProject = project;
drawingManager.clearComponentAreaMap();
updateSelection(EMPTY_SELECTION); updateSelection(EMPTY_SELECTION);
messageDispatcher.dispatchMessage(EventType.PROJECT_LOADED, project, freshStart); messageDispatcher.dispatchMessage(EventType.PROJECT_LOADED, project, freshStart);
messageDispatcher.dispatchMessage(EventType.REPAINT); messageDispatcher.dispatchMessage(EventType.REPAINT);
@@ -32,6 +32,7 @@ import org.diylc.components.passive.RadialFilmCapacitor;
import org.diylc.components.passive.Resistor; import org.diylc.components.passive.Resistor;
import org.diylc.components.semiconductors.DIL_IC; import org.diylc.components.semiconductors.DIL_IC;
import org.diylc.components.semiconductors.DiodePlastic; import org.diylc.components.semiconductors.DiodePlastic;
import org.diylc.components.semiconductors.LED;
import org.diylc.components.semiconductors.TransistorTO92; import org.diylc.components.semiconductors.TransistorTO92;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.Project; import org.diylc.core.Project;
@@ -302,7 +303,7 @@ public class ProjectFileManager {
} }
String sizeAttr = node.getAttributes().getNamedItem("Size").getNodeValue(); String sizeAttr = node.getAttributes().getNamedItem("Size").getNodeValue();
if (sizeAttr.equalsIgnoreCase("small")) { if (sizeAttr.equalsIgnoreCase("small")) {
capacitor.setLength(new Size(3d, SizeUnit.mm)); capacitor.setLength(new Size(3.5d, SizeUnit.mm));
} else if (sizeAttr.equalsIgnoreCase("medium")) { } else if (sizeAttr.equalsIgnoreCase("medium")) {
capacitor.setLength(new Size(5d, SizeUnit.mm)); capacitor.setLength(new Size(5d, SizeUnit.mm));
} else if (sizeAttr.equalsIgnoreCase("large")) { } else if (sizeAttr.equalsIgnoreCase("large")) {
@@ -327,6 +328,17 @@ public class ProjectFileManager {
capacitor.setControlPoint(point1, 0); capacitor.setControlPoint(point1, 0);
capacitor.setControlPoint(point2, 1); capacitor.setControlPoint(point2, 1);
component = capacitor; component = capacitor;
} else if (nodeName.equalsIgnoreCase("led")) {
LOG.debug("Recognized " + nodeName);
LED led = new LED();
led.setName(nameAttr);
led.setValue(valueAttr);
led.setBodyColor(Color.red);
led.setBorderColor(Color.red.darker());
led.setLength(new Size(3d, SizeUnit.mm));
led.setControlPoint(point1, 0);
led.setControlPoint(point2, 1);
component = led;
} else if (nodeName.equalsIgnoreCase("transistor")) { } else if (nodeName.equalsIgnoreCase("transistor")) {
LOG.debug("Recognized " + nodeName); LOG.debug("Recognized " + nodeName);
TransistorTO92 transistor = new TransistorTO92(); TransistorTO92 transistor = new TransistorTO92();
@@ -151,6 +151,10 @@
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
<description>Copy/paste doesn't work for some components (potentiometer, transistor, etc)</description> <description>Copy/paste doesn't work for some components (potentiometer, transistor, etc)</description>
</com.diyfever.gui.update.Change> </com.diyfever.gui.update.Change>
<com.diyfever.gui.update.Change>
<changeType>BUG_FIX</changeType>
<description>Resistor color codes are sometimes wrong</description>
</com.diyfever.gui.update.Change>
<com.diyfever.gui.update.Change> <com.diyfever.gui.update.Change>
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Resistors can specify power handling</description> <description>Resistors can specify power handling</description>