예제 #1
0
  public void actionPerformed(ActionEvent event) {
    if (Debug.isActive()) Debug.println("Action for Collapse Tree button");

    tree_view.collapseLevel();
    toolbar.getYaxisTreeCommitButton().doClick();

    // Set toolbar buttons to reflect status
    toolbar.resetYaxisTreeButtons();
  }
예제 #2
0
 public int getIdFromPoint(int x, int y) {
   Debug.log(5, "union bound: " + getBounds());
   Debug.log(5, "x, y: " + x + "," + y);
   x += getBounds().x;
   y += getBounds().y;
   Debug.log(5, "new x, y: " + x + "," + y);
   for (int i = 0; i < getNumberScreens(); i++)
     if (Screen.getBounds(i).contains(x, y)) {
       return i;
     }
   return 0;
 }
예제 #3
0
  public void actionPerformed(ActionEvent event) {
    Window window;
    String msg;

    if (model.isZoomUndoStackEmpty()) {
      window = SwingUtilities.windowForComponent((JToolBar) toolbar);
      msg = "Zoom Undo Stack is empty";
      Dialogs.warn(window, msg);
    } else model.zoomUndo();

    // Set toolbar buttons to reflect status
    if (toolbar != null) toolbar.resetZoomButtons();

    if (Debug.isActive()) Debug.println("Action for Zoom Undo button.");
  }
예제 #4
0
    private BufferedImage createThumbNailImage(Dimension imgSize, ProgressMonitor pm) {
      Assert.notNull(pm, "pm");

      String thumbNailBandName = getThumbnailBandName();
      Band thumbNailBand = product.getBand(thumbNailBandName);

      Debug.trace(
          "ProductSubsetDialog: Reading thumbnail data for band '" + thumbNailBandName + "'...");
      pm.beginTask("Creating thumbnail image", 5);
      BufferedImage image = null;
      try {
        MultiLevelSource multiLevelSource =
            BandImageMultiLevelSource.create(thumbNailBand, SubProgressMonitor.create(pm, 1));
        final ImageLayer imageLayer = new ImageLayer(multiLevelSource);
        final int imageWidth = imgSize.width;
        final int imageHeight = imgSize.height;
        final int imageType = BufferedImage.TYPE_3BYTE_BGR;
        image = new BufferedImage(imageWidth, imageHeight, imageType);
        Viewport snapshotVp = new DefaultViewport(isModelYAxisDown(imageLayer));
        final BufferedImageRendering imageRendering = new BufferedImageRendering(image, snapshotVp);

        final Graphics2D graphics = imageRendering.getGraphics();
        graphics.setColor(getBackground());
        graphics.fillRect(0, 0, imageWidth, imageHeight);

        snapshotVp.zoom(imageLayer.getModelBounds());
        snapshotVp.moveViewDelta(snapshotVp.getViewBounds().x, snapshotVp.getViewBounds().y);
        imageLayer.render(imageRendering);

        pm.worked(4);
      } finally {
        pm.done();
      }
      return image;
    }
예제 #5
0
  /** Executes the specified command */
  public void run() {
    if (popup != null) {
      popup.show(popupComponent, popupX, popupY);
      popup = null;
      return;
    }

    if (cmd == null) return;

    switch (cmd.commandType) {
        // Open an UrlConnection
      case CommandInfo.COMMAND_TYPE_GET:
        try {
          cmd.commandURL.openConnection();

          BufferedReader in =
              new BufferedReader(new InputStreamReader(cmd.commandURL.openStream()));
          String strLine;
          Debug.println("Server responded:");
          while ((strLine = in.readLine()) != null) {
            Debug.println(strLine);
          }
          in.close();
        } catch (IOException e) {
        }
        break;
        // Open a port
      case CommandInfo.COMMAND_TYPE_OPEN:
        try {
          Socket sockServerConnection = new Socket(cmd.commandHost, (int) cmd.commandPort);
          BufferedReader in =
              new BufferedReader(new InputStreamReader(sockServerConnection.getInputStream()));
          String strLine;
          Debug.println("Server responded:");
          while ((strLine = in.readLine()) != null) {
            Debug.println(strLine);
          }
          in.close();
          sockServerConnection.close();
        } catch (IOException e) {
        }
        break;
    }
    cmd = null;
    Debug.println("Action terminated");
  }
