mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
change layer to double
added solder pad
This commit is contained in:
Binary file not shown.
+5
-6
@@ -2,7 +2,6 @@ package org.diylc.common;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
import org.diylc.core.ComponentLayer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
/**
|
||||
@@ -22,13 +21,13 @@ public class ComponentType {
|
||||
private Icon icon;
|
||||
@SuppressWarnings("unchecked")
|
||||
private Class<? extends IDIYComponent> instanceClass;
|
||||
private ComponentLayer layer;
|
||||
private double zOrder;
|
||||
private boolean stretchable;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ComponentType(String name, String description, String category, String namePrefix,
|
||||
String author, Icon icon, Class<? extends IDIYComponent> instanceClass,
|
||||
ComponentLayer layer, boolean stretchable) {
|
||||
double zOrder, boolean stretchable) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
@@ -37,7 +36,7 @@ public class ComponentType {
|
||||
this.author = author;
|
||||
this.icon = icon;
|
||||
this.instanceClass = instanceClass;
|
||||
this.layer = layer;
|
||||
this.zOrder = zOrder;
|
||||
this.stretchable = stretchable;
|
||||
}
|
||||
|
||||
@@ -70,8 +69,8 @@ public class ComponentType {
|
||||
return instanceClass;
|
||||
}
|
||||
|
||||
public ComponentLayer getLayer() {
|
||||
return layer;
|
||||
public double getZOrder() {
|
||||
return zOrder;
|
||||
}
|
||||
|
||||
public boolean isStretchable() {
|
||||
|
||||
+31
-32
@@ -14,7 +14,6 @@ import javax.swing.JComponent;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.JPopupMenu.Separator;
|
||||
|
||||
import org.diylc.core.ComponentLayer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
|
||||
@@ -219,37 +218,37 @@ public interface IPlugInPort {
|
||||
*/
|
||||
void addComponents(List<IDIYComponent<?>> components, Point preferredPoint);
|
||||
|
||||
/**
|
||||
* Checks if a certain layer is locked for editing.
|
||||
*
|
||||
* @param layer
|
||||
* @return
|
||||
*/
|
||||
boolean isLayerLocked(ComponentLayer layer);
|
||||
|
||||
/**
|
||||
* Changes layer's locked state.
|
||||
*
|
||||
* @param layer
|
||||
* @param locked
|
||||
*/
|
||||
void setLayerLocked(ComponentLayer layer, boolean locked);
|
||||
|
||||
/**
|
||||
* Checks if a certain layer is visible.
|
||||
*
|
||||
* @param layer
|
||||
* @return
|
||||
*/
|
||||
boolean isLayerVisible(ComponentLayer layer);
|
||||
|
||||
/**
|
||||
* Changes layer visibility.
|
||||
*
|
||||
* @param layer
|
||||
* @param visible
|
||||
*/
|
||||
void setLayerVisible(ComponentLayer layer, boolean visible);
|
||||
// /**
|
||||
// * Checks if a certain layer is locked for editing.
|
||||
// *
|
||||
// * @param layer
|
||||
// * @return
|
||||
// */
|
||||
// boolean isLayerLocked(ComponentLayer layer);
|
||||
//
|
||||
// /**
|
||||
// * Changes layer's locked state.
|
||||
// *
|
||||
// * @param layer
|
||||
// * @param locked
|
||||
// */
|
||||
// void setLayerLocked(ComponentLayer layer, boolean locked);
|
||||
//
|
||||
// /**
|
||||
// * Checks if a certain layer is visible.
|
||||
// *
|
||||
// * @param layer
|
||||
// * @return
|
||||
// */
|
||||
// boolean isLayerVisible(ComponentLayer layer);
|
||||
//
|
||||
// /**
|
||||
// * Changes layer visibility.
|
||||
// *
|
||||
// * @param layer
|
||||
// * @param visible
|
||||
// */
|
||||
// void setLayerVisible(ComponentLayer layer, boolean visible);
|
||||
|
||||
/**
|
||||
* Sets default value for the specified property name for currently selected
|
||||
|
||||
+47
@@ -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) {
|
||||
}
|
||||
}
|
||||
-11
@@ -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;
|
||||
}
|
||||
+9
@@ -30,6 +30,15 @@ import org.diylc.core.annotations.EditableProperty;
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
||||
+11
-26
@@ -3,7 +3,6 @@ package org.diylc.core.annotations;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import org.diylc.core.ComponentLayer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
/**
|
||||
@@ -16,53 +15,39 @@ import org.diylc.core.IDIYComponent;
|
||||
public @interface ComponentDescriptor {
|
||||
|
||||
/**
|
||||
* Component type name.
|
||||
*
|
||||
* @return
|
||||
* @return component type name.
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Component type description.
|
||||
*
|
||||
* @return
|
||||
* @return component type description.
|
||||
*/
|
||||
String desciption();
|
||||
String description();
|
||||
|
||||
/**
|
||||
* Component category, e.g. "Passive" or "Semiconductors".
|
||||
*
|
||||
* @return
|
||||
* @return component category, e.g. "Passive", "Semiconductors", etc.
|
||||
*/
|
||||
String category();
|
||||
|
||||
/**
|
||||
* Component author name.
|
||||
*
|
||||
* @return
|
||||
* @return component author name.
|
||||
*/
|
||||
String author();
|
||||
|
||||
/**
|
||||
* Prefix that will be used to generate component instance names, e.g. "R"
|
||||
* for resistors or "Q" for transistors.
|
||||
*
|
||||
* @return
|
||||
* @return prefix that will be used to generate component instance names,
|
||||
* e.g. "R" for resistors or "Q" for transistors.
|
||||
*/
|
||||
String instanceNamePrefix();
|
||||
|
||||
/**
|
||||
* Z-order of the component.
|
||||
*
|
||||
* @return
|
||||
* @return Z-order of the component.
|
||||
*/
|
||||
ComponentLayer componentLayer() default ComponentLayer.COMPONENT;
|
||||
double zOrder();
|
||||
|
||||
/**
|
||||
* When false, moving one control point will cause all the others to move
|
||||
* together with it.
|
||||
*
|
||||
* @return
|
||||
* @return when false, moving one control point will cause all the others to
|
||||
* move together with it.
|
||||
*/
|
||||
boolean stretchable() default true;
|
||||
}
|
||||
|
||||
+5
-6
@@ -16,7 +16,6 @@ import javax.swing.ImageIcon;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.ComponentLayer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -58,16 +57,16 @@ public class ComponentProcessor {
|
||||
String namePrefix;
|
||||
String author;
|
||||
Icon icon;
|
||||
ComponentLayer layer;
|
||||
double zOrder;
|
||||
boolean stretchable;
|
||||
if (clazz.isAnnotationPresent(ComponentDescriptor.class)) {
|
||||
ComponentDescriptor annotation = clazz.getAnnotation(ComponentDescriptor.class);
|
||||
name = annotation.name();
|
||||
description = annotation.desciption();
|
||||
description = annotation.description();
|
||||
category = annotation.category();
|
||||
namePrefix = annotation.instanceNamePrefix();
|
||||
author = annotation.author();
|
||||
layer = annotation.componentLayer();
|
||||
zOrder = annotation.zOrder();
|
||||
stretchable = annotation.stretchable();
|
||||
} else {
|
||||
name = clazz.getSimpleName();
|
||||
@@ -75,7 +74,7 @@ public class ComponentProcessor {
|
||||
category = "Uncategorized";
|
||||
namePrefix = "Unknown";
|
||||
author = "Unknown";
|
||||
layer = ComponentLayer.COMPONENT;
|
||||
zOrder = IDIYComponent.COMPONENT;
|
||||
stretchable = true;
|
||||
}
|
||||
icon = null;
|
||||
@@ -96,7 +95,7 @@ public class ComponentProcessor {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ComponentType componentType = new ComponentType(name, description, category, namePrefix,
|
||||
author, icon, clazz, layer, stretchable);
|
||||
author, icon, clazz, zOrder, stretchable);
|
||||
return componentType;
|
||||
}
|
||||
|
||||
|
||||
+31
-33
@@ -14,7 +14,6 @@ import java.awt.geom.Point2D;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -33,7 +32,6 @@ import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.ComponentLayer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
@@ -88,8 +86,8 @@ public class Presenter implements IPlugInPort {
|
||||
private MessageDispatcher<EventType> messageDispatcher;
|
||||
|
||||
// Layers
|
||||
private Set<ComponentLayer> lockedLayers;
|
||||
private Set<ComponentLayer> visibleLayers;
|
||||
// private Set<ComponentLayer> lockedLayers;
|
||||
// private Set<ComponentLayer> visibleLayers;
|
||||
|
||||
// D&D
|
||||
private boolean dragInProgress = false;
|
||||
@@ -111,8 +109,8 @@ public class Presenter implements IPlugInPort {
|
||||
currentProject = new Project();
|
||||
cloner = new Cloner();
|
||||
|
||||
lockedLayers = EnumSet.noneOf(ComponentLayer.class);
|
||||
visibleLayers = EnumSet.allOf(ComponentLayer.class);
|
||||
// lockedLayers = EnumSet.noneOf(ComponentLayer.class);
|
||||
// visibleLayers = EnumSet.allOf(ComponentLayer.class);
|
||||
}
|
||||
|
||||
public void installPlugin(IPlugIn plugIn) {
|
||||
@@ -607,31 +605,31 @@ public class Presenter implements IPlugInPort {
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
|
||||
public boolean isLayerLocked(ComponentLayer layer) {
|
||||
return lockedLayers.contains(layer);
|
||||
}
|
||||
|
||||
public void setLayerLocked(ComponentLayer layer, boolean locked) {
|
||||
LOG.debug(String.format("setLayerLocked(%s, %s)", layer, locked));
|
||||
if (locked) {
|
||||
lockedLayers.add(layer);
|
||||
} else {
|
||||
lockedLayers.remove(layer);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLayerVisible(ComponentLayer layer) {
|
||||
return visibleLayers.contains(layer);
|
||||
}
|
||||
|
||||
public void setLayerVisible(ComponentLayer layer, boolean visible) {
|
||||
LOG.debug(String.format("setLayerVisible(%s, %s)", layer, visible));
|
||||
if (visible) {
|
||||
visibleLayers.add(layer);
|
||||
} else {
|
||||
visibleLayers.remove(layer);
|
||||
}
|
||||
}
|
||||
// public boolean isLayerLocked(ComponentLayer layer) {
|
||||
// return lockedLayers.contains(layer);
|
||||
// }
|
||||
//
|
||||
// public void setLayerLocked(ComponentLayer layer, boolean locked) {
|
||||
// LOG.debug(String.format("setLayerLocked(%s, %s)", layer, locked));
|
||||
// if (locked) {
|
||||
// lockedLayers.add(layer);
|
||||
// } else {
|
||||
// lockedLayers.remove(layer);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public boolean isLayerVisible(ComponentLayer layer) {
|
||||
// return visibleLayers.contains(layer);
|
||||
// }
|
||||
//
|
||||
// public void setLayerVisible(ComponentLayer layer, boolean visible) {
|
||||
// LOG.debug(String.format("setLayerVisible(%s, %s)", layer, visible));
|
||||
// if (visible) {
|
||||
// visibleLayers.add(layer);
|
||||
// } else {
|
||||
// visibleLayers.remove(layer);
|
||||
// }
|
||||
// }
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@@ -690,8 +688,8 @@ public class Presenter implements IPlugInPort {
|
||||
private void addComponent(IDIYComponent<?> component, ComponentType componentType) {
|
||||
int index = 0;
|
||||
while (index < currentProject.getComponents().size()
|
||||
&& componentType.getLayer().ordinal() >= componentTypeMap.get(
|
||||
currentProject.getComponents().get(index).getClass()).getLayer().ordinal()) {
|
||||
&& componentType.getZOrder() >= componentTypeMap.get(
|
||||
currentProject.getComponents().get(index).getClass()).getZOrder()) {
|
||||
index++;
|
||||
}
|
||||
if (index < currentProject.getComponents().size()) {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import org.diylc.core.measures.ResistanceUnit;
|
||||
import org.diylc.core.measures.Size;
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
Binary file not shown.
+2
-2
@@ -3,10 +3,10 @@ package org.diylc.components.boards;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import org.diylc.core.ComponentLayer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+2
-2
@@ -7,15 +7,15 @@ import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.core.ComponentLayer;
|
||||
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.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+2
-2
@@ -6,15 +6,15 @@ import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.core.ComponentLayer;
|
||||
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.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.diylc.components.interconnects;
|
||||
package org.diylc.components.connectivity;
|
||||
|
||||
public enum AWG {
|
||||
|
||||
+9
-5
@@ -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.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
|
||||
import org.diylc.components.AbstractLeadedDIYComponent;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Trace", author = "Branislav Stojkovic", category = "Interconnects", instanceNamePrefix = "J", desciption = "Jumper wire")
|
||||
public class Trace extends AbstractLeadedDIYComponent<Void> {
|
||||
@ComponentDescriptor(name = "Copper Trace", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "J", description = "Jumper wire", zOrder = IDIYComponent.ABOVE_BOARD)
|
||||
public class CopperTrace extends AbstractLeadedDIYComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -23,7 +25,9 @@ public class Trace extends AbstractLeadedDIYComponent<Void> {
|
||||
|
||||
@Override
|
||||
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
|
||||
@@ -49,7 +53,7 @@ public class Trace extends AbstractLeadedDIYComponent<Void> {
|
||||
@Deprecated
|
||||
public Color getBodyColor() {
|
||||
return super.getBodyColor();
|
||||
};
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
+15
-4
@@ -1,4 +1,4 @@
|
||||
package org.diylc.components.interconnects;
|
||||
package org.diylc.components.connectivity;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.BasicStroke;
|
||||
@@ -6,22 +6,25 @@ import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.awt.geom.Path2D;
|
||||
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
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.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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color GUIDELINE_COLOR = Color.blue;
|
||||
public static Color COLOR = Color.green;
|
||||
public static double INSULATION_THICKNESS_PCT = 0.3;
|
||||
|
||||
private Point[] controlPoints = new Point[] {
|
||||
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
|
||||
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
|
||||
@@ -48,7 +58,8 @@ public class HookupWire extends AbstractTransparentComponent<AWG> {
|
||||
g2d.drawLine(controlPoints[2].x, controlPoints[2].y, controlPoints[3].x,
|
||||
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();
|
||||
path.moveTo(controlPoints[0].x, controlPoints[0].y);
|
||||
path.curveTo(controlPoints[1].x, controlPoints[1].y, controlPoints[2].x,
|
||||
+9
-6
@@ -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.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
|
||||
import org.diylc.components.AbstractLeadedDIYComponent;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
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
|
||||
public Color getBodyColor() {
|
||||
return super.getBodyColor();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Color getBorderColor() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getBorderColor();
|
||||
}
|
||||
|
||||
+67
@@ -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;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -9,15 +9,15 @@ import java.awt.Point;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.core.ComponentLayer;
|
||||
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;
|
||||
|
||||
@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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import java.awt.Shape;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.components.AbstractLeadedDIYComponent;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
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.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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import java.awt.Shape;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
|
||||
import org.diylc.components.AbstractLeadedDIYComponent;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
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.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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import java.awt.Shape;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import org.diylc.components.AbstractLeadedDIYComponent;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
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.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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import java.awt.Shape;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.components.AbstractLeadedDIYComponent;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
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.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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@ import java.awt.geom.RoundRectangle2D;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
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;
|
||||
@@ -22,7 +23,7 @@ import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
Reference in New Issue
Block a user