fixed serialization issues

This commit is contained in:
bancika
2020-09-18 15:58:18 +02:00
parent d55d83c7c3
commit 0fa15650c3
16 changed files with 22 additions and 18 deletions
@@ -98,6 +98,7 @@ public class ProjectFileManager {
}; };
xStream.autodetectAnnotations(true); xStream.autodetectAnnotations(true);
xStream.alias("point", java.awt.geom.Point2D.class); xStream.alias("point", java.awt.geom.Point2D.class);
xStream.alias("point", java.awt.geom.Point2D.Double.class);
xStream.alias("font", java.awt.Font.class); xStream.alias("font", java.awt.Font.class);
xStream.alias("project", Project.class); xStream.alias("project", Project.class);
xStream.aliasPackage("diylc", "org.diylc.components"); xStream.aliasPackage("diylc", "org.diylc.components");
@@ -108,6 +109,7 @@ public class ProjectFileManager {
xStream.registerConverter(new AreaConverter()); xStream.registerConverter(new AreaConverter());
xStream.addImmutableType(Color.class); xStream.addImmutableType(Color.class);
xStream.addImmutableType(java.awt.geom.Point2D.class); xStream.addImmutableType(java.awt.geom.Point2D.class);
xStream.addImmutableType(java.awt.geom.Point2D.Double.class);
xStream.addImmutableType(org.diylc.core.measures.Voltage.class); xStream.addImmutableType(org.diylc.core.measures.Voltage.class);
xStream.addImmutableType(org.diylc.core.measures.Resistance.class); xStream.addImmutableType(org.diylc.core.measures.Resistance.class);
xStream.addImmutableType(org.diylc.core.measures.Capacitance.class); xStream.addImmutableType(org.diylc.core.measures.Capacitance.class);
@@ -59,8 +59,8 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
protected Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0), protected Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0),
new Point2D.Double(DEFAULT_WIDTH.convertToPixels(), DEFAULT_HEIGHT.convertToPixels())}; new Point2D.Double(DEFAULT_WIDTH.convertToPixels(), DEFAULT_HEIGHT.convertToPixels())};
// top-left and bottom-right points // top-left and bottom-right points
protected Point2D firstPoint = new Point2D.Double(); protected Point2D.Double firstPoint = new Point2D.Double();
protected Point2D secondPoint = new Point2D.Double(); protected Point2D.Double secondPoint = new Point2D.Double();
protected Color boardColor = BOARD_COLOR; protected Color boardColor = BOARD_COLOR;
protected Color borderColor = BORDER_COLOR; protected Color borderColor = BORDER_COLOR;
@@ -52,7 +52,7 @@ public class CutLine extends AbstractTransparentComponent<Void> {
private Size width = WIDTH; private Size width = WIDTH;
private Size length = LENGTH; private Size length = LENGTH;
private Color color = COLOR; private Color color = COLOR;
private Point2D point = new Point2D.Double(0, 0); private Point2D.Double point = new Point2D.Double(0, 0);
private OrientationHV orientation = OrientationHV.VERTICAL; private OrientationHV orientation = OrientationHV.VERTICAL;
@Override @Override
@@ -52,7 +52,7 @@ public class Dot extends AbstractComponent<Void> {
private Size size = SIZE; private Size size = SIZE;
private Color color = COLOR; private Color color = COLOR;
private Point2D point = new Point2D.Double(0, 0); private Point2D.Double point = new Point2D.Double(0, 0);
@Override @Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project, public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
@@ -60,7 +60,7 @@ public class Eyelet extends AbstractComponent<String> {
private Size size = SIZE; private Size size = SIZE;
private Size holeSize = HOLE_SIZE; private Size holeSize = HOLE_SIZE;
private Color color = COLOR; private Color color = COLOR;
private Point2D point = new Point2D.Double(0, 0); private Point2D.Double point = new Point2D.Double(0, 0);
private String value = ""; private String value = "";
@Override @Override
@@ -55,7 +55,7 @@ public class SolderPad extends AbstractComponent<Void> {
private Size size = SIZE; private Size size = SIZE;
private Color color = COLOR; private Color color = COLOR;
private Point2D point = new Point2D.Double(0, 0); private Point2D.Double point = new Point2D.Double(0, 0);
private Type type = Type.ROUND; private Type type = Type.ROUND;
private Size holeSize = HOLE_SIZE; private Size holeSize = HOLE_SIZE;
private PCBLayer layer = PCBLayer._1; private PCBLayer layer = PCBLayer._1;
@@ -70,7 +70,7 @@ public class TraceCut extends AbstractComponent<Void> {
private OrientationHV orientation = OrientationHV.VERTICAL; private OrientationHV orientation = OrientationHV.VERTICAL;
private Size holeSpacing = VeroBoard.SPACING; private Size holeSpacing = VeroBoard.SPACING;
protected Point2D point = new Point2D.Double(0, 0); protected Point2D.Double point = new Point2D.Double(0, 0);
@Override @Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project, public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
@@ -58,7 +58,7 @@ public class Turret extends AbstractComponent<String> {
private Size size = SIZE; private Size size = SIZE;
private Size holeSize = HOLE_SIZE; private Size holeSize = HOLE_SIZE;
private Color color = COLOR; private Color color = COLOR;
private Point2D point = new Point2D.Double(0, 0); private Point2D.Double point = new Point2D.Double(0, 0);
private String value = ""; private String value = "";
@Override @Override
@@ -57,7 +57,7 @@ public class BOM extends AbstractComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Size size = DEFAULT_SIZE; private Size size = DEFAULT_SIZE;
private Point2D point = new Point2D.Double(0, 0); private Point2D.Double point = new Point2D.Double(0, 0);
private Color color = COLOR; private Color color = COLOR;
@Override @Override
@@ -50,7 +50,7 @@ public class GroundSymbol extends AbstractComponent<Void> {
public static Color COLOR = Color.black; public static Color COLOR = Color.black;
public static Size SIZE = new Size(0.15d, SizeUnit.in); public static Size SIZE = new Size(0.15d, SizeUnit.in);
private Point2D point = new Point2D.Double(0, 0); private Point2D.Double point = new Point2D.Double(0, 0);
private Color color = COLOR; private Color color = COLOR;
private Size size = SIZE; private Size size = SIZE;
private GroundSymbolType type = GroundSymbolType.DEFAULT; private GroundSymbolType type = GroundSymbolType.DEFAULT;
@@ -57,8 +57,8 @@ public class Image extends AbstractTransparentComponent<Void> {
private static ImageIcon ICON; private static ImageIcon ICON;
private static byte DEFAULT_SCALE = 25; private static byte DEFAULT_SCALE = 25;
private Point2D point = new Point2D.Double(0, 0); private Point2D.Double point = new Point2D.Double(0, 0);
private Point2D secondPoint = null; private Point2D.Double secondPoint = null;
static { static {
String name = "image.png"; String name = "image.png";
@@ -51,7 +51,7 @@ public class Label extends AbstractComponent<String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Point2D point = new Point2D.Double(0, 0); private Point2D.Double point = new Point2D.Double(0, 0);
private String text = DEFAULT_TEXT; private String text = DEFAULT_TEXT;
private Font font = LABEL_FONT; private Font font = LABEL_FONT;
private Color color = LABEL_COLOR; private Color color = LABEL_COLOR;
@@ -55,7 +55,7 @@ public class PCBText extends AbstractComponent<Void> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Point2D point = new Point2D.Double(0, 0); private Point2D.Double point = new Point2D.Double(0, 0);
private String text = DEFAULT_TEXT; private String text = DEFAULT_TEXT;
private Font font = DEFAULT_FONT; private Font font = DEFAULT_FONT;
private Color color = LABEL_COLOR; private Color color = LABEL_COLOR;
@@ -56,8 +56,8 @@ public class WrapLabel extends AbstractComponent<String> {
protected Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0), protected Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0),
new Point2D.Double((int) DEFAULT_WIDTH.convertToPixels(), (int) DEFAULT_HEIGHT.convertToPixels())}; new Point2D.Double((int) DEFAULT_WIDTH.convertToPixels(), (int) DEFAULT_HEIGHT.convertToPixels())};
protected Point2D firstPoint = new Point2D.Double(); protected Point2D.Double firstPoint = new Point2D.Double();
protected Point2D secondPoint = new Point2D.Double(); protected Point2D.Double secondPoint = new Point2D.Double();
private Font font = LABEL_FONT; private Font font = LABEL_FONT;
private Color color = LABEL_COLOR; private Color color = LABEL_COLOR;
@@ -43,8 +43,8 @@ public abstract class AbstractShape extends AbstractTransparentComponent<Void> {
protected String value = ""; protected String value = "";
protected Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0), protected Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0),
new Point2D.Double(DEFAULT_WIDTH.convertToPixels(), DEFAULT_HEIGHT.convertToPixels())}; new Point2D.Double(DEFAULT_WIDTH.convertToPixels(), DEFAULT_HEIGHT.convertToPixels())};
protected Point2D firstPoint = new Point2D.Double(); protected Point2D.Double firstPoint = new Point2D.Double();
protected Point2D secondPoint = new Point2D.Double(); protected Point2D.Double secondPoint = new Point2D.Double();
protected Color color = COLOR; protected Color color = COLOR;
protected Color borderColor = BORDER_COLOR; protected Color borderColor = BORDER_COLOR;
@@ -68,6 +68,8 @@ public class TreeNode {
public String forDisplay() { public String forDisplay() {
if (componentType == null) { if (componentType == null) {
String display = category; String display = category;
if (display == null)
return null;
Matcher match = contributedPattern.matcher(display); Matcher match = contributedPattern.matcher(display);
if (match.find()) { if (match.find()) {
String name = match.group(1); String name = match.group(1);