예제 #6
0
  @Override
  public ScreenImage capture(Rectangle rect) {
    Debug.log(5, "capture: " + rect);

    BufferedImage ret = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = ret.createGraphics();
    for (int i = 0; i < Screen.getNumberScreens(); i++) {
      Rectangle scrBound = Screen.getBounds(i);
      if (scrBound.intersects(rect)) {
        Rectangle inter = scrBound.intersection(rect);
        Debug.log(5, "scrBound: " + scrBound + ", inter: " + inter);
        int ix = inter.x, iy = inter.y;
        inter.x -= scrBound.x;
        inter.y -= scrBound.y;
        ScreenImage img = robots[i].captureScreen(inter);
        g2d.drawImage(img.getImage(), ix - rect.x, iy - rect.y, null);
      }
    }
    g2d.dispose();
    return new ScreenImage(rect, ret);
  }
예제 #7
0
  private static RasterDataNode[] getReferencedNodes(final RasterDataNode node) {
    final Product product = node.getProduct();
    if (product != null) {
      final List<String> expressions = new ArrayList<String>(10);
      if (node.getValidPixelExpression() != null) {
        expressions.add(node.getValidPixelExpression());
      }
      final ProductNodeGroup<Mask> overlayMaskGroup = node.getOverlayMaskGroup();
      if (overlayMaskGroup.getNodeCount() > 0) {
        final Mask[] overlayMasks =
            overlayMaskGroup.toArray(new Mask[overlayMaskGroup.getNodeCount()]);
        for (final Mask overlayMask : overlayMasks) {
          final String expression;
          if (overlayMask.getImageType() == Mask.BandMathsType.INSTANCE) {
            expression = Mask.BandMathsType.getExpression(overlayMask);
          } else if (overlayMask.getImageType() == Mask.RangeType.INSTANCE) {
            expression = Mask.RangeType.getExpression(overlayMask);
          } else {
            expression = null;
          }
          if (expression != null) {
            expressions.add(expression);
          }
        }
      }
      if (node instanceof VirtualBand) {
        final VirtualBand virtualBand = (VirtualBand) node;
        expressions.add(virtualBand.getExpression());
      }

      final ArrayList<Term> termList = new ArrayList<Term>(10);
      for (final String expression : expressions) {
        try {
          final Term term = product.parseExpression(expression);
          if (term != null) {
            termList.add(term);
          }
        } catch (ParseException e) {
          // @todo se handle parse exception
          Debug.trace(e);
        }
      }

      final Term[] terms = termList.toArray(new Term[termList.size()]);
      final RasterDataSymbol[] refRasterDataSymbols = BandArithmetic.getRefRasterDataSymbols(terms);
      return BandArithmetic.getRefRasters(refRasterDataSymbols);
    }
    return new RasterDataNode[0];
  }
