~ubuntu-branches/ubuntu/natty/electric/natty

« back to all changes in this revision

Viewing changes to com/sun/electric/database/topology/Geometric.java

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2010-01-09 16:26:04 UTC
  • mfrom: (1.1.4 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100109162604-1ypvmy8ijmlc6oq7
Tags: 8.10-1
* New upstream version.
* debian/control
  - Add libjava3d-java and quilt build dependencies.
  - Update standards version to 3.8.3.
  - Add libjava3d-java as recommends to binary package.
* debian/rules
  - Use quilt patch system instead of simple patchsys.
  - Add java3d related jar files to DEB_JARS.
* debian/patches/*
  - Update as per current upstream source. Convert to quilt.
* debian/ant.properties
  - Do not disable 3D plugin anymore.
  - Use new property to disable compilation of OS X related classes.
* debian/wrappers/electric
  - Add java3d related jar files to runtime classpath.
* debian/README.source
  - Change text to the appropriate one for quilt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 * This class is the superclass for the Electric classes that have visual
38
38
 * bounds on the screen, specifically NodeInst and ArcInst.
39
39
 */
40
 
public abstract class Geometric extends ElectricObject implements RTBounds
41
 
{
42
 
        // ------------------------------- private data ------------------------------
43
 
 
44
 
        /** Cell containing this Geometric object. */                   protected final Cell parent;
45
 
 
46
 
        // ------------------------ private and protected methods--------------------
47
 
 
48
 
        /**
49
 
         * The constructor is only called from subclasses.
50
 
         */
51
 
        protected Geometric(Cell parent) {
52
 
        this.parent = parent;
 
40
public abstract class Geometric extends ElectricObject implements RTBounds {
 
41
    // ------------------------ private and protected methods--------------------
 
42
    /**
 
43
     * The constructor is only called from subclasses.
 
44
     */
 
45
    protected Geometric() {
53
46
    }
54
47
 
55
 
        /**
56
 
         * Method to describe this Geometric as a string.
57
 
         * This method is overridden by NodeInst and ArcInst.
 
48
    /**
 
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.
60
 
         */
61
 
        public String describe(boolean withQuotes) { return "?"; }
62
 
 
63
 
        /**
64
 
         * Routing to check whether changing of this cell allowed or not.
65
 
         * By default checks whole database change. Overriden in subclasses.
66
 
         */
67
 
        public void checkChanging() { if (parent != null) parent.checkChanging(); }
68
 
 
69
 
        /**
70
 
         * Method to determine the appropriate Cell associated with this ElectricObject.
71
 
         * @return the appropriate Cell associated with this ElectricicObject.
72
 
         */
73
 
        public Cell whichCell() { return parent; }
74
 
 
75
 
        /**
76
 
         * Method to determine which page of a multi-page schematic this Geometric is on.
77
 
         * @return the page number (0-based).
78
 
         */
79
 
        public int whichMultiPage()
80
 
        {
81
 
                int pageNo = 0;
82
 
                if (parent.isMultiPage())
83
 
                {
84
 
                        double cY = getBounds().getCenterY();
85
 
                        pageNo = (int)((cY+Cell.FrameDescription.MULTIPAGESEPARATION/2) / Cell.FrameDescription.MULTIPAGESEPARATION);
86
 
                }
87
 
                return pageNo;
88
 
        }
89
 
 
90
 
        /**
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.
95
 
         */
96
 
        public EDatabase getDatabase() { return parent != null ? parent.getDatabase() : null; }
97
 
 
98
 
        /**
99
 
         * Method to write a description of this Geometric.
100
 
         * Displays the description in the Messages Window.
101
 
         */
102
 
        public void getInfo()
103
 
        {
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.
 
53
     */
 
54
    public abstract String describe(boolean withQuotes);
 
55
 
 
56
    /**
 
57
     * Method to determine which page of a multi-page schematic this Geometric is on.
 
58
     * @return the page number (0-based).
 
59
     */
 
60
    public int whichMultiPage() {
 
61
        int pageNo = 0;
 
62
        if (getParent().isMultiPage()) {
 
63
            double cY = getBounds().getCenterY();
 
64
            pageNo = (int) ((cY + Cell.FrameDescription.MULTIPAGESEPARATION / 2) / Cell.FrameDescription.MULTIPAGESEPARATION);
 
65
        }
 
66
        return pageNo;
 
67
    }
 
68
 
 
69
    /**
 
70
     * Method to write a description of this Geometric.
 
71
     * Displays the description in the Messages Window.
 
72
     */
 
73
    @Override
 
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());
108
79
        super.getInfo();
109
 
        }
110
 
 
111
 
        // ------------------------ public methods -----------------------------
112
 
 
113
 
        /**
114
 
         * Method to return the Cell that contains this Geometric object.
115
 
         * @return the Cell that contains this Geometric object.
116
 
         */
117
 
        public Cell getParent() { return parent; }
 
80
    }
 
81
 
 
82
    // ------------------------ public methods -----------------------------
 
83
    /**
 
84
     * Method to return the Cell that contains this Geometric object.
 
85
     * @return the Cell that contains this Geometric object.
 
86
     */
 
87
    public Cell getParent() {
 
88
        Topology topology = getTopology();
 
89
        return topology != null ? topology.cell : null;
 
90
    }
 
91
 
 
92
    /**
 
93
     * Method to return the Cell Topology that contains this Geometric object.
 
94
     * @return the Topology that contains this Geometric object.
 
95
     */
 
96
    public abstract Topology getTopology();
 
97
 
118
98
 
119
99
    /**
120
100
     * Returns the polygons that describe this Geometric.
123
103
     * These Polys include displayable variables on the Geometric.
124
104
     */
125
105
    public abstract Iterator<Poly> getShape(Poly.Builder polyBuilder);
126
 
    
127
 
        /**
128
 
         * Method to return the bounds of this Geometric.
129
 
         * @return the bounds of this Geometric.
130
 
         */
131
 
        public abstract Rectangle2D getBounds();
132
 
    
133
 
        /**
134
 
         * Method to fill the bounds of this Geometric in lambda units into specified Rectangle2D.
 
106
 
 
107
    /**
 
108
     * Method to return the bounds of this Geometric.
 
109
     * @return the bounds of this Geometric.
 
110
     */
 
111
    public abstract Rectangle2D getBounds();
 
112
 
 
113
    /**
 
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.
138
 
         */
 
117
     * @return the bounds of this Geometric.
 
118
     */
139
119
    public Rectangle2D getLambdaBounds(Rectangle2D r) {
140
 
        if (r == null) r = new Rectangle2D.Double();
 
120
        if (r == null) {
 
121
            r = new Rectangle2D.Double();
 
122
        }
141
123
        r.setRect(getBounds());
142
124
        return r;
143
125
    }
144
126
 
145
 
        /**
146
 
         * Method to fill the bounds of this Geometric in grid units into specified Rectangle2D.
 
127
    /**
 
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.
150
 
         */
 
131
     * @return the bounds of this Geometric.
 
132
     */
151
133
    public Rectangle2D getGridBounds(Rectangle2D r) {
152
 
        if (r == null) r = new Rectangle2D.Double();
 
134
        if (r == null) {
 
135
            r = new Rectangle2D.Double();
 
136
        }
153
137
        Rectangle2D bounds = getBounds();
154
138
        long minX = DBMath.lambdaToGrid(bounds.getMinX());
155
139
        long minY = DBMath.lambdaToGrid(bounds.getMinY());
159
143
        return r;
160
144
    }
161
145
 
162
 
        /**
163
 
         * Method to return the center X coordinate of this Geometric.
164
 
         * @return the center X coordinate of this Geometric.
165
 
         */
166
 
        public double getTrueCenterX() { return getBounds().getCenterX(); }
167
 
 
168
 
        /**
169
 
         * Method to return the center Y coordinate of this Geometric.
170
 
         * @return the center Y coordinate of this Geometric.
171
 
         */
172
 
        public double getTrueCenterY() { return getBounds().getCenterY(); }
173
 
 
174
 
        /**
175
 
         * Method to return the center coordinate of this Geometric.
176
 
         * @return the center coordinate of this Geometric.
177
 
         */
178
 
        public Point2D getTrueCenter() { return new Point2D.Double(getTrueCenterX(), getTrueCenterY()); }
 
146
    /**
 
147
     * Method to return the center X coordinate of this Geometric.
 
148
     * @return the center X coordinate of this Geometric.
 
149
     */
 
150
    public double getTrueCenterX() {
 
151
        return getBounds().getCenterX();
 
152
    }
 
153
 
 
154
    /**
 
155
     * Method to return the center Y coordinate of this Geometric.
 
156
     * @return the center Y coordinate of this Geometric.
 
157
     */
 
158
    public double getTrueCenterY() {
 
159
        return getBounds().getCenterY();
 
160
    }
 
161
 
 
162
    /**
 
163
     * Method to return the center coordinate of this Geometric.
 
164
     * @return the center coordinate of this Geometric.
 
165
     */
 
166
    public Point2D getTrueCenter() {
 
167
        return new Point2D.Double(getTrueCenterX(), getTrueCenterY());
 
168
    }
179
169
 
180
170
    /**
181
171
     * Method to tell whether this Geometric object is connected directly to another