change layer to double

added solder pad
This commit is contained in:
bancika
2011-01-09 23:10:24 +00:00
parent 7af112a28b
commit 5f860348df
25 changed files with 259 additions and 144 deletions
@@ -2,7 +2,6 @@ package org.diylc.common;
import javax.swing.Icon; import javax.swing.Icon;
import org.diylc.core.ComponentLayer;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
/** /**
@@ -22,13 +21,13 @@ public class ComponentType {
private Icon icon; private Icon icon;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Class<? extends IDIYComponent> instanceClass; private Class<? extends IDIYComponent> instanceClass;
private ComponentLayer layer; private double zOrder;
private boolean stretchable; private boolean stretchable;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public ComponentType(String name, String description, String category, String namePrefix, public ComponentType(String name, String description, String category, String namePrefix,
String author, Icon icon, Class<? extends IDIYComponent> instanceClass, String author, Icon icon, Class<? extends IDIYComponent> instanceClass,
ComponentLayer layer, boolean stretchable) { double zOrder, boolean stretchable) {
super(); super();
this.name = name; this.name = name;
this.description = description; this.description = description;
@@ -37,7 +36,7 @@ public class ComponentType {
this.author = author; this.author = author;
this.icon = icon; this.icon = icon;
this.instanceClass = instanceClass; this.instanceClass = instanceClass;
this.layer = layer; this.zOrder = zOrder;
this.stretchable = stretchable; this.stretchable = stretchable;
} }
@@ -70,8 +69,8 @@ public class ComponentType {
return instanceClass; return instanceClass;
} }
public ComponentLayer getLayer() { public double getZOrder() {
return layer; return zOrder;
} }
public boolean isStretchable() { public boolean isStretchable() {
@@ -14,7 +14,6 @@ import javax.swing.JComponent;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.JPopupMenu.Separator; import javax.swing.JPopupMenu.Separator;
import org.diylc.core.ComponentLayer;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.Project; import org.diylc.core.Project;
@@ -219,37 +218,37 @@ public interface IPlugInPort {
*/ */
void addComponents(List<IDIYComponent<?>> components, Point preferredPoint); void addComponents(List<IDIYComponent<?>> components, Point preferredPoint);
/** // /**
* Checks if a certain layer is locked for editing. // * Checks if a certain layer is locked for editing.
* // *
* @param layer // * @param layer
* @return // * @return
*/ // */
boolean isLayerLocked(ComponentLayer layer); // boolean isLayerLocked(ComponentLayer layer);
//
/** // /**
* Changes layer's locked state. // * Changes layer's locked state.
* // *
* @param layer // * @param layer
* @param locked // * @param locked
*/ // */
void setLayerLocked(ComponentLayer layer, boolean locked); // void setLayerLocked(ComponentLayer layer, boolean locked);
//
/** // /**
* Checks if a certain layer is visible. // * Checks if a certain layer is visible.
* // *
* @param layer // * @param layer
* @return // * @return
*/ // */
boolean isLayerVisible(ComponentLayer layer); // boolean isLayerVisible(ComponentLayer layer);
//
/** // /**
* Changes layer visibility. // * Changes layer visibility.
* // *
* @param layer // * @param layer
* @param visible // * @param visible
*/ // */
void setLayerVisible(ComponentLayer layer, boolean visible); // void setLayerVisible(ComponentLayer layer, boolean visible);
/** /**
* Sets default value for the specified property name for currently selected * Sets default value for the specified property name for currently selected
@@ -0,0 +1,47 @@
package org.diylc.components;
import java.awt.Point;
import org.diylc.core.IDIYComponent;
public abstract class AbstractSinglePointComponent implements IDIYComponent<Void> {
private static final long serialVersionUID = 1L;
protected Point point = new Point(0, 0);
@Override
public int getControlPointCount() {
return 1;
}
@Override
public Point getControlPoint(int index) {
return point;
}
@Override
public void setControlPoint(Point point, int index) {
this.point.setLocation(point);
}
@Override
public String getName() {
return "Pad";
}
@Override
public void setName(String name) {
}
@Deprecated
@Override
public Void getValue() {
return null;
}
@Deprecated
@Override
public void setValue(Void value) {
}
}
@@ -1,11 +0,0 @@
package org.diylc.core;
/**
* Enumerates all drawing layers.
*
* @author Branislav Stojkovic
*/
public enum ComponentLayer {
BELOW_CHASSIS, CHASSIS, ABOVE_CHASSIS, BELOW_BOARD, BOARD, TRACE, COMPONENT, ABOVE_COMPONENT;
}
@@ -30,6 +30,15 @@ import org.diylc.core.annotations.EditableProperty;
*/ */
public interface IDIYComponent<T> extends Serializable { public interface IDIYComponent<T> extends Serializable {
public static final int BELOW_CHASSIS = 1;
public static final int CHASSIS = 2;
public static final int ABOVE_CHASSIS = 3;
public static final int BELOW_BOARD = 4;
public static final int BOARD = 5;
public static final int ABOVE_BOARD = 5;
public static final int COMPONENT = 7;
public static final int ABOVE_COMPONENT = 8;
/** /**
* @return component instance name. * @return component instance name.
*/ */
@@ -3,7 +3,6 @@ package org.diylc.core.annotations;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import org.diylc.core.ComponentLayer;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
/** /**
@@ -16,53 +15,39 @@ import org.diylc.core.IDIYComponent;
public @interface ComponentDescriptor { public @interface ComponentDescriptor {
/** /**
* Component type name. * @return component type name.
*
* @return
*/ */
String name(); String name();
/** /**
* Component type description. * @return component type description.
*
* @return
*/ */
String desciption(); String description();
/** /**
* Component category, e.g. "Passive" or "Semiconductors". * @return component category, e.g. "Passive", "Semiconductors", etc.
*
* @return
*/ */
String category(); String category();
/** /**
* Component author name. * @return component author name.
*
* @return
*/ */
String author(); String author();
/** /**
* Prefix that will be used to generate component instance names, e.g. "R" * @return prefix that will be used to generate component instance names,
* for resistors or "Q" for transistors. * e.g. "R" for resistors or "Q" for transistors.
*
* @return
*/ */
String instanceNamePrefix(); String instanceNamePrefix();
/** /**
* Z-order of the component. * @return Z-order of the component.
*
* @return
*/ */
ComponentLayer componentLayer() default ComponentLayer.COMPONENT; double zOrder();
/** /**
* When false, moving one control point will cause all the others to move * @return when false, moving one control point will cause all the others to
* together with it. * move together with it.
*
* @return
*/ */
boolean stretchable() default true; boolean stretchable() default true;
} }
@@ -16,7 +16,6 @@ import javax.swing.ImageIcon;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.diylc.common.ComponentType; import org.diylc.common.ComponentType;
import org.diylc.common.PropertyWrapper; import org.diylc.common.PropertyWrapper;
import org.diylc.core.ComponentLayer;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
@@ -58,16 +57,16 @@ public class ComponentProcessor {
String namePrefix; String namePrefix;
String author; String author;
Icon icon; Icon icon;
ComponentLayer layer; double zOrder;
boolean stretchable; boolean stretchable;
if (clazz.isAnnotationPresent(ComponentDescriptor.class)) { if (clazz.isAnnotationPresent(ComponentDescriptor.class)) {
ComponentDescriptor annotation = clazz.getAnnotation(ComponentDescriptor.class); ComponentDescriptor annotation = clazz.getAnnotation(ComponentDescriptor.class);
name = annotation.name(); name = annotation.name();
description = annotation.desciption(); description = annotation.description();
category = annotation.category(); category = annotation.category();
namePrefix = annotation.instanceNamePrefix(); namePrefix = annotation.instanceNamePrefix();
author = annotation.author(); author = annotation.author();
layer = annotation.componentLayer(); zOrder = annotation.zOrder();
stretchable = annotation.stretchable(); stretchable = annotation.stretchable();
} else { } else {
name = clazz.getSimpleName(); name = clazz.getSimpleName();
@@ -75,7 +74,7 @@ public class ComponentProcessor {
category = "Uncategorized"; category = "Uncategorized";
namePrefix = "Unknown"; namePrefix = "Unknown";
author = "Unknown"; author = "Unknown";
layer = ComponentLayer.COMPONENT; zOrder = IDIYComponent.COMPONENT;
stretchable = true; stretchable = true;
} }
icon = null; icon = null;
@@ -96,7 +95,7 @@ public class ComponentProcessor {
e.printStackTrace(); e.printStackTrace();
} }
ComponentType componentType = new ComponentType(name, description, category, namePrefix, ComponentType componentType = new ComponentType(name, description, category, namePrefix,
author, icon, clazz, layer, stretchable); author, icon, clazz, zOrder, stretchable);
return componentType; return componentType;
} }
@@ -14,7 +14,6 @@ import java.awt.geom.Point2D;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -33,7 +32,6 @@ import org.diylc.common.EventType;
import org.diylc.common.IPlugIn; import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.common.PropertyWrapper; import org.diylc.common.PropertyWrapper;
import org.diylc.core.ComponentLayer;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.Project; import org.diylc.core.Project;
@@ -88,8 +86,8 @@ public class Presenter implements IPlugInPort {
private MessageDispatcher<EventType> messageDispatcher; private MessageDispatcher<EventType> messageDispatcher;
// Layers // Layers
private Set<ComponentLayer> lockedLayers; // private Set<ComponentLayer> lockedLayers;
private Set<ComponentLayer> visibleLayers; // private Set<ComponentLayer> visibleLayers;
// D&D // D&D
private boolean dragInProgress = false; private boolean dragInProgress = false;
@@ -111,8 +109,8 @@ public class Presenter implements IPlugInPort {
currentProject = new Project(); currentProject = new Project();
cloner = new Cloner(); cloner = new Cloner();
lockedLayers = EnumSet.noneOf(ComponentLayer.class); // lockedLayers = EnumSet.noneOf(ComponentLayer.class);
visibleLayers = EnumSet.allOf(ComponentLayer.class); // visibleLayers = EnumSet.allOf(ComponentLayer.class);
} }
public void installPlugin(IPlugIn plugIn) { public void installPlugin(IPlugIn plugIn) {
@@ -607,31 +605,31 @@ public class Presenter implements IPlugInPort {
messageDispatcher.dispatchMessage(EventType.REPAINT); messageDispatcher.dispatchMessage(EventType.REPAINT);
} }
public boolean isLayerLocked(ComponentLayer layer) { // public boolean isLayerLocked(ComponentLayer layer) {
return lockedLayers.contains(layer); // return lockedLayers.contains(layer);
} // }
//
public void setLayerLocked(ComponentLayer layer, boolean locked) { // public void setLayerLocked(ComponentLayer layer, boolean locked) {
LOG.debug(String.format("setLayerLocked(%s, %s)", layer, locked)); // LOG.debug(String.format("setLayerLocked(%s, %s)", layer, locked));
if (locked) { // if (locked) {
lockedLayers.add(layer); // lockedLayers.add(layer);
} else { // } else {
lockedLayers.remove(layer); // lockedLayers.remove(layer);
} // }
} // }
//
public boolean isLayerVisible(ComponentLayer layer) { // public boolean isLayerVisible(ComponentLayer layer) {
return visibleLayers.contains(layer); // return visibleLayers.contains(layer);
} // }
//
public void setLayerVisible(ComponentLayer layer, boolean visible) { // public void setLayerVisible(ComponentLayer layer, boolean visible) {
LOG.debug(String.format("setLayerVisible(%s, %s)", layer, visible)); // LOG.debug(String.format("setLayerVisible(%s, %s)", layer, visible));
if (visible) { // if (visible) {
visibleLayers.add(layer); // visibleLayers.add(layer);
} else { // } else {
visibleLayers.remove(layer); // visibleLayers.remove(layer);
} // }
} // }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
@@ -690,8 +688,8 @@ public class Presenter implements IPlugInPort {
private void addComponent(IDIYComponent<?> component, ComponentType componentType) { private void addComponent(IDIYComponent<?> component, ComponentType componentType) {
int index = 0; int index = 0;
while (index < currentProject.getComponents().size() while (index < currentProject.getComponents().size()
&& componentType.getLayer().ordinal() >= componentTypeMap.get( && componentType.getZOrder() >= componentTypeMap.get(
currentProject.getComponents().get(index).getClass()).getLayer().ordinal()) { currentProject.getComponents().get(index).getClass()).getZOrder()) {
index++; index++;
} }
if (index < currentProject.getComponents().size()) { if (index < currentProject.getComponents().size()) {
@@ -16,7 +16,7 @@ import org.diylc.core.measures.ResistanceUnit;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Mock", author = "bancika", category = "Sample", instanceNamePrefix = "M", desciption = "test") @ComponentDescriptor(name = "Mock", author = "bancika", category = "Sample", instanceNamePrefix = "M", description = "test", zOrder = IDIYComponent.COMPONENT)
public class MockDIYComponent implements IDIYComponent<Capacitance> { public class MockDIYComponent implements IDIYComponent<Capacitance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -3,10 +3,10 @@ package org.diylc.components.boards;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import org.diylc.core.ComponentLayer; import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
@ComponentDescriptor(name = "Blank Board", category = "Boards", author = "Branislav Stojkovic", componentLayer = ComponentLayer.BOARD, instanceNamePrefix = "B", desciption = "Blank circuit board") @ComponentDescriptor(name = "Blank Board", category = "Boards", author = "Branislav Stojkovic", zOrder = IDIYComponent.BOARD, instanceNamePrefix = "B", description = "Blank circuit board")
public class BlankBoard extends AbstractBoard { public class BlankBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -7,15 +7,15 @@ import java.awt.Composite;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import org.diylc.core.ComponentLayer;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project; import org.diylc.core.Project;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
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.utils.Constants; import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Perf Board w/ Pads", category = "Boards", author = "Branislav Stojkovic", componentLayer = ComponentLayer.BOARD, instanceNamePrefix = "B", desciption = "Perforated FR4 board with solder pads spaced 0.1 inch apart") @ComponentDescriptor(name = "Perf Board w/ Pads", category = "Boards", author = "Branislav Stojkovic", zOrder = IDIYComponent.BOARD, instanceNamePrefix = "B", description = "Perforated FR4 board with solder pads spaced 0.1 inch apart")
public class PerfBoard extends AbstractBoard { public class PerfBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -6,15 +6,15 @@ import java.awt.Composite;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import org.diylc.core.ComponentLayer;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project; import org.diylc.core.Project;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
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.utils.Constants; import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Vero Board", category = "Boards", author = "Branislav Stojkovic", componentLayer = ComponentLayer.BOARD, instanceNamePrefix = "B", desciption = "Perforated FR4 board with copper strips connecting all holes in a row") @ComponentDescriptor(name = "Vero Board", category = "Boards", author = "Branislav Stojkovic", zOrder = IDIYComponent.BOARD, instanceNamePrefix = "B", description = "Perforated FR4 board with copper strips connecting all holes in a row")
public class VeroBoard extends AbstractBoard { public class VeroBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -1,4 +1,4 @@
package org.diylc.components.interconnects; package org.diylc.components.connectivity;
public enum AWG { public enum AWG {
@@ -1,17 +1,19 @@
package org.diylc.components.interconnects; package org.diylc.components.connectivity;
import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Shape; import java.awt.Shape;
import org.diylc.components.AbstractLeadedDIYComponent; import org.diylc.components.AbstractLeadedDIYComponent;
import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Trace", author = "Branislav Stojkovic", category = "Interconnects", instanceNamePrefix = "J", desciption = "Jumper wire") @ComponentDescriptor(name = "Copper Trace", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "J", description = "Jumper wire", zOrder = IDIYComponent.ABOVE_BOARD)
public class Trace extends AbstractLeadedDIYComponent<Void> { public class CopperTrace extends AbstractLeadedDIYComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -23,7 +25,9 @@ public class Trace extends AbstractLeadedDIYComponent<Void> {
@Override @Override
public void drawIcon(Graphics2D g2d, int width, int height) { public void drawIcon(Graphics2D g2d, int width, int height) {
g2d.setStroke(new BasicStroke(3));
g2d.setColor(COLOR);
g2d.drawLine(1, height - 2, width - 2, 1);
} }
@Override @Override
@@ -49,7 +53,7 @@ public class Trace extends AbstractLeadedDIYComponent<Void> {
@Deprecated @Deprecated
public Color getBodyColor() { public Color getBodyColor() {
return super.getBodyColor(); return super.getBodyColor();
}; }
@Deprecated @Deprecated
@Override @Override
@@ -1,4 +1,4 @@
package org.diylc.components.interconnects; package org.diylc.components.connectivity;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.BasicStroke; import java.awt.BasicStroke;
@@ -6,22 +6,25 @@ import java.awt.Color;
import java.awt.Composite; import java.awt.Composite;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.geom.CubicCurve2D;
import java.awt.geom.Path2D; import java.awt.geom.Path2D;
import org.diylc.components.AbstractTransparentComponent; import org.diylc.components.AbstractTransparentComponent;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project; import org.diylc.core.Project;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
import org.diylc.utils.Constants; import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Hookup wire", author = "Branislav Stojkovic", category = "Interconnects", instanceNamePrefix = "W", desciption = "Jumper wire") @ComponentDescriptor(name = "Hookup wire", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "W", description = "Jumper wire", zOrder = IDIYComponent.ABOVE_COMPONENT)
public class HookupWire extends AbstractTransparentComponent<AWG> { public class HookupWire extends AbstractTransparentComponent<AWG> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static Color GUIDELINE_COLOR = Color.blue; public static Color GUIDELINE_COLOR = Color.blue;
public static Color COLOR = Color.green; public static Color COLOR = Color.green;
public static double INSULATION_THICKNESS_PCT = 0.3;
private Point[] controlPoints = new Point[] { private Point[] controlPoints = new Point[] {
new Point(-5 * Constants.GRID, -5 * Constants.GRID), new Point(0, -3 * Constants.GRID), new Point(-5 * Constants.GRID, -5 * Constants.GRID), new Point(0, -3 * Constants.GRID),
@@ -32,7 +35,14 @@ public class HookupWire extends AbstractTransparentComponent<AWG> {
@Override @Override
public void drawIcon(Graphics2D g2d, int width, int height) { public void drawIcon(Graphics2D g2d, int width, int height) {
g2d.setColor(COLOR.darker());
g2d.setStroke(new BasicStroke(3));
CubicCurve2D curve = new CubicCurve2D.Double(1, height - 1, width / 4, height / 3,
3 * width / 4, 2 * height / 3, width - 1, 1);
g2d.draw(curve);
g2d.setColor(COLOR);
g2d.setStroke(new BasicStroke(1));
g2d.draw(curve);
} }
@Override @Override
@@ -48,7 +58,8 @@ public class HookupWire extends AbstractTransparentComponent<AWG> {
g2d.drawLine(controlPoints[2].x, controlPoints[2].y, controlPoints[3].x, g2d.drawLine(controlPoints[2].x, controlPoints[2].y, controlPoints[3].x,
controlPoints[3].y); controlPoints[3].y);
} }
int thickness = (int) (Math.pow(Math.E, -1.12436 - 0.11594 * value.getValue()) * Constants.PIXELS_PER_INCH); int thickness = (int) (Math.pow(Math.E, -1.12436 - 0.11594 * value.getValue())
* Constants.PIXELS_PER_INCH * (1 + 2 * INSULATION_THICKNESS_PCT));
Path2D path = new Path2D.Double(); Path2D path = new Path2D.Double();
path.moveTo(controlPoints[0].x, controlPoints[0].y); path.moveTo(controlPoints[0].x, controlPoints[0].y);
path.curveTo(controlPoints[1].x, controlPoints[1].y, controlPoints[2].x, path.curveTo(controlPoints[1].x, controlPoints[1].y, controlPoints[2].x,
@@ -1,32 +1,35 @@
package org.diylc.components.interconnects; package org.diylc.components.connectivity;
import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Shape; import java.awt.Shape;
import org.diylc.components.AbstractLeadedDIYComponent; import org.diylc.components.AbstractLeadedDIYComponent;
import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
@ComponentDescriptor(name = "Jumper", author = "Branislav Stojkovic", category = "Interconnects", instanceNamePrefix = "J", desciption = "Jumper wire") @ComponentDescriptor(name = "Jumper", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "J", description = "Jumper wire", zOrder = IDIYComponent.ABOVE_BOARD)
public class Jumper extends AbstractLeadedDIYComponent<Void> { public class Jumper extends AbstractLeadedDIYComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override @Override
public void drawIcon(Graphics2D g2d, int width, int height) { public void drawIcon(Graphics2D g2d, int width, int height) {
g2d.setStroke(new BasicStroke(1));
g2d.setColor(LEAD_COLOR);
g2d.drawLine(1, height - 2, width - 2, 1);
} }
@Deprecated @Deprecated
public Color getBodyColor() { public Color getBodyColor() {
return super.getBodyColor(); return super.getBodyColor();
}; }
@Deprecated @Deprecated
@Override @Override
public Color getBorderColor() { public Color getBorderColor() {
// TODO Auto-generated method stub
return super.getBorderColor(); return super.getBorderColor();
} }
@@ -0,0 +1,67 @@
package org.diylc.components.connectivity;
import java.awt.Color;
import java.awt.Graphics2D;
import org.diylc.components.AbstractSinglePointComponent;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic", description = "test", instanceNamePrefix = "", stretchable = false, zOrder = IDIYComponent.ABOVE_BOARD + 0.1)
public class SolderPad extends AbstractSinglePointComponent {
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);
public static Color COLOR = Color.black;
private Size size = SIZE;
private Color color = COLOR;
@Override
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
int diameter = size.convertToPixels();
int holeDiameter = HOLE_SIZE.convertToPixels();
g2d.setColor(color);
g2d.fillOval(point.x - diameter / 2, point.y - diameter / 2, diameter, diameter);
g2d.setColor(Constants.CANVAS_COLOR);
g2d.fillOval(point.x - holeDiameter / 2, point.y - holeDiameter / 2, holeDiameter,
holeDiameter);
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
int diameter = width / 2;
int holeDiameter = 4;
g2d.setColor(COLOR);
g2d.fillOval((width - diameter) / 2, (height - diameter) / 2, diameter, diameter);
g2d.setColor(Constants.CANVAS_COLOR);
g2d.fillOval((width - holeDiameter) / 2, (height - holeDiameter) / 2, holeDiameter,
holeDiameter);
}
@EditableProperty
public Size getSize() {
return size;
}
public void setSize(Size size) {
this.size = size;
}
@EditableProperty
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
}
@@ -9,15 +9,15 @@ import java.awt.Point;
import java.awt.geom.RoundRectangle2D; import java.awt.geom.RoundRectangle2D;
import org.diylc.components.AbstractTransparentComponent; import org.diylc.components.AbstractTransparentComponent;
import org.diylc.core.ComponentLayer;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project; import org.diylc.core.Project;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Mini Toggle Switch", category = "Electromechanical", author = "Branislav Stojkovic", desciption = "", stretchable = false, componentLayer = ComponentLayer.COMPONENT, instanceNamePrefix = "SW") @ComponentDescriptor(name = "Mini Toggle Switch", category = "Electromechanical", author = "Branislav Stojkovic", description = "", stretchable = false, zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "SW")
public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchType> { public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchType> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -6,6 +6,7 @@ import java.awt.Shape;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import org.diylc.components.AbstractLeadedDIYComponent; import org.diylc.components.AbstractLeadedDIYComponent;
import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Capacitance; import org.diylc.core.measures.Capacitance;
@@ -13,7 +14,7 @@ import org.diylc.core.measures.CapacitanceUnit;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Axial Film Capacitor", author = "Branislav Stojkovic", category = "Passive", instanceNamePrefix = "C", desciption = "test") @ComponentDescriptor(name = "Axial Film Capacitor", author = "Branislav Stojkovic", category = "Passive", instanceNamePrefix = "C", description = "test", zOrder = IDIYComponent.COMPONENT)
public class AxialFilmCapacitor extends AbstractLeadedDIYComponent<Capacitance> { public class AxialFilmCapacitor extends AbstractLeadedDIYComponent<Capacitance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -6,6 +6,7 @@ import java.awt.Shape;
import java.awt.geom.Ellipse2D; import java.awt.geom.Ellipse2D;
import org.diylc.components.AbstractLeadedDIYComponent; import org.diylc.components.AbstractLeadedDIYComponent;
import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Capacitance; import org.diylc.core.measures.Capacitance;
@@ -13,7 +14,7 @@ import org.diylc.core.measures.CapacitanceUnit;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Ceramic Capacitor", author = "Branislav Stojkovic", category = "Passive", instanceNamePrefix = "C", desciption = "test") @ComponentDescriptor(name = "Ceramic Capacitor", author = "Branislav Stojkovic", category = "Passive", instanceNamePrefix = "C", description = "test", zOrder = IDIYComponent.COMPONENT)
public class RadialCeramicDiskCapacitor extends AbstractLeadedDIYComponent<Capacitance> { public class RadialCeramicDiskCapacitor extends AbstractLeadedDIYComponent<Capacitance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -6,6 +6,7 @@ import java.awt.Shape;
import java.awt.geom.RoundRectangle2D; import java.awt.geom.RoundRectangle2D;
import org.diylc.components.AbstractLeadedDIYComponent; import org.diylc.components.AbstractLeadedDIYComponent;
import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Capacitance; import org.diylc.core.measures.Capacitance;
@@ -13,7 +14,7 @@ import org.diylc.core.measures.CapacitanceUnit;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Radial Film Capacitor", author = "Branislav Stojkovic", category = "Passive", instanceNamePrefix = "C", desciption = "test") @ComponentDescriptor(name = "Radial Film Capacitor", author = "Branislav Stojkovic", category = "Passive", instanceNamePrefix = "C", description = "test", zOrder = IDIYComponent.COMPONENT)
public class RadialFilmCapacitor extends AbstractLeadedDIYComponent<Capacitance> { public class RadialFilmCapacitor extends AbstractLeadedDIYComponent<Capacitance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -6,6 +6,7 @@ import java.awt.Shape;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import org.diylc.components.AbstractLeadedDIYComponent; import org.diylc.components.AbstractLeadedDIYComponent;
import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Resistance; import org.diylc.core.measures.Resistance;
@@ -13,7 +14,7 @@ import org.diylc.core.measures.ResistanceUnit;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Resistor", author = "Branislav Stojkovic", category = "Passive", instanceNamePrefix = "R", desciption = "test") @ComponentDescriptor(name = "Resistor", author = "Branislav Stojkovic", category = "Passive", instanceNamePrefix = "R", description = "test", zOrder = IDIYComponent.COMPONENT)
public class Resistor extends AbstractLeadedDIYComponent<Resistance> { public class Resistor extends AbstractLeadedDIYComponent<Resistance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -15,6 +15,7 @@ import java.awt.geom.RoundRectangle2D;
import org.diylc.common.Orientation; import org.diylc.common.Orientation;
import org.diylc.components.AbstractTransparentComponent; import org.diylc.components.AbstractTransparentComponent;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project; import org.diylc.core.Project;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
@@ -22,7 +23,7 @@ import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants; import org.diylc.utils.Constants;
@ComponentDescriptor(name = "DIL IC", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "IC", desciption = "test", stretchable = false) @ComponentDescriptor(name = "DIL IC", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "IC", description = "test", stretchable = false, zOrder = IDIYComponent.COMPONENT)
public class DIL_IC extends AbstractTransparentComponent<String> { public class DIL_IC extends AbstractTransparentComponent<String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;