-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathPadStackList.java
105 lines (93 loc) · 3.55 KB
/
PadStackList.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// translate2geda.java - a utility for converting device definitions
// to geda gschem and PCB compatibl formats
// PadStackList.java interprets BXL padstack definitions
//
// PadStackList.java v1.0
// Copyright (C) 2016 Erich S. Heinzle, a1039181@gmail.com
// see LICENSE-gpl-v2.txt for software license
// see README.txt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// translate2geda Copyright (C) 2016 Erich S. Heinzle a1039181@gmail.com
import java.util.Scanner;
public class PadStackList {
PadStack [] list = new PadStack [10]; // default size
int padStackCount = 0;
public PadStackList() {
}
public PadStackList(String padStackDefinition) {
addPadStacks(padStackDefinition);
}
public void addPadStacks(String definition) { // multi stack def
Scanner multiPadStackDefinition = new Scanner(definition);
boolean inPadStack = false;
String currentLine = "";
String currentPadStack = "";
while (multiPadStackDefinition.hasNext()) {
currentLine = multiPadStackDefinition.nextLine().trim();
if (currentLine.startsWith("PadStack")) {
inPadStack = true;
currentPadStack = currentLine;
} else if (currentLine.startsWith("EndPadStack")) {
currentPadStack = currentPadStack + "\n" + currentLine;
addPadStack(currentPadStack);
inPadStack = false;
} else if (inPadStack) {
currentPadStack = currentPadStack + "\n" + currentLine;
}
}
}
public void addPadStack(String definition) { // single stack def
list[padStackCount] = new PadStack(definition);
padStackCount++;
if (padStackCount == list.length) {
PadStack [] newList = new PadStack [list.length * 2]; // double it
for (int index = 0; index < (list.length -1); index++) {
newList[index] = list[index];
}
list = newList;
}
}
public String GEDAdef(String identifier, long x, long y, int rot) {
String returnFP = "";
for (int index = 0; index < padStackCount; index++) {
if (list[index].is("identifier")) {
returnFP = returnFP + list[index].fpText(x, y, rot);
}
}
return returnFP;
}
public Pad GEDAPad(String BXLPadDef) { //, long x, long y, int rot) {
Pad newGEDAPad = null;
String [] tempPadDef = BXLPadDef.trim().split(" ");
String padIdentifier = "";
for (int index = 0; index < tempPadDef.length - 1; index++) {
if (tempPadDef[index].equals("(PadStyle")) {
padIdentifier = tempPadDef[index + 1].replaceAll("[\"():,]","");
}
}
int index = 0;
// System.out.println("Sought pad identifier in padstack: "
// + padIdentifier);
while ((newGEDAPad == null) && (index < padStackCount)) {
if (list[index].is(padIdentifier)) {
newGEDAPad = list[index].BXLDefToPad(BXLPadDef);
}
index++;
}
return newGEDAPad;
}
}