Changeset 1053 for branches/bioformats-omero
- Timestamp:
- 10/31/06 15:49:07 (2 years ago)
- Location:
- branches/bioformats-omero/src/ome/formats
- Files:
-
- 9 modified
-
OMEROMetadataStore.java (modified) (5 diffs)
-
importer/FileQueueHandler.java (modified) (5 diffs)
-
importer/FileQueueTable.java (modified) (3 diffs)
-
importer/ImportContainer.java (modified) (1 diff)
-
importer/ImportDialog.java (modified) (13 diffs)
-
importer/ImportFixture.java (modified) (2 diffs)
-
importer/ImportHandler.java (modified) (3 diffs)
-
importer/ImportLibrary.java (modified) (1 diff)
-
importer/Main.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/bioformats-omero/src/ome/formats/OMEROMetadataStore.java
r1043 r1053 31 31 32 32 import java.util.ArrayList; 33 import java.util.HashSet;34 33 import java.util.List; 35 import java.util.Map;36 import java.util.Properties;37 import java.util.Set;38 34 39 35 import loci.formats.FormatReader; 40 36 import loci.formats.MetadataStore; 41 37 import loci.formats.MetadataStoreException; 42 import ome.api.IPojos;43 38 import ome.api.IQuery; 44 39 import ome.api.IUpdate; … … 55 50 import ome.model.core.PixelsDimensions; 56 51 import ome.model.core.PlaneInfo; 57 import ome.model.display.ChannelBinding;58 import ome.model.display.Color;59 import ome.model.display.QuantumDef;60 import ome.model.display.RenderingDef;61 52 import ome.model.enums.AcquisitionMode; 62 53 import ome.model.enums.DimensionOrder; 63 import ome.model.enums.Family;64 54 import ome.model.enums.PhotometricInterpretation; 65 55 import ome.model.enums.PixelsType; 66 import ome.model.enums.RenderingModel;67 56 import ome.model.meta.Experimenter; 68 57 import ome.model.stats.StatsInfo; 69 import ome.parameters.Filter;70 58 import ome.parameters.Parameters; 71 59 import ome.system.Login; 72 60 import ome.system.Server; 73 61 import ome.system.ServiceFactory; 74 import ome.util.builders.PojoOptions;75 62 76 63 import org.apache.commons.logging.Log; … … 215 202 216 203 /** 217 * Creates a set of channel bindings for the current active pixels set.218 *219 * @return list of channel bindings.220 */221 @SuppressWarnings("unchecked")222 private List<ChannelBinding> buildChannelBindings()223 {224 log.debug("Building channel bindings");225 // The actual channel bindings we are returning226 List<ChannelBinding> channelBindings = new ArrayList<ChannelBinding>();227 228 List<Channel> channels = pixels.getChannels();229 int i = 0;230 for (Object o : channels)231 {232 Channel channel = (Channel) o;233 StatsInfo stats = channel.getStatsInfo();234 Family family = (Family) getEnumeration(Family.class, "linear");235 236 ChannelBinding channelBinding = new ChannelBinding();237 channelBinding.setFamily(family);238 channelBinding.setCoefficient(new Double(1));239 // FIXME: Lost of precision, downcast from Double to Float240 channelBinding.setInputStart(new Float(stats.getGlobalMin()));241 channelBinding.setInputEnd(new Float(stats.getGlobalMax()));242 channelBinding.setActive(i == 0 ? true : false);243 channelBinding.setNoiseReduction(false);244 channelBinding.setColor(getColor(i));245 246 channelBindings.add(channelBinding);247 i++;248 }249 250 return channelBindings;251 }252 253 private Color getColor(Integer index)254 {255 switch (index)256 {257 case 0:258 {259 Color c = new Color();260 c.setRed(255);261 c.setGreen(0);262 c.setBlue(0);263 c.setAlpha(255);264 return c;265 }266 case 1:267 {268 Color c = new Color();269 c.setRed(0);270 c.setGreen(255);271 c.setBlue(0);272 c.setAlpha(255);273 return c;274 }275 default:276 {277 Color c = new Color();278 c.setRed(0);279 c.setGreen(0);280 c.setBlue(255);281 c.setAlpha(255);282 return c;283 }284 }285 }286 287 /**288 204 * Retrieves a server side enumeration. 289 205 * … … 372 288 PixelsDimensions dimensions = new PixelsDimensions(); 373 289 374 if (pixelSizeX == 0)375 { 376 log.warn("pixelSizeX is 0.0f, setting to 1.0f");290 if (pixelSizeX <= 0) 291 { 292 log.warn("pixelSizeX is <= 0.0f, setting to 1.0f"); 377 293 pixelSizeX = 1.0f; 378 294 } 379 295 380 if (pixelSizeY == 0)381 { 382 log.warn("pixelSizeY is 0.0f, setting to 1.0f");296 if (pixelSizeY <= 0) 297 { 298 log.warn("pixelSizeY is <= 0.0f, setting to 1.0f"); 383 299 pixelSizeY = 1.0f; 384 300 } 385 301 386 if (pixelSizeZ == 0)387 { 388 log.warn("pixelSizeZ is 0.0f, setting to 1.0f");302 if (pixelSizeZ <= 0) 303 { 304 log.warn("pixelSizeZ is <= 0.0f, setting to 1.0f"); 389 305 pixelSizeZ = 1.0f; 390 306 } … … 615 531 * @see loci.formats.MetadataStore#setDefaultDisplaySettings(java.lang.Integer) 616 532 */ 617 public void setDefaultDisplaySettings(Integer i) 618 { 619 //return; 620 // The default rendering definition settings 621 RenderingDef renderingDef = new RenderingDef(); 622 renderingDef.setDefaultZ(pixels.getSizeZ() / 2); 623 renderingDef.setDefaultT(0); 624 renderingDef.setModel((RenderingModel) getEnumeration( 625 RenderingModel.class, "greyscale")); 626 627 // Quantization settings 628 QuantumDef quantumDef = new QuantumDef(); 629 quantumDef.setCdStart(0); 630 quantumDef.setCdEnd(255); 631 quantumDef.setBitResolution(255); 632 renderingDef.setQuantization(quantumDef); 633 634 // Build and set the channel bindings 635 List<ChannelBinding> channelBindings = buildChannelBindings(); 636 renderingDef.setWaveRendering(channelBindings); 637 638 // Now link the rendering def to the pixel set 639 pixels.addRenderingDef(renderingDef); 640 } 533 public void setDefaultDisplaySettings(Integer i) {} 641 534 642 535 /** -
branches/bioformats-omero/src/ome/formats/importer/FileQueueHandler.java
r1043 r1053 40 40 41 41 import javax.swing.JFrame; 42 import javax.swing.JOptionPane; 42 43 import javax.swing.JPanel; 43 44 import javax.swing.JSplitPane; … … 117 118 try { 118 119 store = viewer.loginHandler.getMetadataStore(); 119 } catch (Exception ex) { return; } 120 } catch (Exception ex) { 121 ex.printStackTrace(); 122 return; 123 } 120 124 121 125 if (store != null) … … 127 131 128 132 addFileToQueue(file, dialog.dataset, 129 dialog.dataset.getName(), dialog.project.getName()); 133 dialog.dataset.getName(), dialog.project.getName(), 134 dialog.useFullPath, dialog.numOfDirectories); 135 } else { 136 JOptionPane.showMessageDialog(viewer, 137 "Due to an error the application is unable to \n" + 138 "retrieve an OMEROMetadataStore and can't continue"); 130 139 } 131 140 } catch (Exception ex) { … … 170 179 addFileToQueue(f, dialog.dataset, 171 180 dialog.dataset.getName(), 172 dialog.project.getName()); 181 dialog.project.getName(), 182 dialog.useFullPath, 183 dialog.numOfDirectories); 173 184 } 185 } else { 186 JOptionPane.showMessageDialog(viewer, 187 "Due to an error the application is unable to \n" + 188 "retrieve an OMEROMetadataStore and can't continue"); 174 189 } 175 190 } catch (Exception ex) { … … 237 252 238 253 239 private void addFileToQueue(File file, Dataset dataset, String dName, String project) 254 private void addFileToQueue(File file, Dataset dataset, String dName, 255 String project, Boolean useFullPath, int numOfDirectories) 240 256 { 241 257 Vector row = new Vector(); 242 258 243 row.add(file); 259 String imageName = getImageName(file, useFullPath, numOfDirectories); 260 261 row.add(imageName); 244 262 row.add(project + "/" + dName); 245 263 row.add("added"); 246 264 row.add(dataset); 265 row.add(file); 247 266 qTable.table.addRow(row); 248 267 if (qTable.table.getRowCount() == 1) 249 268 qTable.importBtn.setEnabled(true); 269 } 270 271 private String getImageName(File file, Boolean useFullPath, int numOfDirectories) 272 { 273 if (useFullPath == true) return file.toString(); 274 else if (numOfDirectories == 0) return file.getName(); 275 else return file.getName(); 276 } 277 278 279 private String[] splitDirectories(File file) 280 { 281 String[] fields = file.getPath().split(File.pathSeparator); 282 283 return fields; 250 284 } 251 285 -
branches/bioformats-omero/src/ome/formats/importer/FileQueueTable.java
r1043 r1053 140 140 .addListSelectionListener(listener); 141 141 142 // Hide 3 and 4th columns 142 143 TableColumnModel tcm = queue.getColumnModel(); 143 TableColumn column = tcm.getColumn(3); 144 tcm.removeColumn(column); 144 TableColumn datasetColumn = tcm.getColumn(3); 145 tcm.removeColumn(datasetColumn); 146 TableColumn pathColumn = tcm.getColumn(3); 147 tcm.removeColumn(pathColumn); 148 145 149 146 150 // Add the table to the scollpane … … 217 221 for (int i = 0; i < num; i++) 218 222 { 219 File file = new File(table.getValueAt(i, 0).toString());220 223 try { 224 File file = new File(table.getValueAt(i, 4).toString()); 221 225 Dataset dataset = (Dataset) table.getValueAt(i, 3); 222 fads[i] = new ImportContainer(file, dataset); } 226 String imageName = table.getValueAt(i, 0).toString(); 227 fads[i] = new ImportContainer(file, dataset, imageName); } 223 228 catch (ArrayIndexOutOfBoundsException e) { 224 229 e.printStackTrace(); … … 253 258 254 259 private static final long serialVersionUID = 1L; 255 private String[] columnNames = {"Files in Queue", "Project/Dataset", "Status", "DatasetNum" };260 private String[] columnNames = {"Files in Queue", "Project/Dataset", "Status", "DatasetNum", "Path"}; 256 261 257 262 public void tableChanged(TableModelEvent arg0) { } -
branches/bioformats-omero/src/ome/formats/importer/ImportContainer.java
r1043 r1053 10 10 public File file; 11 11 public Dataset dataset; 12 public String imageName; 12 13 13 ImportContainer(File file, Dataset dataset )14 ImportContainer(File file, Dataset dataset, String imageName) 14 15 { 15 16 this.file = file; 16 17 this.dataset = dataset; 18 this.imageName = imageName; 17 19 } 18 20 } -
branches/bioformats-omero/src/ome/formats/importer/ImportDialog.java
r1020 r1053 35 35 import java.awt.GridBagLayout; 36 36 import java.awt.Insets; 37 import java.awt.Toolkit; 37 38 import java.awt.event.ActionEvent; 38 39 import java.awt.event.ActionListener; 40 import java.text.NumberFormat; 41 import java.text.ParseException; 39 42 import java.util.List; 43 import java.util.Locale; 40 44 import java.util.prefs.Preferences; 41 45 46 import javax.swing.BorderFactory; 47 import javax.swing.ButtonGroup; 42 48 import javax.swing.JButton; 43 49 import javax.swing.JComboBox; … … 45 51 import javax.swing.JFrame; 46 52 import javax.swing.JLabel; 47 import javax.swing.JPasswordField; 53 import javax.swing.JPanel; 54 import javax.swing.JRadioButton; 48 55 import javax.swing.JTextField; 49 56 import javax.swing.JTextPane; 57 import javax.swing.UIManager; 58 import javax.swing.text.AttributeSet; 50 59 import javax.swing.text.BadLocationException; 51 60 import javax.swing.text.DefaultStyledDocument; 61 import javax.swing.text.Document; 62 import javax.swing.text.PlainDocument; 52 63 import javax.swing.text.Style; 53 64 import javax.swing.text.StyleConstants; … … 65 76 { 66 77 78 private JRadioButton fullPathButton; 79 private JRadioButton partPathButton; 80 81 public boolean useFullPath = true; 82 83 private WholeNumberField numOfDirectoriesField; 84 public int numOfDirectories; 85 67 86 JButton cancelBtn; 68 69 87 JButton importBtn; 70 88 … … 92 110 this.store = store; 93 111 94 projectItems = ProjectItem.createProjectItems(store.getProjects()); 95 96 datasetItems = 97 DatasetItem.createEmptyDataset(); 112 if (store != null) 113 { 114 projectItems = ProjectItem.createProjectItems(store.getProjects()); 115 datasetItems = DatasetItem.createEmptyDataset(); 116 } 98 117 99 100 101 118 setTitle(title); 102 119 setModal(modal); 103 120 setResizable(false); 104 setSize(new Dimension(300, 2 00));121 setSize(new Dimension(300, 280)); 105 122 setLocationRelativeTo(owner); 106 123 … … 115 132 pbox = addComboBox(this, "Project: ", projectItems, 'P', c, 0, 1, 2, 116 133 "Select dataset to use for this import."); 117 134 118 135 dbox = addComboBox(this, "Dataset: ", datasetItems, 'D', c, 0, 1, 2, 119 136 "Select dataset to use for this import."); … … 121 138 dbox.setEnabled(false); 122 139 140 JPanel namedPanel = addNamedPanel(this, " File Naming ", c, 0, 4, 1.0f); 141 142 fullPathButton = addRadioButton("Use the full path name", c); 143 partPathButton = addRadioButton("Use the file name", c); 144 145 ButtonGroup group = new ButtonGroup(); 146 group.add(fullPathButton); 147 group.add(partPathButton); 148 149 group.setSelected(fullPathButton.getModel(), true); 150 151 namedPanel.add(fullPathButton, c); 152 namedPanel.add(partPathButton, c); 153 154 JPanel plainPanel = addPlainPanel(namedPanel, c); 155 numOfDirectoriesField = addEntryField(plainPanel, 156 "and prefex with " , "0", " directories", 0, 157 "Add this number of leading directories to the file names", 158 3); 159 123 160 importBtn = addButton(this, "Import", c, 2, 1, 1.0f, null); 124 161 cancelBtn = addButton(this, "Cancel", c, 1, 1, 1.0f, null); 125 162 126 163 importBtn.setEnabled(false); 127 164 165 166 fullPathButton.addActionListener(this); 167 partPathButton.addActionListener(this); 168 numOfDirectoriesField.addActionListener(this); 128 169 cancelBtn.addActionListener(this); 129 170 importBtn.addActionListener(this); 130 171 pbox.addActionListener(this); 131 172 132 133 if (savedProject != 0) { 173 if (savedProject != 0 && projectItems != null) { 134 174 for (int i = 0; i < projectItems.length; i++) 135 175 { 176 177 136 178 Long pId = projectItems[i].getId(); 137 179 … … 172 214 } 173 215 174 static JTextField addEntryField(Container container, String name, 175 String initialValue, int mnemonic, GridBagConstraints c, 216 private JRadioButton addRadioButton(String string, GridBagConstraints c) 217 { 218 c.fill = GridBagConstraints.HORIZONTAL; 219 c.insets = new Insets(2, 2, 2, 2); 220 c.weightx = 0.0; 221 222 c.gridx = 0; 223 c.gridwidth = 3; 224 225 JRadioButton button = new JRadioButton(string); 226 227 return button; 228 229 } 230 231 private WholeNumberField addEntryField(Container container, String prefexStr, 232 String initialValue, String suffexStr, int mnemonic, String tooltip, 233 int fieldWidth) 234 { 235 JLabel prefex = new JLabel(prefexStr); 236 prefex.setDisplayedMnemonic(mnemonic); 237 container.add(prefex); 238 239 WholeNumberField result = new WholeNumberField(0, fieldWidth); 240 result.setHorizontalAlignment(JTextField.CENTER); 241 prefex.setLabelFor(result); 242 result.setToolTipText(tooltip); 243 result.setMinimumSize(new Dimension(34,20)); 244 result.setPreferredSize(new Dimension(34,20)); 245 if (initialValue != null) result.setText(initialValue); 246 247 container.add(result); 248 249 JLabel suffex = new JLabel(suffexStr); 250 container.add(suffex); 251 252 return result; 253 } 254 255 static JComboBox addComboBox(Container container, String name, 256 Object[] initialValues, int mnemonic, GridBagConstraints c, 176 257 int labelCol, int labelWidth, int fieldWidth, String tooltip) 177 258 { … … 194 275 c.gridwidth = fieldWidth; 195 276 196 JTextField result = new JTextField(100); 277 JComboBox result = null; 278 if (initialValues != null) 279 { 280 result = new JComboBox(initialValues); 281 } else { 282 result = new JComboBox(); 283 } 197 284 label.setLabelFor(result); 198 285 result.setToolTipText(tooltip); 199 if (initialValue != null) result.setText(initialValue);200 container.add(result, c);201 return result;202 }203 204 static JComboBox addComboBox(Container container, String name,205 Object[] initialValues, int mnemonic, GridBagConstraints c,206 int labelCol, int labelWidth, int fieldWidth, String tooltip)207 {208 209 c.fill = GridBagConstraints.HORIZONTAL;210 c.insets = new Insets(2, 20, 2, 2);211 c.weightx = 0.0;212 213 c.gridx = labelCol;214 c.gridwidth = labelWidth;215 216 JLabel label = new JLabel(name);217 label.setDisplayedMnemonic(mnemonic);218 container.add(label, c);219 220 c.insets = new Insets(2, 2, 2, 20);221 c.weightx = 1.0;222 223 c.gridx = labelCol + 1;224 c.gridwidth = fieldWidth;225 226 JComboBox result = new JComboBox(initialValues);227 label.setLabelFor(result);228 result.setToolTipText(tooltip);229 container.add(result, c);230 return result;231 }232 233 static JPasswordField addPasswordField(Container container, String name,234 String initialValue, int mnemonic, GridBagConstraints c,235 int labelCol, int labelWidth, int fieldWidth, String tooltip)236 {237 238 c.fill = GridBagConstraints.HORIZONTAL;239 c.insets = new Insets(2, 20, 2, 2);240 c.weightx = 0.0;241 242 c.gridx = labelCol;243 c.gridwidth = labelWidth;244 245 JLabel label = new JLabel(name);246 label.setDisplayedMnemonic(mnemonic);247 container.add(label, c);248 249 c.insets = new Insets(2, 2, 2, 20);250 c.weightx = 1.0;251 252 c.gridx = labelCol + 1;253 c.gridwidth = fieldWidth;254 255 JPasswordField result = new JPasswordField(100);256 label.setLabelFor(result);257 result.setToolTipText(tooltip);258 if (initialValue != null) result.setText(initialValue);259 286 container.add(result, c); 260 287 return result; … … 320 347 } 321 348 349 static JPanel addNamedPanel(Container container, String name, 350 GridBagConstraints c, int column, int width, float weight) 351 { 352 353 c.anchor = GridBagConstraints.SOUTH; 354 c.fill = GridBagConstraints.HORIZONTAL; 355 c.insets = new Insets(2, 20, 2, 20); 356 c.weightx = weight; 357 358 c.gridx = column; 359 c.gridwidth = width; 360 361 JPanel namedPanel = new JPanel(); 362 GridBagLayout gridbag = new GridBagLayout(); 363 GridBagConstraints g = new GridBagConstraints(); 364 365 namedPanel.setLayout(gridbag); 366 namedPanel.setBorder(BorderFactory.createTitledBorder(name)); 367 368 container.add(namedPanel, c); 369 370 return namedPanel; 371 } 372 373 static JPanel addPlainPanel(Container container, GridBagConstraints c) 374 { 375 376 c.fill = GridBagConstraints.HORIZONTAL; 377 c.insets = new Insets(2, 20, 2, 2); 378 c.weightx = 2.0; 379 380 c.gridx = 0; 381 c.gridwidth = 0; 382 383 JPanel panel = new JPanel(); 384 GridBagLayout gridbag = new GridBagLayout(); 385 GridBagConstraints g = new GridBagConstraints(); 386 panel.setLayout(gridbag); 387 388 //container.add(panel, c); 389 390 return panel; 391 } 392 322 393 public void actionPerformed(ActionEvent e) 323 394 { 395 if (e.getSource() == fullPathButton) 396 { 397 useFullPath = true; 398 399 } 400 if (e.getSource() == partPathButton) 401 { 402 useFullPath = false; 403 } 324 404 if (e.getSource() == cancelBtn) 325 405 { … … 330 410 {
