~ubuntu-branches/ubuntu/vivid/electric/vivid

« back to all changes in this revision

Viewing changes to com/sun/electric/tool/user/ExportChanges.java

  • Committer: Package Import Robot
  • Author(s): Markus Koschany
  • Date: 2014-07-08 21:54:23 UTC
  • mfrom: (1.1.6) (3.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20140708215423-4zrgsca1e28tzcoc
Tags: 9.05+dfsg-1
* Imported Upstream version 9.05+dfsg.
* Add signing-key.pgp and check for valid upstream tarballs with uscan's
  pgpsigurlmangle feature.
* Move the package to Git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
package com.sun.electric.tool.user;
23
23
 
24
24
import com.sun.electric.database.EditingPreferences;
 
25
import com.sun.electric.database.geometry.EPoint;
25
26
import com.sun.electric.database.geometry.ERectangle;
26
27
import com.sun.electric.database.geometry.Poly;
 
28
import com.sun.electric.database.geometry.ScreenPoint;
27
29
import com.sun.electric.database.hierarchy.Cell;
28
30
import com.sun.electric.database.hierarchy.EDatabase;
29
31
import com.sun.electric.database.hierarchy.Export;
55
57
import com.sun.electric.util.math.MutableInteger;
56
58
 
57
59
import java.awt.Font;
58
 
import java.awt.Point;
59
60
import java.awt.font.FontRenderContext;
60
61
import java.awt.font.GlyphVector;
61
62
import java.awt.font.LineMetrics;
1593
1594
 
1594
1595
                // determine the height of text in screen space
1595
1596
                int fontSize = EditWindow.getDefaultFontSize();
1596
 
                Point screenOrigin = wnd.databaseToScreen(0, 0);
1597
 
                Point2D thPoint = wnd.screenToDatabase(screenOrigin.x, screenOrigin.y + fontSize);
 
1597
                ScreenPoint screenOrigin = wnd.databaseToScreen(0, 0);
 
1598
                Point2D thPoint = wnd.screenToDatabase(screenOrigin.getX(), screenOrigin.getY() + fontSize);
1598
1599
                double textHeight = Math.abs(thPoint.getY());
1599
1600
 
1600
1601
                // determine the location of the port labels
1694
1695
                        String msg = portList[index].pp.getName();
1695
1696
 
1696
1697
                        // get the connecting-line coordinates in screen space
1697
 
                        Point locationLabel = wnd.databaseToScreen(loc.getX(), loc.getY());
1698
 
                        Point locationPort = wnd.databaseToScreen(portList[index].loc.getX(), portList[index].loc.getY());
 
1698
                        ScreenPoint locationLabel = wnd.databaseToScreen(loc.getX(), loc.getY());
 
1699
                        long locationLabelX = locationLabel.getX(), locationLabelY = locationLabel.getY();
 
1700
                        ScreenPoint locationPort = wnd.databaseToScreen(portList[index].loc.getX(), portList[index].loc.getY());
1699
1701
 
1700
1702
                        // determine the opposite corner of the text
1701
1703
                        GlyphVector v = font.createGlyphVector(frc, msg);
1702
1704
                        Rectangle2D glyphBounds = v.getLogicalBounds();
1703
 
                        int otherX = locationLabel.x + (int)glyphBounds.getWidth();
1704
 
                        int otherY = locationLabel.y - (int)glyphBounds.getHeight();
 
1705
                        long otherX = locationLabelX + (int)glyphBounds.getWidth();
 
1706
                        long otherY = locationLabelY - (int)glyphBounds.getHeight();
1705
1707
                        Point2D locOther = wnd.screenToDatabase(otherX, otherY);
1706
1708
 
1707
1709
                        // if the text is off-screen, adjust it
1708
1710
                        if (otherX > wnd.getSize().width)
1709
1711
                        {
1710
 
                                int offDist = otherX - wnd.getSize().width;
1711
 
                                locationLabel.x -= offDist;
 
1712
                                long offDist = otherX - wnd.getSize().width;
 
1713
                                locationLabelX -= offDist;
1712
1714
                                otherX -= offDist;
1713
 
                                loc = wnd.screenToDatabase(locationLabel.x, locationLabel.y);
 
1715
                                loc = wnd.screenToDatabase(locationLabelX, locationLabelY);
1714
1716
                        }
1715
1717
 
1716
1718
                        // change the attachment point on the label to be closest to the port
1717
 
                        if (Math.abs(locationPort.x-locationLabel.x) > Math.abs(locationPort.x-otherX))
1718
 
                                locationLabel.x = otherX;
1719
 
                        if (Math.abs(locationPort.y-locationLabel.y) > Math.abs(locationPort.y-otherY))
1720
 
                                locationLabel.y = otherY;
 
1719
                        if (Math.abs(locationPort.getX()-locationLabelX) > Math.abs(locationPort.getX()-otherX))
 
1720
                                locationLabelX = otherX;
 
1721
                        if (Math.abs(locationPort.getY()-locationLabelY) > Math.abs(locationPort.getY()-otherY))
 
1722
                                locationLabelY = otherY;
1721
1723
 
1722
1724
                        // convert this shift back to database units for the highlight
1723
 
                        Point2D locLineEnd = wnd.screenToDatabase(locationLabel.x, locationLabel.y);
 
1725
                        Point2D locLineEnd = wnd.screenToDatabase(locationLabelX, locationLabelY);
1724
1726
 
1725
1727
                        // draw the port name
1726
1728
                        highlighter.addMessage(cell, msg, new Point2D.Double(loc.getX()+baselineHor, loc.getY()+baselineVer));
1937
1939
                        {
1938
1940
                                NodeInst ni = it.next();
1939
1941
                                Cell newType = cellsToReplace.get(ni);
1940
 
                                ni.replace(newType, ep, true, true);
 
1942
                                ni.replace(newType, ep, true, true, true);
1941
1943
                                replacements++;
1942
1944
                        }
1943
1945
                        System.out.println("Changed " + replacements + " cell instances");