mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
setup sticky and visibility policy for each point inidividually
This commit is contained in:
Binary file not shown.
+1
-9
@@ -12,7 +12,6 @@ import org.diylc.core.IDIYComponent;
|
|||||||
*
|
*
|
||||||
* @see IDIYComponent
|
* @see IDIYComponent
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public class ComponentType {
|
public class ComponentType {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
@@ -25,12 +24,10 @@ public class ComponentType {
|
|||||||
private Class<? extends IDIYComponent> instanceClass;
|
private Class<? extends IDIYComponent> instanceClass;
|
||||||
private double zOrder;
|
private double zOrder;
|
||||||
private boolean stretchable;
|
private boolean stretchable;
|
||||||
private boolean sticky;
|
|
||||||
|
|
||||||
public ComponentType(String name, String description, CreationMethod creationMethod,
|
public ComponentType(String name, String description, CreationMethod creationMethod,
|
||||||
String category, String namePrefix, String author, Icon icon,
|
String category, String namePrefix, String author, Icon icon,
|
||||||
Class<? extends IDIYComponent> instanceClass, double zOrder, boolean stretchable,
|
Class<? extends IDIYComponent> instanceClass, double zOrder, boolean stretchable) {
|
||||||
boolean sticky) {
|
|
||||||
super();
|
super();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@@ -42,7 +39,6 @@ public class ComponentType {
|
|||||||
this.instanceClass = instanceClass;
|
this.instanceClass = instanceClass;
|
||||||
this.zOrder = zOrder;
|
this.zOrder = zOrder;
|
||||||
this.stretchable = stretchable;
|
this.stretchable = stretchable;
|
||||||
this.sticky = sticky;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -85,10 +81,6 @@ public class ComponentType {
|
|||||||
return stretchable;
|
return stretchable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSticky() {
|
|
||||||
return sticky;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
|
|||||||
+11
@@ -11,6 +11,7 @@ import java.awt.geom.CubicCurve2D;
|
|||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
@@ -98,6 +99,16 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
|
|||||||
return controlPoints.length;
|
return controlPoints.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return index == 0 || index == 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return index == 0 || index == 3 ? VisibilityPolicy.ALWAYS : VisibilityPolicy.WHEN_SELECTED;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Point getControlPoint(int index) {
|
public Point getControlPoint(int index) {
|
||||||
return controlPoints[index];
|
return controlPoints[index];
|
||||||
|
|||||||
+14
@@ -15,6 +15,7 @@ import org.diylc.common.Display;
|
|||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
@@ -167,10 +168,23 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
|||||||
return (Point) points[index];
|
return (Point) points[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return VisibilityPolicy.ALWAYS;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setControlPoint(Point point, int index) {
|
public void setControlPoint(Point point, int index) {
|
||||||
|
// Only accept the change if ending points are not the same.
|
||||||
|
if (!point.equals(points[1 - index])) {
|
||||||
points[index].setLocation(point);
|
points[index].setLocation(point);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Color")
|
@EditableProperty(name = "Color")
|
||||||
public Color getBodyColor() {
|
public Color getBodyColor() {
|
||||||
|
|||||||
+4
@@ -87,6 +87,10 @@ public interface IDIYComponent<T> extends Serializable {
|
|||||||
*/
|
*/
|
||||||
void setControlPoint(Point point, int index);
|
void setControlPoint(Point point, int index);
|
||||||
|
|
||||||
|
boolean isControlPointSticky(int index);
|
||||||
|
|
||||||
|
VisibilityPolicy getControlPointVisibilityPolicy(int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the component onto the {@link Graphics2D}.
|
* Draws the component onto the {@link Graphics2D}.
|
||||||
*
|
*
|
||||||
|
|||||||
-5
@@ -59,9 +59,4 @@ public @interface ComponentDescriptor {
|
|||||||
*/
|
*/
|
||||||
boolean stretchable() default true;
|
boolean stretchable() default true;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true, if control points may stick to other components' control
|
|
||||||
* points.
|
|
||||||
*/
|
|
||||||
boolean sticky() default false;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -62,7 +62,6 @@ public class ComponentProcessor {
|
|||||||
Icon icon;
|
Icon icon;
|
||||||
double zOrder;
|
double zOrder;
|
||||||
boolean stretchable;
|
boolean stretchable;
|
||||||
boolean sticky;
|
|
||||||
if (clazz.isAnnotationPresent(ComponentDescriptor.class)) {
|
if (clazz.isAnnotationPresent(ComponentDescriptor.class)) {
|
||||||
ComponentDescriptor annotation = clazz.getAnnotation(ComponentDescriptor.class);
|
ComponentDescriptor annotation = clazz.getAnnotation(ComponentDescriptor.class);
|
||||||
name = annotation.name();
|
name = annotation.name();
|
||||||
@@ -73,7 +72,6 @@ public class ComponentProcessor {
|
|||||||
author = annotation.author();
|
author = annotation.author();
|
||||||
zOrder = annotation.zOrder();
|
zOrder = annotation.zOrder();
|
||||||
stretchable = annotation.stretchable();
|
stretchable = annotation.stretchable();
|
||||||
sticky = annotation.sticky();
|
|
||||||
} else {
|
} else {
|
||||||
name = clazz.getSimpleName();
|
name = clazz.getSimpleName();
|
||||||
description = "";
|
description = "";
|
||||||
@@ -83,7 +81,6 @@ public class ComponentProcessor {
|
|||||||
author = "Unknown";
|
author = "Unknown";
|
||||||
zOrder = IDIYComponent.COMPONENT;
|
zOrder = IDIYComponent.COMPONENT;
|
||||||
stretchable = true;
|
stretchable = true;
|
||||||
sticky = false;
|
|
||||||
}
|
}
|
||||||
icon = null;
|
icon = null;
|
||||||
// Draw component icon.
|
// Draw component icon.
|
||||||
@@ -92,7 +89,9 @@ public class ComponentProcessor {
|
|||||||
Image image = new BufferedImage(Presenter.ICON_SIZE, Presenter.ICON_SIZE,
|
Image image = new BufferedImage(Presenter.ICON_SIZE, Presenter.ICON_SIZE,
|
||||||
java.awt.image.BufferedImage.TYPE_INT_ARGB);
|
java.awt.image.BufferedImage.TYPE_INT_ARGB);
|
||||||
Graphics2D g2d = (Graphics2D) image.getGraphics();
|
Graphics2D g2d = (Graphics2D) image.getGraphics();
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g2d
|
||||||
|
.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
componentInstance.drawIcon(g2d, Presenter.ICON_SIZE, Presenter.ICON_SIZE);
|
componentInstance.drawIcon(g2d, Presenter.ICON_SIZE, Presenter.ICON_SIZE);
|
||||||
icon = new ImageIcon(image);
|
icon = new ImageIcon(image);
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
@@ -101,7 +100,7 @@ public class ComponentProcessor {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
ComponentType componentType = new ComponentType(name, description, creationMethod,
|
ComponentType componentType = new ComponentType(name, description, creationMethod,
|
||||||
category, namePrefix, author, icon, clazz, zOrder, stretchable, sticky);
|
category, namePrefix, author, icon, clazz, zOrder, stretchable);
|
||||||
return componentType;
|
return componentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-10
@@ -306,14 +306,15 @@ public class Presenter implements IPlugInPort {
|
|||||||
if (currentProject == null) {
|
if (currentProject == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<IDIYComponent<?>> drawControlPoints = new HashSet<IDIYComponent<?>>();
|
Set<IDIYComponent<?>> groupedComponents = new HashSet<IDIYComponent<?>>();
|
||||||
for (IDIYComponent<?> component : currentProject.getComponents()) {
|
for (IDIYComponent<?> component : currentProject.getComponents()) {
|
||||||
if (shouldShowControlPointsFor(component)) {
|
// Only try to draw control points of ungrouped
|
||||||
drawControlPoints.add(component);
|
if (findAllGroupedComponents(component).size() > 1) {
|
||||||
|
groupedComponents.add(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
projectPainter.drawProject(g2d, currentProject, drawOptions, filter, selectionRect,
|
projectPainter.drawProject(g2d, currentProject, drawOptions, filter, selectionRect,
|
||||||
selectedComponents, drawControlPoints, Arrays.asList(controlPointSlot,
|
selectedComponents, groupedComponents, Arrays.asList(controlPointSlot,
|
||||||
potentialControlPoint), dragInProgress, zoomLevel);
|
potentialControlPoint), dragInProgress, zoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,13 +570,14 @@ public class Presenter implements IPlugInPort {
|
|||||||
for (IDIYComponent<?> component : currentProject.getComponents()) {
|
for (IDIYComponent<?> component : currentProject.getComponents()) {
|
||||||
// Do not process a component if it's already in the map.
|
// Do not process a component if it's already in the map.
|
||||||
ComponentType componentType = componentTypeMap.get(component.getClass().getName());
|
ComponentType componentType = componentTypeMap.get(component.getClass().getName());
|
||||||
if (!controlPointMap.containsKey(component) && componentType.isSticky()) {
|
|
||||||
// Check if there's a control point in the current selection
|
// Check if there's a control point in the current selection
|
||||||
// that matches with one of its control points.
|
// that matches with one of its control points.
|
||||||
for (int i = 0; i < component.getControlPointCount(); i++) {
|
for (int i = 0; i < component.getControlPointCount(); i++) {
|
||||||
if (controlPointMap.containsKey(component)) {
|
if (controlPointMap.containsKey(component)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!controlPointMap.containsKey(component) && component.isControlPointSticky(i)) {
|
||||||
boolean componentMatches = false;
|
boolean componentMatches = false;
|
||||||
for (Map.Entry<IDIYComponent<?>, Set<Integer>> entry : controlPointMap
|
for (Map.Entry<IDIYComponent<?>, Set<Integer>> entry : controlPointMap
|
||||||
.entrySet()) {
|
.entrySet()) {
|
||||||
@@ -1154,11 +1156,6 @@ public class Presenter implements IPlugInPort {
|
|||||||
* component.
|
* component.
|
||||||
*/
|
*/
|
||||||
private boolean shouldShowControlPointsFor(IDIYComponent<?> component) {
|
private boolean shouldShowControlPointsFor(IDIYComponent<?> component) {
|
||||||
ComponentType componentType = componentTypeMap.get(component.getClass().getName());
|
|
||||||
// Do not show control points for non-stretchable components.
|
|
||||||
if (!componentType.isStretchable()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (findAllGroupedComponents(component).size() > 1) {
|
if (findAllGroupedComponents(component).size() > 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-6
@@ -22,6 +22,7 @@ import org.diylc.common.IComponentFiler;
|
|||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,7 +51,7 @@ public class ProjectPainter {
|
|||||||
|
|
||||||
public void drawProject(Graphics2D g2d, Project project, Set<DrawOption> drawOptions,
|
public void drawProject(Graphics2D g2d, Project project, Set<DrawOption> drawOptions,
|
||||||
IComponentFiler filter, Rectangle selectionRect, ComponentSelection selectedComponents,
|
IComponentFiler filter, Rectangle selectionRect, ComponentSelection selectedComponents,
|
||||||
Set<IDIYComponent<?>> drawControlPoints, List<Point> controlPointSlot,
|
Set<IDIYComponent<?>> groupedComponents, List<Point> controlPointSlot,
|
||||||
boolean dragInProgress, double zoomLevel) {
|
boolean dragInProgress, double zoomLevel) {
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
return;
|
return;
|
||||||
@@ -137,10 +138,17 @@ public class ProjectPainter {
|
|||||||
if (drawOptions.contains(DrawOption.CONTROL_POINTS)) {
|
if (drawOptions.contains(DrawOption.CONTROL_POINTS)) {
|
||||||
// Draw unselected points first to make sure they are below.
|
// Draw unselected points first to make sure they are below.
|
||||||
for (IDIYComponent<?> component : project.getComponents()) {
|
for (IDIYComponent<?> component : project.getComponents()) {
|
||||||
if (drawControlPoints.contains(component)
|
|
||||||
&& !selectedComponents.contains(component)) {
|
|
||||||
g2dWrapper.setColor(Constants.CONTROL_POINT_COLOR);
|
|
||||||
for (int i = 0; i < component.getControlPointCount(); i++) {
|
for (int i = 0; i < component.getControlPointCount(); i++) {
|
||||||
|
VisibilityPolicy visibilityPolicy = component
|
||||||
|
.getControlPointVisibilityPolicy(i);
|
||||||
|
if ((groupedComponents.contains(component)
|
||||||
|
&& (visibilityPolicy == VisibilityPolicy.ALWAYS || (selectedComponents
|
||||||
|
.contains(component) && visibilityPolicy == VisibilityPolicy.WHEN_SELECTED)) || (!groupedComponents
|
||||||
|
.contains(component)
|
||||||
|
&& !selectedComponents.contains(component) && component
|
||||||
|
.getControlPointVisibilityPolicy(i) == VisibilityPolicy.ALWAYS))) {
|
||||||
|
g2dWrapper.setColor(Constants.CONTROL_POINT_COLOR);
|
||||||
|
|
||||||
Point controlPoint = component.getControlPoint(i);
|
Point controlPoint = component.getControlPoint(i);
|
||||||
int pointSize = CONTROL_POINT_SIZE - 2;
|
int pointSize = CONTROL_POINT_SIZE - 2;
|
||||||
g2dWrapper.fillOval(controlPoint.x - pointSize / 2, controlPoint.y
|
g2dWrapper.fillOval(controlPoint.x - pointSize / 2, controlPoint.y
|
||||||
@@ -150,9 +158,12 @@ public class ProjectPainter {
|
|||||||
}
|
}
|
||||||
// Then draw the selected ones.
|
// Then draw the selected ones.
|
||||||
for (IDIYComponent<?> component : selectedComponents) {
|
for (IDIYComponent<?> component : selectedComponents) {
|
||||||
if (drawControlPoints.contains(component)) {
|
|
||||||
g2dWrapper.setColor(Constants.SELECTED_CONTROL_POINT_COLOR);
|
|
||||||
for (int i = 0; i < component.getControlPointCount(); i++) {
|
for (int i = 0; i < component.getControlPointCount(); i++) {
|
||||||
|
if (!groupedComponents.contains(component)
|
||||||
|
&& (component.getControlPointVisibilityPolicy(i) == VisibilityPolicy.WHEN_SELECTED || component
|
||||||
|
.getControlPointVisibilityPolicy(i) == VisibilityPolicy.ALWAYS)) {
|
||||||
|
g2dWrapper.setColor(Constants.SELECTED_CONTROL_POINT_COLOR);
|
||||||
|
|
||||||
Point controlPoint = component.getControlPoint(i);
|
Point controlPoint = component.getControlPoint(i);
|
||||||
int pointSize = CONTROL_POINT_SIZE;
|
int pointSize = CONTROL_POINT_SIZE;
|
||||||
g2dWrapper.fillOval(controlPoint.x - pointSize / 2, controlPoint.y
|
g2dWrapper.fillOval(controlPoint.x - pointSize / 2, controlPoint.y
|
||||||
|
|||||||
+11
@@ -8,6 +8,7 @@ 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;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Capacitance;
|
import org.diylc.core.measures.Capacitance;
|
||||||
@@ -59,6 +60,16 @@ public class MockDIYComponent implements IDIYComponent<Capacitance> {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return VisibilityPolicy.WHEN_SELECTED;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Point getControlPoint(int index) {
|
public Point getControlPoint(int index) {
|
||||||
return leftTopCorner;
|
return leftTopCorner;
|
||||||
|
|||||||
+11
@@ -10,6 +10,7 @@ import org.diylc.components.AbstractTransparentComponent;
|
|||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
@@ -84,6 +85,16 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
return controlPoints[index];
|
return controlPoints[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return VisibilityPolicy.WHEN_SELECTED;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setControlPoint(Point point, int index) {
|
public void setControlPoint(Point point, int index) {
|
||||||
controlPoints[index].setLocation(point);
|
controlPoints[index].setLocation(point);
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ import org.diylc.core.annotations.EditableProperty;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Copper Trace", author = "Branislav Stojkovic", category = "Connectivity", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "Trace", description = "", zOrder = IDIYComponent.ABOVE_BOARD, sticky = true)
|
@ComponentDescriptor(name = "Copper Trace", author = "Branislav Stojkovic", category = "Connectivity", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "Trace", description = "", zOrder = IDIYComponent.ABOVE_BOARD)
|
||||||
public class CopperTrace extends AbstractLeadedComponent<Void> {
|
public class CopperTrace extends AbstractLeadedComponent<Void> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ import org.diylc.core.annotations.EditableProperty;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Curved Trace", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "Trace", description = "Curved copper trace with two control points", zOrder = IDIYComponent.ABOVE_BOARD, sticky = true)
|
@ComponentDescriptor(name = "Curved Trace", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "Trace", description = "Curved copper trace with two control points", zOrder = IDIYComponent.ABOVE_BOARD)
|
||||||
public class CurvedTrace extends AbstractCurvedComponent<Void> {
|
public class CurvedTrace extends AbstractCurvedComponent<Void> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ import org.diylc.core.annotations.ComponentDescriptor;
|
|||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Hookup Wire", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "W", description = "Flexible wire with two control points", zOrder = IDIYComponent.ABOVE_COMPONENT, sticky = true)
|
@ComponentDescriptor(name = "Hookup Wire", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "W", description = "Flexible wire with two control points", zOrder = IDIYComponent.ABOVE_COMPONENT)
|
||||||
public class HookupWire extends AbstractCurvedComponent<AWG> {
|
public class HookupWire extends AbstractCurvedComponent<AWG> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ import org.diylc.core.annotations.ComponentDescriptor;
|
|||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Jumper", author = "Branislav Stojkovic", category = "Connectivity", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "J", description = "", zOrder = IDIYComponent.ABOVE_BOARD, sticky = true)
|
@ComponentDescriptor(name = "Jumper", author = "Branislav Stojkovic", category = "Connectivity", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "J", description = "", zOrder = IDIYComponent.ABOVE_BOARD)
|
||||||
public class Jumper extends AbstractLeadedComponent<Void> {
|
public class Jumper extends AbstractLeadedComponent<Void> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
+12
-1
@@ -9,13 +9,14 @@ 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;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic", description = "test", instanceNamePrefix = "Pad", stretchable = false, zOrder = IDIYComponent.ABOVE_BOARD + 0.1, sticky = true)
|
@ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic", description = "test", instanceNamePrefix = "Pad", stretchable = false, zOrder = IDIYComponent.ABOVE_BOARD + 0.1)
|
||||||
public class SolderPad extends AbstractComponent<Void> {
|
public class SolderPad extends AbstractComponent<Void> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -72,6 +73,16 @@ public class SolderPad extends AbstractComponent<Void> {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return VisibilityPolicy.NEVER;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Point getControlPoint(int index) {
|
public Point getControlPoint(int index) {
|
||||||
return point;
|
return point;
|
||||||
|
|||||||
+43
-2
@@ -2,12 +2,14 @@ package org.diylc.components.connectivity;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Point;
|
||||||
|
|
||||||
import org.diylc.components.AbstractSinglePointComponent;
|
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;
|
||||||
import org.diylc.core.IDrawingObserver;
|
import org.diylc.core.IDrawingObserver;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
@@ -15,7 +17,7 @@ import org.diylc.core.measures.SizeUnit;
|
|||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Trace Cut", category = "Connectivity", author = "Branislav Stojkovic", description = "test", instanceNamePrefix = "Cut", stretchable = false, zOrder = IDIYComponent.ABOVE_BOARD)
|
@ComponentDescriptor(name = "Trace Cut", category = "Connectivity", author = "Branislav Stojkovic", description = "test", instanceNamePrefix = "Cut", stretchable = false, zOrder = IDIYComponent.ABOVE_BOARD)
|
||||||
public class TraceCut extends AbstractSinglePointComponent {
|
public class TraceCut extends AbstractComponent<Void> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -28,6 +30,8 @@ public class TraceCut extends AbstractSinglePointComponent {
|
|||||||
private Color fillColor = FILL_COLOR;
|
private Color fillColor = FILL_COLOR;
|
||||||
private Color borderColor = BORDER_COLOR;
|
private Color borderColor = BORDER_COLOR;
|
||||||
|
|
||||||
|
protected Point point = new Point(0, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
@@ -57,6 +61,43 @@ public class TraceCut extends AbstractSinglePointComponent {
|
|||||||
dotDiameter);
|
dotDiameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getControlPointCount() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Point getControlPoint(int index) {
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return VisibilityPolicy.NEVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setControlPoint(Point point, int index) {
|
||||||
|
this.point.setLocation(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public Void getValue() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public void setValue(Void value) {
|
||||||
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
public Size getSize() {
|
public Size getSize() {
|
||||||
return size;
|
return size;
|
||||||
|
|||||||
+12
-1
@@ -14,12 +14,13 @@ 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;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Mini Toggle Switch", category = "Electromechanical", author = "Branislav Stojkovic", description = "", stretchable = false, zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "SW", sticky = true)
|
@ComponentDescriptor(name = "Mini Toggle Switch", category = "Electromechanical", author = "Branislav Stojkovic", description = "", stretchable = false, zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "SW")
|
||||||
public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchType> {
|
public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchType> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -116,6 +117,16 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
return controlPoints[index];
|
return controlPoints[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return VisibilityPolicy.NEVER;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getControlPointCount() {
|
public int getControlPointCount() {
|
||||||
return controlPoints.length;
|
return controlPoints.length;
|
||||||
|
|||||||
+11
@@ -14,6 +14,7 @@ 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;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
@@ -135,6 +136,16 @@ public class BOM extends AbstractComponent<Void> {
|
|||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return VisibilityPolicy.NEVER;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setControlPoint(Point point, int index) {
|
public void setControlPoint(Point point, int index) {
|
||||||
this.point.setLocation(point);
|
this.point.setLocation(point);
|
||||||
|
|||||||
+11
@@ -12,6 +12,7 @@ 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;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
@@ -81,6 +82,16 @@ public class ProjectInformation extends AbstractComponent<Void> {
|
|||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return VisibilityPolicy.NEVER;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setControlPoint(Point point, int index) {
|
public void setControlPoint(Point point, int index) {
|
||||||
this.point.setLocation(point);
|
this.point.setLocation(point);
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ import org.diylc.core.measures.CapacitanceUnit;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Axial Film Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "test", zOrder = IDIYComponent.COMPONENT, sticky = true)
|
@ComponentDescriptor(name = "Axial Film Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "test", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ import org.diylc.core.measures.CapacitanceUnit;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Ceramic Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "test", zOrder = IDIYComponent.COMPONENT, sticky = true)
|
@ComponentDescriptor(name = "Ceramic Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "test", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class RadialCeramicDiskCapacitor extends AbstractLeadedComponent<Capacitance> {
|
public class RadialCeramicDiskCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ import org.diylc.core.measures.CapacitanceUnit;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Radial Film Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "test", zOrder = IDIYComponent.COMPONENT, sticky = true)
|
@ComponentDescriptor(name = "Radial Film Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "test", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ import org.diylc.core.measures.ResistanceUnit;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Resistor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "R", description = "test", zOrder = IDIYComponent.COMPONENT, sticky = true)
|
@ComponentDescriptor(name = "Resistor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "R", description = "test", zOrder = IDIYComponent.COMPONENT)
|
||||||
public class Resistor extends AbstractLeadedComponent<Resistance> {
|
public class Resistor extends AbstractLeadedComponent<Resistance> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
+12
-1
@@ -18,13 +18,14 @@ 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;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "DIL IC", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "IC", description = "test", stretchable = false, zOrder = IDIYComponent.COMPONENT, sticky = true)
|
@ComponentDescriptor(name = "DIL IC", author = "Branislav Stojkovic", category = "Semiconductors", instanceNamePrefix = "IC", description = "test", stretchable = false, zOrder = IDIYComponent.COMPONENT)
|
||||||
public class DIL_IC extends AbstractTransparentComponent<String> {
|
public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -125,6 +126,16 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
|||||||
return controlPoints[index];
|
return controlPoints[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return VisibilityPolicy.NEVER;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setControlPoint(Point point, int index) {
|
public void setControlPoint(Point point, int index) {
|
||||||
controlPoints[index].setLocation(point);
|
controlPoints[index].setLocation(point);
|
||||||
|
|||||||
Reference in New Issue
Block a user