mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
refactor component transformation
This commit is contained in:
@@ -29,13 +29,13 @@ public class ComponentType {
|
||||
private boolean stretchable;
|
||||
private BomPolicy bomPolicy;
|
||||
private boolean autoEdit;
|
||||
private boolean rotatable;
|
||||
private IComponentTransformer transformer;
|
||||
private KeywordPolicy keywordPolicy;
|
||||
private String keywordTag;
|
||||
|
||||
public ComponentType(String name, String description, CreationMethod creationMethod, String category,
|
||||
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) {
|
||||
super();
|
||||
this.name = name;
|
||||
@@ -51,7 +51,7 @@ public class ComponentType {
|
||||
this.stretchable = stretchable;
|
||||
this.bomPolicy = bomPolicy;
|
||||
this.autoEdit = autoEdit;
|
||||
this.rotatable = rotatable;
|
||||
this.transformer = transformer;
|
||||
this.keywordPolicy = keywordPolicy;
|
||||
this.keywordTag = keywordTag;
|
||||
}
|
||||
@@ -108,8 +108,8 @@ public class ComponentType {
|
||||
return autoEdit;
|
||||
}
|
||||
|
||||
public boolean isRotatable() {
|
||||
return rotatable;
|
||||
public IComponentTransformer getTransformer() {
|
||||
return transformer;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -9,12 +9,6 @@ import org.diylc.core.IDIYComponent;
|
||||
|
||||
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}.
|
||||
*
|
||||
|
||||
@@ -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.RetentionPolicy;
|
||||
|
||||
import org.diylc.common.DefaultTransformer;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
@@ -77,10 +79,9 @@ public @interface ComponentDescriptor {
|
||||
boolean autoEdit() default true;
|
||||
|
||||
/**
|
||||
* @return true if component may be rotated, false otherwise
|
||||
* @return
|
||||
* @return if the component can be rotated and/or mirrored, returns a class of the transformer that can do it
|
||||
*/
|
||||
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
|
||||
|
||||
@@ -17,6 +17,7 @@ import javax.swing.ImageIcon;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -40,6 +41,7 @@ public class ComponentProcessor {
|
||||
private Map<String, List<PropertyWrapper>> propertyCache;
|
||||
private Map<String, IPropertyValidator> propertyValidatorCache;
|
||||
private Map<String, ComponentType> componentTypeMap;
|
||||
private Map<String, IComponentTransformer> componentTransformerMap;
|
||||
|
||||
public static ComponentProcessor getInstance() {
|
||||
if (instance == null) {
|
||||
@@ -53,6 +55,7 @@ public class ComponentProcessor {
|
||||
this.propertyCache = new HashMap<String, List<PropertyWrapper>>();
|
||||
this.componentTypeMap = new HashMap<String, ComponentType>();
|
||||
this.propertyValidatorCache = new HashMap<String, IPropertyValidator>();
|
||||
this.componentTransformerMap = new HashMap<String, IComponentTransformer>();
|
||||
}
|
||||
|
||||
public ComponentType extractComponentTypeFrom(Class<? extends IDIYComponent<?>> clazz) {
|
||||
@@ -71,7 +74,7 @@ public class ComponentProcessor {
|
||||
boolean stretchable;
|
||||
BomPolicy bomPolicy;
|
||||
boolean autoEdit;
|
||||
boolean rotatable;
|
||||
IComponentTransformer transformer;
|
||||
KeywordPolicy keywordPolicy;
|
||||
String keywordTag;
|
||||
if (clazz.isAnnotationPresent(ComponentDescriptor.class)) {
|
||||
@@ -87,7 +90,7 @@ public class ComponentProcessor {
|
||||
stretchable = annotation.stretchable();
|
||||
bomPolicy = annotation.bomPolicy();
|
||||
autoEdit = annotation.autoEdit();
|
||||
rotatable = annotation.rotatable();
|
||||
transformer = getComponentTransformer(annotation.transformer());
|
||||
keywordPolicy = annotation.keywordPolicy();
|
||||
keywordTag = annotation.keywordTag();
|
||||
} else { // default
|
||||
@@ -102,7 +105,7 @@ public class ComponentProcessor {
|
||||
stretchable = true;
|
||||
bomPolicy = BomPolicy.SHOW_ALL_NAMES;
|
||||
autoEdit = true;
|
||||
rotatable = true;
|
||||
transformer = null;
|
||||
keywordPolicy = KeywordPolicy.NEVER_SHOW;
|
||||
keywordTag = null;
|
||||
}
|
||||
@@ -124,7 +127,7 @@ public class ComponentProcessor {
|
||||
}
|
||||
ComponentType componentType =
|
||||
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);
|
||||
return componentType;
|
||||
}
|
||||
@@ -186,7 +189,8 @@ public class ComponentProcessor {
|
||||
* @param selectedComponents
|
||||
* @return
|
||||
*/
|
||||
public List<PropertyWrapper> getMutualSelectionProperties(Collection<IDIYComponent<?>> selectedComponents) throws Exception {
|
||||
public List<PropertyWrapper> getMutualSelectionProperties(Collection<IDIYComponent<?>> selectedComponents)
|
||||
throws Exception {
|
||||
if (selectedComponents.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -242,4 +246,21 @@ public class ComponentProcessor {
|
||||
propertyValidatorCache.put(clazz.getName(), 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",
|
||||
"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() {}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.io.BufferedInputStream;
|
||||
@@ -38,12 +37,10 @@ import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IComponentFiler;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.common.IKeyProcessor;
|
||||
import org.diylc.common.IPlugIn;
|
||||
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.core.ExpansionMode;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -612,10 +609,10 @@ public class Presenter implements IPlugInPort {
|
||||
rotateComponents(this.selectedComponents, -1, snapToGrid);
|
||||
} else if (key == IKeyProcessor.VK_H) {
|
||||
oldProject = currentProject.clone();
|
||||
mirrorSelection(ISelectionProcessor.HORIZONTAL);
|
||||
mirrorComponents(this.selectedComponents, IComponentTransformer.HORIZONTAL, snapToGrid);
|
||||
} else if (key == IKeyProcessor.VK_V) {
|
||||
oldProject = currentProject.clone();
|
||||
mirrorSelection(ISelectionProcessor.VERTICAL);
|
||||
mirrorComponents(this.selectedComponents, IComponentTransformer.VERTICAL, snapToGrid);
|
||||
} else
|
||||
return false;
|
||||
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) {
|
||||
Point center = getCenterOf(components, snapToGrid);
|
||||
|
||||
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);
|
||||
boolean canRotate = true;
|
||||
for (IDIYComponent<?> component : selectedComponents) {
|
||||
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);
|
||||
}
|
||||
if (type.getTransformer() == null || !type.getTransformer().canRotate(component)) {
|
||||
canRotate = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
public void mirrorSelection(int direction) {
|
||||
if (!selectedComponents.isEmpty()) {
|
||||
LOG.trace("Mirroring selected components");
|
||||
Project oldProject = currentProject.clone();
|
||||
|
||||
Point center = getCenterOf(selectedComponents, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mirrorComponents(selectedComponents, direction, isSnapToGrid());
|
||||
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, currentProject.clone(),
|
||||
"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) {
|
||||
// Determine center of rotation
|
||||
int minX = Integer.MAX_VALUE;
|
||||
|
||||
Binary file not shown.
@@ -2,12 +2,27 @@ package org.diylc.components;
|
||||
|
||||
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 {
|
||||
|
||||
private GeneralPath path;
|
||||
|
||||
private double prevX = Double.NaN;
|
||||
private double prevY = Double.NaN;
|
||||
boolean isFirst = true;
|
||||
private double x = Double.NaN;
|
||||
private double y = Double.NaN;
|
||||
|
||||
@@ -22,12 +37,11 @@ public class RoundedPath {
|
||||
path.moveTo(x, y);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.prevX = Double.NaN;
|
||||
this.prevY = Double.NaN;
|
||||
isFirst = true;
|
||||
}
|
||||
|
||||
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 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));
|
||||
@@ -36,8 +50,7 @@ public class RoundedPath {
|
||||
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;
|
||||
this.prevY = this.y;
|
||||
isFirst = false;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.diylc.components.boards;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -12,7 +13,7 @@ import org.diylc.core.annotations.ComponentDescriptor;
|
||||
|
||||
@ComponentDescriptor(name = "Blank Board", category = "Boards", author = "Branislav Stojkovic",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Shape;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -20,7 +21,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Eyelet Board", category = "Boards", author = "Branislav Stojkovic",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Shape;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -22,7 +23,7 @@ import org.diylc.utils.Constants;
|
||||
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board",
|
||||
description = "Perforated board as found on some Marshall and Trainwreck amps",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Shape;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
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",
|
||||
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", description = "Perforated board with solder pads",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Shape;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.common.OrientationHV;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -22,7 +23,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "TriPad Board", category = "Boards", author = "Hauke Juhls", zOrder = IDIYComponent.BOARD,
|
||||
instanceNamePrefix = "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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Shape;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.common.OrientationHV;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -23,7 +24,8 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Vero Board", category = "Boards", author = "Branislav Stojkovic",
|
||||
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.PCBLayer;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
@@ -21,7 +22,7 @@ import org.diylc.core.measures.SizeUnit;
|
||||
@ComponentDescriptor(name = "Copper Trace", author = "Branislav Stojkovic", category = "Connectivity",
|
||||
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "Trace",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.PCBLayer;
|
||||
import org.diylc.components.AbstractCurvedComponent;
|
||||
@@ -19,7 +20,7 @@ import org.diylc.core.measures.SizeUnit;
|
||||
@ComponentDescriptor(name = "Curved Trace", author = "Branislav Stojkovic", category = "Connectivity",
|
||||
instanceNamePrefix = "Trace", description = "Curved copper trace with two control points",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -18,7 +19,7 @@ import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Dot", category = "Connectivity", author = "Branislav Stojkovic",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -21,7 +22,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Eyelet", category = "Connectivity", author = "Branislav Stojkovic",
|
||||
description = "Eyelet or turret terminal", instanceNamePrefix = "Eyelet", stretchable = 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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.Arrays;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.PCBLayer;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -21,7 +22,7 @@ import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Ground Fill", author = "Branislav Stojkovic", category = "Connectivity",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractCurvedComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -15,7 +16,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Hookup Wire", author = "Branislav Stojkovic", category = "Connectivity",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.awt.Shape;
|
||||
|
||||
import org.diylc.common.Display;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.CreationMethod;
|
||||
@@ -17,7 +18,8 @@ import org.diylc.core.measures.Size;
|
||||
|
||||
@ComponentDescriptor(name = "Jumper", author = "Branislav Stojkovic", category = "Connectivity",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.awt.Shape;
|
||||
|
||||
import org.diylc.common.Display;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.CreationMethod;
|
||||
@@ -19,7 +20,8 @@ import org.diylc.core.measures.Size;
|
||||
|
||||
@ComponentDescriptor(name = "Line", author = "Branislav Stojkovic", category = "Shapes",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.common.PCBLayer;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -23,7 +24,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic",
|
||||
description = "Copper solder pad, round or square", instanceNamePrefix = "Pad", stretchable = 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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.components.boards.AbstractBoard;
|
||||
import org.diylc.components.boards.VeroBoard;
|
||||
@@ -21,7 +22,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@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",
|
||||
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> {
|
||||
|
||||
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",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+3
-1
@@ -8,6 +8,7 @@ import java.awt.geom.Rectangle2D;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -22,7 +23,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Electrolytic Capacitor (axial)", author = "Branislav Stojkovic", category = "Passive",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
import org.diylc.core.CreationMethod;
|
||||
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",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.GeneralPath;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractSchematicLeadedSymbol;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -18,7 +19,7 @@ import org.diylc.core.measures.SizeUnit;
|
||||
@ComponentDescriptor(name = "Capacitor (symbol)", author = "Branislav Stojkovic", category = "Schematics",
|
||||
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.GeneralPath;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractSchematicLeadedSymbol;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -20,7 +21,7 @@ import org.diylc.core.measures.SizeUnit;
|
||||
@ComponentDescriptor(name = "Inductor (symbol)", author = "Branislav Stojkovic", category = "Schematics",
|
||||
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "L",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -16,8 +16,7 @@ import org.diylc.components.semiconductors.SymbolFlipping;
|
||||
|
||||
@ComponentDescriptor(name = "Potentiometer (symbol)", author = "MCbx", category = "Schematics",
|
||||
instanceNamePrefix = "VR", description = "Potentiometer symbol", stretchable = false,
|
||||
zOrder = IDIYComponent.COMPONENT, rotatable = true, keywordPolicy = KeywordPolicy.SHOW_TAG,
|
||||
keywordTag = "Schematic")
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "Schematic")
|
||||
public class PotentiometerSymbol extends Abstract3LegSymbol {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+3
-1
@@ -5,6 +5,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractRadialComponent;
|
||||
import org.diylc.core.CreationMethod;
|
||||
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",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.awt.geom.RoundRectangle2D;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractRadialComponent;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -25,7 +26,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Electrolytic Capacitor (radial)", author = "Branislav Stojkovic", category = "Passive",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractRadialComponent;
|
||||
import org.diylc.core.CreationMethod;
|
||||
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",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.ResistorColorCode;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -19,7 +20,7 @@ import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Resistor", author = "Branislav Stojkovic", category = "Passive",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.GeneralPath;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractSchematicLeadedSymbol;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -18,7 +19,7 @@ import org.diylc.core.measures.SizeUnit;
|
||||
@ComponentDescriptor(name = "Resistor (symbol)", author = "Branislav Stojkovic", category = "Schematics",
|
||||
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "R",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.diylc.utils.Constants;
|
||||
category = "Schematics",
|
||||
instanceNamePrefix = "L",
|
||||
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")
|
||||
public class TransformerCoil extends AbstractComponent<org.diylc.core.measures.Voltage> {
|
||||
|
||||
@@ -231,9 +231,11 @@ public class TransformerCoil extends AbstractComponent<org.diylc.core.measures.V
|
||||
|
||||
int i = 0;
|
||||
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.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 dy = this.controlPoints[i + 1].getY() - this.controlPoints[i].getY();
|
||||
@@ -246,16 +248,13 @@ public class TransformerCoil extends AbstractComponent<org.diylc.core.measures.V
|
||||
double dxa = x2 - x1;
|
||||
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++) {
|
||||
coil.curveTo(
|
||||
x1 + dxa / coilsPerTap * j,
|
||||
y1 + dya / coilsPerTap * j,
|
||||
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));
|
||||
coil.curveTo(x1 + dxa / coilsPerTap * j, y1 + dya / coilsPerTap * j, 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];
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.diylc.utils.Constants;
|
||||
category = "Schematics",
|
||||
instanceNamePrefix = "T",
|
||||
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")
|
||||
public class TransformerCore extends AbstractComponent<Void> {
|
||||
|
||||
@@ -99,7 +99,8 @@ public class TransformerCore extends AbstractComponent<Void> {
|
||||
}
|
||||
|
||||
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();
|
||||
// System.out.println(theta);
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@ import org.diylc.core.annotations.KeywordPolicy;
|
||||
|
||||
@ComponentDescriptor(name = "BJT (symbol)", author = "Branislav Stojkovic", category = "Schematics",
|
||||
instanceNamePrefix = "Q", description = "Bipolar junction transistor schematic symbol", stretchable = false,
|
||||
zOrder = IDIYComponent.COMPONENT, rotatable = true, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE,
|
||||
keywordTag = "Schematic")
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
|
||||
public class BJTSymbol extends Abstract3LegSymbol {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -19,7 +20,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Diode (glass)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -19,7 +20,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Diode (plastic)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
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",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -33,8 +33,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "IC (symbol)", author = "Branislav Stojkovic", category = "Schematics",
|
||||
instanceNamePrefix = "IC", description = "IC symbol with 3 or 5 contacts", stretchable = false,
|
||||
zOrder = IDIYComponent.COMPONENT, rotatable = false, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE,
|
||||
keywordTag = "Schematic")
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
|
||||
public class ICSymbol extends AbstractTransparentComponent<String> {
|
||||
|
||||
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",
|
||||
instanceNamePrefix = "Q", description = "JFET transistor schematic symbol", stretchable = false,
|
||||
zOrder = IDIYComponent.COMPONENT, rotatable = true, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE,
|
||||
keywordTag = "Schematic")
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
|
||||
public class JFETSymbol extends Abstract3LegSymbol {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
@@ -18,7 +19,7 @@ import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "LED", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
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> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.awt.Polygon;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
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",
|
||||
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 {
|
||||
|
||||
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",
|
||||
instanceNamePrefix = "Q", description = "MOSFET transistor schematic symbol", stretchable = false,
|
||||
zOrder = IDIYComponent.COMPONENT, rotatable = true, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE,
|
||||
keywordTag = "Schematic")
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_TAG_AND_VALUE, keywordTag = "Schematic")
|
||||
public class MOSFETSymbol extends Abstract3LegSymbol {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
+4
-3
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
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.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Schottky Siode (symbol)", author = "Branislav Stojkovic",
|
||||
category = "Schematics", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D",
|
||||
@ComponentDescriptor(name = "Schottky Siode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
|
||||
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
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",
|
||||
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
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",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.awt.Point;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -18,7 +19,8 @@ import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
@ComponentDescriptor(name = "Polygon", author = "Branislav Stojkovic", category = "Shapes",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -17,7 +18,8 @@ import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Rectangle", author = "Branislav Stojkovic", category = "Shapes",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.diylc.core.annotations.KeywordPolicy;
|
||||
|
||||
@ComponentDescriptor(name = "Diode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -26,8 +26,8 @@ public class DiodeSymbol extends AbstractTubeSymbol {
|
||||
|
||||
public DiodeSymbol() {
|
||||
super();
|
||||
this.controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0),
|
||||
new Point(0, 0)};
|
||||
this.controlPoints =
|
||||
new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)};
|
||||
updateControlPoints();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.diylc.core.annotations.KeywordPolicy;
|
||||
|
||||
@ComponentDescriptor(name = "Pentode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -25,8 +25,9 @@ public class PentodeSymbol extends AbstractTubeSymbol {
|
||||
|
||||
public PentodeSymbol() {
|
||||
super();
|
||||
this.controlPoints = 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)};
|
||||
this.controlPoints =
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -104,7 +105,8 @@ public class PentodeSymbol extends AbstractTubeSymbol {
|
||||
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);
|
||||
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
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.diylc.core.annotations.KeywordPolicy;
|
||||
|
||||
@ComponentDescriptor(name = "Triode (symbol)", author = "Branislav Stojkovic", category = "Schematics",
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -25,8 +25,8 @@ public class TriodeSymbol extends AbstractTubeSymbol {
|
||||
|
||||
public TriodeSymbol() {
|
||||
super();
|
||||
this.controlPoints = new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0),
|
||||
new Point(0, 0)};
|
||||
this.controlPoints =
|
||||
new Point[] {new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0)};
|
||||
updateControlPoints();
|
||||
}
|
||||
|
||||
|
||||
@@ -729,6 +729,7 @@ public class V1FileParser implements IOldFileParser {
|
||||
|
||||
private long randSeed = 0;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int randInt(int range) {
|
||||
long newSeed = randSeed * 0x08088405 + 1;
|
||||
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.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ISelectionProcessor;
|
||||
import org.diylc.common.ITask;
|
||||
@@ -938,7 +939,7 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.direction = direction;
|
||||
if (direction == ISelectionProcessor.HORIZONTAL) {
|
||||
if (direction == IComponentTransformer.HORIZONTAL) {
|
||||
putValue(AbstractAction.NAME, "Mirror Horizontally");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.FlipHorizontal.getIcon());
|
||||
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.common.BadPositionException;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ISelectionProcessor;
|
||||
@@ -409,7 +410,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
public ActionFactory.MirrorSelectionAction getMirrorHorizontallyAction() {
|
||||
if (mirrorHorizontallyAction == null) {
|
||||
mirrorHorizontallyAction =
|
||||
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, ISelectionProcessor.HORIZONTAL);
|
||||
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, IComponentTransformer.HORIZONTAL);
|
||||
}
|
||||
return mirrorHorizontallyAction;
|
||||
}
|
||||
@@ -417,7 +418,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
public ActionFactory.MirrorSelectionAction getMirrorVerticallyAction() {
|
||||
if (mirrorVerticallyAction == null) {
|
||||
mirrorVerticallyAction =
|
||||
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, ISelectionProcessor.VERTICAL);
|
||||
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, IComponentTransformer.VERTICAL);
|
||||
}
|
||||
return mirrorVerticallyAction;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ import java.util.EnumSet;
|
||||
import org.diylc.appframework.undo.IUndoListener;
|
||||
import org.diylc.appframework.undo.UndoHandler;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ISelectionProcessor;
|
||||
import org.diylc.core.ExpansionMode;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.images.IconLoader;
|
||||
@@ -205,7 +205,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
public ActionFactory.MirrorSelectionAction getMirrorHorizontallyAction() {
|
||||
if (mirrorHorizontallyAction == null) {
|
||||
mirrorHorizontallyAction =
|
||||
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, ISelectionProcessor.HORIZONTAL);
|
||||
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, IComponentTransformer.HORIZONTAL);
|
||||
}
|
||||
return mirrorHorizontallyAction;
|
||||
}
|
||||
@@ -213,7 +213,7 @@ public class EditMenuPlugin implements IPlugIn, ClipboardOwner {
|
||||
public ActionFactory.MirrorSelectionAction getMirrorVerticallyAction() {
|
||||
if (mirrorVerticallyAction == null) {
|
||||
mirrorVerticallyAction =
|
||||
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, ISelectionProcessor.VERTICAL);
|
||||
ActionFactory.getInstance().createMirrorSelectionAction(plugInPort, IComponentTransformer.VERTICAL);
|
||||
}
|
||||
return mirrorVerticallyAction;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user