001: /*
002: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
003: * for visualizing and manipulating spatial features with geometry and attributes.
004: *
005: * Copyright (C) 2003 Vivid Solutions
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: *
021: * For more information, contact:
022: *
023: * Vivid Solutions
024: * Suite #1A
025: * 2328 Government Street
026: * Victoria BC V8T 5G5
027: * Canada
028: *
029: * (250)385-6040
030: * www.vividsolutions.com
031: */
032:
033: package com.vividsolutions.jump.plugin.edit;
034:
035: import java.util.*;
036: import java.awt.*;
037: import java.awt.event.*;
038:
039: import javax.swing.*;
040: import com.vividsolutions.jump.I18N;
041:
042: import com.vividsolutions.jts.geom.*;
043: import com.vividsolutions.jump.geom.*;
044: import com.vividsolutions.jump.util.ColorUtil;
045: import com.vividsolutions.jump.feature.*;
046: import com.vividsolutions.jump.task.*;
047: import com.vividsolutions.jump.workbench.WorkbenchContext;
048: import com.vividsolutions.jump.workbench.model.*;
049: import com.vividsolutions.jump.workbench.plugin.*;
050: import com.vividsolutions.jump.workbench.ui.*;
051:
052: /**
053: * Computes a translation, scale and rotation
054: * from two vectors (each with a start and end point)
055: *
056: * @author Martin Davis
057: * @version 1.0
058: */
059: abstract class TransRotScaleBuilder {
060: protected double originX = 0.0;
061: protected double originY = 0.0;
062: protected double scaleX = 0.0;
063: protected double scaleY = 0.0;
064: protected double dx = 0.0;
065: protected double dy = 0.0;
066: protected double angle = 0.0; // in degrees
067:
068: public TransRotScaleBuilder(Coordinate[] srcPts,
069: Coordinate[] destPts) {
070: compute(srcPts, destPts);
071: }
072:
073: protected abstract void compute(Coordinate[] srcPts,
074: Coordinate[] destPts);
075:
076: public double getOriginX() {
077: return originX;
078: }
079:
080: public double getOriginY() {
081: return originY;
082: }
083:
084: public boolean isScale() {
085: return scaleX > 0.0;
086: }
087:
088: public double getScaleX() {
089: return scaleX;
090: }
091:
092: public double getScaleY() {
093: return scaleY;
094: }
095:
096: public boolean isTranslate() {
097: return dx != 0.0 | dy != 0.0;
098: }
099:
100: public double getTranslateX() {
101: return dx;
102: }
103:
104: public double getTranslateY() {
105: return dy;
106: }
107:
108: public double getRotationAngle() {
109: return angle;
110: }
111:
112: }
|