001: /*
002: * uDig - User Friendly Desktop Internet GIS client
003: * http://udig.refractions.net
004: * (C) 2004, Refractions Research Inc.
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */
017: package net.refractions.udig.project.ui.internal;
018:
019: import net.refractions.udig.project.IMap;
020: import net.refractions.udig.project.render.IViewportModel;
021: import net.refractions.udig.project.ui.UDIGEditorInput;
022:
023: import org.eclipse.jface.resource.ImageDescriptor;
024: import org.eclipse.ui.IPersistableElement;
025: import org.geotools.geometry.jts.ReferencedEnvelope;
026: import org.geotools.referencing.crs.DefaultGeographicCRS;
027: import org.opengis.referencing.crs.CoordinateReferenceSystem;
028:
029: import com.vividsolutions.jts.geom.Envelope;
030:
031: /**
032: * Provides access for editing maps in uDig
033: *
034: * @author Richard Gould
035: * @since 0.3
036: */
037: public class MapEditorInput extends UDIGEditorInput {
038:
039: public MapEditorInput() {
040:
041: }
042:
043: public MapEditorInput(IMap map) {
044: setProjectElement(map);
045: }
046:
047: /** MUST BE LAT LONG */
048: public Envelope getExtent() {
049: IViewportModel model = getProjectElement().getViewportModel();
050: Envelope bounds = model.getBounds();
051: CoordinateReferenceSystem crs = model.getCRS();
052: ReferencedEnvelope extent = new ReferencedEnvelope(bounds, crs);
053: try {
054: return extent.transform(DefaultGeographicCRS.WGS84, true);
055: } catch (Exception e) {
056: return new Envelope(-180, 180, -90, 90);
057: }
058: }
059:
060: public IMap getProjectElement() {
061: return (IMap) super .getProjectElement();
062: }
063:
064: /**
065: * @see org.eclipse.ui.IEditorInput#exists()
066: */
067: public boolean exists() {
068: return true;
069: }
070:
071: /**
072: * TODO summary sentence for getImageDescriptor ...
073: *
074: * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
075: * @return ImageDescriptor
076: */
077: public ImageDescriptor getImageDescriptor() {
078: return null;
079: }
080:
081: /**
082: * TODO summary sentence for getPersistable ...
083: *
084: * @see org.eclipse.ui.IEditorInput#getPersistable()
085: * @return null
086: */
087: public IPersistableElement getPersistable() {
088: return null;
089: }
090:
091: /**
092: * TODO summary sentence for getToolTipText ...
093: *
094: * @see org.eclipse.ui.IEditorInput#getToolTipText()
095: * @return getName
096: */
097: public String getToolTipText() {
098: return getName();
099: }
100:
101: /**
102: * TODO summary sentence for getAdapter ...
103: *
104: * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
105: * @param adapter
106: * @return null
107: */
108: public Object getAdapter(Class adapter) {
109: return null;
110: }
111:
112: /**
113: * @see org.eclipse.ui.IEditorInput#getName()
114: */
115: public String getName() {
116: return Messages.MapEditorInput_name;
117: }
118:
119: }
|