예제 #8
0
  public pmLogin(JFrame f, String title, String msg, pmTop t, String h) {

    super(f, title, true); // modal

    theTop = t;
    theTag = h;
    theFrame = f;

    JLabel l;
    JPanel p;

    // initialize constraints
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(10, 10, 10, 10);
    c.anchor = GridBagConstraints.EAST;

    // top panel contains the desired message
    p = new JPanel();
    p.setLayout(new GridBagLayout());

    l = new JLabel(msg, SwingConstants.CENTER);
    p.add(l, c);
    this.getContentPane().add(p, "North");

    // NIS middle panel
    // contains username and password
    if (t.ns.getNameService().equals("nis")) {

      p = new JPanel();
      p.setLayout(new GridBagLayout());

      l = new JLabel(pmUtility.getResource("Hostname:"), SwingConstants.RIGHT);
      p.add(l, c);

      l = new JLabel(pmUtility.getResource("Username:"******"Password:"******"Password.mnemonic"));

      c.gridx = 1;
      c.weightx = 1.0;

      String nisMaster;
      try {
        nisMaster = theTop.host.getNisMaster();
      } catch (Exception e) {
        nisMaster = new String("Unknown");
        Debug.warning("pmLogin: getNisMaster() returns exception: " + e);
      }

      c.anchor = GridBagConstraints.WEST;

      l = new JLabel(nisMaster, SwingConstants.LEFT);
      p.add(l, c);

      l = new JLabel(("root"), SwingConstants.LEFT);
      p.add(l, c);

      c.fill = GridBagConstraints.HORIZONTAL;
      c.anchor = GridBagConstraints.CENTER;
      c.gridy = GridBagConstraints.RELATIVE;

      p.add(passwordField, c);
      passwordField.setEchoChar('*');

      this.getContentPane().add(p, "Center");

    } else if (t.ns.getNameService().equals("ldap")) {

      // middle panel contains LDAP server name, distinguished name,
      // and password
      p = new JPanel();
      p.setLayout(new GridBagLayout());

      // LDAP Server Name
      l = new JLabel(pmUtility.getResource("LDAP.Server:"), SwingConstants.RIGHT);
      p.add(l, c);

      serverField = new pmTextField(25);
      serverField.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              okPressed();
            }
          });

      String ldapMaster;
      try {
        ldapMaster = theTop.host.getLDAPMaster();
      } catch (Exception e) {
        ldapMaster = new String("");
        Debug.warning("pmLdap: getLDAPMaster() returns exception: " + e);
      }

      serverField.setText(ldapMaster);
      c.gridx = 1;
      p.add(serverField, c);

      // Distinguished Name
      c.gridx = 0;
      l = new JLabel(pmUtility.getResource("Distinguished.Name:"), SwingConstants.RIGHT);
      p.add(l, c);

      dnField = new pmTextField(25);
      dnField.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              okPressed();
            }
          });

      String defaultDN;
      try {
        defaultDN = theTop.host.getDefaultAdminDN();
      } catch (Exception e) {
        defaultDN = new String("");
        Debug.warning("pmLdap: getDefaultAdminDN() returns exception: " + e);
      }

      dnField.setText(defaultDN);
      c.gridx = 1;
      p.add(dnField, c);

      // Password
      c.gridx = 0;
      l = new JLabel(pmUtility.getResource("Password:"******"Password.mnemonic"));

      c.gridx = 1;
      c.weightx = 1.0;

      c.fill = GridBagConstraints.HORIZONTAL;
      c.anchor = GridBagConstraints.CENTER;
      c.gridy = GridBagConstraints.RELATIVE;

      p.add(passwordField, c);
      passwordField.setEchoChar('*');

      this.getContentPane().add(p, "Center");
    }

    // bottom panel contains buttons
    c.gridx = 0;
    c.weightx = 1.0;
    c.weighty = 0.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;

    JPanel thePanel = new JPanel();

    okButton = new pmButton(pmUtility.getResource("OK"));
    okButton.setMnemonic(pmUtility.getIntResource("OK.mnemonic"));
    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            okPressed();
          }
        });
    thePanel.add(okButton, c);

    cancelButton = new pmButton(pmUtility.getResource("Cancel"));
    cancelButton.setMnemonic(pmUtility.getIntResource("Cancel.mnemonic"));
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            cancelPressed();
          }
        });
    thePanel.add(cancelButton, c);

    if (theTag != null && theTop != null) {

      helpButton = new pmButton(pmUtility.getResource("Help"));
      helpButton.setMnemonic(pmUtility.getIntResource("Help.mnemonic"));
      p.add(helpButton);
      helpButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              helpPressed();
            }
          });
      thePanel.add(helpButton, c);
    }

    this.getContentPane().add(thePanel, "South");

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            returnValue = JOptionPane.CLOSED_OPTION;
            pmLogin.this.setVisible(false);
          }
        });

    // handle Esc as cancel in any case
    this.getRootPane()
        .registerKeyboardAction(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                Debug.message("CLNT:  default cancel action");
                cancelPressed();
              }
            },
            KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false),
            JComponent.WHEN_IN_FOCUSED_WINDOW);

    // lay out the dialog
    this.pack();

    // set focus and defaults after packing...
    // this.getRootPane().setDefaultButton(okButton);
    okButton.setAsDefaultButton();

    passwordField.requestFocus();
  }