001/** 002 * Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ 003 * 004 * This file is part of Dicoogle/dicoogle. 005 * 006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Dicoogle/dicoogle 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 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package pt.ua.dicoogle.server; 020import java.util.Collections; 021import java.util.HashMap; 022import java.util.Map; 023 024import org.dcm4che2.data.UID; 025 026/** 027 * 028 * @author Marco Pereira 029 * @author Frederico Silva 030 */ 031public class TransfersStorage { 032 private boolean accepted; 033 private boolean [] TS; 034 035 /* [0] ImplicitVRLittleEndian 036 * [1] ExplicitVRLittleEndian 037 * [2] DeflatedExplicitVRLittleEndian 038 * [3] ExplicitVRBigEndian 039 * [4] JPEGLossless 040 * [5] JPEGLSLossless 041 * [6] JPEGLosslessNonHierarchical14 042 * [7] JPEG2000LosslessOnly 043 * [8] JPEGBaseline1 044 * [9] JPEGExtended24 045 * [10] JPEGLSLossyNearLossless 046 * [11] JPEG2000 047 * [12] RLELossless 048 * [13] MPEG2 049 */ 050 051 public static final Map<Integer, String> globalTransferMap; 052 static { 053 Map<Integer, String> aMap = new HashMap<>(); 054 aMap.put(0, "ImplicitVRLittleEndian"); 055 aMap.put(1, "ExplicitVRLittleEndian"); 056 aMap.put(2, "DeflatedExplicitVRLittleEndian"); 057 aMap.put(3, "ExplicitVRBigEndian"); 058 aMap.put(4, "JPEGLossless"); 059 aMap.put(5, "JPEGLSLossless"); 060 aMap.put(6, "JPEGLosslessNonHierarchical14"); 061 aMap.put(7, "JPEG2000LosslessOnly"); 062 aMap.put(8, "JPEGBaseline1"); 063 aMap.put(9, "JPEGExtended24"); 064 aMap.put(10, "JPEGLSLossyNearLossless"); 065 aMap.put(11, "JPEG2000"); 066 aMap.put(12, "RLELossless"); 067 aMap.put(13, "MPEG2"); 068 globalTransferMap = Collections.unmodifiableMap(aMap); 069 } 070 public TransfersStorage() 071 { 072 int i; 073 accepted = false; 074 TS = new boolean [14]; 075 for(i = 0; i< TS.length; i++) 076 { 077 TS[i] = false; 078 } 079 } 080 081 public void setAccepted(boolean status) 082 { 083 accepted = status; 084 } 085 086 public boolean getAccepted() 087 { 088 return accepted; 089 } 090 091 public int setTS(boolean [] status) 092 { 093 int i; 094 095 if (status.length != 14) 096 { 097 return -1; 098 } 099 100 for(i=0; i<status.length; i++) 101 { 102 TS[i] = status[i]; 103 } 104 105 return 0; 106 } 107 108 public int setTS(boolean status, int index) 109 { 110 int i; 111 112 if(index < 0 || index > 13) 113 { 114 return -1; 115 } 116 TS[index] = status; 117 118 return 0; 119 } 120 121 public boolean[] getTS() 122 { 123 return TS; 124 } 125 126 public void setDefaultSettings() 127 { 128 TS[0] = true; 129 TS[1] = true; 130 TS[4] = true; 131 TS[5] = true; 132 TS[8] = true; 133 accepted = true; 134 135 } 136 137 public String [] getVerboseTS() 138 { 139 int i, count =0; 140 String [] return_value = null; 141 for(i= 0; i<14; i++) 142 { 143 if(TS[i]) 144 { 145 count++; 146 } 147 } 148 if(count > 0) 149 { 150 i = 0; 151 return_value = new String[count]; 152 if (TS[0]) 153 { 154 return_value[i] = UID.ImplicitVRLittleEndian; 155 i++; 156 } 157 if (TS[1]) 158 { 159 return_value[i] = UID.ExplicitVRLittleEndian; 160 i++; 161 } 162 if (TS[2]) 163 { 164 return_value[i] = UID.DeflatedExplicitVRLittleEndian; 165 i++; 166 } 167 if (TS[3]) 168 { 169 return_value[i] = UID.ExplicitVRBigEndian; 170 i++; 171 } 172 if (TS[4]) 173 { 174 return_value[i] = UID.JPEGLossless; 175 i++; 176 } 177 if (TS[5]) 178 { 179 return_value[i] = UID.JPEGLSLossless; 180 i++; 181 } 182 if (TS[6]) 183 { 184 return_value[i] = UID.JPEGLosslessNonHierarchical14; 185 i++; 186 } 187 if (TS[7]) 188 { 189 return_value[i] = UID.JPEG2000LosslessOnly; 190 i++; 191 } 192 if (TS[8]) 193 { 194 return_value[i] = UID.JPEGBaseline1; 195 i++; 196 } 197 if (TS[9]) 198 { 199 return_value[i] = UID.JPEGExtended24; 200 i++; 201 } 202 if (TS[10]) 203 { 204 return_value[i] = UID.JPEGLSLossyNearLossless; 205 i++; 206 } 207 if (TS[11]) 208 { 209 return_value[i] = UID.JPEG2000; 210 i++; 211 } 212 if (TS[12]) 213 { 214 return_value[i] = UID.RLELossless; 215 i++; 216 } 217 if (TS[13]) 218 { 219 return_value[i] = UID.MPEG2; 220 i++; 221 } 222 } 223 return return_value; 224 } 225}