001 /* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2013 005 * Space Science and Engineering Center (SSEC) 006 * University of Wisconsin - Madison 007 * 1225 W. Dayton Street, Madison, WI 53706, USA 008 * https://www.ssec.wisc.edu/mcidas 009 * 010 * All Rights Reserved 011 * 012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and 013 * some McIDAS-V source code is based on IDV and VisAD source code. 014 * 015 * McIDAS-V is free software; you can redistribute it and/or modify 016 * it under the terms of the GNU Lesser Public License as published by 017 * the Free Software Foundation; either version 3 of the License, or 018 * (at your option) any later version. 019 * 020 * McIDAS-V is distributed in the hope that it will be useful, 021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 023 * GNU Lesser Public License for more details. 024 * 025 * You should have received a copy of the GNU Lesser Public License 026 * along with this program. If not, see http://www.gnu.org/licenses. 027 */ 028 029 package edu.wisc.ssec.mcidasv.control; 030 031 032 import ucar.unidata.data.DataChoice; 033 import ucar.unidata.data.grid.GridUtil; 034 035 import ucar.unidata.idv.DisplayConventions; 036 import ucar.unidata.idv.control.ImagePlanViewControl; 037 038 import ucar.unidata.ui.colortable.ColorTableManager; 039 import ucar.unidata.util.GuiUtils; 040 import ucar.unidata.util.Misc; 041 import ucar.unidata.util.Range; 042 import ucar.unidata.util.ColorTable; 043 044 import ucar.visad.display.DisplayableData; 045 import ucar.visad.display.Grid2DDisplayable; 046 047 import visad.*; 048 import visad.VisADException; 049 050 import java.rmi.RemoteException; 051 052 import java.util.List; 053 054 /** 055 * Class for controlling the display of images. 056 * @author IDV Development Group 057 * @version $Revision$ 058 */ 059 public class HydraPlanViewControl extends ImagePlanViewControl { 060 061 /** 062 * Default constructor. Sets the attribute flags used by 063 * this particular <code>PlanViewControl</code> 064 */ 065 public HydraPlanViewControl() { 066 super(); 067 setAttributeFlags(FLAG_COLORTABLE | FLAG_DISPLAYUNIT 068 | FLAG_ZPOSITION | FLAG_SKIPFACTOR); 069 } 070 071 /** 072 * Method to create the particular <code>DisplayableData</code> that 073 * this this instance uses for data depictions. 074 * @return Contour2DDisplayable for this instance. 075 * 076 * @throws VisADException VisAD error 077 * @throws RemoteException RMI error 078 */ 079 protected DisplayableData createPlanDisplay() 080 throws VisADException, RemoteException { 081 Grid2DDisplayable gridDisplay = 082 new Grid2DDisplayable("ImagePlanViewControl_" + ((datachoice != null) 083 ? datachoice.toString() 084 : ""), true); 085 gridDisplay.setTextureEnable(true); 086 /* TODO: Find out why this causes redisplays 087 if (BaseImageControl.EMPTY_IMAGE != null) { 088 gridDisplay.loadData(BaseImageControl.EMPTY_IMAGE); 089 } 090 */ 091 //gridDisplay.setUseRGBTypeForSelect(true); 092 addAttributedDisplayable(gridDisplay); 093 return gridDisplay; 094 } 095 096 /** 097 * Get the initial color table for the data 098 * 099 * @return intitial color table 100 */ 101 protected ColorTable getInitialColorTable() { 102 /* 103 DisplayConventions dc = getDisplayConventions(); 104 List colorNames = dc.getColorNameList(); 105 ColorTable colorTable = super.getInitialColorTable(); 106 if (colorTable.getName().equalsIgnoreCase("default")) { 107 colorTable = dc.getParamColorTable("image"); 108 } 109 */ 110 ColorTableManager ctm = getControlContext().getColorTableManager(); 111 ColorTable colorTable = ctm.getColorTable("ColorTable_AOD"); 112 return colorTable; 113 } 114 115 116 /** 117 * Get whether this display should allow smoothing 118 * @return true if allows smoothing. 119 */ 120 public boolean getAllowSmoothing() { 121 return false; 122 } 123 124 125 /** 126 * Get the initial range for the data and color table. 127 * @return initial range 128 * 129 * @throws RemoteException Java RMI error 130 * @throws VisADException VisAD Error 131 */ 132 protected Range getInitialRange() throws RemoteException, VisADException { 133 Range range = getDisplayConventions().getParamRange(paramName, 134 getDisplayUnit()); 135 System.out.println(paramName); 136 System.out.println(range); 137 //Don't do this for now 138 /** 139 if (range == null) { 140 range = getRangeFromColorTable(); 141 if ((range != null) && (range.getMin() == range.getMax())) { 142 range = null; 143 } 144 } 145 146 if (range == null) { 147 range = getDisplayConventions().getParamRange("image", 148 getDisplayUnit()); 149 } 150 if (range == null) { 151 return new Range(0, 255); 152 } 153 **/ 154 range = new Range((double)0.0, (double)0.99); 155 return range; 156 } 157 158 /** 159 * Get the slice for the display 160 * 161 * @param slice slice to use 162 * 163 * @return slice with skip value applied 164 * 165 * @throws VisADException problem subsetting the slice 166 */ 167 protected FieldImpl getSliceForDisplay(FieldImpl slice) 168 throws VisADException { 169 checkImageSize(slice); 170 if (getSkipValue() <= 0) { 171 return slice; 172 } 173 return GridUtil.subset(slice, getSkipValue() + 1); 174 } 175 176 /** 177 * Return the label that is to be used for the skip widget 178 * This allows derived classes to override this and provide their 179 * own name, 180 * 181 * @return Label used for the line width widget 182 */ 183 public String getSkipWidgetLabel() { 184 return "Pixel Sampling"; 185 } 186 187 }