mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 01:02:08 +10:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e218ca8105 |
@@ -62,12 +62,6 @@
|
||||
<attribute name="Class-Path" value="${manifest.class.path}" />
|
||||
</manifest>
|
||||
</jar>
|
||||
<copy todir="../diylc-swing/lib" overwrite="true">
|
||||
<fileset dir="${jar.dir}" includes="${ant.project.name}.jar" />
|
||||
</copy>
|
||||
<copy todir="../diylc-library/lib" overwrite="true">
|
||||
<fileset dir="${jar.dir}" includes="${ant.project.name}.jar" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="javadoc">
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package org.diylc.common;
|
||||
|
||||
public enum HorizontalAlignment {
|
||||
LEFT, CENTER, RIGHT
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package org.diylc.common;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
public interface IMouseProcessor {
|
||||
|
||||
/**
|
||||
* Notifies the presenter that mouse is clicked.
|
||||
*
|
||||
* Note: point coordinates are display based, i.e. scaled for zoom factor.
|
||||
*
|
||||
* @param point
|
||||
* @param ctrlDown
|
||||
* @param shiftDown
|
||||
* @param altDown
|
||||
* @param clickCount
|
||||
*/
|
||||
void mouseClicked(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown,
|
||||
int clickCount);
|
||||
|
||||
/**
|
||||
* Notifies the presenter that mouse is moved.
|
||||
*
|
||||
* Note: point coordinates are display based, i.e. scaled for zoom factor.
|
||||
*
|
||||
* @param point
|
||||
* @param ctrlDown
|
||||
* @param shiftDown
|
||||
* @param altDown
|
||||
*/
|
||||
void mouseMoved(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown);
|
||||
|
||||
/**
|
||||
* Notification that drag has been started from the specified point.
|
||||
*
|
||||
* Note: point coordinates are scaled for zoom factor.
|
||||
*
|
||||
* @param point
|
||||
* @param dragAction
|
||||
*/
|
||||
void dragStarted(Point point, int dragAction);
|
||||
|
||||
/**
|
||||
* Checks if it's possible to drop over the specified point.
|
||||
*
|
||||
* Note: point coordinates are scaled for zoom factor.
|
||||
*
|
||||
* @param point
|
||||
* @return
|
||||
*/
|
||||
boolean dragOver(Point point);
|
||||
|
||||
/**
|
||||
* Changes the current drag action during the dragging.
|
||||
*
|
||||
* @param dragAction
|
||||
*/
|
||||
void dragActionChanged(int dragAction);
|
||||
|
||||
/**
|
||||
* Notification that drag has been ended in the specified point.
|
||||
*
|
||||
* Note: point coordinates are scaled for zoom factor.
|
||||
*
|
||||
* @param point
|
||||
*/
|
||||
void dragEnded(Point point);
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import org.diylc.core.Theme;
|
||||
* @see IMessageListener
|
||||
* @see EventType
|
||||
*/
|
||||
public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor {
|
||||
public interface IPlugInPort {
|
||||
|
||||
public static final String ANTI_ALIASING_KEY = "antiAliasing";
|
||||
public static final String HI_QUALITY_RENDER_KEY = "hiQualityRender";
|
||||
@@ -45,9 +45,6 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor {
|
||||
public static final String THEME_KEY = "theme";
|
||||
public static final String RECENT_COMPONENTS_KEY = "recentComponents";
|
||||
|
||||
public static final int DND_TOGGLE_STICKY = 0x1;
|
||||
public static final int DND_TOGGLE_SNAP = 0x40000000;
|
||||
|
||||
/**
|
||||
* Returns size of the canvas that takes project dimensions into account as
|
||||
* well as zoom level. Each dimension is calculated as the product of the
|
||||
@@ -162,6 +159,84 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor {
|
||||
*/
|
||||
void setZoomLevel(double zoomLevel);
|
||||
|
||||
/**
|
||||
* Notifies the presenter that mouse is clicked.
|
||||
*
|
||||
* Note: point coordinates are display based, i.e. scaled for zoom factor.
|
||||
*
|
||||
* @param point
|
||||
* @param ctrlDown
|
||||
* @param shiftDown
|
||||
* @param altDown
|
||||
* @param clickCount
|
||||
*/
|
||||
void mouseClicked(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown,
|
||||
int clickCount);
|
||||
|
||||
/**
|
||||
* Notifies the presenter that mouse is moved.
|
||||
*
|
||||
* Note: point coordinates are display based, i.e. scaled for zoom factor.
|
||||
*
|
||||
* @param point
|
||||
* @param ctrlDown
|
||||
* @param shiftDown
|
||||
* @param altDown
|
||||
*/
|
||||
void mouseMoved(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown);
|
||||
|
||||
/**
|
||||
* Returns the current {@link ComponentTransferable}.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<IDIYComponent<?>> getSelectedComponents();
|
||||
|
||||
/**
|
||||
* Updates the selection with the specified list of component. Also, updates
|
||||
* control point map with all components that are stuck to the newly
|
||||
* selected components.
|
||||
*
|
||||
* @param newSelection
|
||||
*/
|
||||
void updateSelection(List<IDIYComponent<?>> newSelection);
|
||||
|
||||
/**
|
||||
* Selects all components in the project.
|
||||
*/
|
||||
void selectAll();
|
||||
|
||||
/**
|
||||
* Notification that drag has been started from the specified point.
|
||||
*
|
||||
* Note: point coordinates are scaled for zoom factor.
|
||||
*
|
||||
* @param point
|
||||
* @param ctrlDown
|
||||
* @param shiftDown
|
||||
* @param altDown
|
||||
*/
|
||||
void dragStarted(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown);
|
||||
|
||||
/**
|
||||
* Checks if it's possible to drop over the specified point.
|
||||
*
|
||||
* Note: point coordinates are scaled for zoom factor.
|
||||
*
|
||||
* @param point
|
||||
* @return
|
||||
*/
|
||||
boolean dragOver(Point point);
|
||||
|
||||
/**
|
||||
* Notification that drag has been ended in the specified point.
|
||||
*
|
||||
* Note: point coordinates are scaled for zoom factor.
|
||||
*
|
||||
* @param point
|
||||
*/
|
||||
void dragEnded(Point point);
|
||||
|
||||
/**
|
||||
* Returns current version number.
|
||||
*
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package org.diylc.common;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.List;
|
||||
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public interface ISelectionProcessor {
|
||||
|
||||
/**
|
||||
* Returns the current {@link ComponentTransferable}.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<IDIYComponent<?>> getSelectedComponents();
|
||||
|
||||
/**
|
||||
* Updates the selection with the specified list of component. Also, updates
|
||||
* control point map with all components that are stuck to the newly
|
||||
* selected components.
|
||||
*
|
||||
* @param newSelection
|
||||
*/
|
||||
void updateSelection(List<IDIYComponent<?>> newSelection);
|
||||
|
||||
/**
|
||||
* Finds all components at the specified location, sorted by z-index from
|
||||
* top to bottom.
|
||||
*
|
||||
* @param point
|
||||
* @return
|
||||
*/
|
||||
List<IDIYComponent<?>> findComponentsAt(Point point);
|
||||
|
||||
/**
|
||||
* Selects all components in the project.
|
||||
*/
|
||||
void selectAll();
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package org.diylc.common;
|
||||
|
||||
public enum VerticalAlignment {
|
||||
TOP, CENTER, BOTTOM
|
||||
}
|
||||
@@ -2,15 +2,8 @@ package org.diylc.components;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.GlyphVector;
|
||||
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
@@ -77,43 +70,4 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void drawCenteredText(Graphics2D g2d, String text, int x, int y,
|
||||
HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) {
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||
Rectangle stringBounds = fontMetrics.getStringBounds(text, g2d).getBounds();
|
||||
|
||||
Font font = g2d.getFont();
|
||||
FontRenderContext renderContext = g2d.getFontRenderContext();
|
||||
GlyphVector glyphVector = font.createGlyphVector(renderContext, text);
|
||||
Rectangle visualBounds = glyphVector.getVisualBounds().getBounds();
|
||||
|
||||
int textX = 0;
|
||||
switch (horizontalAlignment) {
|
||||
case CENTER:
|
||||
textX = x - stringBounds.width / 2;
|
||||
break;
|
||||
case LEFT:
|
||||
textX = x;
|
||||
break;
|
||||
case RIGHT:
|
||||
textX = x - stringBounds.width;
|
||||
break;
|
||||
}
|
||||
|
||||
int textY = 0;
|
||||
switch (verticalAlignment) {
|
||||
case TOP:
|
||||
textY = y + stringBounds.height;
|
||||
break;
|
||||
case CENTER:
|
||||
textY = y - visualBounds.height / 2 - visualBounds.y;
|
||||
break;
|
||||
case BOTTOM:
|
||||
textY = y - visualBounds.y;
|
||||
break;
|
||||
}
|
||||
|
||||
g2d.drawString(text, textX, textY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,16 +195,13 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
g2d.setColor(finalLabelColor);
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||
String label = display == Display.NAME ? getName() : getValue().toString();
|
||||
Rectangle2D textRect = fontMetrics.getStringBounds(label, g2d);
|
||||
// Don't offset in outline mode.
|
||||
int offset = outlineMode ? 0 : getLabelOffset((int) shapeRect.getWidth(), (int) textRect.getWidth());
|
||||
// Adjust label angle if needed to make sure that it's readable.
|
||||
if ((theta >= Math.PI / 2 && theta <= Math.PI)
|
||||
|| (theta < -Math.PI / 2 && theta > -Math.PI)) {
|
||||
g2d.rotate(Math.PI, shapeRect.width / 2, shapeRect.height / 2);
|
||||
offset = -offset;
|
||||
}
|
||||
g2d.drawString(label, (int) (shapeRect.width - textRect.getWidth()) / 2 + offset,
|
||||
}
|
||||
Rectangle2D textRect = fontMetrics.getStringBounds(label, g2d);
|
||||
g2d.drawString(label, (int) (shapeRect.width - textRect.getWidth()) / 2,
|
||||
calculateLabelYCoordinate(shapeRect, textRect, fontMetrics));
|
||||
g2d.setTransform(oldTransform);
|
||||
}
|
||||
@@ -240,10 +237,6 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
protected boolean supportsStandingMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected int getLabelOffset(int bodyWidth, int labelWidth) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return default component length.
|
||||
|
||||
@@ -201,8 +201,8 @@ public class Project implements Serializable {
|
||||
public void validate(Object value) throws ValidationException {
|
||||
super.validate(value);
|
||||
Size size = (Size) value;
|
||||
if (size.compareTo(new Size(0.5d, SizeUnit.mm)) < 0) {
|
||||
throw new ValidationException("must be at least 0.5mm");
|
||||
if (size.compareTo(new Size(1d, SizeUnit.mm)) < 0) {
|
||||
throw new ValidationException("must be greater than 1mm");
|
||||
}
|
||||
if (size.compareTo(new Size(1d, SizeUnit.in)) > 0) {
|
||||
throw new ValidationException("must be less than 1in");
|
||||
|
||||
@@ -76,6 +76,6 @@ public class AbstractMeasure<T extends Enum<? extends Unit>> implements Serializ
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return format.format(value) + unit;
|
||||
return format.format(value) + " " + unit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package org.diylc.core.measures;
|
||||
|
||||
public class Power extends AbstractMeasure<PowerUnit> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Power() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public Power(Double value, PowerUnit unit) {
|
||||
super(value, unit);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public Power clone() throws CloneNotSupportedException {
|
||||
return new Power(value, unit);
|
||||
}
|
||||
|
||||
public static Power parseCapacitance(String value) {
|
||||
for (PowerUnit unit : PowerUnit.values()) {
|
||||
if (value.toLowerCase().endsWith(unit.toString().toLowerCase())) {
|
||||
value = value.substring(0, value.length() - unit.toString().length() - 1).trim();
|
||||
return new Power(Double.parseDouble(value), unit);
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Could not parse power: " + value);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.diylc.core.measures;
|
||||
|
||||
public enum PowerUnit implements Unit {
|
||||
|
||||
MW(1e-1, "mW"), W(1, "W"), KW(1e3, "KW");
|
||||
|
||||
double factor;
|
||||
String display;
|
||||
|
||||
private PowerUnit(double factor, String display) {
|
||||
this.factor = factor;
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFactor() {
|
||||
return factor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return display;
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class Resistance extends AbstractMeasure<ResistanceUnit> {
|
||||
public static Resistance parseResistance(String value) {
|
||||
for (ResistanceUnit unit : ResistanceUnit.values()) {
|
||||
if (value.toLowerCase().endsWith(unit.toString().toLowerCase())) {
|
||||
value = value.substring(0, value.length() - unit.toString().length()).trim();
|
||||
value = value.substring(0, value.length() - unit.toString().length() - 1).trim();
|
||||
return new Resistance(Double.parseDouble(value), unit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.diylc.core.measures;
|
||||
|
||||
public enum ResistanceUnit implements Unit {
|
||||
|
||||
R(1, "R"), K(1e3, "K"), M(1e6, "M");
|
||||
R(1, "\u03a9"), K(1e3, "K"), M(1e6, "M");
|
||||
|
||||
double factor;
|
||||
String display;
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package org.diylc.core.measures;
|
||||
|
||||
public class Voltage extends AbstractMeasure<VoltageUnit> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Voltage() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public Voltage(Double value, VoltageUnit unit) {
|
||||
super(value, unit);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public Voltage clone() throws CloneNotSupportedException {
|
||||
return new Voltage(value, unit);
|
||||
}
|
||||
|
||||
public static Voltage parseCapacitance(String value) {
|
||||
for (VoltageUnit unit : VoltageUnit.values()) {
|
||||
if (value.toLowerCase().endsWith(unit.toString().toLowerCase())) {
|
||||
value = value.substring(0, value.length() - unit.toString().length() - 1).trim();
|
||||
return new Voltage(Double.parseDouble(value), unit);
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Could not parse voltage: " + value);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.diylc.core.measures;
|
||||
|
||||
public enum VoltageUnit implements Unit {
|
||||
|
||||
MV(1e-1, "mV"), V(1, "V"), KV(1e3, "KV");
|
||||
|
||||
double factor;
|
||||
String display;
|
||||
|
||||
private VoltageUnit(double factor, String display) {
|
||||
this.factor = factor;
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getFactor() {
|
||||
return factor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return display;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public enum IconLoader {
|
||||
"donate.png"), Bug("bug.png"), IconLarge("icon_large.png"), IconMedium(
|
||||
"icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit("document_edit.png"), EditComponent(
|
||||
"edit_component.png"), Size("size.png"), Front("front.png"), Back("back.png"), Pens(
|
||||
"pens.png"), Sort("sort.png"), ElementsSelection("elements_selection.png");
|
||||
"pens.png"), Sort("sort.png");
|
||||
|
||||
protected String name;
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 771 B |
@@ -362,7 +362,7 @@ public class DrawingManager {
|
||||
for (int i = 0; i < project.getComponents().size(); i++) {
|
||||
Area area = componentAreaMap.get(project.getComponents().get(i));
|
||||
if (area != null && area.contains(point)) {
|
||||
components.add(0, project.getComponents().get(i));
|
||||
components.add(project.getComponents().get(i));
|
||||
}
|
||||
}
|
||||
return components;
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.lang.reflect.Modifier;
|
||||
@@ -55,7 +54,7 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(Presenter.class);
|
||||
|
||||
public static final VersionNumber CURRENT_VERSION = new VersionNumber(3, 2, 0);
|
||||
public static final VersionNumber CURRENT_VERSION = new VersionNumber(3, 1, 0);
|
||||
public static final String DEFAULTS_KEY_PREFIX = "default.";
|
||||
|
||||
public static final List<IDIYComponent<?>> EMPTY_SELECTION = Collections.emptyList();
|
||||
@@ -94,7 +93,6 @@ public class Presenter implements IPlugInPort {
|
||||
// Previous mouse location, not scaled for zoom factor.
|
||||
private Point previousDragPoint = null;
|
||||
private Project preDragProject = null;
|
||||
private int dragAction;
|
||||
|
||||
public Presenter(IView view) {
|
||||
super();
|
||||
@@ -341,7 +339,7 @@ public class Presenter implements IPlugInPort {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<IDIYComponent<?>> findComponentsAtScaled(Point point) {
|
||||
private List<IDIYComponent<?>> findComponentsAt(Point point) {
|
||||
List<IDIYComponent<?>> components = drawingManager.findComponentsAt(point, currentProject);
|
||||
Iterator<IDIYComponent<?>> iterator = components.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
@@ -352,13 +350,6 @@ public class Presenter implements IPlugInPort {
|
||||
return components;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IDIYComponent<?>> findComponentsAt(Point point) {
|
||||
Point scaledPoint = scalePoint(point);
|
||||
List<IDIYComponent<?>> components = findComponentsAtScaled(scaledPoint);
|
||||
return components;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown,
|
||||
int clickCount) {
|
||||
@@ -375,7 +366,8 @@ public class Presenter implements IPlugInPort {
|
||||
switch (componentTypeSlot.getCreationMethod()) {
|
||||
case SINGLE_CLICK:
|
||||
try {
|
||||
if (isSnapToGrid()) {
|
||||
if (ConfigurationManager.getInstance().readBoolean(
|
||||
IPlugInPort.SNAP_TO_GRID_KEY, true)) {
|
||||
CalcUtils.snapPointToGrid(scaledPoint, currentProject.getGridSpacing());
|
||||
}
|
||||
IDIYComponent<?> component = instantiationManager.instantiateComponent(
|
||||
@@ -409,7 +401,8 @@ public class Presenter implements IPlugInPort {
|
||||
case POINT_BY_POINT:
|
||||
// First click is just to set the controlPointSlot and
|
||||
// componentSlot.
|
||||
if (isSnapToGrid()) {
|
||||
if (ConfigurationManager.getInstance().readBoolean(
|
||||
IPlugInPort.SNAP_TO_GRID_KEY, true)) {
|
||||
CalcUtils.snapPointToGrid(scaledPoint, currentProject.getGridSpacing());
|
||||
}
|
||||
if (instantiationManager.getComponentSlot() == null) {
|
||||
@@ -462,14 +455,14 @@ public class Presenter implements IPlugInPort {
|
||||
} else {
|
||||
List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>(
|
||||
selectedComponents);
|
||||
List<IDIYComponent<?>> components = findComponentsAtScaled(scaledPoint);
|
||||
List<IDIYComponent<?>> components = findComponentsAt(scaledPoint);
|
||||
// If there's nothing under mouse cursor deselect all.
|
||||
if (components.isEmpty()) {
|
||||
if (!ctrlDown) {
|
||||
newSelection.clear();
|
||||
}
|
||||
} else {
|
||||
IDIYComponent<?> component = components.get(0);
|
||||
IDIYComponent<?> component = components.get(components.size() - 1);
|
||||
// If ctrl is pressed just toggle the component under mouse
|
||||
// cursor.
|
||||
if (ctrlDown) {
|
||||
@@ -524,7 +517,7 @@ public class Presenter implements IPlugInPort {
|
||||
Map<IDIYComponent<?>, Set<Integer>> components = new HashMap<IDIYComponent<?>, Set<Integer>>();
|
||||
Point scaledPoint = scalePoint(point);
|
||||
if (instantiationManager.getComponentTypeSlot() != null) {
|
||||
if (isSnapToGrid()) {
|
||||
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.SNAP_TO_GRID_KEY, true)) {
|
||||
CalcUtils.snapPointToGrid(scaledPoint, currentProject.getGridSpacing());
|
||||
}
|
||||
boolean refresh = false;
|
||||
@@ -533,7 +526,8 @@ public class Presenter implements IPlugInPort {
|
||||
refresh = instantiationManager.updatePointByPoint(scaledPoint);
|
||||
break;
|
||||
case SINGLE_CLICK:
|
||||
refresh = instantiationManager.updateSingleClick(scaledPoint, isSnapToGrid(),
|
||||
refresh = instantiationManager.updateSingleClick(scaledPoint, ConfigurationManager
|
||||
.getInstance().readBoolean(IPlugInPort.SNAP_TO_GRID_KEY, true),
|
||||
currentProject.getGridSpacing());
|
||||
break;
|
||||
}
|
||||
@@ -591,8 +585,7 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public void selectAll() {
|
||||
LOG.info("selectAll()");
|
||||
List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>(currentProject
|
||||
.getComponents());
|
||||
List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>(currentProject.getComponents());
|
||||
newSelection.removeAll(getLockedComponents());
|
||||
updateSelection(newSelection);
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
@@ -608,24 +601,21 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragStarted(Point point, int dragAction) {
|
||||
LOG.debug(String.format("dragStarted(%s, %s)", point, dragAction));
|
||||
public void dragStarted(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown) {
|
||||
LOG.debug(String.format("dragStarted(%s)", point));
|
||||
if (instantiationManager.getComponentTypeSlot() != null) {
|
||||
LOG.debug("Cannot start drag because a new component is being created.");
|
||||
mouseClicked(point, dragAction == DnDConstants.ACTION_COPY,
|
||||
dragAction == DnDConstants.ACTION_LINK, dragAction == DnDConstants.ACTION_MOVE,
|
||||
1);
|
||||
mouseClicked(point, ctrlDown, shiftDown, altDown, 1);
|
||||
return;
|
||||
}
|
||||
this.dragInProgress = true;
|
||||
this.dragAction = dragAction;
|
||||
dragInProgress = true;
|
||||
preDragProject = cloner.deepClone(currentProject);
|
||||
Point scaledPoint = scalePoint(point);
|
||||
this.previousDragPoint = scaledPoint;
|
||||
List<IDIYComponent<?>> components = findComponentsAtScaled(scaledPoint);
|
||||
if (!this.controlPointMap.isEmpty()) {
|
||||
previousDragPoint = scaledPoint;
|
||||
List<IDIYComponent<?>> components = findComponentsAt(scaledPoint);
|
||||
if (!controlPointMap.isEmpty()) {
|
||||
// If we're dragging control points reset selection.
|
||||
updateSelection(new ArrayList<IDIYComponent<?>>(this.controlPointMap.keySet()));
|
||||
updateSelection(new ArrayList<IDIYComponent<?>>(controlPointMap.keySet()));
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
// selectedComponents);
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
@@ -641,7 +631,7 @@ public class Presenter implements IPlugInPort {
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
} else {
|
||||
// Take the last component, i.e. the top order component.
|
||||
IDIYComponent<?> component = components.get(0);
|
||||
IDIYComponent<?> component = components.get(components.size() - 1);
|
||||
// If the component under the cursor is not already selected, make
|
||||
// it into the only selected component.
|
||||
if (!selectedComponents.contains(component)) {
|
||||
@@ -661,13 +651,13 @@ public class Presenter implements IPlugInPort {
|
||||
for (int i = 0; i < c.getControlPointCount(); i++) {
|
||||
pointIndices.add(i);
|
||||
}
|
||||
this.controlPointMap.put(c, pointIndices);
|
||||
controlPointMap.put(c, pointIndices);
|
||||
}
|
||||
}
|
||||
// Expand control points to include all stuck components.
|
||||
boolean sticky = ConfigurationManager.getInstance().readBoolean(
|
||||
IPlugInPort.STICKY_POINTS_KEY, true);
|
||||
if (this.dragAction == IPlugInPort.DND_TOGGLE_STICKY) {
|
||||
if (ctrlDown) {
|
||||
sticky = !sticky;
|
||||
}
|
||||
if (sticky) {
|
||||
@@ -676,12 +666,6 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragActionChanged(int dragAction) {
|
||||
LOG.debug("dragActionChanged(" + dragAction + ")");
|
||||
this.dragAction = dragAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds any components that are stuck to one of the components already in
|
||||
* the map.
|
||||
@@ -757,14 +741,6 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSnapToGrid() {
|
||||
boolean snapToGrid = ConfigurationManager.getInstance().readBoolean(
|
||||
IPlugInPort.SNAP_TO_GRID_KEY, true);
|
||||
if (this.dragAction == IPlugInPort.DND_TOGGLE_SNAP)
|
||||
snapToGrid = !snapToGrid;
|
||||
return snapToGrid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dragOver(Point point) {
|
||||
if (point == null) {
|
||||
@@ -797,7 +773,8 @@ public class Presenter implements IPlugInPort {
|
||||
isFirst = false;
|
||||
Point testPoint = new Point(controlPoints[index]);
|
||||
testPoint.translate(dx, dy);
|
||||
if (isSnapToGrid()) {
|
||||
if (ConfigurationManager.getInstance().readBoolean(
|
||||
IPlugInPort.SNAP_TO_GRID_KEY, true)) {
|
||||
CalcUtils.snapPointToGrid(testPoint, currentProject
|
||||
.getGridSpacing());
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -18,12 +17,8 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.common.Display;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.components.boards.AbstractBoard;
|
||||
import org.diylc.components.boards.BlankBoard;
|
||||
import org.diylc.components.boards.PerfBoard;
|
||||
@@ -33,11 +28,9 @@ import org.diylc.components.connectivity.HookupWire;
|
||||
import org.diylc.components.connectivity.Jumper;
|
||||
import org.diylc.components.connectivity.SolderPad;
|
||||
import org.diylc.components.misc.Label;
|
||||
import org.diylc.components.passive.PotentiometerPanel;
|
||||
import org.diylc.components.passive.RadialElectrolytic;
|
||||
import org.diylc.components.passive.RadialFilmCapacitor;
|
||||
import org.diylc.components.passive.Resistor;
|
||||
import org.diylc.components.passive.Taper;
|
||||
import org.diylc.components.semiconductors.DIL_IC;
|
||||
import org.diylc.components.semiconductors.DiodePlastic;
|
||||
import org.diylc.components.semiconductors.LED;
|
||||
@@ -243,7 +236,7 @@ public class ProjectFileManager {
|
||||
label.setText(valueAttr);
|
||||
label.setCenter(false);
|
||||
label.setControlPoint(convertV1CoordinatesToV3Point(referencePoint, x1Attr,
|
||||
y1Attr + 1), 0);
|
||||
y1Attr), 0);
|
||||
component = label;
|
||||
} else if (nodeName.equalsIgnoreCase("pad")) {
|
||||
LOG.debug("Recognized " + nodeName);
|
||||
@@ -277,8 +270,6 @@ public class ProjectFileManager {
|
||||
HookupWire wire = new HookupWire();
|
||||
Point midPoint = new Point((point1.x + point2.x) / 2, (point1.y + point2.y) / 2);
|
||||
wire.setName(nameAttr);
|
||||
String colorAttr = node.getAttributes().getNamedItem("Color").getNodeValue();
|
||||
wire.setColor(parseV1Color(colorAttr));
|
||||
wire.setControlPoint(point1, 0);
|
||||
wire.setControlPoint(midPoint, 1);
|
||||
wire.setControlPoint(midPoint, 2);
|
||||
@@ -293,8 +284,8 @@ public class ProjectFileManager {
|
||||
} catch (Exception e) {
|
||||
LOG.debug("Could not set value of " + nameAttr);
|
||||
}
|
||||
resistor.setLength(new Size(6.35d, SizeUnit.mm));
|
||||
resistor.setWidth(new Size(2.2d, SizeUnit.mm));
|
||||
resistor.setLength(new Size(6d, SizeUnit.mm));
|
||||
resistor.setWidth(new Size(2d, SizeUnit.mm));
|
||||
resistor.setControlPoint(point1, 0);
|
||||
resistor.setControlPoint(point2, 1);
|
||||
component = resistor;
|
||||
@@ -321,20 +312,15 @@ public class ProjectFileManager {
|
||||
} catch (Exception e) {
|
||||
LOG.debug("Could not set value of " + nameAttr);
|
||||
}
|
||||
try {
|
||||
String sizeAttr = node.getAttributes().getNamedItem("Size").getNodeValue();
|
||||
if (sizeAttr.equalsIgnoreCase("small")) {
|
||||
capacitor.setLength(new Size(3.5d, SizeUnit.mm));
|
||||
} else if (sizeAttr.equalsIgnoreCase("medium")) {
|
||||
capacitor.setLength(new Size(5d, SizeUnit.mm));
|
||||
} else if (sizeAttr.equalsIgnoreCase("large")) {
|
||||
capacitor.setLength(new Size(7d, SizeUnit.mm));
|
||||
} else {
|
||||
capacitor.setLength(new Size(4d, SizeUnit.mm));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String sizeAttr = node.getAttributes().getNamedItem("Size").getNodeValue();
|
||||
if (sizeAttr.equalsIgnoreCase("small")) {
|
||||
capacitor.setLength(new Size(3.5d, SizeUnit.mm));
|
||||
} else if (sizeAttr.equalsIgnoreCase("medium")) {
|
||||
capacitor.setLength(new Size(5d, SizeUnit.mm));
|
||||
LOG.debug("Could not set size of " + nameAttr);
|
||||
} else if (sizeAttr.equalsIgnoreCase("large")) {
|
||||
capacitor.setLength(new Size(7d, SizeUnit.mm));
|
||||
} else {
|
||||
capacitor.setLength(new Size(4d, SizeUnit.mm));
|
||||
}
|
||||
capacitor.setControlPoint(point1, 0);
|
||||
capacitor.setControlPoint(point2, 1);
|
||||
@@ -388,27 +374,18 @@ public class ProjectFileManager {
|
||||
} else if (nodeName.equalsIgnoreCase("ic")) {
|
||||
LOG.debug("Recognized " + nodeName);
|
||||
DIL_IC ic = new DIL_IC();
|
||||
int pinCount = 8;
|
||||
int rowSpace = 3;
|
||||
if (x1Attr < x2Attr && y1Attr < y2Attr) {
|
||||
pinCount = (y2Attr - y1Attr + 1) * 2;
|
||||
rowSpace = x2Attr - x1Attr;
|
||||
ic.setOrientation(Orientation.DEFAULT);
|
||||
} else if (x1Attr > x2Attr && y1Attr < y2Attr) {
|
||||
pinCount = (x1Attr - x2Attr + 1) * 2;
|
||||
rowSpace = y2Attr - y1Attr;
|
||||
ic.setOrientation(Orientation._90);
|
||||
} else if (x1Attr > x2Attr && y1Attr > y2Attr) {
|
||||
rowSpace = x1Attr - x2Attr;
|
||||
pinCount = (y1Attr - y2Attr + 1) * 2;
|
||||
ic.setOrientation(Orientation._180);
|
||||
} else if (x1Attr < x2Attr && y1Attr > y2Attr) {
|
||||
rowSpace = y1Attr - y2Attr;
|
||||
pinCount = (x2Attr - x1Attr + 1) * 2;
|
||||
ic.setOrientation(Orientation._270);
|
||||
if (x1Attr + 3 == x2Attr) {
|
||||
if (y1Attr < y2Attr) {
|
||||
ic
|
||||
.setPinCount(DIL_IC.PinCount.valueOf("_" + 2
|
||||
* (y2Attr - y1Attr + 1)));
|
||||
} else {
|
||||
ic.setOrientation(Orientation._180);
|
||||
ic
|
||||
.setPinCount(DIL_IC.PinCount.valueOf("_" + 2
|
||||
* (y1Attr - y2Attr + 1)));
|
||||
}
|
||||
}
|
||||
ic.setRowSpacing(new Size(0.1 * rowSpace, SizeUnit.in));
|
||||
ic.setPinCount(DIL_IC.PinCount.valueOf("_" + pinCount));
|
||||
ic.setName(nameAttr);
|
||||
// Translate control points.
|
||||
for (int j = 0; j < ic.getControlPointCount(); j++) {
|
||||
@@ -418,58 +395,6 @@ public class ProjectFileManager {
|
||||
}
|
||||
ic.setValue(valueAttr);
|
||||
component = ic;
|
||||
} else if (nodeName.equalsIgnoreCase("pot")) {
|
||||
LOG.debug("Recognized " + nodeName);
|
||||
PotentiometerPanel pot = new PotentiometerPanel();
|
||||
pot.setBodyDiameter(new Size(14d, SizeUnit.mm));
|
||||
pot.setSpacing(new Size(0.2, SizeUnit.in));
|
||||
pot.setName(nameAttr);
|
||||
try {
|
||||
pot.setResistance(Resistance.parseResistance(valueAttr));
|
||||
} catch (Exception e) {
|
||||
LOG.debug("Could not set value of " + nameAttr);
|
||||
}
|
||||
String taperAttr = node.getAttributes().getNamedItem("Taper").getNodeValue();
|
||||
if ("Linear".equals(taperAttr)) {
|
||||
pot.setTaper(Taper.LIN);
|
||||
} else if ("Audio".equals(taperAttr)) {
|
||||
pot.setTaper(Taper.LOG);
|
||||
} else if ("Reverse Audio".equals(taperAttr)) {
|
||||
pot.setTaper(Taper.REV_LOG);
|
||||
}
|
||||
// Pin spacing, we'll need to move pot around a bit.
|
||||
int delta = Constants.PIXELS_PER_INCH / 5;
|
||||
if (x1Attr < x2Attr) {
|
||||
pot.setOrientation(Orientation.DEFAULT);
|
||||
for (int j = 0; j < pot.getControlPointCount(); j++) {
|
||||
Point p = new Point(pot.getControlPoint(j));
|
||||
p.translate(point1.x - delta, point1.y);
|
||||
pot.setControlPoint(p, j);
|
||||
}
|
||||
} else if (x1Attr > x2Attr) {
|
||||
pot.setOrientation(Orientation._180);
|
||||
for (int j = 0; j < pot.getControlPointCount(); j++) {
|
||||
Point p = new Point(pot.getControlPoint(j));
|
||||
p.translate(point1.x + delta, point1.y);
|
||||
pot.setControlPoint(p, j);
|
||||
}
|
||||
} else if (y1Attr < y2Attr) {
|
||||
pot.setOrientation(Orientation._90);
|
||||
for (int j = 0; j < pot.getControlPointCount(); j++) {
|
||||
Point p = new Point(pot.getControlPoint(j));
|
||||
p.translate(point1.x, point1.y - delta);
|
||||
pot.setControlPoint(p, j);
|
||||
}
|
||||
} else if (y1Attr > y2Attr) {
|
||||
pot.setOrientation(Orientation._270);
|
||||
for (int j = 0; j < pot.getControlPointCount(); j++) {
|
||||
Point p = new Point(pot.getControlPoint(j));
|
||||
p.translate(point1.x, point1.y + delta);
|
||||
pot.setControlPoint(p, j);
|
||||
}
|
||||
;
|
||||
}
|
||||
component = pot;
|
||||
} else {
|
||||
String message = "Could not recognize component type " + nodeName;
|
||||
LOG.debug(message);
|
||||
@@ -478,12 +403,6 @@ public class ProjectFileManager {
|
||||
}
|
||||
}
|
||||
if (component != null) {
|
||||
if (component instanceof AbstractLeadedComponent<?>) {
|
||||
((AbstractLeadedComponent<?>) component).setDisplay(Display.NAME);
|
||||
}
|
||||
if (component instanceof AbstractTransparentComponent<?>) {
|
||||
((AbstractTransparentComponent<?>) component).setAlpha((byte) 100);
|
||||
}
|
||||
project.getComponents().add(component);
|
||||
}
|
||||
}
|
||||
@@ -500,18 +419,6 @@ public class ProjectFileManager {
|
||||
return point;
|
||||
}
|
||||
|
||||
private Color parseV1Color(String color) {
|
||||
if ("brown".equals(color.toLowerCase()))
|
||||
return new Color(139, 69, 19);
|
||||
try {
|
||||
Field field = Color.class.getDeclaredField(color.toLowerCase());
|
||||
return (Color) field.get(null);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not parse color \"" + color + "\"", e);
|
||||
return Color.black;
|
||||
}
|
||||
}
|
||||
|
||||
private Project parseV2File(Element root) {
|
||||
Project project = new Project();
|
||||
String projectName = root.getAttribute("projectName");
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes.dir}" />
|
||||
<echo>Compile with JDK ${java.runtime.version}</echo>
|
||||
<javac encoding="8859_1" srcdir="${basedir}/${src.dir}" destdir="${classes.dir}" classpathref="class.path" debug="true" />
|
||||
<javac encoding="8859_1" srcdir="${basedir}/${src.dir}" destdir="${classes.dir}" classpathref="class.path" />
|
||||
</target>
|
||||
|
||||
<target name="resource.copy">
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
<target name="jar" depends="clean, lib.copy, resource.copy, compile">
|
||||
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}" />
|
||||
<copy todir="../diylc-swing/library" overwrite="true">
|
||||
<copy todir="../DIYLC/library" overwrite="true">
|
||||
<fileset dir="${jar.dir}" includes="${ant.project.name}.jar" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
Binary file not shown.
@@ -6,9 +6,7 @@ import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -24,8 +22,6 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
|
||||
public static Color BOARD_COLOR = Color.decode("#F8EBB3");
|
||||
public static Color BORDER_COLOR = BOARD_COLOR.darker();
|
||||
public static Color COORDINATE_COLOR = Color.gray.brighter();
|
||||
public static float COORDINATE_FONT_SIZE = 9f;
|
||||
public static Size DEFAULT_WIDTH = new Size(1.5d, SizeUnit.in);
|
||||
public static Size DEFAULT_HEIGHT = new Size(1.2d, SizeUnit.in);
|
||||
|
||||
@@ -38,12 +34,10 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
|
||||
protected Color boardColor = BOARD_COLOR;
|
||||
protected Color borderColor = BORDER_COLOR;
|
||||
protected Color coordinateColor = COORDINATE_COLOR;
|
||||
protected Boolean drawCoordinates = true;
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||
Project project, IDrawingObserver drawingObserver) {
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
Composite oldComposite = g2d.getComposite();
|
||||
@@ -65,44 +59,6 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
drawingObserver.stopTracking();
|
||||
}
|
||||
|
||||
protected void drawCoordinates(Graphics2D g2d, int spacing) {
|
||||
if (!getDrawCoordinates())
|
||||
return;
|
||||
Point p = new Point(firstPoint);
|
||||
g2d.setColor(coordinateColor);
|
||||
g2d.setFont(LABEL_FONT.deriveFont(COORDINATE_FONT_SIZE));
|
||||
|
||||
int t = 1;
|
||||
while (p.y < secondPoint.y - spacing) {
|
||||
p.y += spacing;
|
||||
super.drawCenteredText(g2d, getCoordinateLabel(t++), p.x + 2, p.y,
|
||||
HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
|
||||
}
|
||||
|
||||
p = new Point(firstPoint);
|
||||
t = 1;
|
||||
while (p.x < secondPoint.x - spacing) {
|
||||
p.x += spacing;
|
||||
super.drawCenteredText(g2d, getCoordinateLabel(t++), p.x, p.y - 2,
|
||||
HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||
}
|
||||
}
|
||||
|
||||
private String getCoordinateLabel(int coordinate) {
|
||||
String result = "";
|
||||
while (coordinate > 0) {
|
||||
int digit = coordinate % 26;
|
||||
coordinate /= 26;
|
||||
if (digit == 0) {
|
||||
result = 'Z' + result;
|
||||
coordinate--;
|
||||
} else {
|
||||
result = (char) ((int) 'A' + digit - 1) + result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Color")
|
||||
public Color getBoardColor() {
|
||||
return boardColor;
|
||||
@@ -112,16 +68,6 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
this.boardColor = boardColor;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Coordinate Color")
|
||||
public Color getCoordinateColor() {
|
||||
// Null protection for older files
|
||||
return coordinateColor == null ? COORDINATE_COLOR : coordinateColor;
|
||||
}
|
||||
|
||||
public void setCoordinateColor(Color coordinateColor) {
|
||||
this.coordinateColor = coordinateColor;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Border")
|
||||
public Color getBorderColor() {
|
||||
return borderColor;
|
||||
@@ -131,16 +77,6 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Draw Coordinates")
|
||||
public boolean getDrawCoordinates() {
|
||||
// Null protection for older files
|
||||
return drawCoordinates == null || drawCoordinates;
|
||||
}
|
||||
|
||||
public void setDrawCoordinates(boolean drawCoordinates) {
|
||||
this.drawCoordinates = drawCoordinates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return controlPoints.length;
|
||||
|
||||
@@ -17,10 +17,4 @@ public class BlankBoard extends AbstractBoard {
|
||||
g2d.setColor(BORDER_COLOR);
|
||||
g2d.drawRect(2, 2, width - 4, height - 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDrawCoordinates() {
|
||||
// Override to prevent editing.
|
||||
return super.getDrawCoordinates();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,6 @@ public class EyeletBoard extends AbstractBoard {
|
||||
holeDiameter);
|
||||
}
|
||||
}
|
||||
super.drawCoordinates(g2d, spacing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ public class MarshallPerfBoard extends AbstractBoard {
|
||||
holeDiameter);
|
||||
}
|
||||
}
|
||||
super.drawCoordinates(g2d, spacing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ public class PerfBoard extends AbstractBoard {
|
||||
holeDiameter);
|
||||
}
|
||||
}
|
||||
super.drawCoordinates(g2d, spacing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ public class VeroBoard extends AbstractBoard {
|
||||
}
|
||||
}
|
||||
g2d.setComposite(oldComposite);
|
||||
super.drawCoordinates(g2d, spacing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.diylc.core.measures.Capacitance;
|
||||
import org.diylc.core.measures.CapacitanceUnit;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.core.measures.VoltageUnit;
|
||||
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)
|
||||
@@ -34,10 +33,7 @@ public class AxialElectrolyticCapacitor extends AbstractLeadedComponent<Capacita
|
||||
public static Color TICK_COLOR = Color.white;
|
||||
|
||||
private Capacitance value = new Capacitance(1d, CapacitanceUnit.uF);
|
||||
@Deprecated
|
||||
private Voltage voltage = Voltage._63V;
|
||||
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(63d,
|
||||
VoltageUnit.V);
|
||||
|
||||
private Color markerColor = MARKER_COLOR;
|
||||
private Color tickColor = TICK_COLOR;
|
||||
@@ -58,30 +54,14 @@ public class AxialElectrolyticCapacitor extends AbstractLeadedComponent<Capacita
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@EditableProperty
|
||||
public Voltage getVoltage() {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setVoltage(Voltage voltage) {
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Voltage")
|
||||
public org.diylc.core.measures.Voltage getVoltageNew() {
|
||||
// Backward comptibility
|
||||
if (voltageNew == null) {
|
||||
voltageNew = voltage.convertToNewFormat();
|
||||
voltage = null;
|
||||
// Clear old value, don't need it anymore
|
||||
}
|
||||
return voltageNew;
|
||||
}
|
||||
|
||||
public void setVoltageNew(org.diylc.core.measures.Voltage voltageNew) {
|
||||
this.voltageNew = voltageNew;
|
||||
}
|
||||
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.diylc.core.measures.Capacitance;
|
||||
import org.diylc.core.measures.CapacitanceUnit;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.core.measures.VoltageUnit;
|
||||
|
||||
@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)
|
||||
public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||
@@ -27,10 +26,7 @@ public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||
|
||||
private Capacitance value = new Capacitance(22d, CapacitanceUnit.nF);
|
||||
@Deprecated
|
||||
private Voltage voltage = Voltage._63V;
|
||||
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(63d,
|
||||
VoltageUnit.V);
|
||||
|
||||
public AxialFilmCapacitor() {
|
||||
super();
|
||||
@@ -52,30 +48,15 @@ public class AxialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@EditableProperty
|
||||
public Voltage getVoltage() {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setVoltage(Voltage voltage) {
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Voltage")
|
||||
public org.diylc.core.measures.Voltage getVoltageNew() {
|
||||
// Backward comptibility
|
||||
if (voltageNew == null) {
|
||||
voltageNew = voltage.convertToNewFormat();
|
||||
voltage = null;
|
||||
// Clear old value, don't need it anymore
|
||||
}
|
||||
return voltageNew;
|
||||
}
|
||||
|
||||
public void setVoltageNew(org.diylc.core.measures.Voltage voltageNew) {
|
||||
this.voltageNew = voltageNew;
|
||||
}
|
||||
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.diylc.core.measures.Capacitance;
|
||||
import org.diylc.core.measures.CapacitanceUnit;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.core.measures.VoltageUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Capacitor (schematic symbol)", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Capacitor schematic symbol with an optional polarity sign", zOrder = IDIYComponent.COMPONENT)
|
||||
public class CapacitorSymbol extends AbstractSchematicLeadedSymbol<Capacitance> {
|
||||
@@ -24,10 +23,7 @@ public class CapacitorSymbol extends AbstractSchematicLeadedSymbol<Capacitance>
|
||||
public static Size DEFAULT_WIDTH = new Size(0.15, SizeUnit.in);
|
||||
|
||||
private Capacitance value = new Capacitance(22d, CapacitanceUnit.nF);
|
||||
@Deprecated
|
||||
private Voltage voltage = Voltage._63V;
|
||||
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(63d,
|
||||
VoltageUnit.V);
|
||||
private boolean polarized = false;
|
||||
|
||||
@EditableProperty
|
||||
@@ -39,31 +35,15 @@ public class CapacitorSymbol extends AbstractSchematicLeadedSymbol<Capacitance>
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@EditableProperty
|
||||
public Voltage getVoltage() {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setVoltage(Voltage voltage) {
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Voltage")
|
||||
public org.diylc.core.measures.Voltage getVoltageNew() {
|
||||
// Backward compatibility
|
||||
if (voltageNew == null) {
|
||||
voltageNew = voltage.convertToNewFormat();
|
||||
voltage = null;
|
||||
// Clear old value, don't need it anymore
|
||||
}
|
||||
return voltageNew;
|
||||
}
|
||||
|
||||
public void setVoltageNew(org.diylc.core.measures.Voltage voltageNew) {
|
||||
this.voltageNew = voltageNew;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public boolean getPolarized() {
|
||||
return polarized;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.diylc.components.passive;
|
||||
|
||||
import org.diylc.core.measures.PowerUnit;
|
||||
|
||||
public enum Power {
|
||||
|
||||
EIGHT("1/8W"), QUARTER("1/4W"), HALF("1/2W"), ONE("1W"), TWO("2W"), FIVE("5W"), TEN("10W"), FIFTY(
|
||||
@@ -17,40 +15,4 @@ public enum Power {
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public org.diylc.core.measures.Power convertToNewFormat() {
|
||||
org.diylc.core.measures.Power powerNew;
|
||||
switch (this) {
|
||||
case EIGHT:
|
||||
powerNew = new org.diylc.core.measures.Power(1 / 8d, PowerUnit.W);
|
||||
break;
|
||||
case FIVE:
|
||||
powerNew = new org.diylc.core.measures.Power(5d, PowerUnit.W);
|
||||
break;
|
||||
case FIFTY:
|
||||
powerNew = new org.diylc.core.measures.Power(50d, PowerUnit.W);
|
||||
break;
|
||||
case HALF:
|
||||
powerNew = new org.diylc.core.measures.Power(1 / 2d, PowerUnit.W);
|
||||
break;
|
||||
case HUNDRED:
|
||||
powerNew = new org.diylc.core.measures.Power(100d, PowerUnit.W);
|
||||
break;
|
||||
case ONE:
|
||||
powerNew = new org.diylc.core.measures.Power(1d, PowerUnit.W);
|
||||
break;
|
||||
case QUARTER:
|
||||
powerNew = new org.diylc.core.measures.Power(1 / 4d, PowerUnit.W);
|
||||
break;
|
||||
case TEN:
|
||||
powerNew = new org.diylc.core.measures.Power(10d, PowerUnit.W);
|
||||
break;
|
||||
case TWO:
|
||||
powerNew = new org.diylc.core.measures.Power(2d, PowerUnit.W);
|
||||
break;
|
||||
default:
|
||||
powerNew = new org.diylc.core.measures.Power(1 / 2d, PowerUnit.W);
|
||||
}
|
||||
return powerNew;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.diylc.core.measures.Capacitance;
|
||||
import org.diylc.core.measures.CapacitanceUnit;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.core.measures.VoltageUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Electrolytic Capacitor", author = "Branislav Stojkovic", category = "Passive", creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "C", description = "Vertical mounted electrolytic capacitor, polarized or bipolar", zOrder = IDIYComponent.COMPONENT)
|
||||
@@ -35,10 +34,7 @@ public class RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
|
||||
public static Color TICK_COLOR = Color.white;
|
||||
|
||||
private Capacitance value = new Capacitance(1d, CapacitanceUnit.uF);
|
||||
@Deprecated
|
||||
private Voltage voltage = Voltage._63V;
|
||||
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(63d,
|
||||
VoltageUnit.V);
|
||||
|
||||
private Color markerColor = MARKER_COLOR;
|
||||
private Color tickColor = TICK_COLOR;
|
||||
@@ -59,30 +55,14 @@ public class RadialElectrolytic extends AbstractLeadedComponent<Capacitance> {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@EditableProperty
|
||||
public Voltage getVoltage() {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setVoltage(Voltage voltage) {
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Voltage")
|
||||
public org.diylc.core.measures.Voltage getVoltageNew() {
|
||||
// Backward comptibility
|
||||
if (voltageNew == null) {
|
||||
voltageNew = voltage.convertToNewFormat();
|
||||
voltage = null;
|
||||
// Clear old value, don't need it anymore
|
||||
}
|
||||
return voltageNew;
|
||||
}
|
||||
|
||||
public void setVoltageNew(org.diylc.core.measures.Voltage voltageNew) {
|
||||
this.voltageNew = voltageNew;
|
||||
}
|
||||
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.setColor(BODY_COLOR);
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.diylc.core.measures.Capacitance;
|
||||
import org.diylc.core.measures.CapacitanceUnit;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.core.measures.VoltageUnit;
|
||||
|
||||
@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)
|
||||
public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||
@@ -27,10 +26,7 @@ public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||
|
||||
private Capacitance value = new Capacitance(123d, CapacitanceUnit.nF);
|
||||
@Deprecated
|
||||
private Voltage voltage = Voltage._63V;
|
||||
private org.diylc.core.measures.Voltage voltageNew = new org.diylc.core.measures.Voltage(63d,
|
||||
VoltageUnit.V);
|
||||
|
||||
public RadialFilmCapacitor() {
|
||||
super();
|
||||
@@ -47,31 +43,16 @@ public class RadialFilmCapacitor extends AbstractLeadedComponent<Capacitance> {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@EditableProperty
|
||||
public Voltage getVoltage() {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setVoltage(Voltage voltage) {
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Voltage")
|
||||
public org.diylc.core.measures.Voltage getVoltageNew() {
|
||||
// Backward comptibility
|
||||
if (voltageNew == null) {
|
||||
voltageNew = voltage.convertToNewFormat();
|
||||
voltage = null;
|
||||
// Clear old value, don't need it anymore
|
||||
}
|
||||
return voltageNew;
|
||||
}
|
||||
|
||||
public void setVoltageNew(org.diylc.core.measures.Voltage voltageNew) {
|
||||
this.voltageNew = voltageNew;
|
||||
}
|
||||
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||
g2d.setColor(LEAD_COLOR);
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.PositiveMeasureValidator;
|
||||
import org.diylc.core.measures.PowerUnit;
|
||||
import org.diylc.core.measures.Resistance;
|
||||
import org.diylc.core.measures.ResistanceUnit;
|
||||
import org.diylc.core.measures.Size;
|
||||
@@ -28,14 +27,9 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
||||
public static Size DEFAULT_HEIGHT = new Size(1d / 8, SizeUnit.in);
|
||||
public static Color BODY_COLOR = Color.decode("#82CFFD");
|
||||
public static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||
public static int BAND_SPACING = 5;
|
||||
public static int FIRST_BAND = 4;
|
||||
|
||||
private Resistance value = new Resistance(123d, ResistanceUnit.K);
|
||||
@Deprecated
|
||||
private Power power = Power.HALF;
|
||||
private org.diylc.core.measures.Power powerNew = new org.diylc.core.measures.Power(0.5,
|
||||
PowerUnit.W);
|
||||
private ResistorColorCode colorCode = ResistorColorCode._5_BAND;
|
||||
|
||||
public Resistor() {
|
||||
@@ -43,7 +37,7 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
||||
this.bodyColor = BODY_COLOR;
|
||||
this.borderColor = BORDER_COLOR;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean supportsStandingMode() {
|
||||
return true;
|
||||
@@ -58,31 +52,15 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@EditableProperty
|
||||
public Power getPower() {
|
||||
return power;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setPower(Power power) {
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Power rating")
|
||||
public org.diylc.core.measures.Power getPowerNew() {
|
||||
// Backward compatibility
|
||||
if (powerNew == null) {
|
||||
powerNew = power.convertToNewFormat();
|
||||
// Clear old value, don't need it anymore
|
||||
power = null;
|
||||
}
|
||||
return powerNew;
|
||||
}
|
||||
|
||||
public void setPowerNew(org.diylc.core.measures.Power powerNew) {
|
||||
this.powerNew = powerNew;
|
||||
}
|
||||
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||
g2d.setColor(LEAD_COLOR);
|
||||
@@ -132,22 +110,12 @@ public class Resistor extends AbstractLeadedComponent<Resistance> {
|
||||
}
|
||||
int height = getClosestOdd(getWidth().convertToPixels());
|
||||
Color[] bands = value.getColorCode(colorCode);
|
||||
int x = FIRST_BAND;
|
||||
int x = 4;
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2));
|
||||
for (int i = 0; i < bands.length; i++) {
|
||||
g2d.setColor(bands[i]);
|
||||
g2d.drawLine(x, 1, x, height - 1);
|
||||
x += BAND_SPACING;
|
||||
x += 5;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLabelOffset(int bodyWidth, int labelWidth) {
|
||||
Color[] bands = value.getColorCode(colorCode);
|
||||
int bandArea = FIRST_BAND + BAND_SPACING * (bands.length - 1);
|
||||
// Only offset the label if overlaping with the band area.
|
||||
if (labelWidth > bodyWidth - 2 * bandArea)
|
||||
return bandArea / 2;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.PowerUnit;
|
||||
import org.diylc.core.measures.Resistance;
|
||||
import org.diylc.core.measures.ResistanceUnit;
|
||||
import org.diylc.core.measures.Size;
|
||||
@@ -24,10 +23,7 @@ public class ResistorSymbol extends AbstractSchematicLeadedSymbol<Resistance> {
|
||||
public static Size DEFAULT_WIDTH = new Size(0.08, SizeUnit.in);
|
||||
|
||||
private Resistance value = new Resistance(100d, ResistanceUnit.K);
|
||||
@Deprecated
|
||||
private Power power = Power.HALF;
|
||||
private org.diylc.core.measures.Power powerNew = new org.diylc.core.measures.Power(0.5,
|
||||
PowerUnit.W);
|
||||
|
||||
@EditableProperty
|
||||
public Resistance getValue() {
|
||||
@@ -38,31 +34,14 @@ public class ResistorSymbol extends AbstractSchematicLeadedSymbol<Resistance> {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@EditableProperty
|
||||
public Power getPower() {
|
||||
return power;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setPower(Power power) {
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Power rating")
|
||||
public org.diylc.core.measures.Power getPowerNew() {
|
||||
// Backward compatibility
|
||||
if (powerNew == null) {
|
||||
powerNew = power.convertToNewFormat();
|
||||
// Clear old value, don't need it anymore
|
||||
power = null;
|
||||
}
|
||||
return powerNew;
|
||||
}
|
||||
|
||||
public void setPowerNew(org.diylc.core.measures.Power powerNew) {
|
||||
this.powerNew = powerNew;
|
||||
}
|
||||
|
||||
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
g2d.rotate(-Math.PI / 4, width / 2, height / 2);
|
||||
|
||||
@@ -1,58 +1,11 @@
|
||||
package org.diylc.components.passive;
|
||||
|
||||
import org.diylc.core.measures.VoltageUnit;
|
||||
|
||||
public enum Voltage {
|
||||
|
||||
_16V, _25V, _63V, _100V, _160V, _250V, _300V, _350V, _400V, _500V, _630V, _1KV;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().replace("_", "");
|
||||
}
|
||||
|
||||
public org.diylc.core.measures.Voltage convertToNewFormat() {
|
||||
org.diylc.core.measures.Voltage voltageNew;
|
||||
switch (this) {
|
||||
case _100V:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(100d, VoltageUnit.V);
|
||||
break;
|
||||
case _160V:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(160d, VoltageUnit.V);
|
||||
break;
|
||||
case _16V:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(16d, VoltageUnit.V);
|
||||
break;
|
||||
case _1KV:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(1d, VoltageUnit.KV);
|
||||
break;
|
||||
case _250V:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(250d, VoltageUnit.V);
|
||||
break;
|
||||
case _25V:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(25d, VoltageUnit.V);
|
||||
break;
|
||||
case _300V:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(300d, VoltageUnit.V);
|
||||
break;
|
||||
case _350V:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(350d, VoltageUnit.V);
|
||||
break;
|
||||
case _400V:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(400d, VoltageUnit.V);
|
||||
break;
|
||||
case _500V:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(500d, VoltageUnit.V);
|
||||
break;
|
||||
case _630V:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(630d, VoltageUnit.V);
|
||||
break;
|
||||
case _63V:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(63d, VoltageUnit.V);
|
||||
break;
|
||||
default:
|
||||
voltageNew = new org.diylc.core.measures.Voltage(100d, VoltageUnit.V);
|
||||
}
|
||||
return voltageNew;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<classpathentry kind="lib" path="lib/objenesis-1.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/poi-3.5-FINAL-20090928.jar"/>
|
||||
<classpathentry kind="lib" path="library/main.jar" sourcepath="/diylc-library"/>
|
||||
<classpathentry kind="lib" path="library/main.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/diylc-core"/>
|
||||
<classpathentry kind="lib" path="lib/app-framework.jar"/>
|
||||
<classpathentry kind="lib" path="lib/swing-framework.jar"/>
|
||||
|
||||
@@ -11,5 +11,5 @@
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;Library&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;DIYLC&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.diylc.DIYLCStarter"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="diylc-swing"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms256m -Xmx512m -Ddorg.diylc.debugComponentAreas=true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms256m -Xmx512m -Dorg.diylc.debugComponentAreas=true"/>
|
||||
</launchConfiguration>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -31,7 +31,7 @@ public enum IconLoader {
|
||||
"donate.png"), Bug("bug.png"), IconLarge("icon_large.png"), IconMedium(
|
||||
"icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit("document_edit.png"), EditComponent(
|
||||
"edit_component.png"), Size("size.png"), Front("front.png"), Back("back.png"), Pens(
|
||||
"pens.png"), Sort("sort.png"), ElementsSelection("elements_selection.png");
|
||||
"pens.png"), Sort("sort.png");
|
||||
|
||||
protected String name;
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 771 B |
@@ -21,7 +21,8 @@ class CanvasGestureListener implements DragGestureListener {
|
||||
|
||||
@Override
|
||||
public void dragGestureRecognized(DragGestureEvent dge) {
|
||||
presenter.dragStarted(dge.getDragOrigin(), dge.getDragAction());
|
||||
presenter.dragStarted(dge.getDragOrigin(), dge.getTriggerEvent().isControlDown(), dge
|
||||
.getTriggerEvent().isShiftDown(), dge.getTriggerEvent().isAltDown());
|
||||
dge.startDrag(presenter.getCursorAt(dge.getDragOrigin()), new EmptyTransferable(),
|
||||
new CanvasSourceListener(presenter));
|
||||
}
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
package org.diylc.swing.plugins.canvas;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.ClipboardOwner;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
@@ -29,10 +22,8 @@ import org.diylc.common.BadPositionException;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.images.IconLoader;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.ActionFactory;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
@@ -48,7 +39,6 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
private RulerScrollPane scrollPane;
|
||||
private CanvasPanel canvasPanel;
|
||||
private JPopupMenu popupMenu;
|
||||
private JMenu selectionMenu;
|
||||
|
||||
private ActionFactory.CutAction cutAction;
|
||||
private ActionFactory.CopyAction copyAction;
|
||||
@@ -109,7 +99,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
getSendToBackAction().setEnabled(enabled);
|
||||
getBringToFrontAction().setEnabled(enabled);
|
||||
|
||||
showPopupAt(e.getX(), e.getY());
|
||||
getPopupMenu().show(canvasPanel, e.getX(), e.getY());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -173,16 +163,9 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
return scrollPane;
|
||||
}
|
||||
|
||||
private void showPopupAt(int x, int y) {
|
||||
updateSelectionMenu(x, y);
|
||||
getPopupMenu().show(canvasPanel, x, y);
|
||||
}
|
||||
|
||||
public JPopupMenu getPopupMenu() {
|
||||
if (popupMenu == null) {
|
||||
popupMenu = new JPopupMenu();
|
||||
popupMenu.add(getSelectionMenu());
|
||||
popupMenu.addSeparator();
|
||||
popupMenu.add(getCutAction());
|
||||
popupMenu.add(getCopyAction());
|
||||
popupMenu.add(getPasteAction());
|
||||
@@ -199,33 +182,6 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
||||
return popupMenu;
|
||||
}
|
||||
|
||||
public JMenu getSelectionMenu() {
|
||||
if (selectionMenu == null) {
|
||||
selectionMenu = new JMenu("Select");
|
||||
selectionMenu.setIcon(IconLoader.ElementsSelection.getIcon());
|
||||
}
|
||||
return selectionMenu;
|
||||
}
|
||||
|
||||
private void updateSelectionMenu(int x, int y) {
|
||||
getSelectionMenu().removeAll();
|
||||
for (IDIYComponent<?> component : plugInPort.findComponentsAt(new Point(x, y))) {
|
||||
JMenuItem item = new JMenuItem(component.getName());
|
||||
final IDIYComponent<?> finalComponent = component;
|
||||
item.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
List<IDIYComponent<?>> newSelection = new ArrayList<IDIYComponent<?>>();
|
||||
newSelection.add(finalComponent);
|
||||
plugInPort.updateSelection(newSelection);
|
||||
plugInPort.refresh();
|
||||
}
|
||||
});
|
||||
getSelectionMenu().add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public ActionFactory.CutAction getCutAction() {
|
||||
if (cutAction == null) {
|
||||
cutAction = ActionFactory.getInstance().createCutAction(plugInPort, clipboard, this);
|
||||
|
||||
@@ -91,6 +91,5 @@ class CanvasTargetListener implements DropTargetListener {
|
||||
|
||||
@Override
|
||||
public void dropActionChanged(DropTargetDragEvent dtde) {
|
||||
presenter.dragActionChanged(dtde.getDropAction());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,49 +409,5 @@
|
||||
</changes>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||
</com.diyfever.gui.update.Version>
|
||||
<com.diyfever.gui.update.Version>
|
||||
<versionNumber>
|
||||
<major>3</major>
|
||||
<minor>2</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2012-02-19 20:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<com.diyfever.gui.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Select components from context menu even when they are under other components</description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
<com.diyfever.gui.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Ctrl+Shift toggles "Snap to Grid" option</description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
<com.diyfever.gui.update.Change>
|
||||
<changeType>NEW_FEATURE</changeType>
|
||||
<description>Perfboards can show hole coordinates</description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
<com.diyfever.gui.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Smarter resistor labels; try not to overlap label with color code bands</description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
<com.diyfever.gui.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved import from v1 file format</description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
<com.diyfever.gui.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Imperial ruler is divided to .1" instead of 1/4"</description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
<com.diyfever.gui.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Allow finer grid spacing up to 0.5mm (0.02")</description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
<com.diyfever.gui.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Do not hard-code voltage and power ratings</description>
|
||||
</com.diyfever.gui.update.Change>
|
||||
</changes>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||
</com.diyfever.gui.update.Version>
|
||||
</a>
|
||||
</java.util.Arrays_-ArrayList>
|
||||
Reference in New Issue
Block a user