37
37
* This class is the superclass for the Electric classes that have visual
38
38
* bounds on the screen, specifically NodeInst and ArcInst.
40
public abstract class Geometric extends ElectricObject implements RTBounds
42
// ------------------------------- private data ------------------------------
44
/** Cell containing this Geometric object. */ protected final Cell parent;
46
// ------------------------ private and protected methods--------------------
49
* The constructor is only called from subclasses.
51
protected Geometric(Cell parent) {
40
public abstract class Geometric extends ElectricObject implements RTBounds {
41
// ------------------------ private and protected methods--------------------
43
* The constructor is only called from subclasses.
45
protected Geometric() {
56
* Method to describe this Geometric as a string.
57
* This method is overridden by NodeInst and ArcInst.
49
* Method to describe this Geometric as a string.
50
* This method is overridden by NodeInst and ArcInst.
58
51
* @param withQuotes to wrap description between quotes
59
* @return a description of this Geometric as a string.
61
public String describe(boolean withQuotes) { return "?"; }
64
* Routing to check whether changing of this cell allowed or not.
65
* By default checks whole database change. Overriden in subclasses.
67
public void checkChanging() { if (parent != null) parent.checkChanging(); }
70
* Method to determine the appropriate Cell associated with this ElectricObject.
71
* @return the appropriate Cell associated with this ElectricicObject.
73
public Cell whichCell() { return parent; }
76
* Method to determine which page of a multi-page schematic this Geometric is on.
77
* @return the page number (0-based).
79
public int whichMultiPage()
82
if (parent.isMultiPage())
84
double cY = getBounds().getCenterY();
85
pageNo = (int)((cY+Cell.FrameDescription.MULTIPAGESEPARATION/2) / Cell.FrameDescription.MULTIPAGESEPARATION);
91
* Returns database to which this Geometric belongs.
92
* Some objects are not in database, for example Geometrics in PaletteFrame.
93
* Method returns null for non-database objects.
94
* @return database to which this Geometric belongs.
96
public EDatabase getDatabase() { return parent != null ? parent.getDatabase() : null; }
99
* Method to write a description of this Geometric.
100
* Displays the description in the Messages Window.
102
public void getInfo()
104
Rectangle2D visBounds = getBounds();
105
System.out.println(" Bounds: (" + visBounds.getCenterX() + "," + visBounds.getCenterY() + "), size: " +
106
visBounds.getWidth() + "x" + visBounds.getHeight());
107
System.out.println(" Parent: " + parent);
52
* @return a description of this Geometric as a string.
54
public abstract String describe(boolean withQuotes);
57
* Method to determine which page of a multi-page schematic this Geometric is on.
58
* @return the page number (0-based).
60
public int whichMultiPage() {
62
if (getParent().isMultiPage()) {
63
double cY = getBounds().getCenterY();
64
pageNo = (int) ((cY + Cell.FrameDescription.MULTIPAGESEPARATION / 2) / Cell.FrameDescription.MULTIPAGESEPARATION);
70
* Method to write a description of this Geometric.
71
* Displays the description in the Messages Window.
74
public void getInfo() {
75
Rectangle2D visBounds = getBounds();
76
System.out.println(" Bounds: (" + visBounds.getCenterX() + "," + visBounds.getCenterY() + "), size: "
77
+ visBounds.getWidth() + "x" + visBounds.getHeight());
78
System.out.println(" Parent: " + getParent());
111
// ------------------------ public methods -----------------------------
114
* Method to return the Cell that contains this Geometric object.
115
* @return the Cell that contains this Geometric object.
117
public Cell getParent() { return parent; }
82
// ------------------------ public methods -----------------------------
84
* Method to return the Cell that contains this Geometric object.
85
* @return the Cell that contains this Geometric object.
87
public Cell getParent() {
88
Topology topology = getTopology();
89
return topology != null ? topology.cell : null;
93
* Method to return the Cell Topology that contains this Geometric object.
94
* @return the Topology that contains this Geometric object.
96
public abstract Topology getTopology();
120
100
* Returns the polygons that describe this Geometric.
123
103
* These Polys include displayable variables on the Geometric.
125
105
public abstract Iterator<Poly> getShape(Poly.Builder polyBuilder);
128
* Method to return the bounds of this Geometric.
129
* @return the bounds of this Geometric.
131
public abstract Rectangle2D getBounds();
134
* Method to fill the bounds of this Geometric in lambda units into specified Rectangle2D.
108
* Method to return the bounds of this Geometric.
109
* @return the bounds of this Geometric.
111
public abstract Rectangle2D getBounds();
114
* Method to fill the bounds of this Geometric in lambda units into specified Rectangle2D.
135
115
* If specified Rectangle2D is null, a new Rectangle2D.Double is allocated.
136
116
* @param r rectangle to fill
137
* @return the bounds of this Geometric.
117
* @return the bounds of this Geometric.
139
119
public Rectangle2D getLambdaBounds(Rectangle2D r) {
140
if (r == null) r = new Rectangle2D.Double();
121
r = new Rectangle2D.Double();
141
123
r.setRect(getBounds());
146
* Method to fill the bounds of this Geometric in grid units into specified Rectangle2D.
128
* Method to fill the bounds of this Geometric in grid units into specified Rectangle2D.
147
129
* If specified Rectangle2D is null, a new Rectangle2D.Double is allocated.
148
130
* @param r rectangle to fill
149
* @return the bounds of this Geometric.
131
* @return the bounds of this Geometric.
151
133
public Rectangle2D getGridBounds(Rectangle2D r) {
152
if (r == null) r = new Rectangle2D.Double();
135
r = new Rectangle2D.Double();
153
137
Rectangle2D bounds = getBounds();
154
138
long minX = DBMath.lambdaToGrid(bounds.getMinX());
155
139
long minY = DBMath.lambdaToGrid(bounds.getMinY());
163
* Method to return the center X coordinate of this Geometric.
164
* @return the center X coordinate of this Geometric.
166
public double getTrueCenterX() { return getBounds().getCenterX(); }
169
* Method to return the center Y coordinate of this Geometric.
170
* @return the center Y coordinate of this Geometric.
172
public double getTrueCenterY() { return getBounds().getCenterY(); }
175
* Method to return the center coordinate of this Geometric.
176
* @return the center coordinate of this Geometric.
178
public Point2D getTrueCenter() { return new Point2D.Double(getTrueCenterX(), getTrueCenterY()); }
147
* Method to return the center X coordinate of this Geometric.
148
* @return the center X coordinate of this Geometric.
150
public double getTrueCenterX() {
151
return getBounds().getCenterX();
155
* Method to return the center Y coordinate of this Geometric.
156
* @return the center Y coordinate of this Geometric.
158
public double getTrueCenterY() {
159
return getBounds().getCenterY();
163
* Method to return the center coordinate of this Geometric.
164
* @return the center coordinate of this Geometric.
166
public Point2D getTrueCenter() {
167
return new Point2D.Double(getTrueCenterX(), getTrueCenterY());
181
171
* Method to tell whether this Geometric object is connected directly to another