mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
protoboard transformer added
This commit is contained in:
@@ -3312,7 +3312,7 @@
|
|||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Apply context menu rotation to Breadboard components</description>
|
<description>Apply context menu rotation to Breadboard and P-0+o (Proto) Board components</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,24 @@
|
|||||||
|
package org.diylc.components.boards;
|
||||||
|
|
||||||
|
import org.diylc.common.Orientation;
|
||||||
|
import org.diylc.components.AbstractComponent;
|
||||||
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
|
|
||||||
|
public abstract class AbstractProtoBoard extends AbstractComponent<Void> {
|
||||||
|
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
protected Orientation orientation;
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public Orientation getOrientation() {
|
||||||
|
if (orientation == null)
|
||||||
|
orientation = Orientation.DEFAULT;
|
||||||
|
return orientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrientation(Orientation orientation) {
|
||||||
|
this.orientation = orientation;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,10 +34,8 @@ import java.awt.geom.RoundRectangle2D;
|
|||||||
import org.diylc.awt.StringUtils;
|
import org.diylc.awt.StringUtils;
|
||||||
import org.diylc.common.HorizontalAlignment;
|
import org.diylc.common.HorizontalAlignment;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
|
||||||
import org.diylc.common.VerticalAlignment;
|
import org.diylc.common.VerticalAlignment;
|
||||||
import org.diylc.components.AbstractComponent;
|
import org.diylc.components.transform.ProtoBoardTransformer;
|
||||||
import org.diylc.components.transform.BreadboardTransformer;
|
|
||||||
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;
|
||||||
@@ -53,8 +51,8 @@ import org.diylc.core.measures.SizeUnit;
|
|||||||
@ComponentDescriptor(name = "Breadboard", category = "Boards", author = "Branislav Stojkovic",
|
@ComponentDescriptor(name = "Breadboard", category = "Boards", author = "Branislav Stojkovic",
|
||||||
description = "Prototyping solderless breadboard", instanceNamePrefix = "BB",
|
description = "Prototyping solderless breadboard", instanceNamePrefix = "BB",
|
||||||
zOrder = IDIYComponent.BOARD, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
|
zOrder = IDIYComponent.BOARD, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
|
||||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, enableCache = true, transformer = BreadboardTransformer.class)
|
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, enableCache = true, transformer = ProtoBoardTransformer.class)
|
||||||
public class Breadboard extends AbstractComponent<Void> {
|
public class Breadboard extends AbstractProtoBoard {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -78,7 +76,7 @@ public class Breadboard extends AbstractComponent<Void> {
|
|||||||
|
|
||||||
protected BreadboardSize breadboardSize;
|
protected BreadboardSize breadboardSize;
|
||||||
protected PowerStripPosition powerStripPosition;
|
protected PowerStripPosition powerStripPosition;
|
||||||
protected Orientation orientation;
|
|
||||||
|
|
||||||
@SuppressWarnings("incomplete-switch")
|
@SuppressWarnings("incomplete-switch")
|
||||||
@Override
|
@Override
|
||||||
@@ -282,17 +280,6 @@ public class Breadboard extends AbstractComponent<Void> {
|
|||||||
g2d.drawLine(width / 2, 2 / factor, width / 2, height - 4 / factor);
|
g2d.drawLine(width / 2, 2 / factor, width / 2, height - 4 / factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
|
||||||
public Orientation getOrientation() {
|
|
||||||
if (orientation == null)
|
|
||||||
orientation = Orientation.DEFAULT;
|
|
||||||
return orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrientation(Orientation orientation) {
|
|
||||||
this.orientation = orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty(name = "Size")
|
@EditableProperty(name = "Size")
|
||||||
public BreadboardSize getBreadboardSize() {
|
public BreadboardSize getBreadboardSize() {
|
||||||
if (breadboardSize == null)
|
if (breadboardSize == null)
|
||||||
|
|||||||
@@ -31,9 +31,8 @@ import java.awt.geom.Rectangle2D;
|
|||||||
import org.diylc.awt.StringUtils;
|
import org.diylc.awt.StringUtils;
|
||||||
import org.diylc.common.HorizontalAlignment;
|
import org.diylc.common.HorizontalAlignment;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.common.Orientation;
|
|
||||||
import org.diylc.common.VerticalAlignment;
|
import org.diylc.common.VerticalAlignment;
|
||||||
import org.diylc.components.AbstractComponent;
|
import org.diylc.components.transform.ProtoBoardTransformer;
|
||||||
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;
|
||||||
@@ -49,8 +48,8 @@ import org.diylc.core.measures.SizeUnit;
|
|||||||
@ComponentDescriptor(name = "P-0+o (Proto) Board", category = "Boards", author = "Branislav Stojkovic",
|
@ComponentDescriptor(name = "P-0+o (Proto) Board", category = "Boards", author = "Branislav Stojkovic",
|
||||||
description = "A prototyping board for modular synths, central bus with V+ GND and V-", instanceNamePrefix = "BB",
|
description = "A prototyping board for modular synths, central bus with V+ GND and V-", instanceNamePrefix = "BB",
|
||||||
zOrder = IDIYComponent.BOARD, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
|
zOrder = IDIYComponent.BOARD, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
|
||||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, enableCache = true)
|
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, enableCache = true, transformer = ProtoBoardTransformer.class)
|
||||||
public class ProtoBoard extends AbstractComponent<Void> {
|
public class ProtoBoard extends AbstractProtoBoard {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -82,8 +81,6 @@ public class ProtoBoard extends AbstractComponent<Void> {
|
|||||||
|
|
||||||
protected Point2D point = new Point2D.Double(0, 0);
|
protected Point2D point = new Point2D.Double(0, 0);
|
||||||
|
|
||||||
protected Orientation orientation;
|
|
||||||
|
|
||||||
protected Color boardColor = FILL_COLOR;
|
protected Color boardColor = FILL_COLOR;
|
||||||
protected Color padColor = PAD_COLOR;
|
protected Color padColor = PAD_COLOR;
|
||||||
protected Color traceColor = TRACE_COLOR;
|
protected Color traceColor = TRACE_COLOR;
|
||||||
@@ -565,17 +562,6 @@ public class ProtoBoard extends AbstractComponent<Void> {
|
|||||||
g2d.fillOval(2 * width / 3 - 2 / factor + size / 2 - 1, 2 * width / 3 - 2 / factor + size / 2 - 1, 3, 3);
|
g2d.fillOval(2 * width / 3 - 2 / factor + size / 2 - 1, 2 * width / 3 - 2 / factor + size / 2 - 1, 3, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
|
||||||
public Orientation getOrientation() {
|
|
||||||
if (orientation == null)
|
|
||||||
orientation = Orientation.DEFAULT;
|
|
||||||
return orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrientation(Orientation orientation) {
|
|
||||||
this.orientation = orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EditableProperty(name = "Board Color")
|
@EditableProperty(name = "Board Color")
|
||||||
public Color getBoardColor() {
|
public Color getBoardColor() {
|
||||||
return boardColor;
|
return boardColor;
|
||||||
|
|||||||
+4
-4
@@ -26,14 +26,14 @@ import java.awt.geom.Point2D;
|
|||||||
|
|
||||||
import org.diylc.common.IComponentTransformer;
|
import org.diylc.common.IComponentTransformer;
|
||||||
import org.diylc.common.Orientation;
|
import org.diylc.common.Orientation;
|
||||||
import org.diylc.components.boards.Breadboard;
|
import org.diylc.components.boards.AbstractProtoBoard;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
|
|
||||||
public class BreadboardTransformer implements IComponentTransformer {
|
public class ProtoBoardTransformer implements IComponentTransformer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRotate(IDIYComponent<?> component) {
|
public boolean canRotate(IDIYComponent<?> component) {
|
||||||
return component.getClass().equals(Breadboard.class);
|
return AbstractProtoBoard.class.isAssignableFrom(component.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,7 +55,7 @@ public class BreadboardTransformer implements IComponentTransformer {
|
|||||||
component.setControlPoint(p, index);
|
component.setControlPoint(p, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
Breadboard board = (Breadboard) component;
|
AbstractProtoBoard board = (AbstractProtoBoard) component;
|
||||||
Orientation o = board.getOrientation();
|
Orientation o = board.getOrientation();
|
||||||
int oValue = o.ordinal();
|
int oValue = o.ordinal();
|
||||||
oValue += direction;
|
oValue += direction;
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user