mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12: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>
|
||||
<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>
|
||||
<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.common.HorizontalAlignment;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.components.transform.BreadboardTransformer;
|
||||
import org.diylc.components.transform.ProtoBoardTransformer;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
@@ -53,8 +51,8 @@ import org.diylc.core.measures.SizeUnit;
|
||||
@ComponentDescriptor(name = "Breadboard", category = "Boards", author = "Branislav Stojkovic",
|
||||
description = "Prototyping solderless breadboard", instanceNamePrefix = "BB",
|
||||
zOrder = IDIYComponent.BOARD, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, enableCache = true, transformer = BreadboardTransformer.class)
|
||||
public class Breadboard extends AbstractComponent<Void> {
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, enableCache = true, transformer = ProtoBoardTransformer.class)
|
||||
public class Breadboard extends AbstractProtoBoard {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -78,7 +76,7 @@ public class Breadboard extends AbstractComponent<Void> {
|
||||
|
||||
protected BreadboardSize breadboardSize;
|
||||
protected PowerStripPosition powerStripPosition;
|
||||
protected Orientation orientation;
|
||||
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
@@ -282,17 +280,6 @@ public class Breadboard extends AbstractComponent<Void> {
|
||||
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")
|
||||
public BreadboardSize getBreadboardSize() {
|
||||
if (breadboardSize == null)
|
||||
|
||||
@@ -31,9 +31,8 @@ import java.awt.geom.Rectangle2D;
|
||||
import org.diylc.awt.StringUtils;
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.Orientation;
|
||||
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.IDIYComponent;
|
||||
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",
|
||||
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,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, enableCache = true)
|
||||
public class ProtoBoard extends AbstractComponent<Void> {
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, enableCache = true, transformer = ProtoBoardTransformer.class)
|
||||
public class ProtoBoard extends AbstractProtoBoard {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -80,9 +79,7 @@ public class ProtoBoard extends AbstractComponent<Void> {
|
||||
private static int[] GAPS = new int[] { 1, 0, 2, 0, 0, 0 };
|
||||
private static int[] SEGMENTS_STARTS = new int[] { 0, 3, 6, 11, 14, 17 };
|
||||
|
||||
protected Point2D point = new Point2D.Double(0, 0);
|
||||
|
||||
protected Orientation orientation;
|
||||
protected Point2D point = new Point2D.Double(0, 0);
|
||||
|
||||
protected Color boardColor = FILL_COLOR;
|
||||
protected Color padColor = PAD_COLOR;
|
||||
@@ -563,17 +560,6 @@ public class ProtoBoard extends AbstractComponent<Void> {
|
||||
g2d.fillOval(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, 6 / 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")
|
||||
|
||||
+4
-4
@@ -26,14 +26,14 @@ import java.awt.geom.Point2D;
|
||||
|
||||
import org.diylc.common.IComponentTransformer;
|
||||
import org.diylc.common.Orientation;
|
||||
import org.diylc.components.boards.Breadboard;
|
||||
import org.diylc.components.boards.AbstractProtoBoard;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public class BreadboardTransformer implements IComponentTransformer {
|
||||
public class ProtoBoardTransformer implements IComponentTransformer {
|
||||
|
||||
@Override
|
||||
public boolean canRotate(IDIYComponent<?> component) {
|
||||
return component.getClass().equals(Breadboard.class);
|
||||
return AbstractProtoBoard.class.isAssignableFrom(component.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +55,7 @@ public class BreadboardTransformer implements IComponentTransformer {
|
||||
component.setControlPoint(p, index);
|
||||
}
|
||||
|
||||
Breadboard board = (Breadboard) component;
|
||||
AbstractProtoBoard board = (AbstractProtoBoard) component;
|
||||
Orientation o = board.getOrientation();
|
||||
int oValue = o.ordinal();
|
||||
oValue += direction;
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user