Exemple #1
0
    public void mouseWheelMoved(MouseWheelEvent e) {

      int notches = e.getWheelRotation();
      int sign = 1;
      if (notches > 0) {
        sign = -1;
      }
      if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
        int numClicks = e.getScrollAmount();
        scale = scale + (numClicks * 0.1f) * sign;
        if (scale <= 0) scale = 0.1f;
      }

      TheDisplayPanel.initDisplay();
      TheDisplayPanel.repaint();

      JScrollBar verticalScrollBar = TheScrollPane.getVerticalScrollBar();
      JScrollBar horizScrollBar = TheScrollPane.getHorizontalScrollBar();

      // Point pInImage = new
      // Point((int)(mouseMovePoint.x+lastScrollValueX),
      // (int)(mouseMovePoint.y+lastScrollValueY));

      verticalScrollBar.setValue((int) (lastScrollValueY + mouseMovePoint.y));
      horizScrollBar.setValue((int) (lastScrollValueX + mouseMovePoint.x));

      lastScrollValueX = horizScrollBar.getValue();
      lastScrollValueY = verticalScrollBar.getValue();

      TheFrame.validate();
      TheFrame.repaint();
    }
Exemple #2
0
 public void mousePressed(MouseEvent e) {
   // TODO Auto-generated method stub
   Dragging = true;
   startPoint = e.getPoint();
   JScrollBar verticalScrollBar = TheScrollPane.getVerticalScrollBar();
   JScrollBar horizScrollBar = TheScrollPane.getHorizontalScrollBar();
   lastScrollValueX = horizScrollBar.getValue();
   lastScrollValueY = verticalScrollBar.getValue();
 }
Exemple #3
0
    public void mouseDragged(MouseEvent e) {

      JScrollBar verticalScrollBar = TheScrollPane.getVerticalScrollBar();
      JScrollBar horizScrollBar = TheScrollPane.getHorizontalScrollBar();

      verticalScrollBar.setValue((int) (lastScrollValueY + startPoint.y - e.getPoint().y));
      horizScrollBar.setValue((int) (lastScrollValueX + startPoint.x - e.getPoint().x));

      lastScrollValueX = horizScrollBar.getValue();
      lastScrollValueY = verticalScrollBar.getValue();
    }
Exemple #4
0
    public void run() {
      totalHeight = 0;
      totalWidth = 0;
      int rows = wells.length;
      int cols = wells[0].length;
      int[][] widths = new int[rows][cols];
      int[][] heights = new int[rows][cols];
      maxNumFields = ThePlate.getMaxNumberOfFields();

      // if (rows * cols == 384)
      // scale = 0.5f;

      if (scale < 0.1f) scale = 0.1f;

      if (FieldSelected != ALL) {
        TheImageArray = new BufferedImage[rows][cols][1];

        for (int r = 0; r < rows; r++) {
          for (int c = 0; c < cols; c++) {

            if (wells[r][c].getFields() != null && wells[r][c].getFields().length > 0) {
              File f = wells[r][c].getFields()[FieldSelected].getImageFile(ChannelSelected);
              RenderedImage im = JAI.create("fileload", f.getAbsolutePath());
              RenderedImage im2 =
                  rescale(
                      resizeImage(im, scale, scale),
                      0,
                      (int)
                          models.Model_Main.getModel()
                              .getMaxValues_ImageDisplay()[ChannelSelected]);
              widths[r][c] = im2.getWidth();
              heights[r][c] = im2.getHeight();

              TheImageArray[r][c][0] = tools.ImageTools.convertRenderedImage(im2);

              numWellsDone++;
            }

            repaint();
            TheFrame.validate();
            TheFrame.repaint();
          }
        }
        cols_display = 1;
        rows_display = 1;
      } else // Displaying all fields
      {
        // Calc number of display rows and cols for each well (make a
        // square grid)
        cols_display = 0;
        rows_display = 0;
        if (maxNumFields == 2) {

          cols_display = 2;
          rows_display = 1;
        } else if (maxNumFields == 4 || maxNumFields == 3) {
          cols_display = 2;
          rows_display = 2;
        } else if (maxNumFields > 4 && maxNumFields < 10) {
          cols_display = 3;
          rows_display = 3;
        }
        if (maxNumFields == 1) {
          cols_display = 1;
          rows_display = 1;
        }

        TheImageArray = new BufferedImage[rows][cols][maxNumFields];
        for (int r = 0; r < rows; r++) {
          for (int c = 0; c < cols; c++) {

            if (wells[r][c].getFields() != null && wells[r][c].getFields().length > 0) {
              Model_Field[] fields = wells[r][c].getFields();
              if (fields != null) {
                int nf = fields.length;

                for (int i = 0; i < nf; i++) {
                  File f = fields[i].getImageFile(ChannelSelected);
                  RenderedImage im = JAI.create("fileload", f.getAbsolutePath());
                  RenderedImage im2 =
                      rescale(
                          resizeImage(im, scale / rows_display, scale / cols_display),
                          0,
                          (int)
                              models.Model_Main.getModel()
                                  .getMaxValues_ImageDisplay()[ChannelSelected]);
                  widths[r][c] = im2.getWidth();
                  heights[r][c] = im2.getHeight();

                  TheImageArray[r][c][i] = tools.ImageTools.convertRenderedImage(im2);
                  System.out.println(wells[r][c].name + "  f_" + i);
                }
                System.out.println();
              }
            }
            numWellsDone++;
            repaint();
            TheFrame.validate();
            TheFrame.repaint();
          }
        }
      }

      // Computing maxWidth & maxHeights for entire ThePlate
      imWidth = -1;
      imHeight = -1;
      for (int r = 0; r < rows; r++) {
        for (int c = 0; c < cols; c++) {

          if (widths[r][c] != 0) {
            if (imWidth == -1) imWidth = widths[r][c];
            if (imHeight == -1) imHeight = heights[r][c];
          }
        }
      }
      totalHeight = rows * imHeight * rows_display;
      totalWidth = cols * imWidth * cols_display;

      Dimension dim2 = new Dimension(totalWidth, totalHeight);

      TheDisplayPanel.setPreferredSize(dim2);
      TheDisplayPanel.revalidate();
      TheScrollPane.revalidate();

      initializing = false;
      TheDisplayPanel.repaint();
    }