private void updateMemDisplay() {
   if (product != null) {
     long storageMem = product.getRawStorageSize(productSubsetDef);
     double factor = 1.0 / (1024 * 1024);
     double megas = MathUtils.round(factor * storageMem, 10);
     if (megas > memWarnLimit) {
       memLabel.setForeground(MEM_LABEL_WARN_COLOR);
     } else {
       memLabel.setForeground(MEM_LABEL_NORM_COLOR);
     }
     memLabel.setText(MEM_LABEL_TEXT + megas + "M");
   } else {
     memLabel.setText(" ");
   }
 }
    private void updateUIState(ParamChangeEvent event) {
      if (updatingUI.compareAndSet(false, true)) {
        try {
          if (event != null && canUseGeoCoordinates(product)) {
            final String parmName = event.getParameter().getName();
            if (parmName.startsWith("geo_")) {
              final GeoPos geoPos1 =
                  new GeoPos((Float) paramNorthLat1.getValue(), (Float) paramWestLon1.getValue());
              final GeoPos geoPos2 =
                  new GeoPos((Float) paramSouthLat2.getValue(), (Float) paramEastLon2.getValue());
              updateXYParams(geoPos1, geoPos2);
            } else if (parmName.startsWith("source_x") || parmName.startsWith("source_y")) {
              syncLatLonWithXYParams();
            }
          }
          int x1 = ((Number) paramX1.getValue()).intValue();
          int y1 = ((Number) paramY1.getValue()).intValue();
          int x2 = ((Number) paramX2.getValue()).intValue();
          int y2 = ((Number) paramY2.getValue()).intValue();

          int sx = ((Number) paramSX.getValue()).intValue();
          int sy = ((Number) paramSY.getValue()).intValue();

          updateSubsetDefRegion(x1, y1, x2, y2, sx, sy);

          Dimension s =
              productSubsetDef.getSceneRasterSize(
                  product.getSceneRasterWidth(), product.getSceneRasterHeight());
          subsetWidthLabel.setText(String.valueOf(s.getWidth()));
          subsetHeightLabel.setText(String.valueOf(s.getHeight()));

          int sliderBoxX1 = x1 / thumbNailSubSampling;
          int sliderBoxY1 = y1 / thumbNailSubSampling;
          int sliderBoxX2 = x2 / thumbNailSubSampling;
          int sliderBoxY2 = y2 / thumbNailSubSampling;
          int sliderBoxW = sliderBoxX2 - sliderBoxX1 + 1;
          int sliderBoxH = sliderBoxY2 - sliderBoxY1 + 1;
          Rectangle box =
              getScaledRectangle(new Rectangle(sliderBoxX1, sliderBoxY1, sliderBoxW, sliderBoxH));
          imageCanvas.setSliderBoxBounds(box);
        } finally {
          updatingUI.set(false);
        }
      }
    }
    private void createUI() {

      ActionListener productNodeCheckListener =
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              updateUIState();
            }
          };

      checkers = new ArrayList<JCheckBox>(10);
      JPanel checkersPane = GridBagUtils.createPanel();
      setComponentName(checkersPane, "CheckersPane");

      GridBagConstraints gbc =
          GridBagUtils.createConstraints("insets.left=4,anchor=WEST,fill=HORIZONTAL");
      for (int i = 0; i < productNodes.length; i++) {
        ProductNode productNode = (ProductNode) productNodes[i];

        String name = productNode.getName();
        JCheckBox productNodeCheck = new JCheckBox(name);
        productNodeCheck.setSelected(selected);
        productNodeCheck.setFont(SMALL_PLAIN_FONT);
        productNodeCheck.addActionListener(productNodeCheckListener);

        if (includeAlways != null && StringUtils.containsIgnoreCase(includeAlways, name)) {
          productNodeCheck.setSelected(true);
          productNodeCheck.setEnabled(false);
        } else if (givenProductSubsetDef != null) {
          productNodeCheck.setSelected(givenProductSubsetDef.containsNodeName(name));
        }
        checkers.add(productNodeCheck);

        String description = productNode.getDescription();
        JLabel productNodeLabel = new JLabel(description != null ? description : " ");
        productNodeLabel.setFont(SMALL_ITALIC_FONT);

        GridBagUtils.addToPanel(
            checkersPane, productNodeCheck, gbc, "weightx=0,gridx=0,gridy=" + i);
        GridBagUtils.addToPanel(
            checkersPane, productNodeLabel, gbc, "weightx=1,gridx=1,gridy=" + i);
      }
      // Add a last 'filler' row
      GridBagUtils.addToPanel(
          checkersPane,
          new JLabel(" "),
          gbc,
          "gridwidth=2,weightx=1,weighty=1,gridx=0,gridy=" + productNodes.length);

      ActionListener allCheckListener =
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              if (e.getSource() == allCheck) {
                checkAllProductNodes(true);
              } else if (e.getSource() == noneCheck) {
                checkAllProductNodes(false);
              }
              updateUIState();
            }
          };

      allCheck = new JCheckBox("Select all");
      allCheck.setName("selectAll");
      allCheck.setMnemonic('a');
      allCheck.addActionListener(allCheckListener);

      noneCheck = new JCheckBox("Select none");
      noneCheck.setName("SelectNone");
      noneCheck.setMnemonic('n');
      noneCheck.addActionListener(allCheckListener);

      JScrollPane scrollPane = new JScrollPane(checkersPane);
      scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
      scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

      JPanel buttonRow = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 4));
      buttonRow.add(allCheck);
      buttonRow.add(noneCheck);

      setLayout(new BorderLayout());
      add(scrollPane, BorderLayout.CENTER);
      add(buttonRow, BorderLayout.SOUTH);
      setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));

      updateUIState();
    }