001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.uml.ui.support.viewfactorysupport;
043:
044: import java.awt.Rectangle;
045:
046: import org.netbeans.modules.uml.core.support.umlsupport.ETDeviceRect;
047: import org.netbeans.modules.uml.core.support.umlsupport.IETRect;
048: import org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI;
049: import com.tomsawyer.editor.graphics.TSEGraphics;
050: import com.tomsawyer.graph.TSGraphObject;
051:
052: /**
053: * Base class for those objects that deal with transformations.
054: *
055: * @author Trey Spiva
056: */
057: public abstract class ETTransformOwner extends ETTransform {
058: public abstract TSGraphObject getOwnerGraphObject();
059:
060: /**
061: * Returns the rectangle in diagram logical coordinates that this draw
062: * engine's node occupies
063: */
064: public IETRect getBoundingRect() {
065: return getWinClientRect();
066: }
067:
068: /**
069: * Returns the rectangle in diagram logical coordinates that this draw
070: * engine's node occupies
071: *
072: * @return The logical bounding rectangle.
073: */
074: public IETRect getLogicalBoundingRect() {
075: return getTSAbsoluteRect();
076: }
077:
078: /*
079: * Returns the rectangle in device coordinates, on the owner graph window including zoom.
080: * @return The device bounding rectangle.
081: */
082: public IETRect getDeviceBoundingRect() {
083: IETGraphObject object = this .getObject();
084: return object != null ? new ETDeviceRect(getTransform()
085: .boundsToDevice(object.getBounds())) : null;
086: }
087:
088: /*
089: * Returns the Device Rectangle on the owner graph window graph window including the zoom
090: */
091: public Rectangle getDeviceBoundingRectangle() {
092: IETRect deviceBounds = getDeviceBoundingRect();
093: return deviceBounds != null ? deviceBounds.getRectangle()
094: : null;
095: }
096:
097: /*
098: * Retruns the Device Rectangle on the Given Device
099: */
100: public Rectangle getDeviceBoundingRectangle(TSEGraphics graphics) {
101: IETRect deviceBounds = getDeviceBounds(graphics);
102: return deviceBounds != null ? deviceBounds.getRectangle()
103: : null;
104: }
105:
106: /*
107: * Retruns the Device Rectangle on the Given Device
108: */
109: public Rectangle getDeviceBoundingRectangle(IDrawInfo drawInfo) {
110: IETRect deviceBounds = getDeviceBounds(drawInfo);
111: return deviceBounds != null ? deviceBounds.getRectangle()
112: : null;
113: }
114:
115: /*
116: * Returns the device bounding rectangle, for the given device, may or may not by the GraphWindow.
117: */
118: public IETRect getDeviceBoundingRect(IDrawInfo info) {
119: return this .getDeviceBounds(info);
120: }
121:
122: /*
123: * Returns the device bounding rectangle, for the given device, may or may not by the GraphWindow.
124: */
125: public IETRect getDeviceBoundingRect(TSEGraphics graphics) {
126: return this .getDeviceBounds(graphics);
127: }
128:
129: /*
130: * Returns the device bounding rectangle, for the given device, may or may not by the GraphWindow.
131: */
132: public IETRect getDeviceBounds(TSEGraphics graphics) {
133: IETGraphObject object = getObject();
134: return graphics != null && object != null ? new ETDeviceRect(
135: graphics.getTSTransform().boundsToDevice(
136: object.getBounds())) : null;
137: }
138:
139: /*
140: * Returns the
141: */
142: public IETRect getDeviceBounds(IDrawInfo drawInfo) {
143: return getDeviceBounds(drawInfo.getTSEGraphics());
144: }
145:
146: public void clearTransformOwner() {
147: setGraphObject(null);
148: }
149:
150: public IETGraphObject getObject() {
151: return getOwnerGraphObject() instanceof IETGraphObject ? (IETGraphObject) getOwnerGraphObject()
152: : null;
153: }
154:
155: public IETGraphObjectUI getObjectUI() {
156: IETGraphObject object = getObject();
157: return object != null ? object.getETUI() : null;
158: }
159:
160: }
|