mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
change layer to double
added solder pad
This commit is contained in:
+5
-6
@@ -2,7 +2,6 @@ package org.diylc.common;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
import org.diylc.core.ComponentLayer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
/**
|
||||
@@ -22,13 +21,13 @@ public class ComponentType {
|
||||
private Icon icon;
|
||||
@SuppressWarnings("unchecked")
|
||||
private Class<? extends IDIYComponent> instanceClass;
|
||||
private ComponentLayer layer;
|
||||
private double zOrder;
|
||||
private boolean stretchable;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ComponentType(String name, String description, String category, String namePrefix,
|
||||
String author, Icon icon, Class<? extends IDIYComponent> instanceClass,
|
||||
ComponentLayer layer, boolean stretchable) {
|
||||
double zOrder, boolean stretchable) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
@@ -37,7 +36,7 @@ public class ComponentType {
|
||||
this.author = author;
|
||||
this.icon = icon;
|
||||
this.instanceClass = instanceClass;
|
||||
this.layer = layer;
|
||||
this.zOrder = zOrder;
|
||||
this.stretchable = stretchable;
|
||||
}
|
||||
|
||||
@@ -70,8 +69,8 @@ public class ComponentType {
|
||||
return instanceClass;
|
||||
}
|
||||
|
||||
public ComponentLayer getLayer() {
|
||||
return layer;
|
||||
public double getZOrder() {
|
||||
return zOrder;
|
||||
}
|
||||
|
||||
public boolean isStretchable() {
|
||||
|
||||
+31
-32
@@ -14,7 +14,6 @@ import javax.swing.JComponent;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.JPopupMenu.Separator;
|
||||
|
||||
import org.diylc.core.ComponentLayer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
|
||||
@@ -219,37 +218,37 @@ public interface IPlugInPort {
|
||||
*/
|
||||
void addComponents(List<IDIYComponent<?>> components, Point preferredPoint);
|
||||
|
||||
/**
|
||||
* Checks if a certain layer is locked for editing.
|
||||
*
|
||||
* @param layer
|
||||
* @return
|
||||
*/
|
||||
boolean isLayerLocked(ComponentLayer layer);
|
||||
|
||||
/**
|
||||
* Changes layer's locked state.
|
||||
*
|
||||
* @param layer
|
||||
* @param locked
|
||||
*/
|
||||
void setLayerLocked(ComponentLayer layer, boolean locked);
|
||||
|
||||
/**
|
||||
* Checks if a certain layer is visible.
|
||||
*
|
||||
* @param layer
|
||||
* @return
|
||||
*/
|
||||
boolean isLayerVisible(ComponentLayer layer);
|
||||
|
||||
/**
|
||||
* Changes layer visibility.
|
||||
*
|
||||
* @param layer
|
||||
* @param visible
|
||||
*/
|
||||
void setLayerVisible(ComponentLayer layer, boolean visible);
|
||||
// /**
|
||||
// * Checks if a certain layer is locked for editing.
|
||||
// *
|
||||
// * @param layer
|
||||
// * @return
|
||||
// */
|
||||
// boolean isLayerLocked(ComponentLayer layer);
|
||||
//
|
||||
// /**
|
||||
// * Changes layer's locked state.
|
||||
// *
|
||||
// * @param layer
|
||||
// * @param locked
|
||||
// */
|
||||
// void setLayerLocked(ComponentLayer layer, boolean locked);
|
||||
//
|
||||
// /**
|
||||
// * Checks if a certain layer is visible.
|
||||
// *
|
||||
// * @param layer
|
||||
// * @return
|
||||
// */
|
||||
// boolean isLayerVisible(ComponentLayer layer);
|
||||
//
|
||||
// /**
|
||||
// * Changes layer visibility.
|
||||
// *
|
||||
// * @param layer
|
||||
// * @param visible
|
||||
// */
|
||||
// void setLayerVisible(ComponentLayer layer, boolean visible);
|
||||
|
||||
/**
|
||||
* Sets default value for the specified property name for currently selected
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package org.diylc.components;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public abstract class AbstractSinglePointComponent implements IDIYComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected Point point = new Point(0, 0);
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getControlPoint(int index) {
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point point, int index) {
|
||||
this.point.setLocation(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Pad";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setValue(Void value) {
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
package org.diylc.core;
|
||||
|
||||
/**
|
||||
* Enumerates all drawing layers.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public enum ComponentLayer {
|
||||
|
||||
BELOW_CHASSIS, CHASSIS, ABOVE_CHASSIS, BELOW_BOARD, BOARD, TRACE, COMPONENT, ABOVE_COMPONENT;
|
||||
}
|
||||
+9
@@ -30,6 +30,15 @@ import org.diylc.core.annotations.EditableProperty;
|
||||
*/
|
||||
public interface IDIYComponent<T> extends Serializable {
|
||||
|
||||
public static final int BELOW_CHASSIS = 1;
|
||||
public static final int CHASSIS = 2;
|
||||
public static final int ABOVE_CHASSIS = 3;
|
||||
public static final int BELOW_BOARD = 4;
|
||||
public static final int BOARD = 5;
|
||||
public static final int ABOVE_BOARD = 5;
|
||||
public static final int COMPONENT = 7;
|
||||
public static final int ABOVE_COMPONENT = 8;
|
||||
|
||||
/**
|
||||
* @return component instance name.
|
||||
*/
|
||||
|
||||
+11
-26
@@ -3,7 +3,6 @@ package org.diylc.core.annotations;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import org.diylc.core.ComponentLayer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
/**
|
||||
@@ -16,53 +15,39 @@ import org.diylc.core.IDIYComponent;
|
||||
public @interface ComponentDescriptor {
|
||||
|
||||
/**
|
||||
* Component type name.
|
||||
*
|
||||
* @return
|
||||
* @return component type name.
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Component type description.
|
||||
*
|
||||
* @return
|
||||
* @return component type description.
|
||||
*/
|
||||
String desciption();
|
||||
String description();
|
||||
|
||||
/**
|
||||
* Component category, e.g. "Passive" or "Semiconductors".
|
||||
*
|
||||
* @return
|
||||
* @return component category, e.g. "Passive", "Semiconductors", etc.
|
||||
*/
|
||||
String category();
|
||||
|
||||
/**
|
||||
* Component author name.
|
||||
*
|
||||
* @return
|
||||
* @return component author name.
|
||||
*/
|
||||
String author();
|
||||
|
||||
/**
|
||||
* Prefix that will be used to generate component instance names, e.g. "R"
|
||||
* for resistors or "Q" for transistors.
|
||||
*
|
||||
* @return
|
||||
* @return prefix that will be used to generate component instance names,
|
||||
* e.g. "R" for resistors or "Q" for transistors.
|
||||
*/
|
||||
String instanceNamePrefix();
|
||||
|
||||
/**
|
||||
* Z-order of the component.
|
||||
*
|
||||
* @return
|
||||
* @return Z-order of the component.
|
||||
*/
|
||||
ComponentLayer componentLayer() default ComponentLayer.COMPONENT;
|
||||
double zOrder();
|
||||
|
||||
/**
|
||||
* When false, moving one control point will cause all the others to move
|
||||
* together with it.
|
||||
*
|
||||
* @return
|
||||
* @return when false, moving one control point will cause all the others to
|
||||
* move together with it.
|
||||
*/
|
||||
boolean stretchable() default true;
|
||||
}
|
||||
|
||||
+5
-6
@@ -16,7 +16,6 @@ import javax.swing.ImageIcon;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.ComponentLayer;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
@@ -58,16 +57,16 @@ public class ComponentProcessor {
|
||||
String namePrefix;
|
||||
String author;
|
||||
Icon icon;
|
||||
ComponentLayer layer;
|
||||
double zOrder;
|
||||
boolean stretchable;
|
||||
if (clazz.isAnnotationPresent(ComponentDescriptor.class)) {
|
||||
ComponentDescriptor annotation = clazz.getAnnotation(ComponentDescriptor.class);
|
||||
name = annotation.name();
|
||||
description = annotation.desciption();
|
||||
description = annotation.description();
|
||||
category = annotation.category();
|
||||
namePrefix = annotation.instanceNamePrefix();
|
||||
author = annotation.author();
|
||||
layer = annotation.componentLayer();
|
||||
zOrder = annotation.zOrder();
|
||||
stretchable = annotation.stretchable();
|
||||
} else {
|
||||
name = clazz.getSimpleName();
|
||||
@@ -75,7 +74,7 @@ public class ComponentProcessor {
|
||||
category = "Uncategorized";
|
||||
namePrefix = "Unknown";
|
||||
author = "Unknown";
|
||||
layer = ComponentLayer.COMPONENT;
|
||||
zOrder = IDIYComponent.COMPONENT;
|
||||
stretchable = true;
|
||||
}
|
||||
icon = null;
|
||||
@@ -96,7 +95,7 @@ public class ComponentProcessor {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ComponentType componentType = new ComponentType(name, description, category, namePrefix,
|
||||
author, icon, clazz, layer, stretchable);
|
||||
author, icon, clazz, zOrder, stretchable);
|
||||
return componentType;
|
||||
}
|
||||
|
||||
|
||||
+31
-33
@@ -14,7 +14,6 @@ import java.awt.geom.Point2D;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -33,7 +32,6 @@ import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.ComponentLayer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
@@ -88,8 +86,8 @@ public class Presenter implements IPlugInPort {
|
||||
private MessageDispatcher<EventType> messageDispatcher;
|
||||
|
||||
// Layers
|
||||
private Set<ComponentLayer> lockedLayers;
|
||||
private Set<ComponentLayer> visibleLayers;
|
||||
// private Set<ComponentLayer> lockedLayers;
|
||||
// private Set<ComponentLayer> visibleLayers;
|
||||
|
||||
// D&D
|
||||
private boolean dragInProgress = false;
|
||||
@@ -111,8 +109,8 @@ public class Presenter implements IPlugInPort {
|
||||
currentProject = new Project();
|
||||
cloner = new Cloner();
|
||||
|
||||
lockedLayers = EnumSet.noneOf(ComponentLayer.class);
|
||||
visibleLayers = EnumSet.allOf(ComponentLayer.class);
|
||||
// lockedLayers = EnumSet.noneOf(ComponentLayer.class);
|
||||
// visibleLayers = EnumSet.allOf(ComponentLayer.class);
|
||||
}
|
||||
|
||||
public void installPlugin(IPlugIn plugIn) {
|
||||
@@ -607,31 +605,31 @@ public class Presenter implements IPlugInPort {
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
|
||||
public boolean isLayerLocked(ComponentLayer layer) {
|
||||
return lockedLayers.contains(layer);
|
||||
}
|
||||
|
||||
public void setLayerLocked(ComponentLayer layer, boolean locked) {
|
||||
LOG.debug(String.format("setLayerLocked(%s, %s)", layer, locked));
|
||||
if (locked) {
|
||||
lockedLayers.add(layer);
|
||||
} else {
|
||||
lockedLayers.remove(layer);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLayerVisible(ComponentLayer layer) {
|
||||
return visibleLayers.contains(layer);
|
||||
}
|
||||
|
||||
public void setLayerVisible(ComponentLayer layer, boolean visible) {
|
||||
LOG.debug(String.format("setLayerVisible(%s, %s)", layer, visible));
|
||||
if (visible) {
|
||||
visibleLayers.add(layer);
|
||||
} else {
|
||||
visibleLayers.remove(layer);
|
||||
}
|
||||
}
|
||||
// public boolean isLayerLocked(ComponentLayer layer) {
|
||||
// return lockedLayers.contains(layer);
|
||||
// }
|
||||
//
|
||||
// public void setLayerLocked(ComponentLayer layer, boolean locked) {
|
||||
// LOG.debug(String.format("setLayerLocked(%s, %s)", layer, locked));
|
||||
// if (locked) {
|
||||
// lockedLayers.add(layer);
|
||||
// } else {
|
||||
// lockedLayers.remove(layer);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public boolean isLayerVisible(ComponentLayer layer) {
|
||||
// return visibleLayers.contains(layer);
|
||||
// }
|
||||
//
|
||||
// public void setLayerVisible(ComponentLayer layer, boolean visible) {
|
||||
// LOG.debug(String.format("setLayerVisible(%s, %s)", layer, visible));
|
||||
// if (visible) {
|
||||
// visibleLayers.add(layer);
|
||||
// } else {
|
||||
// visibleLayers.remove(layer);
|
||||
// }
|
||||
// }
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@@ -690,8 +688,8 @@ public class Presenter implements IPlugInPort {
|
||||
private void addComponent(IDIYComponent<?> component, ComponentType componentType) {
|
||||
int index = 0;
|
||||
while (index < currentProject.getComponents().size()
|
||||
&& componentType.getLayer().ordinal() >= componentTypeMap.get(
|
||||
currentProject.getComponents().get(index).getClass()).getLayer().ordinal()) {
|
||||
&& componentType.getZOrder() >= componentTypeMap.get(
|
||||
currentProject.getComponents().get(index).getClass()).getZOrder()) {
|
||||
index++;
|
||||
}
|
||||
if (index < currentProject.getComponents().size()) {
|
||||
|
||||
Reference in New Issue
Block a user