001/* 002 * $Id: McIDASVLatLonProjection.java,v 1.7 2011/03/24 16:06:32 davep Exp $ 003 * 004 * This file is part of McIDAS-V 005 * 006 * Copyright 2007-2011 007 * Space Science and Engineering Center (SSEC) 008 * University of Wisconsin - Madison 009 * 1225 W. Dayton Street, Madison, WI 53706, USA 010 * https://www.ssec.wisc.edu/mcidas 011 * 012 * All Rights Reserved 013 * 014 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and 015 * some McIDAS-V source code is based on IDV and VisAD source code. 016 * 017 * McIDAS-V is free software; you can redistribute it and/or modify 018 * it under the terms of the GNU Lesser Public License as published by 019 * the Free Software Foundation; either version 3 of the License, or 020 * (at your option) any later version. 021 * 022 * McIDAS-V is distributed in the hope that it will be useful, 023 * but WITHOUT ANY WARRANTY; without even the implied warranty of 024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 025 * GNU Lesser Public License for more details. 026 * 027 * You should have received a copy of the GNU Lesser Public License 028 * along with this program. If not, see http://www.gnu.org/licenses. 029 */ 030 031package edu.wisc.ssec.mcidasv.data; 032 033import ucar.unidata.geoloc.ProjectionImpl; 034import ucar.unidata.geoloc.ProjectionRect; 035import ucar.unidata.geoloc.projection.LatLonProjection; 036 037/** 038 * An extension of <tt>LatLonProjection</tt> that adds properties for 039 * the center point and dimensions of the projection box. Appropriate 040 * getters and setters are added so they will be picked up by the 041 * <tt>ProjectionImpl</tt> and thereby editable by the user. 042 * 043 * @author McIDAS-V Dev Team, UW SSEC 044 * @version $Id: McIDASVLatLonProjection.java,v 1.7 2011/03/24 16:06:32 davep Exp $ 045 */ 046public class McIDASVLatLonProjection extends LatLonProjection { 047 048 private static final long serialVersionUID = -4939597425144220140L; 049 050 public McIDASVLatLonProjection() { 051 this(""); 052 } 053 054 public McIDASVLatLonProjection(String name) { 055 this(name, new ProjectionRect(-180, -90, 180, 90)); 056 } 057 058 public McIDASVLatLonProjection(String name, ProjectionRect mapArea) { 059 addParameter(ATTR_NAME, "McVLatLon"); 060 this.name = name; 061 isLatLon = true; 062 defaultMapArea = mapArea; 063 } 064 065 /** 066 * Get the class name 067 * @return class name 068 */ 069 public String getClassName() { 070 return "McVLatLon"; 071 } 072 073 074 /** 075 * Get the label to be used in the gui for this type of projection 076 * 077 * @return Type label 078 */ 079 public String getProjectionTypeLabel() { 080 return "McV Lat/Lon"; 081 } 082 083 /** 084 * Set the center of the projection box X coord. 085 * @param x 086 */ 087 public void setCenterX(double x) { 088 defaultMapArea.x = x - defaultMapArea.width/2; 089 } 090 091 /** 092 * Set the center of the projection box Y coord. 093 * @param y 094 */ 095 public void setCenterY(double y) { 096 defaultMapArea.y = y - defaultMapArea.height/2; 097 } 098 099 /** 100 * Set the overall width of the projection box. 101 * @param w 102 */ 103 public void setLonWidth(double w) { 104 defaultMapArea.width = w; 105 } 106 107 /** 108 * Set the overall height of the projection box 109 * @param h 110 */ 111 public void setLatHeight(double h) { 112 defaultMapArea.height = h; 113 } 114 115 public double getCenterX() { 116 return defaultMapArea.x + defaultMapArea.width/2; 117 } 118 119 public double getCenterY() { 120 return defaultMapArea.y + defaultMapArea.height/2; 121 } 122 123 public double getLonWidth() { 124 return defaultMapArea.width; 125 } 126 127 public double getLatHeight() { 128 return defaultMapArea.height; 129 } 130 131 /** 132 * Make the default display projection 133 * @return Default display projection 134 */ 135 protected ProjectionImpl makeDefaultProjection() { 136 return new McIDASVLatLonProjection("World", 137 new ProjectionRect(-180., -180., 180., 138 180.)); 139 } 140 141}