refactor component transformation

This commit is contained in:
bancika
2017-01-06 15:24:55 +01:00
parent 8a3f017468
commit af39da27aa
64 changed files with 411 additions and 215 deletions
@@ -29,13 +29,13 @@ public class ComponentType {
private boolean stretchable; private boolean stretchable;
private BomPolicy bomPolicy; private BomPolicy bomPolicy;
private boolean autoEdit; private boolean autoEdit;
private boolean rotatable; private IComponentTransformer transformer;
private KeywordPolicy keywordPolicy; private KeywordPolicy keywordPolicy;
private String keywordTag; private String keywordTag;
public ComponentType(String name, String description, CreationMethod creationMethod, String category, public ComponentType(String name, String description, CreationMethod creationMethod, String category,
String namePrefix, String author, Icon icon, Class<? extends IDIYComponent<?>> instanceClass, double zOrder, String namePrefix, String author, Icon icon, Class<? extends IDIYComponent<?>> instanceClass, double zOrder,
boolean flexibleZOrder, boolean stretchable, BomPolicy bomPolicy, boolean autoEdit, boolean rotatable, boolean flexibleZOrder, boolean stretchable, BomPolicy bomPolicy, boolean autoEdit, IComponentTransformer transformer,
KeywordPolicy keywordPolicy, String keywordTag) { KeywordPolicy keywordPolicy, String keywordTag) {
super(); super();
this.name = name; this.name = name;
@@ -51,7 +51,7 @@ public class ComponentType {
this.stretchable = stretchable; this.stretchable = stretchable;
this.bomPolicy = bomPolicy; this.bomPolicy = bomPolicy;
this.autoEdit = autoEdit; this.autoEdit = autoEdit;
this.rotatable = rotatable; this.transformer = transformer;
this.keywordPolicy = keywordPolicy; this.keywordPolicy = keywordPolicy;
this.keywordTag = keywordTag; this.keywordTag = keywordTag;
} }
@@ -108,8 +108,8 @@ public class ComponentType {
return autoEdit; return autoEdit;
} }
public boolean isRotatable() { public IComponentTransformer getTransformer() {
return rotatable; return transformer;
} }
public KeywordPolicy getKeywordPolicy() { public KeywordPolicy getKeywordPolicy() {
@@ -0,0 +1,27 @@
package org.diylc.common;
import java.awt.Point;
import org.diylc.core.IDIYComponent;
public class DefaultTransformer implements IComponentTransformer {
@Override
public boolean canRotate(IDIYComponent<?> component) {
return false;
}
@Override
public boolean canMirror(IDIYComponent<?> component) {
return false;
}
@Override
public void rotate(IDIYComponent<?> component, Point center, int direction) {
}
@Override
public void mirror(IDIYComponent<?> component, Point center, int direction) {
}
}
@@ -0,0 +1,22 @@
package org.diylc.common;
import java.awt.Point;
import org.diylc.core.IDIYComponent;
public interface IComponentTransformer {
public static final int CLOCKWISE = 1;
public static final int COUNTER_CLOCKWISE = 1;
public static final int HORIZONTAL = 0;
public static final int VERTICAL = 1;
boolean canRotate(IDIYComponent<?> component);
boolean canMirror(IDIYComponent<?> component);
void rotate(IDIYComponent<?> component, Point center, int direction);
void mirror(IDIYComponent<?> component, Point center, int direction);
}
@@ -8,12 +8,6 @@ import org.diylc.core.ExpansionMode;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
public interface ISelectionProcessor { public interface ISelectionProcessor {
public static final int CLOCKWISE = 1;
public static final int COUNTER_CLOCKWISE = 1;
public static final int HORIZONTAL = 0;
public static final int VERTICAL = 1;
/** /**
* Returns the current {@link ComponentTransferable}. * Returns the current {@link ComponentTransferable}.
@@ -17,7 +17,7 @@ public interface ITemplateProcessor {
void applyTemplateToSelection(Template template); void applyTemplateToSelection(Template template);
void deleteTemplate(String categoryName, String componentTypeName, String templateName); void deleteTemplate(String categoryName, String componentTypeName, String templateName);
void setTemplateDefault(String categoryName, String componentTypeName, String templateName, boolean defaultFlag); void setTemplateDefault(String categoryName, String componentTypeName, String templateName, boolean defaultFlag);
public class TemplateAlreadyExistsException extends Exception { public class TemplateAlreadyExistsException extends Exception {
@@ -0,0 +1,42 @@
package org.diylc.common;
import java.awt.Point;
import java.awt.geom.AffineTransform;
import org.diylc.core.IDIYComponent;
public class SimpleComponentTransformer implements IComponentTransformer {
@Override
public boolean canRotate(IDIYComponent<?> component) {
return true;
}
@Override
public boolean canMirror(IDIYComponent<?> component) {
return true;
}
@Override
public void rotate(IDIYComponent<?> component, Point center, int direction) {
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.x, center.y);
for (int index = 0; index < component.getControlPointCount(); index++) {
Point p = new Point(component.getControlPoint(index));
rotate.transform(p, p);
component.setControlPoint(p, index);
}
}
@Override
public void mirror(IDIYComponent<?> component, Point center, int direction) {
for (int i = 0; i < component.getControlPointCount(); i++) {
Point p = component.getControlPoint(i);
if (direction == IComponentTransformer.HORIZONTAL) {
component.setControlPoint(new Point(p.x - 2 * (p.x - center.x), p.y), i);
} else {
component.setControlPoint(new Point(p.x, p.y - 2 * (p.y - center.y)), i);
}
}
}
}
@@ -3,6 +3,8 @@ 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.common.DefaultTransformer;
import org.diylc.common.IComponentTransformer;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -77,10 +79,9 @@ public @interface ComponentDescriptor {
boolean autoEdit() default true; boolean autoEdit() default true;
/** /**
* @return true if component may be rotated, false otherwise * @return if the component can be rotated and/or mirrored, returns a class of the transformer that can do it
* @return
*/ */
boolean rotatable() default true; Class<? extends IComponentTransformer> transformer() default DefaultTransformer.class;
/** /**
* Defines if and how a component should appear in auto-generated project keywords. See * Defines if and how a component should appear in auto-generated project keywords. See
@@ -17,6 +17,7 @@ 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.IComponentTransformer;
import org.diylc.common.PropertyWrapper; import org.diylc.common.PropertyWrapper;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -40,6 +41,7 @@ public class ComponentProcessor {
private Map<String, List<PropertyWrapper>> propertyCache; private Map<String, List<PropertyWrapper>> propertyCache;
private Map<String, IPropertyValidator> propertyValidatorCache; private Map<String, IPropertyValidator> propertyValidatorCache;
private Map<String, ComponentType> componentTypeMap; private Map<String, ComponentType> componentTypeMap;
private Map<String, IComponentTransformer> componentTransformerMap;
public static ComponentProcessor getInstance() { public static ComponentProcessor getInstance() {
if (instance == null) { if (instance == null) {
@@ -53,6 +55,7 @@ public class ComponentProcessor {
this.propertyCache = new HashMap<String, List<PropertyWrapper>>(); this.propertyCache = new HashMap<String, List<PropertyWrapper>>();
this.componentTypeMap = new HashMap<String, ComponentType>(); this.componentTypeMap = new HashMap<String, ComponentType>();
this.propertyValidatorCache = new HashMap<String, IPropertyValidator>(); this.propertyValidatorCache = new HashMap<String, IPropertyValidator>();
this.componentTransformerMap = new HashMap<String, IComponentTransformer>();
} }
public ComponentType extractComponentTypeFrom(Class<? extends IDIYComponent<?>> clazz) { public ComponentType extractComponentTypeFrom(Class<? extends IDIYComponent<?>> clazz) {
@@ -71,7 +74,7 @@ public class ComponentProcessor {
boolean stretchable; boolean stretchable;
BomPolicy bomPolicy; BomPolicy bomPolicy;
boolean autoEdit; boolean autoEdit;
boolean rotatable; IComponentTransformer transformer;
KeywordPolicy keywordPolicy; KeywordPolicy keywordPolicy;
String keywordTag; String keywordTag;
if (clazz.isAnnotationPresent(ComponentDescriptor.class)) { if (clazz.isAnnotationPresent(ComponentDescriptor.class)) {
@@ -87,7 +90,7 @@ public class ComponentProcessor {
stretchable = annotation.stretchable(); stretchable = annotation.stretchable();
bomPolicy = annotation.bomPolicy(); bomPolicy = annotation.bomPolicy();
autoEdit = annotation.autoEdit(); autoEdit = annotation.autoEdit();
rotatable = annotation.rotatable(); transformer = getComponentTransformer(annotation.transformer());
keywordPolicy = annotation.keywordPolicy(); keywordPolicy = annotation.keywordPolicy();
keywordTag = annotation.keywordTag(); keywordTag = annotation.keywordTag();
} else { // default } else { // default
@@ -102,7 +105,7 @@ public class ComponentProcessor {
stretchable = true; stretchable = true;
bomPolicy = BomPolicy.SHOW_ALL_NAMES; bomPolicy = BomPolicy.SHOW_ALL_NAMES;
autoEdit = true; autoEdit = true;
rotatable = true; transformer = null;
keywordPolicy = KeywordPolicy.NEVER_SHOW; keywordPolicy = KeywordPolicy.NEVER_SHOW;
keywordTag = null; keywordTag = null;
} }
@@ -124,7 +127,7 @@ public class ComponentProcessor {
} }
ComponentType componentType = ComponentType componentType =
new ComponentType(name, description, creationMethod, category, namePrefix, author, icon, clazz, zOrder, new ComponentType(name, description, creationMethod, category, namePrefix, author, icon, clazz, zOrder,
flexibleZOrder, stretchable, bomPolicy, autoEdit, rotatable, keywordPolicy, keywordTag); flexibleZOrder, stretchable, bomPolicy, autoEdit, transformer, keywordPolicy, keywordTag);
componentTypeMap.put(clazz.getName(), componentType); componentTypeMap.put(clazz.getName(), componentType);
return componentType; return componentType;
} }
@@ -186,14 +189,15 @@ public class ComponentProcessor {
* @param selectedComponents * @param selectedComponents
* @return * @return
*/ */
public List<PropertyWrapper> getMutualSelectionProperties(Collection<IDIYComponent<?>> selectedComponents) throws Exception { public List<PropertyWrapper> getMutualSelectionProperties(Collection<IDIYComponent<?>> selectedComponents)
throws Exception {
if (selectedComponents.isEmpty()) { if (selectedComponents.isEmpty()) {
return null; return null;
} }
List<PropertyWrapper> properties = new ArrayList<PropertyWrapper>(); List<PropertyWrapper> properties = new ArrayList<PropertyWrapper>();
List<IDIYComponent<?>> selectedList = new ArrayList<IDIYComponent<?>>(selectedComponents); List<IDIYComponent<?>> selectedList = new ArrayList<IDIYComponent<?>>(selectedComponents);
IDIYComponent<?> firstComponent = selectedList.get(0); IDIYComponent<?> firstComponent = selectedList.get(0);
properties.addAll(extractProperties(firstComponent.getClass())); properties.addAll(extractProperties(firstComponent.getClass()));
// Initialize values // Initialize values
@@ -242,4 +246,21 @@ public class ComponentProcessor {
propertyValidatorCache.put(clazz.getName(), validator); propertyValidatorCache.put(clazz.getName(), validator);
return validator; return validator;
} }
private IComponentTransformer getComponentTransformer(Class<? extends IComponentTransformer> clazz) {
if (clazz == null)
return null;
if (componentTransformerMap.containsKey(clazz.getName())) {
return componentTransformerMap.get(clazz.getName());
}
IComponentTransformer transformer;
try {
transformer = clazz.newInstance();
} catch (Exception e) {
LOG.error("Could not instantiate validator for " + clazz.getName(), e);
return null;
}
componentTransformerMap.put(clazz.getName(), transformer);
return transformer;
}
} }
@@ -41,7 +41,7 @@ public class InstantiationManager {
private static final ComponentType clipboardType = new ComponentType("Clipboard contents", private static final ComponentType clipboardType = new ComponentType("Clipboard contents",
"Components from the clipboard", CreationMethod.SINGLE_CLICK, "Multi", "", "", null, null, 0, false, false, null, "Components from the clipboard", CreationMethod.SINGLE_CLICK, "Multi", "", "", null, null, 0, false, false, null,
false, true, KeywordPolicy.NEVER_SHOW, null); false, null, KeywordPolicy.NEVER_SHOW, null);
public InstantiationManager() {} public InstantiationManager() {}
@@ -6,7 +6,6 @@ import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.dnd.DnDConstants; import java.awt.dnd.DnDConstants;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area; import java.awt.geom.Area;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
@@ -38,12 +37,10 @@ import org.diylc.common.ComponentType;
import org.diylc.common.DrawOption; import org.diylc.common.DrawOption;
import org.diylc.common.EventType; import org.diylc.common.EventType;
import org.diylc.common.IComponentFiler; import org.diylc.common.IComponentFiler;
import org.diylc.common.IComponentTransformer;
import org.diylc.common.IKeyProcessor; import org.diylc.common.IKeyProcessor;
import org.diylc.common.IPlugIn; import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.common.ISelectionProcessor;
import org.diylc.common.Orientation;
import org.diylc.common.OrientationHV;
import org.diylc.common.PropertyWrapper; import org.diylc.common.PropertyWrapper;
import org.diylc.core.ExpansionMode; import org.diylc.core.ExpansionMode;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -612,10 +609,10 @@ public class Presenter implements IPlugInPort {
rotateComponents(this.selectedComponents, -1, snapToGrid); rotateComponents(this.selectedComponents, -1, snapToGrid);
} else if (key == IKeyProcessor.VK_H) { } else if (key == IKeyProcessor.VK_H) {
oldProject = currentProject.clone(); oldProject = currentProject.clone();
mirrorSelection(ISelectionProcessor.HORIZONTAL); mirrorComponents(this.selectedComponents, IComponentTransformer.HORIZONTAL, snapToGrid);
} else if (key == IKeyProcessor.VK_V) { } else if (key == IKeyProcessor.VK_V) {
oldProject = currentProject.clone(); oldProject = currentProject.clone();
mirrorSelection(ISelectionProcessor.VERTICAL); mirrorComponents(this.selectedComponents, IComponentTransformer.VERTICAL, snapToGrid);
} else } else
return false; return false;
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(), messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(),
@@ -1082,105 +1079,100 @@ public class Presenter implements IPlugInPort {
private void rotateComponents(Collection<IDIYComponent<?>> components, int direction, boolean snapToGrid) { private void rotateComponents(Collection<IDIYComponent<?>> components, int direction, boolean snapToGrid) {
Point center = getCenterOf(components, snapToGrid); Point center = getCenterOf(components, snapToGrid);
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.x, center.y); boolean canRotate = true;
for (IDIYComponent<?> component : selectedComponents) {
// Update all points to new location.
for (IDIYComponent<?> component : components) {
drawingManager.invalidateComponent(component);
ComponentType type = ComponentType type =
ComponentProcessor.getInstance().extractComponentTypeFrom( ComponentProcessor.getInstance().extractComponentTypeFrom(
(Class<? extends IDIYComponent<?>>) component.getClass()); (Class<? extends IDIYComponent<?>>) component.getClass());
if (type.isRotatable()) { if (type.getTransformer() == null || !type.getTransformer().canRotate(component)) {
for (int index = 0; index < component.getControlPointCount(); index++) { canRotate = false;
Point p = new Point(component.getControlPoint(index)); break;
rotate.transform(p, p);
component.setControlPoint(p, index);
}
// If component has orientation, change it too
List<PropertyWrapper> newProperties = ComponentProcessor.getInstance().extractProperties(component.getClass());
for (PropertyWrapper property : newProperties) {
if (property.getType() == Orientation.class) {
try {
property.readFrom(component);
Orientation orientation = (Orientation) property.getValue();
Orientation[] values = Orientation.values();
int newIndex = orientation.ordinal() + direction;
if (newIndex < 0)
newIndex = values.length - 1;
else if (newIndex >= values.length)
newIndex = 0;
property.setValue(values[newIndex]);
property.writeTo(component);
} catch (Exception e) {
LOG.error("Could not change component orientation for " + component.getName(), e);
}
} else if (property.getType() == OrientationHV.class) {
try {
property.readFrom(component);
OrientationHV orientation = (OrientationHV) property.getValue();
property.setValue(OrientationHV.values()[1 - orientation.ordinal()]);
property.writeTo(component);
} catch (Exception e) {
LOG.error("Could not change component orientation for " + component.getName(), e);
}
}
}
} else {
// Non-rotatable
Point componentCenter = getCenterOf(Arrays.asList(new IDIYComponent<?>[] {component}), false);
Point rotatedComponentCenter = new Point();
rotate.transform(componentCenter, rotatedComponentCenter);
for (int index = 0; index < component.getControlPointCount(); index++) {
Point p = new Point(component.getControlPoint(index));
p.translate(rotatedComponentCenter.x - componentCenter.x, rotatedComponentCenter.y - componentCenter.y);
component.setControlPoint(p, index);
}
} }
} }
if (!canRotate)
if (view.showConfirmDialog("Selection contains components that cannot be rotated. Do you want to exclude them?",
"Mirror Selection", IView.YES_NO_OPTION, IView.QUESTION_MESSAGE) != IView.YES_OPTION)
return;
for (IDIYComponent<?> component : selectedComponents) {
ComponentType type =
ComponentProcessor.getInstance().extractComponentTypeFrom(
(Class<? extends IDIYComponent<?>>) component.getClass());
if (type.getTransformer() != null && type.getTransformer().canRotate(component)) {
drawingManager.invalidateComponent(component);
type.getTransformer().rotate(component, center, direction);
}
}
// AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.x,
// center.y);
//
// // Update all points to new location.
// for (IDIYComponent<?> component : components) {
// drawingManager.invalidateComponent(component);
// ComponentType type =
// ComponentProcessor.getInstance().extractComponentTypeFrom(
// (Class<? extends IDIYComponent<?>>) component.getClass());
// if (type.isRotatable()) {
// for (int index = 0; index < component.getControlPointCount(); index++) {
// Point p = new Point(component.getControlPoint(index));
// rotate.transform(p, p);
// component.setControlPoint(p, index);
// }
// // If component has orientation, change it too
// List<PropertyWrapper> newProperties =
// ComponentProcessor.getInstance().extractProperties(component.getClass());
// for (PropertyWrapper property : newProperties) {
// if (property.getType() == Orientation.class) {
// try {
// property.readFrom(component);
// Orientation orientation = (Orientation) property.getValue();
// Orientation[] values = Orientation.values();
// int newIndex = orientation.ordinal() + direction;
// if (newIndex < 0)
// newIndex = values.length - 1;
// else if (newIndex >= values.length)
// newIndex = 0;
// property.setValue(values[newIndex]);
// property.writeTo(component);
// } catch (Exception e) {
// LOG.error("Could not change component orientation for " + component.getName(), e);
// }
// } else if (property.getType() == OrientationHV.class) {
// try {
// property.readFrom(component);
// OrientationHV orientation = (OrientationHV) property.getValue();
// property.setValue(OrientationHV.values()[1 - orientation.ordinal()]);
// property.writeTo(component);
// } catch (Exception e) {
// LOG.error("Could not change component orientation for " + component.getName(), e);
// }
// }
// }
// } else {
// // Non-rotatable
// Point componentCenter = getCenterOf(Arrays.asList(new IDIYComponent<?>[] {component}),
// false);
// Point rotatedComponentCenter = new Point();
// rotate.transform(componentCenter, rotatedComponentCenter);
// for (int index = 0; index < component.getControlPointCount(); index++) {
// Point p = new Point(component.getControlPoint(index));
// p.translate(rotatedComponentCenter.x - componentCenter.x, rotatedComponentCenter.y -
// componentCenter.y);
// component.setControlPoint(p, index);
// }
// }
// }
} }
@SuppressWarnings("unchecked")
@Override @Override
public void mirrorSelection(int direction) { public void mirrorSelection(int direction) {
if (!selectedComponents.isEmpty()) { if (!selectedComponents.isEmpty()) {
LOG.trace("Mirroring selected components"); LOG.trace("Mirroring selected components");
Project oldProject = currentProject.clone(); Project oldProject = currentProject.clone();
Point center = getCenterOf(selectedComponents, isSnapToGrid()); mirrorComponents(selectedComponents, direction, isSnapToGrid());
boolean canMirror = true;
for (IDIYComponent<?> component : selectedComponents) {
ComponentType type =
ComponentProcessor.getInstance().extractComponentTypeFrom(
(Class<? extends IDIYComponent<?>>) component.getClass());
if (!type.isStretchable() && component.getControlPointCount() > 1) {
canMirror = false;
break;
}
}
if (!canMirror)
if (view.showConfirmDialog(
"Selection contains components that cannot bi mirrored. Do you want to exclude them?", "Mirror Selection",
IView.YES_NO_OPTION, IView.QUESTION_MESSAGE) != IView.YES_OPTION)
return;
for (IDIYComponent<?> component : selectedComponents) {
ComponentType type =
ComponentProcessor.getInstance().extractComponentTypeFrom(
(Class<? extends IDIYComponent<?>>) component.getClass());
if (type.isStretchable() || component.getControlPointCount() == 1) {
drawingManager.invalidateComponent(component);
for (int i = 0; i < component.getControlPointCount(); i++) {
Point p = component.getControlPoint(i);
if (direction == ISelectionProcessor.HORIZONTAL) {
component.setControlPoint(new Point(p.x - 2 * (p.x - center.x), p.y), i);
} else {
component.setControlPoint(new Point(p.x, p.y - 2 * (p.y - center.y)), i);
}
}
}
}
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(), messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(),
"Mirror Selection"); "Mirror Selection");
@@ -1188,6 +1180,39 @@ public class Presenter implements IPlugInPort {
} }
} }
@SuppressWarnings("unchecked")
private void mirrorComponents(Collection<IDIYComponent<?>> components, int direction, boolean snapToGrid) {
Point center = getCenterOf(components, snapToGrid);
boolean canMirror = true;
for (IDIYComponent<?> component : components) {
ComponentType type =
ComponentProcessor.getInstance().extractComponentTypeFrom(
(Class<? extends IDIYComponent<?>>) component.getClass());
if (type.getTransformer() == null || !type.getTransformer().canMirror(component)) {
canMirror = false;
break;
}
}
if (!canMirror)
if (view.showConfirmDialog("Selection contains components that cannot be mirrored. Do you want to exclude them?",
"Mirror Selection", IView.YES_NO_OPTION, IView.QUESTION_MESSAGE) != IView.YES_OPTION)
return;
for (IDIYComponent<?> component : components) {
ComponentType type =
ComponentProcessor.getInstance().extractComponentTypeFrom(
(Class<? extends IDIYComponent<?>>) component.getClass());
if (type.isStretchable() || component.getControlPointCount() == 1) {
drawingManager.invalidateComponent(component);
if (type.getTransformer() != null && type.getTransformer().canMirror(component)) {
type.getTransformer().mirror(component, center, direction);
}
}
}
}
private Point getCenterOf(Collection<IDIYComponent<?>> components, boolean snapToGrid) { private Point getCenterOf(Collection<IDIYComponent<?>> components, boolean snapToGrid) {
// Determine center of rotation // Determine center of rotation
int minX = Integer.MAX_VALUE; int minX = Integer.MAX_VALUE;
Binary file not shown.
@@ -2,12 +2,27 @@ package org.diylc.components;
import java.awt.geom.GeneralPath; import java.awt.geom.GeneralPath;
/***
*
* Creates a {@link GeneralPath} with rounded edges. To create a rounded path, follow these steps:
*
* <ul>
* <li>instantiate a {@link RoundedPath}</li>
* <li>place a starting point using {@link RoundedPath#moveTo(double, double)}</li>
* <li>create a polygon using a series of {@link RoundedPath#lineTo(double, double)} calls</li>
* <li>call {@link RoundedPath#getPath()} to get a rounded path</li>
* </ul>
*
* Note that the starting point shouldn't lie on a corner of the polygon if you want that corner to
* get rounded too. Instead, place the starting/ending point on one of the polygon sides.
*
* @author bancika
*/
public class RoundedPath { public class RoundedPath {
private GeneralPath path; private GeneralPath path;
private double prevX = Double.NaN; boolean isFirst = true;
private double prevY = Double.NaN;
private double x = Double.NaN; private double x = Double.NaN;
private double y = Double.NaN; private double y = Double.NaN;
@@ -22,26 +37,24 @@ public class RoundedPath {
path.moveTo(x, y); path.moveTo(x, y);
this.x = x; this.x = x;
this.y = y; this.y = y;
this.prevX = Double.NaN; isFirst = true;
this.prevY = Double.NaN;
} }
public final void lineTo(double x, double y) { public final void lineTo(double x, double y) {
if (Double.isNaN(prevX)) { if (isFirst) {
double theta = Math.atan2(y - this.y, x - this.x); double theta = Math.atan2(y - this.y, x - this.x);
double r = Math.sqrt((y - this.y) * (y - this.y) + (x - this.x) * (x - this.x)); double r = Math.sqrt((y - this.y) * (y - this.y) + (x - this.x) * (x - this.x));
path.lineTo(this.x + Math.cos(theta) * (r - radius), this.y + Math.sin(theta) * (r - radius)); path.lineTo(this.x + Math.cos(theta) * (r - radius), this.y + Math.sin(theta) * (r - radius));
} else { } else {
double theta = Math.atan2(y - this.y, x - this.x); double theta = Math.atan2(y - this.y, x - this.x);
path.curveTo(this.x, this.y, this.x, this.y, this.x + Math.cos(theta) * radius, this.y + Math.sin(theta) * radius); path.curveTo(this.x, this.y, this.x, this.y, this.x + Math.cos(theta) * radius, this.y + Math.sin(theta) * radius);
} }
this.prevX = this.x; isFirst = false;
this.prevY = this.y;
this.x = x; this.x = x;
this.y = y; this.y = y;
} }
public GeneralPath getPath() { public GeneralPath getPath() {
return path; return path;
} }
@@ -3,6 +3,7 @@ package org.diylc.components.boards;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Shape; import java.awt.Shape;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver; import org.diylc.core.IDrawingObserver;
@@ -12,7 +13,7 @@ import org.diylc.core.annotations.ComponentDescriptor;
@ComponentDescriptor(name = "Blank Board", category = "Boards", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Blank Board", category = "Boards", author = "Branislav Stojkovic",
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", description = "Blank circuit board", zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", description = "Blank circuit board",
bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false) bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, transformer = SimpleComponentTransformer.class)
public class BlankBoard extends AbstractBoard { public class BlankBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -6,6 +6,7 @@ import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.Shape; import java.awt.Shape;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver; import org.diylc.core.IDrawingObserver;
@@ -20,7 +21,8 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Eyelet Board", category = "Boards", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Eyelet Board", category = "Boards", author = "Branislav Stojkovic",
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", description = "Perforated board with eyelets", zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", description = "Perforated board with eyelets",
bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME) bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME,
transformer = SimpleComponentTransformer.class)
public class EyeletBoard extends AbstractBoard { public class EyeletBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -6,6 +6,7 @@ import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.Shape; import java.awt.Shape;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver; import org.diylc.core.IDrawingObserver;
@@ -22,7 +23,7 @@ import org.diylc.utils.Constants;
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board",
description = "Perforated board as found on some Marshall and Trainwreck amps", description = "Perforated board as found on some Marshall and Trainwreck amps",
bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG,
keywordTag = "Perf Board") keywordTag = "Perf Board", transformer = SimpleComponentTransformer.class)
public class MarshallPerfBoard extends AbstractBoard { public class MarshallPerfBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -6,6 +6,7 @@ import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.Shape; import java.awt.Shape;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver; import org.diylc.core.IDrawingObserver;
@@ -21,7 +22,7 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Perf Board w/ Pads", category = "Boards", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Perf Board w/ Pads", category = "Boards", author = "Branislav Stojkovic",
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", description = "Perforated board with solder pads", zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", description = "Perforated board with solder pads",
bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG,
keywordTag = "Perf Board") keywordTag = "Perf Board", transformer = SimpleComponentTransformer.class)
public class PerfBoard extends AbstractBoard { public class PerfBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -7,6 +7,7 @@ import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.Shape; import java.awt.Shape;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.common.OrientationHV; import org.diylc.common.OrientationHV;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -22,11 +23,11 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "TriPad Board", category = "Boards", author = "Hauke Juhls", zOrder = IDIYComponent.BOARD, @ComponentDescriptor(name = "TriPad Board", category = "Boards", author = "Hauke Juhls", zOrder = IDIYComponent.BOARD,
instanceNamePrefix = "Board", instanceNamePrefix = "Board",
description = "Perforated FR4 board with copper strips connecting 3 holes in a row (aka TriPad Board)", description = "Perforated FR4 board with copper strips connecting 3 holes in a row (aka TriPad Board)",
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME) keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = SimpleComponentTransformer.class)
public class TriPadBoard extends AbstractBoard { public class TriPadBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static Color BORDER_COLOR = BOARD_COLOR.darker(); public static Color BORDER_COLOR = BOARD_COLOR.darker();
public static Size SPACING = new Size(0.1d, SizeUnit.in); public static Size SPACING = new Size(0.1d, SizeUnit.in);
@@ -131,7 +132,7 @@ public class TriPadBoard extends AbstractBoard {
} }
} }
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
super.drawCoordinates(g2d, spacing); super.drawCoordinates(g2d, spacing);
} }
} }
@@ -7,6 +7,7 @@ import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.Shape; import java.awt.Shape;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.common.OrientationHV; import org.diylc.common.OrientationHV;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -23,7 +24,8 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Vero Board", category = "Boards", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Vero Board", category = "Boards", author = "Branislav Stojkovic",
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board",
description = "Perforated FR4 board with copper strips connecting all holes in a row", description = "Perforated FR4 board with copper strips connecting all holes in a row",
bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME) bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME,
transformer = SimpleComponentTransformer.class)
public class VeroBoard extends AbstractBoard { public class VeroBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -131,16 +133,16 @@ public class VeroBoard extends AbstractBoard {
g2d.drawRect(0, 2 / factor, width - 1, height - 4 / factor); g2d.drawRect(0, 2 / factor, width - 1, height - 4 / factor);
g2d.setColor(COPPER_COLOR); g2d.setColor(COPPER_COLOR);
g2d.fillRect(1 / factor, width / 4, width - 2 / factor, width / 2); g2d.fillRect(1 / factor, width / 4, width - 2 / factor, width / 2);
g2d.setColor(COPPER_COLOR.darker()); g2d.setColor(COPPER_COLOR.darker());
g2d.drawRect(1 / factor, width / 4, width - 2 / factor, width / 2); g2d.drawRect(1 / factor, width / 4, width - 2 / factor, width / 2);
g2d.setColor(COPPER_COLOR); g2d.setColor(COPPER_COLOR);
g2d.fillRect(1 / factor, 2 / factor, width - 2 / factor, 3 / factor); g2d.fillRect(1 / factor, 2 / factor, width - 2 / factor, 3 / factor);
g2d.fillRect(1 / factor, height - 5 / factor, width - 2 / factor, 3 / factor); g2d.fillRect(1 / factor, height - 5 / factor, width - 2 / factor, 3 / factor);
g2d.setColor(COPPER_COLOR.darker()); g2d.setColor(COPPER_COLOR.darker());
g2d.drawRect(1 / factor, 2 / factor, width - 2 / factor, 3 / factor); g2d.drawRect(1 / factor, 2 / factor, width - 2 / factor, 3 / factor);
g2d.drawRect(1 / factor, height - 5 / factor, width - 2 / factor, 3 / factor); g2d.drawRect(1 / factor, height - 5 / factor, width - 2 / factor, 3 / factor);
g2d.setColor(Constants.CANVAS_COLOR); g2d.setColor(Constants.CANVAS_COLOR);
g2d.fillOval(width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor), g2d.fillOval(width / 3 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
getClosestOdd(5.0 / factor)); getClosestOdd(5.0 / factor));
@@ -4,6 +4,7 @@ import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Shape; import java.awt.Shape;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.PCBLayer; import org.diylc.common.PCBLayer;
import org.diylc.components.AbstractLeadedComponent; import org.diylc.components.AbstractLeadedComponent;
@@ -21,7 +22,7 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Copper Trace", author = "Branislav Stojkovic", category = "Connectivity", @ComponentDescriptor(name = "Copper Trace", author = "Branislav Stojkovic", category = "Connectivity",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "Trace", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "Trace",
description = "Straight copper trace", zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW, description = "Straight copper trace", zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW,
autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB") autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class)
public class CopperTrace extends AbstractLeadedComponent<Void> { public class CopperTrace extends AbstractLeadedComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -4,6 +4,7 @@ import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.geom.CubicCurve2D; import java.awt.geom.CubicCurve2D;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.PCBLayer; import org.diylc.common.PCBLayer;
import org.diylc.components.AbstractCurvedComponent; import org.diylc.components.AbstractCurvedComponent;
@@ -19,7 +20,7 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Curved Trace", author = "Branislav Stojkovic", category = "Connectivity", @ComponentDescriptor(name = "Curved Trace", author = "Branislav Stojkovic", category = "Connectivity",
instanceNamePrefix = "Trace", description = "Curved copper trace with two control points", instanceNamePrefix = "Trace", description = "Curved copper trace with two control points",
zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB") keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class)
public class CurvedTrace extends AbstractCurvedComponent<Void> { public class CurvedTrace extends AbstractCurvedComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -4,6 +4,7 @@ import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractComponent; import org.diylc.components.AbstractComponent;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -18,7 +19,7 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Dot", category = "Connectivity", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Dot", category = "Connectivity", author = "Branislav Stojkovic",
description = "Connector dot", instanceNamePrefix = "Dot", stretchable = false, zOrder = IDIYComponent.COMPONENT, description = "Connector dot", instanceNamePrefix = "Dot", stretchable = false, zOrder = IDIYComponent.COMPONENT,
bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false) bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
public class Dot extends AbstractComponent<Void> { public class Dot extends AbstractComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -4,6 +4,7 @@ import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractComponent; import org.diylc.components.AbstractComponent;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -21,7 +22,7 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Eyelet", category = "Connectivity", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Eyelet", category = "Connectivity", author = "Branislav Stojkovic",
description = "Eyelet or turret terminal", instanceNamePrefix = "Eyelet", stretchable = false, description = "Eyelet or turret terminal", instanceNamePrefix = "Eyelet", stretchable = false,
zOrder = IDIYComponent.TRACE + 0.1, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, zOrder = IDIYComponent.TRACE + 0.1, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME) keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = SimpleComponentTransformer.class)
public class Eyelet extends AbstractComponent<String> { public class Eyelet extends AbstractComponent<String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -7,6 +7,7 @@ import java.util.Arrays;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.PCBLayer; import org.diylc.common.PCBLayer;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractComponent; import org.diylc.components.AbstractComponent;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -21,7 +22,7 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Ground Fill", author = "Branislav Stojkovic", category = "Connectivity", @ComponentDescriptor(name = "Ground Fill", author = "Branislav Stojkovic", category = "Connectivity",
instanceNamePrefix = "GF", description = "Polygonal ground fill area", zOrder = IDIYComponent.TRACE, instanceNamePrefix = "GF", description = "Polygonal ground fill area", zOrder = IDIYComponent.TRACE,
bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false) bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
public class GroundFill extends AbstractComponent<Void> { public class GroundFill extends AbstractComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -5,6 +5,7 @@ import java.awt.Graphics2D;
import java.awt.geom.CubicCurve2D; import java.awt.geom.CubicCurve2D;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractCurvedComponent; import org.diylc.components.AbstractCurvedComponent;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -15,7 +16,7 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Hookup Wire", author = "Branislav Stojkovic", category = "Connectivity", @ComponentDescriptor(name = "Hookup Wire", author = "Branislav Stojkovic", category = "Connectivity",
instanceNamePrefix = "W", description = "Flexible wire with two control points", zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "W", description = "Flexible wire with two control points", zOrder = IDIYComponent.COMPONENT,
bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false) bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, transformer = SimpleComponentTransformer.class)
public class HookupWire extends AbstractCurvedComponent<Void> { public class HookupWire extends AbstractCurvedComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -6,6 +6,7 @@ import java.awt.Shape;
import org.diylc.common.Display; import org.diylc.common.Display;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractLeadedComponent; import org.diylc.components.AbstractLeadedComponent;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
@@ -17,7 +18,8 @@ import org.diylc.core.measures.Size;
@ComponentDescriptor(name = "Jumper", author = "Branislav Stojkovic", category = "Connectivity", @ComponentDescriptor(name = "Jumper", author = "Branislav Stojkovic", category = "Connectivity",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "J", description = "", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "J", description = "",
zOrder = IDIYComponent.COMPONENT, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false) zOrder = IDIYComponent.COMPONENT, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
transformer = SimpleComponentTransformer.class)
public class Jumper extends AbstractLeadedComponent<Void> { public class Jumper extends AbstractLeadedComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -6,6 +6,7 @@ import java.awt.Shape;
import org.diylc.common.Display; import org.diylc.common.Display;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractLeadedComponent; import org.diylc.components.AbstractLeadedComponent;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
@@ -19,7 +20,8 @@ import org.diylc.core.measures.Size;
@ComponentDescriptor(name = "Line", author = "Branislav Stojkovic", category = "Shapes", @ComponentDescriptor(name = "Line", author = "Branislav Stojkovic", category = "Shapes",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "LN", description = "", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "LN", description = "",
zOrder = IDIYComponent.COMPONENT, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false) zOrder = IDIYComponent.COMPONENT, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
transformer = SimpleComponentTransformer.class)
public class Line extends AbstractLeadedComponent<Void> { public class Line extends AbstractLeadedComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -5,6 +5,7 @@ import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import org.diylc.common.PCBLayer; import org.diylc.common.PCBLayer;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractComponent; import org.diylc.components.AbstractComponent;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -23,7 +24,7 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic",
description = "Copper solder pad, round or square", instanceNamePrefix = "Pad", stretchable = false, description = "Copper solder pad, round or square", instanceNamePrefix = "Pad", stretchable = false,
zOrder = IDIYComponent.TRACE + 0.1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false, zOrder = IDIYComponent.TRACE + 0.1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB") keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class)
public class SolderPad extends AbstractComponent<Void> { public class SolderPad extends AbstractComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -4,6 +4,7 @@ import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractComponent; import org.diylc.components.AbstractComponent;
import org.diylc.components.boards.AbstractBoard; import org.diylc.components.boards.AbstractBoard;
import org.diylc.components.boards.VeroBoard; import org.diylc.components.boards.VeroBoard;
@@ -21,7 +22,8 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Trace Cut", category = "Connectivity", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Trace Cut", category = "Connectivity", author = "Branislav Stojkovic",
description = "Designates the place where a trace on the vero board needs to be cut", instanceNamePrefix = "Cut", description = "Designates the place where a trace on the vero board needs to be cut", instanceNamePrefix = "Cut",
stretchable = false, zOrder = IDIYComponent.BOARD + 1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false) stretchable = false, zOrder = IDIYComponent.BOARD + 1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
transformer = SimpleComponentTransformer.class)
public class TraceCut extends AbstractComponent<Void> { public class TraceCut extends AbstractComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -30,7 +30,7 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Plastic DC Jack", category = "Electromechanical", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Plastic DC Jack", category = "Electromechanical", author = "Branislav Stojkovic",
description = "Panel mount plastic DC jack", stretchable = false, zOrder = IDIYComponent.COMPONENT, description = "Panel mount plastic DC jack", stretchable = false, zOrder = IDIYComponent.COMPONENT,
instanceNamePrefix = "J", autoEdit = false, rotatable = false) instanceNamePrefix = "J", autoEdit = false)
public class PlasticDCJack extends AbstractTransparentComponent<String> { public class PlasticDCJack extends AbstractTransparentComponent<String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -8,6 +8,7 @@ import java.awt.geom.Rectangle2D;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractLeadedComponent; import org.diylc.components.AbstractLeadedComponent;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -22,7 +23,8 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Electrolytic Capacitor (axial)", author = "Branislav Stojkovic", category = "Passive", @ComponentDescriptor(name = "Electrolytic Capacitor (axial)", author = "Branislav Stojkovic", category = "Passive",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C",
description = "Axial electrolytic capacitor, similar to Sprague Atom, F&T, etc", zOrder = IDIYComponent.COMPONENT) description = "Axial electrolytic capacitor, similar to Sprague Atom, F&T, etc", zOrder = IDIYComponent.COMPONENT,
transformer = SimpleComponentTransformer.class)
public class AxialElectrolyticCapacitor extends AbstractLeadedComponent<Capacitance> { public class AxialElectrolyticCapacitor extends AbstractLeadedComponent<Capacitance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -5,6 +5,7 @@ import java.awt.Graphics2D;
import java.awt.Shape; import java.awt.Shape;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractLeadedComponent; import org.diylc.components.AbstractLeadedComponent;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -17,7 +18,8 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Film Capacitor (axial)", author = "Branislav Stojkovic", category = "Passive", @ComponentDescriptor(name = "Film Capacitor (axial)", author = "Branislav Stojkovic", category = "Passive",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C",
description = "Axial film capacitor, similar to Mallory 150s", zOrder = IDIYComponent.COMPONENT) description = "Axial film capacitor, similar to Mallory 150s", zOrder = IDIYComponent.COMPONENT,
transformer = SimpleComponentTransformer.class)
public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> { public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
import java.awt.Shape; import java.awt.Shape;
import java.awt.geom.GeneralPath; import java.awt.geom.GeneralPath;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractSchematicLeadedSymbol; import org.diylc.components.AbstractSchematicLeadedSymbol;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -18,7 +19,7 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Capacitor (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "Capacitor (symbol)", author = "Branislav Stojkovic", category = "Schematics",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C",
description = "Capacitor schematic symbol with an optional polarity sign", zOrder = IDIYComponent.COMPONENT, description = "Capacitor schematic symbol with an optional polarity sign", zOrder = IDIYComponent.COMPONENT,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic") keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic", transformer = SimpleComponentTransformer.class)
public class CapacitorSymbol extends AbstractSchematicLeadedSymbol<Capacitance> { public class CapacitorSymbol extends AbstractSchematicLeadedSymbol<Capacitance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
import java.awt.Shape; import java.awt.Shape;
import java.awt.geom.GeneralPath; import java.awt.geom.GeneralPath;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractSchematicLeadedSymbol; import org.diylc.components.AbstractSchematicLeadedSymbol;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -20,7 +21,7 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Inductor (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "Inductor (symbol)", author = "Branislav Stojkovic", category = "Schematics",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "L", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "L",
description = "Inductor schematic symbol", zOrder = IDIYComponent.COMPONENT, description = "Inductor schematic symbol", zOrder = IDIYComponent.COMPONENT,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic") keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic", transformer = SimpleComponentTransformer.class)
public class InductorSymbol extends AbstractSchematicLeadedSymbol<Inductance> { public class InductorSymbol extends AbstractSchematicLeadedSymbol<Inductance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -16,8 +16,7 @@ import org.diylc.components.semiconductors.SymbolFlipping;
@ComponentDescriptor(name = "Potentiometer (symbol)", author = "MCbx", category = "Schematics", @ComponentDescriptor(name = "Potentiometer (symbol)", author = "MCbx", category = "Schematics",
instanceNamePrefix = "VR", description = "Potentiometer symbol", stretchable = false, instanceNamePrefix = "VR", description = "Potentiometer symbol", stretchable = false,
zOrder = IDIYComponent.COMPONENT, rotatable = true, keywordPolicy = KeywordPolicy.SHOW_TAG, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic")
keywordTag = "Schematic")
public class PotentiometerSymbol extends Abstract3LegSymbol { public class PotentiometerSymbol extends Abstract3LegSymbol {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -5,6 +5,7 @@ import java.awt.Graphics2D;
import java.awt.Shape; import java.awt.Shape;
import java.awt.geom.Ellipse2D; import java.awt.geom.Ellipse2D;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractRadialComponent; import org.diylc.components.AbstractRadialComponent;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -17,7 +18,8 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Ceramic Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive", @ComponentDescriptor(name = "Ceramic Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C",
description = "Standard radial ceramic capacitor", zOrder = IDIYComponent.COMPONENT) description = "Standard radial ceramic capacitor", zOrder = IDIYComponent.COMPONENT,
transformer = SimpleComponentTransformer.class)
public class RadialCeramicDiskCapacitor extends AbstractRadialComponent<Capacitance> { public class RadialCeramicDiskCapacitor extends AbstractRadialComponent<Capacitance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -11,6 +11,7 @@ import java.awt.geom.RoundRectangle2D;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractRadialComponent; import org.diylc.components.AbstractRadialComponent;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -25,7 +26,8 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Electrolytic Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive", @ComponentDescriptor(name = "Electrolytic Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C",
description = "Vertical mounted electrolytic capacitor, polarized or bipolar", zOrder = IDIYComponent.COMPONENT) description = "Vertical mounted electrolytic capacitor, polarized or bipolar", zOrder = IDIYComponent.COMPONENT,
transformer = SimpleComponentTransformer.class)
public class RadialElectrolytic extends AbstractRadialComponent<Capacitance> { public class RadialElectrolytic extends AbstractRadialComponent<Capacitance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -5,6 +5,7 @@ import java.awt.Graphics2D;
import java.awt.Shape; import java.awt.Shape;
import java.awt.geom.RoundRectangle2D; import java.awt.geom.RoundRectangle2D;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractRadialComponent; import org.diylc.components.AbstractRadialComponent;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -17,7 +18,8 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Film Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive", @ComponentDescriptor(name = "Film Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C",
description = "Radial film capacitor, similar to Sprague Orange Drop", zOrder = IDIYComponent.COMPONENT) description = "Radial film capacitor, similar to Sprague Orange Drop", zOrder = IDIYComponent.COMPONENT,
transformer = SimpleComponentTransformer.class)
public class RadialFilmCapacitor extends AbstractRadialComponent<Capacitance> { public class RadialFilmCapacitor extends AbstractRadialComponent<Capacitance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -7,6 +7,7 @@ import java.awt.geom.Rectangle2D;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.ResistorColorCode; import org.diylc.common.ResistorColorCode;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractLeadedComponent; import org.diylc.components.AbstractLeadedComponent;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -19,7 +20,7 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Resistor", author = "Branislav Stojkovic", category = "Passive", @ComponentDescriptor(name = "Resistor", author = "Branislav Stojkovic", category = "Passive",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "R", description = "Resistor layout symbol", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "R", description = "Resistor layout symbol",
zOrder = IDIYComponent.COMPONENT) zOrder = IDIYComponent.COMPONENT, transformer = SimpleComponentTransformer.class)
public class Resistor extends AbstractLeadedComponent<Resistance> { public class Resistor extends AbstractLeadedComponent<Resistance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
import java.awt.Shape; import java.awt.Shape;
import java.awt.geom.GeneralPath; import java.awt.geom.GeneralPath;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractSchematicLeadedSymbol; import org.diylc.components.AbstractSchematicLeadedSymbol;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -18,7 +19,7 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Resistor (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "Resistor (symbol)", author = "Branislav Stojkovic", category = "Schematics",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "R", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "R",
description = "Resistor schematic symbol", zOrder = IDIYComponent.COMPONENT, description = "Resistor schematic symbol", zOrder = IDIYComponent.COMPONENT,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic") keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic", transformer = SimpleComponentTransformer.class)
public class ResistorSymbol extends AbstractSchematicLeadedSymbol<Resistance> { public class ResistorSymbol extends AbstractSchematicLeadedSymbol<Resistance> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -30,7 +30,7 @@ import org.diylc.utils.Constants;
category = "Schematics", category = "Schematics",
instanceNamePrefix = "L", instanceNamePrefix = "L",
description = "Transformer coil symbol. Use multiple instances together with \"Transformer Core Symbol\"<br>to draw transformer schematics.", description = "Transformer coil symbol. Use multiple instances together with \"Transformer Core Symbol\"<br>to draw transformer schematics.",
stretchable = false, zOrder = IDIYComponent.COMPONENT, rotatable = true, keywordPolicy = KeywordPolicy.SHOW_TAG, stretchable = false, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG,
keywordTag = "Schematic") keywordTag = "Schematic")
public class TransformerCoil extends AbstractComponent<org.diylc.core.measures.Voltage> { public class TransformerCoil extends AbstractComponent<org.diylc.core.measures.Voltage> {
@@ -226,19 +226,21 @@ public class TransformerCoil extends AbstractComponent<org.diylc.core.measures.V
GeneralPath coil = new GeneralPath(); GeneralPath coil = new GeneralPath();
int coilsPerTap = (int) Math.round(4 * tapSpacing.convertToPixels() / TAP_SPACING.convertToPixels()); int coilsPerTap = (int) Math.round(4 * tapSpacing.convertToPixels() / TAP_SPACING.convertToPixels());
double offset = OFFSET.convertToPixels(); double offset = OFFSET.convertToPixels();
int i = 0; int i = 0;
leads.moveTo(this.controlPoints[i].x, this.controlPoints[i].y); leads.moveTo(this.controlPoints[i].x, this.controlPoints[i].y);
leads.lineTo(this.controlPoints[i].x + fx * (spacing + offset), this.controlPoints[i].y + fy * (spacing + offset)); leads
.lineTo(this.controlPoints[i].x + fx * (spacing + offset), this.controlPoints[i].y + fy * (spacing + offset));
leads.moveTo(this.controlPoints[i + 1].x, this.controlPoints[i + 1].y); leads.moveTo(this.controlPoints[i + 1].x, this.controlPoints[i + 1].y);
leads.lineTo(this.controlPoints[i + 1].x + fx * (spacing + offset), this.controlPoints[i + 1].y + fy * (spacing + offset)); leads.lineTo(this.controlPoints[i + 1].x + fx * (spacing + offset), this.controlPoints[i + 1].y + fy
* (spacing + offset));
double dx = this.controlPoints[i + 1].getX() - this.controlPoints[i].getX(); double dx = this.controlPoints[i + 1].getX() - this.controlPoints[i].getX();
double dy = this.controlPoints[i + 1].getY() - this.controlPoints[i].getY(); double dy = this.controlPoints[i + 1].getY() - this.controlPoints[i].getY();
double d = Math.max(Math.abs(dx), Math.abs(dy)) / coilsPerTap; double d = Math.max(Math.abs(dx), Math.abs(dy)) / coilsPerTap;
double x1 = this.controlPoints[i].getX() + fx * (spacing + d + offset); double x1 = this.controlPoints[i].getX() + fx * (spacing + d + offset);
double y1 = this.controlPoints[i].getY() + fy * (spacing + d + offset); double y1 = this.controlPoints[i].getY() + fy * (spacing + d + offset);
double x2 = this.controlPoints[i + 1].getX() + fx * (spacing + d + offset); double x2 = this.controlPoints[i + 1].getX() + fx * (spacing + d + offset);
@@ -246,16 +248,13 @@ public class TransformerCoil extends AbstractComponent<org.diylc.core.measures.V
double dxa = x2 - x1; double dxa = x2 - x1;
double dya = y2 - y1; double dya = y2 - y1;
coil.moveTo(this.controlPoints[i].getX() + fx * (spacing + offset), this.controlPoints[i].getY() + fy * (spacing + offset)); coil.moveTo(this.controlPoints[i].getX() + fx * (spacing + offset), this.controlPoints[i].getY() + fy
* (spacing + offset));
for (int j = 0; j < coilsPerTap; j++) { for (int j = 0; j < coilsPerTap; j++) {
coil.curveTo( coil.curveTo(x1 + dxa / coilsPerTap * j, y1 + dya / coilsPerTap * j, x1 + dxa / coilsPerTap * (j + 1), y1 + dya
x1 + dxa / coilsPerTap * j, / coilsPerTap * (j + 1), this.controlPoints[i].getX() + fx * (spacing + offset) + dx / coilsPerTap
y1 + dya / coilsPerTap * j, * (j + 1), this.controlPoints[i].getY() + fy * (spacing + offset) + dy / coilsPerTap * (j + 1));
x1 + dxa / coilsPerTap * (j + 1),
y1 + dya / coilsPerTap * (j + 1),
this.controlPoints[i].getX() + fx * (spacing + offset) + dx / coilsPerTap * (j + 1),
this.controlPoints[i].getY() + fy * (spacing + offset) + dy / coilsPerTap * (j + 1));
} }
body = new Shape[2]; body = new Shape[2];
@@ -29,7 +29,7 @@ import org.diylc.utils.Constants;
category = "Schematics", category = "Schematics",
instanceNamePrefix = "T", instanceNamePrefix = "T",
description = "Transformer core symbol. Use multiple instances together with \"Transformer Coil Symbol\"<br>to draw transformer schematics.", description = "Transformer core symbol. Use multiple instances together with \"Transformer Coil Symbol\"<br>to draw transformer schematics.",
stretchable = true, zOrder = IDIYComponent.COMPONENT, rotatable = true, keywordPolicy = KeywordPolicy.SHOW_TAG, stretchable = true, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG,
creationMethod = CreationMethod.POINT_BY_POINT, keywordTag = "Schematic") creationMethod = CreationMethod.POINT_BY_POINT, keywordTag = "Schematic")
public class TransformerCore extends AbstractComponent<Void> { public class TransformerCore extends AbstractComponent<Void> {
@@ -99,7 +99,8 @@ public class TransformerCore extends AbstractComponent<Void> {
} }
double theta = double theta =
Math.atan2(this.controlPoints[1].y - this.controlPoints[0].y, this.controlPoints[1].x - this.controlPoints[0].x) + Math.PI / 2; Math.atan2(this.controlPoints[1].y - this.controlPoints[0].y, this.controlPoints[1].x - this.controlPoints[0].x)
+ Math.PI / 2;
double spacing = SPACING.convertToPixels(); double spacing = SPACING.convertToPixels();
// System.out.println(theta); // System.out.println(theta);
@@ -16,8 +16,7 @@ import org.diylc.core.annotations.KeywordPolicy;
@ComponentDescriptor(name = "BJT (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "BJT (symbol)", author = "Branislav Stojkovic", category = "Schematics",
instanceNamePrefix = "Q", description = "Bipolar junction transistor schematic symbol", stretchable = false, instanceNamePrefix = "Q", description = "Bipolar junction transistor schematic symbol", stretchable = false,
zOrder = IDIYComponent.COMPONENT, rotatable = true, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
keywordTag = "Schematic")
public class BJTSymbol extends Abstract3LegSymbol { public class BJTSymbol extends Abstract3LegSymbol {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -7,6 +7,7 @@ import java.awt.geom.Rectangle2D;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractLeadedComponent; import org.diylc.components.AbstractLeadedComponent;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -19,7 +20,8 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Diode (glass)", author = "Branislav Stojkovic", category = "Semiconductors", @ComponentDescriptor(name = "Diode (glass)", author = "Branislav Stojkovic", category = "Semiconductors",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D",
description = "Glass diode, like most small signal diodes.", zOrder = IDIYComponent.COMPONENT) description = "Glass diode, like most small signal diodes.", zOrder = IDIYComponent.COMPONENT,
transformer = SimpleComponentTransformer.class)
public class DiodeGlass extends AbstractLeadedComponent<String> { public class DiodeGlass extends AbstractLeadedComponent<String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -112,7 +114,7 @@ public class DiodeGlass extends AbstractLeadedComponent<String> {
int length = getClosestOdd(getLength().convertToPixels()); int length = getClosestOdd(getLength().convertToPixels());
// draw the inside // draw the inside
if (!outlineMode) { if (!outlineMode) {
g2d.setColor(getInsideColor()); g2d.setColor(getInsideColor());
int width = getClosestOdd(getWidth().convertToPixels()); int width = getClosestOdd(getWidth().convertToPixels());
int insideLength = getClosestOdd(length - 0.2 * width); int insideLength = getClosestOdd(length - 0.2 * width);
int insideWidth = getClosestOdd(width * 0.8); int insideWidth = getClosestOdd(width * 0.8);
@@ -7,6 +7,7 @@ import java.awt.geom.Rectangle2D;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractLeadedComponent; import org.diylc.components.AbstractLeadedComponent;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -19,7 +20,8 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Diode (plastic)", author = "Branislav Stojkovic", category = "Semiconductors", @ComponentDescriptor(name = "Diode (plastic)", author = "Branislav Stojkovic", category = "Semiconductors",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D",
description = "Plastic diode, like most rectifier, zener, schottky, etc.", zOrder = IDIYComponent.COMPONENT) description = "Plastic diode, like most rectifier, zener, schottky, etc.", zOrder = IDIYComponent.COMPONENT,
transformer = SimpleComponentTransformer.class)
public class DiodePlastic extends AbstractLeadedComponent<String> { public class DiodePlastic extends AbstractLeadedComponent<String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
import java.awt.Polygon; import java.awt.Polygon;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
@@ -13,7 +14,8 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Diode (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "Diode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "Diode schematic symbol", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "Diode schematic symbol",
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic") zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic",
transformer = SimpleComponentTransformer.class)
public class DiodeSymbol extends AbstractDiodeSymbol { public class DiodeSymbol extends AbstractDiodeSymbol {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -33,8 +33,7 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "IC (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "IC (symbol)", author = "Branislav Stojkovic", category = "Schematics",
instanceNamePrefix = "IC", description = "IC symbol with 3 or 5 contacts", stretchable = false, instanceNamePrefix = "IC", description = "IC symbol with 3 or 5 contacts", stretchable = false,
zOrder = IDIYComponent.COMPONENT, rotatable = false, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
keywordTag = "Schematic")
public class ICSymbol extends AbstractTransparentComponent<String> { public class ICSymbol extends AbstractTransparentComponent<String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -14,8 +14,7 @@ import org.diylc.core.annotations.KeywordPolicy;
@ComponentDescriptor(name = "JFET (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "JFET (symbol)", author = "Branislav Stojkovic", category = "Schematics",
instanceNamePrefix = "Q", description = "JFET transistor schematic symbol", stretchable = false, instanceNamePrefix = "Q", description = "JFET transistor schematic symbol", stretchable = false,
zOrder = IDIYComponent.COMPONENT, rotatable = true, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
keywordTag = "Schematic")
public class JFETSymbol extends Abstract3LegSymbol { public class JFETSymbol extends Abstract3LegSymbol {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -8,6 +8,7 @@ import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.AbstractLeadedComponent; import org.diylc.components.AbstractLeadedComponent;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
@@ -18,7 +19,7 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "LED", author = "Branislav Stojkovic", category = "Semiconductors", @ComponentDescriptor(name = "LED", author = "Branislav Stojkovic", category = "Semiconductors",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "Light Emitting Diode", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "Light Emitting Diode",
zOrder = IDIYComponent.COMPONENT) zOrder = IDIYComponent.COMPONENT, transformer = SimpleComponentTransformer.class)
public class LED extends AbstractLeadedComponent<String> { public class LED extends AbstractLeadedComponent<String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -5,6 +5,7 @@ import java.awt.Polygon;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
@@ -12,7 +13,8 @@ import org.diylc.core.annotations.KeywordPolicy;
@ComponentDescriptor(name = "LED (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "LED (symbol)", author = "Branislav Stojkovic", category = "Schematics",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "Diode schematic symbol", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", description = "Diode schematic symbol",
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic") zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic",
transformer = SimpleComponentTransformer.class)
public class LEDSymbol extends DiodeSymbol { public class LEDSymbol extends DiodeSymbol {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -14,8 +14,7 @@ import org.diylc.core.annotations.KeywordPolicy;
@ComponentDescriptor(name = "MOSFET (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "MOSFET (symbol)", author = "Branislav Stojkovic", category = "Schematics",
instanceNamePrefix = "Q", description = "MOSFET transistor schematic symbol", stretchable = false, instanceNamePrefix = "Q", description = "MOSFET transistor schematic symbol", stretchable = false,
zOrder = IDIYComponent.COMPONENT, rotatable = true, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
keywordTag = "Schematic")
public class MOSFETSymbol extends Abstract3LegSymbol { public class MOSFETSymbol extends Abstract3LegSymbol {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
import java.awt.Polygon; import java.awt.Polygon;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
@@ -11,10 +12,10 @@ import org.diylc.core.annotations.KeywordPolicy;
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 = "Schottky Siode (symbol)", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Schottky Siode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
category = "Schematics", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D",
description = "Schottky diode schematic symbol", zOrder = IDIYComponent.COMPONENT, description = "Schottky diode schematic symbol", zOrder = IDIYComponent.COMPONENT,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic") keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic", transformer = SimpleComponentTransformer.class)
public class SchottkyDiodeSymbol extends AbstractDiodeSymbol { public class SchottkyDiodeSymbol extends AbstractDiodeSymbol {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
import java.awt.Polygon; import java.awt.Polygon;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
@@ -14,7 +15,7 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Zener Diode (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "Zener Diode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D",
description = "Zener diode schematic symbol", zOrder = IDIYComponent.COMPONENT, description = "Zener diode schematic symbol", zOrder = IDIYComponent.COMPONENT,
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic") keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic", transformer = SimpleComponentTransformer.class)
public class ZenerDiodeSymbol extends AbstractDiodeSymbol { public class ZenerDiodeSymbol extends AbstractDiodeSymbol {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -5,6 +5,7 @@ import java.awt.Composite;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver; import org.diylc.core.IDrawingObserver;
@@ -14,7 +15,7 @@ import org.diylc.core.annotations.ComponentDescriptor;
@ComponentDescriptor(name = "Ellipse", author = "Branislav Stojkovic", category = "Shapes", instanceNamePrefix = "ELL", @ComponentDescriptor(name = "Ellipse", author = "Branislav Stojkovic", category = "Shapes", instanceNamePrefix = "ELL",
description = "Elliptical area", zOrder = IDIYComponent.COMPONENT, flexibleZOrder = true, description = "Elliptical area", zOrder = IDIYComponent.COMPONENT, flexibleZOrder = true,
bomPolicy = BomPolicy.SHOW_ALL_NAMES, autoEdit = false) bomPolicy = BomPolicy.SHOW_ALL_NAMES, autoEdit = false, transformer = SimpleComponentTransformer.class)
public class Ellipse extends AbstractShape { public class Ellipse extends AbstractShape {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -8,6 +8,7 @@ import java.awt.Point;
import java.util.Arrays; import java.util.Arrays;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver; import org.diylc.core.IDrawingObserver;
@@ -18,7 +19,8 @@ import org.diylc.core.annotations.EditableProperty;
@ComponentDescriptor(name = "Polygon", author = "Branislav Stojkovic", category = "Shapes", @ComponentDescriptor(name = "Polygon", author = "Branislav Stojkovic", category = "Shapes",
instanceNamePrefix = "POLY", description = "Polygonal area", zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "POLY", description = "Polygonal area", zOrder = IDIYComponent.COMPONENT,
flexibleZOrder = true, bomPolicy = BomPolicy.SHOW_ALL_NAMES, autoEdit = false) flexibleZOrder = true, bomPolicy = BomPolicy.SHOW_ALL_NAMES, autoEdit = false,
transformer = SimpleComponentTransformer.class)
public class Polygon extends AbstractShape { public class Polygon extends AbstractShape {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -5,6 +5,7 @@ import java.awt.Composite;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver; import org.diylc.core.IDrawingObserver;
@@ -17,7 +18,8 @@ import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Rectangle", author = "Branislav Stojkovic", category = "Shapes", @ComponentDescriptor(name = "Rectangle", author = "Branislav Stojkovic", category = "Shapes",
instanceNamePrefix = "RECT", description = "Ractangular area, with or withouth rounded edges", instanceNamePrefix = "RECT", description = "Ractangular area, with or withouth rounded edges",
zOrder = IDIYComponent.COMPONENT, flexibleZOrder = true, bomPolicy = BomPolicy.SHOW_ALL_NAMES, autoEdit = false) zOrder = IDIYComponent.COMPONENT, flexibleZOrder = true, bomPolicy = BomPolicy.SHOW_ALL_NAMES, autoEdit = false,
transformer = SimpleComponentTransformer.class)
public class Rectangle extends AbstractShape { public class Rectangle extends AbstractShape {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -17,17 +17,17 @@ import org.diylc.core.annotations.KeywordPolicy;
@ComponentDescriptor(name = "Diode (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "Diode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
instanceNamePrefix = "V", description = "Diode tube symbol", stretchable = false, zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "V", description = "Diode tube symbol", stretchable = false, zOrder = IDIYComponent.COMPONENT,
rotatable = false, keywordPolicy = KeywordPolicy.SHOW_VALUE) keywordPolicy = KeywordPolicy.SHOW_VALUE)
public class DiodeSymbol extends AbstractTubeSymbol { public class DiodeSymbol extends AbstractTubeSymbol {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
protected boolean directlyHeated = false; protected boolean directlyHeated = false;
public DiodeSymbol() { public DiodeSymbol() {
super(); super();
this.controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0), this.controlPoints =
new Point(0, 0)}; new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)};
updateControlPoints(); updateControlPoints();
} }
@@ -16,7 +16,7 @@ import org.diylc.core.annotations.KeywordPolicy;
@ComponentDescriptor(name = "Pentode (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "Pentode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
instanceNamePrefix = "V", description = "Pentode tube symbol", stretchable = false, instanceNamePrefix = "V", description = "Pentode tube symbol", stretchable = false,
zOrder = IDIYComponent.COMPONENT, rotatable = false, keywordPolicy = KeywordPolicy.SHOW_VALUE) zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
public class PentodeSymbol extends AbstractTubeSymbol { public class PentodeSymbol extends AbstractTubeSymbol {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -25,8 +25,9 @@ public class PentodeSymbol extends AbstractTubeSymbol {
public PentodeSymbol() { public PentodeSymbol() {
super(); super();
this.controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0), this.controlPoints =
new Point(0, 0), new Point(0, 0), new Point(0, 0)}; new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0),
new Point(0, 0), new Point(0, 0)};
updateControlPoints(); updateControlPoints();
} }
@@ -103,8 +104,9 @@ public class PentodeSymbol extends AbstractTubeSymbol {
polyline.lineTo(x + pinSpacing * 5, y - pinSpacing * 5 / 4); polyline.lineTo(x + pinSpacing * 5, y - pinSpacing * 5 / 4);
polyline.curveTo(x + pinSpacing * 21 / 4, y - pinSpacing * 5 / 4, x + pinSpacing * 21 / 4, y - pinSpacing * 3 polyline.curveTo(x + pinSpacing * 21 / 4, y - pinSpacing * 5 / 4, x + pinSpacing * 21 / 4, y - pinSpacing * 3
/ 4, x + pinSpacing * 5, y - pinSpacing * 3 / 4); / 4, x + pinSpacing * 5, y - pinSpacing * 3 / 4);
polyline.moveTo(x + pinSpacing * 5, y - pinSpacing * 3 / 4); polyline.moveTo(x + pinSpacing * 5, y - pinSpacing * 3 / 4);
polyline.curveTo(x + pinSpacing * 5, y + pinSpacing * 3 / 8, x + pinSpacing * 5, y + pinSpacing * 3 / 8, x + pinSpacing * 4, y + pinSpacing * 3 / 8); polyline.curveTo(x + pinSpacing * 5, y + pinSpacing * 3 / 8, x + pinSpacing * 5, y + pinSpacing * 3 / 8, x
+ pinSpacing * 4, y + pinSpacing * 3 / 8);
} }
// plate // plate
@@ -205,7 +207,7 @@ public class PentodeSymbol extends AbstractTubeSymbol {
public void setExposeSuppressorGrid(boolean exposeSuppressorGrid) { public void setExposeSuppressorGrid(boolean exposeSuppressorGrid) {
this.exposeSuppressorGrid = exposeSuppressorGrid; this.exposeSuppressorGrid = exposeSuppressorGrid;
refreshDrawing(); refreshDrawing();
} }
} }
@@ -16,7 +16,7 @@ import org.diylc.core.annotations.KeywordPolicy;
@ComponentDescriptor(name = "Triode (symbol)", author = "Branislav Stojkovic", category = "Schematics", @ComponentDescriptor(name = "Triode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
instanceNamePrefix = "V", description = "Triode tube symbol", stretchable = false, instanceNamePrefix = "V", description = "Triode tube symbol", stretchable = false,
zOrder = IDIYComponent.COMPONENT, rotatable = false, keywordPolicy = KeywordPolicy.SHOW_VALUE) zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
public class TriodeSymbol extends AbstractTubeSymbol { public class TriodeSymbol extends AbstractTubeSymbol {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -25,8 +25,8 @@ public class TriodeSymbol extends AbstractTubeSymbol {
public TriodeSymbol() { public TriodeSymbol() {
super(); super();
this.controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0), this.controlPoints =
new Point(0, 0)}; new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)};
updateControlPoints(); updateControlPoints();
} }
@@ -729,6 +729,7 @@ public class V1FileParser implements IOldFileParser {
private long randSeed = 0; private long randSeed = 0;
@SuppressWarnings("unused")
private int randInt(int range) { private int randInt(int range) {
long newSeed = randSeed * 0x08088405 + 1; long newSeed = randSeed * 0x08088405 + 1;
randSeed = newSeed; randSeed = newSeed;
Binary file not shown.
Binary file not shown.
@@ -17,6 +17,7 @@ import javax.swing.KeyStroke;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IComponentTransformer;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.common.ISelectionProcessor; import org.diylc.common.ISelectionProcessor;
import org.diylc.common.ITask; import org.diylc.common.ITask;
@@ -938,7 +939,7 @@ public class ActionFactory {
super(); super();
this.plugInPort = plugInPort; this.plugInPort = plugInPort;
this.direction = direction; this.direction = direction;
if (direction == ISelectionProcessor.HORIZONTAL) { if (direction == IComponentTransformer.HORIZONTAL) {
putValue(AbstractAction.NAME, "Mirror Horizontally"); putValue(AbstractAction.NAME, "Mirror Horizontally");
putValue(AbstractAction.SMALL_ICON, IconLoader.FlipHorizontal.getIcon()); putValue(AbstractAction.SMALL_ICON, IconLoader.FlipHorizontal.getIcon());
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK)); putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK));
@@ -30,6 +30,7 @@ import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.appframework.miscutils.IConfigListener; import org.diylc.appframework.miscutils.IConfigListener;
import org.diylc.common.BadPositionException; import org.diylc.common.BadPositionException;
import org.diylc.common.EventType; import org.diylc.common.EventType;
import org.diylc.common.IComponentTransformer;
import org.diylc.common.IPlugIn; import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.common.ISelectionProcessor; import org.diylc.common.ISelectionProcessor;
@@ -409,7 +410,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
public ActionFactory.MirrorSelectionAction getMirrorHorizontallyAction() { public ActionFactory.MirrorSelectionAction getMirrorHorizontallyAction() {
if (mirrorHorizontallyAction == null) { if (mirrorHorizontallyAction == null) {
mirrorHorizontallyAction = mirrorHorizontallyAction =
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, ISelectionProcessor.HORIZONTAL); ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, IComponentTransformer.HORIZONTAL);
} }
return mirrorHorizontallyAction; return mirrorHorizontallyAction;
} }
@@ -417,7 +418,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
public ActionFactory.MirrorSelectionAction getMirrorVerticallyAction() { public ActionFactory.MirrorSelectionAction getMirrorVerticallyAction() {
if (mirrorVerticallyAction == null) { if (mirrorVerticallyAction == null) {
mirrorVerticallyAction = mirrorVerticallyAction =
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, ISelectionProcessor.VERTICAL); ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, IComponentTransformer.VERTICAL);
} }
return mirrorVerticallyAction; return mirrorVerticallyAction;
} }
@@ -11,9 +11,9 @@ import java.util.EnumSet;
import org.diylc.appframework.undo.IUndoListener; import org.diylc.appframework.undo.IUndoListener;
import org.diylc.appframework.undo.UndoHandler; import org.diylc.appframework.undo.UndoHandler;
import org.diylc.common.EventType; import org.diylc.common.EventType;
import org.diylc.common.IComponentTransformer;
import org.diylc.common.IPlugIn; import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.common.ISelectionProcessor;
import org.diylc.core.ExpansionMode; import org.diylc.core.ExpansionMode;
import org.diylc.core.Project; import org.diylc.core.Project;
import org.diylc.images.IconLoader; import org.diylc.images.IconLoader;
@@ -205,7 +205,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
public ActionFactory.MirrorSelectionAction getMirrorHorizontallyAction() { public ActionFactory.MirrorSelectionAction getMirrorHorizontallyAction() {
if (mirrorHorizontallyAction == null) { if (mirrorHorizontallyAction == null) {
mirrorHorizontallyAction = mirrorHorizontallyAction =
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, ISelectionProcessor.HORIZONTAL); ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, IComponentTransformer.HORIZONTAL);
} }
return mirrorHorizontallyAction; return mirrorHorizontallyAction;
} }
@@ -213,7 +213,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
public ActionFactory.MirrorSelectionAction getMirrorVerticallyAction() { public ActionFactory.MirrorSelectionAction getMirrorVerticallyAction() {
if (mirrorVerticallyAction == null) { if (mirrorVerticallyAction == null) {
mirrorVerticallyAction = mirrorVerticallyAction =
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, ISelectionProcessor.VERTICAL); ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, IComponentTransformer.VERTICAL);
} }
return mirrorVerticallyAction; return mirrorVerticallyAction;
} }