~ubuntu-branches/ubuntu/jaunty/electric/jaunty

« back to all changes in this revision

Viewing changes to com/sun/electric/tool/user/dialogs/GetInfoOutline.java

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2009-01-08 02:05:08 UTC
  • mfrom: (1.1.2 upstream) (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090108020508-0h3li7zt9mu5gf0i
Tags: 8.08-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
import com.sun.electric.database.change.DatabaseChangeEvent;
27
27
import com.sun.electric.database.change.DatabaseChangeListener;
 
28
import com.sun.electric.database.geometry.EPoint;
28
29
import com.sun.electric.database.text.TextUtils;
29
30
import com.sun.electric.database.topology.NodeInst;
30
31
import com.sun.electric.tool.Client;
47
48
import javax.swing.event.DocumentEvent;
48
49
import javax.swing.event.DocumentListener;
49
50
 
50
 
 
51
51
/**
52
52
 * Class to handle the "GetInfoOutline" dialog.
53
53
 */
94
94
                initComponents();
95
95
        getRootPane().setDefaultButton(apply);
96
96
 
 
97
                // make all text fields select-all when entered
 
98
            EDialog.makeTextFieldSelectAllOnTab(xValue);
 
99
            EDialog.makeTextFieldSelectAllOnTab(yValue);
 
100
 
97
101
        UserInterfaceMain.addDatabaseChangeListener(this);
98
102
        Highlighter.addHighlightListener(this);
99
103
 
125
129
 
126
130
                // must have a node
127
131
        EditWindow wnd = EditWindow.getCurrent();
128
 
                ni = (NodeInst)wnd.getHighlighter().getOneElectricObject(NodeInst.class);
 
132
        if (wnd == null) // not an edit window. Eg 3D ViewWindows
 
133
            return;
 
134
        ni = (NodeInst)wnd.getHighlighter().getOneElectricObject(NodeInst.class);
129
135
                if (ni == null) return;
130
136
 
131
137
                // node must have coordinates
145
151
                // load the coordinates
146
152
                Point2D [] dbSpacePoints = new Point2D[points.length];
147
153
                for(int i=0; i<points.length; i++)
148
 
                        dbSpacePoints[i] = new Point2D.Double(points[i].getX() + ni.getAnchorCenterX(), points[i].getY() + ni.getAnchorCenterY());
 
154
                {
 
155
                        if (points[i] != null)
 
156
                                dbSpacePoints[i] = new Point2D.Double(points[i].getX() + ni.getAnchorCenterX(),
 
157
                                        points[i].getY() + ni.getAnchorCenterY());
 
158
                }
149
159
                loadList(dbSpacePoints, 0);
150
160
                listClick();
151
161
        }
165
175
                changingCoordinates = true;
166
176
                String line = (String)list.getSelectedValue();
167
177
                Point2D clickedValue = getPointValue(line);
168
 
                xValue.setText(TextUtils.formatDouble(clickedValue.getX()));
169
 
                yValue.setText(TextUtils.formatDouble(clickedValue.getY()));
 
178
                if (clickedValue == null)
 
179
                {
 
180
                        xValue.setText("");
 
181
                        yValue.setText("");
 
182
                } else
 
183
                {
 
184
                        xValue.setText(TextUtils.formatDouble(clickedValue.getX()));
 
185
                        yValue.setText(TextUtils.formatDouble(clickedValue.getY()));
 
186
                }
170
187
                changingCoordinates = false;
171
188
        }
172
189
 
173
190
        private String makeLine(int index, Point2D pt)
174
191
        {
 
192
                if (pt == null) return "-------------";
175
193
                return index + ": (" +
176
194
                        TextUtils.formatDouble(pt.getX()) + ", " +
177
195
                        TextUtils.formatDouble(pt.getY()) + ")";
198
216
                {
199
217
                        xV = TextUtils.atof(line.substring(openPos+1, commaPos));
200
218
                        yV = TextUtils.atof(line.substring(commaPos+1, closePos));
 
219
                        return new Point2D.Double(xV, yV);
201
220
                }
202
 
                return new Point2D.Double(xV, yV);
 
221
                return null;
203
222
        }
204
223
 
205
224
        /**
408
427
        private void applyActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_applyActionPerformed
409
428
        {//GEN-HEADEREND:event_applyActionPerformed
410
429
                int newPointCount = model.size();
411
 
                double [] x = new double[newPointCount];
412
 
                double [] y = new double[newPointCount];
 
430
                EPoint [] pts = new EPoint[newPointCount];
413
431
                for(int i=0; i<newPointCount; i++)
414
432
                {
415
433
                        String line = (String)model.get(i);
416
434
                        Point2D pt = getPointValue(line);
417
 
                        x[i] = pt.getX();
418
 
                        y[i] = pt.getY();
 
435
                        if (pt != null)
 
436
                                pts[i] = new EPoint(pt.getX(), pt.getY());
419
437
                }
420
 
                new AdjustOutline(ni, x, y);
 
438
                new AdjustOutline(ni, pts);
421
439
        }//GEN-LAST:event_applyActionPerformed
422
440
 
423
441
        private void duplicatePointActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_duplicatePointActionPerformed
431
449
                for(int i=0; i<newPointCount; i++)
432
450
                {
433
451
                        String line = (String)model.get(i);
434
 
                        if (i == index) newPoints[j++] = getPointValue(line);
 
452
                        if (i == index)
 
453
                        {
 
454
                                Point2D insertPt = getPointValue(line);
 
455
                                if (insertPt != null)
 
456
                                        newPoints[j++] = insertPt;
 
457
                        }
435
458
                        newPoints[j++] = getPointValue(line);
436
459
                }
437
460
 
475
498
        private static class AdjustOutline extends Job
476
499
        {
477
500
                private NodeInst ni;
478
 
                private double [] x, y;
 
501
                private EPoint [] pts;
479
502
 
480
 
                private AdjustOutline(NodeInst ni, double [] x, double [] y)
 
503
                private AdjustOutline(NodeInst ni, EPoint [] pts)
481
504
                {
482
505
                        super("Adjust Outline", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
483
506
                        this.ni = ni;
484
 
                        this.x = x;
485
 
                        this.y = y;
 
507
                        this.pts = pts;
486
508
                        startJob();
487
509
                }
488
510
 
491
513
                 */
492
514
                public boolean doIt() throws JobException
493
515
                {
494
 
                        Point2D [] points = new Point2D[x.length];
495
 
                        for(int i=0; i<x.length; i++)
496
 
                                points[i] = new Point2D.Double(x[i], y[i]);
497
 
                        ni.setTrace(points);
 
516
                        ni.setTrace(pts);
498
517
                        return true;
499
518
                }
500
519
        }