public void setZoom(float zoom) {
   if (!SwingUtilities.isEventDispatchThread()) {
     throw new IllegalStateException("Must be on EDT");
   }
   if (zoom == zoom && zoom > 0.01 && Math.abs(zoom - this.zoom) > 0.01) {
     JScrollBar hsb = scrollPane.getHorizontalScrollBar();
     JScrollBar vsb = scrollPane.getVerticalScrollBar();
     float hv = (float) hsb.getValue();
     float vv = (float) vsb.getValue();
     float hm = (float) hsb.getMaximum();
     float vm = (float) vsb.getMaximum();
     this.zoom = zoom;
     view.setSize(view.getPreferredSize());
     listener.setEnabled(false); // don't send adjustment events
     Dimension viewsize = view.getSize();
     hv *= ((float) viewsize.width) / hm;
     vv *= ((float) viewsize.height) / vm;
     hsb.setMaximum(viewsize.width);
     vsb.setMaximum(viewsize.height);
     hsb.setValue(Math.round(hv));
     vsb.setValue(Math.round(vv));
     listener.setEnabled(true);
     view.revalidate();
     view.repaint();
   }
 }
Exemplo n.º 2
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();
    }
Exemplo n.º 3
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();
 }
Exemplo n.º 4
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();
    }
Exemplo n.º 5
0
  public void toChatScreen(String toScreen, boolean selfSeen)
      throws IOException, BadLocationException {
    // Timestamp ts = new Timestamp();
    String toScreenFinal = "";
    Date now = Calendar.getInstance().getTime();
    SimpleDateFormat format = new SimpleDateFormat("hh:mm");
    String ts = format.format(now);

    // chatScreen.append(ts + " " + toScreen + "\n");
    toScreenFinal = "<font color=gray>" + ts + "</font> ";
    if (selfSeen) toScreenFinal = toScreenFinal + "<font color=red>" + toScreen + "</font>";
    else toScreenFinal = toScreenFinal + toScreen;

    // chatter.addTo(toScreen);

    // if(standardWindow) {
    //    chatScreen.setCaretPosition(chatScreen.getDocument().getLength());
    // }
    // else {
    JScrollBar vBar = scrollChat.getVerticalScrollBar();
    int vSize = vBar.getVisibleAmount();
    int maxVBar = vBar.getMaximum();
    int currVBar = vBar.getValue() + vSize;
    kit.insertHTML(doc, doc.getLength(), toScreenFinal, 0, 0, null);
    if (maxVBar == currVBar) {
      chatScreen.setCaretPosition(chatScreen.getDocument().getLength());
    }

    // }

    // kit.insertHTML(doc, doc.getLength(), toScreenFinal, 0, 0, null);

  }
Exemplo n.º 6
0
  public void print(final String line) {
    if (!SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              ConsoleTab.this.print(line);
            }
          });
      return;
    }

    Document document = this.console.getDocument();
    JScrollBar scrollBar = getVerticalScrollBar();
    boolean shouldScroll = false;

    if (getViewport().getView() == this.console) {
      shouldScroll =
          scrollBar.getValue() + scrollBar.getSize().getHeight() + MONOSPACED.getSize() * 4
              > scrollBar.getMaximum();
    }
    try {
      document.insertString(document.getLength(), line, null);
    } catch (BadLocationException localBadLocationException) {
    }
    if (shouldScroll) scrollBar.setValue(2147483647);
  }
Exemplo n.º 7
0
      public void mouseWheelMoved(MouseWheelEvent e) {
        String st[] = {"PER UNITA'", "PER BLOCCO"};

        int unit = e.getUnitsToScroll();

        // calcolo per la scrollbar verticale l'attuale posizione
        // e l'unità di incremento per scroll
        JScrollBar sb = sp.getVerticalScrollBar();
        int y = sb.getValue();
        int y1 =
            e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL
                ? sb.getUnitIncrement(1)
                : sb.getBlockIncrement(1);

        sb.setValue(y + y1 * unit); // aggiorna la view della textarea

        int a = e.getScrollAmount();
        int b = e.getScrollType();
        int c = e.getUnitsToScroll();
        int d = e.getWheelRotation();
        double f = e.getPreciseWheelRotation();
        String g =
            "Unità da scorrere per giro di tacca: "
                + a
                + "\nTipo di scroll: "
                + st[e.getScrollType()]
                + "\nUnità che scorreranno verso l'alto: "
                + c
                + "\nNumero di tacche ruotate: "
                + d
                + "\nNumero di tacche precisamente ruotate: "
                + f;

        wheel_area.setText(g);
      }
 /** Returns the coordinates of the top left corner of the value at the given index. */
 public Point getCoordinates(int index) {
   JScrollBar bar = scrollPane.getVerticalScrollBar();
   Rectangle r = pinsTable.getCellRect(index, 2, true);
   pinsTable.scrollRectToVisible(r);
   return new Point(
       (int) (r.getX() + topLevelLocation.getX()),
       (int) (r.getY() + topLevelLocation.getY() - bar.getValue()));
 }
Exemplo n.º 9
0
 private double unfoldX(double foldedX) {
   double maxX;
   synchronized (resultList) {
     maxX = calls;
   }
   double mul = zoomXBar.getValue() / 100.0;
   return maxX * Math.pow(10.0, (foldedX - 0.98) * 10.0 / mul);
 }
Exemplo n.º 10
0
 private double foldX(double x) {
   double maxX;
   synchronized (resultList) {
     maxX = calls;
   }
   double mul = zoomXBar.getValue() / 100.0;
   return MathTN.log10(x / maxX) / 10 * mul + 0.98;
 }
Exemplo n.º 11
0
  /**
   * This method is used to append a line of text to be displayed.
   *
   * @param text Is the text to be apppended
   */
  private void append(final String text) {
    this.textArea.append(text);

    JScrollBar vertBar = this.scrollPane.getVerticalScrollBar();

    if (vertBar.getValue() == vertBar.getMaximum() - vertBar.getVisibleAmount()) {
      this.autoscroll = true;
    }
  }
Exemplo n.º 12
0
 /* (non-Javadoc)
  * @see bias.extension.DashBoard.snippet.InfoSnippet#serializeSettings()
  */
 @Override
 public byte[] serializeSettings() {
   settings.setProperty(PROPERTY_FONT_SIZE, "" + currentFontSize);
   JScrollBar sb = getJScrollPane().getVerticalScrollBar();
   if (sb != null && sb.getValue() != 0) {
     settings.setProperty(PROPERTY_SCROLLBAR_VERT, "" + sb.getValue());
   } else {
     settings.remove(PROPERTY_SCROLLBAR_VERT);
   }
   sb = getJScrollPane().getHorizontalScrollBar();
   if (sb != null && sb.getValue() != 0) {
     settings.setProperty(PROPERTY_SCROLLBAR_HORIZ, "" + sb.getValue());
   } else {
     settings.remove(PROPERTY_SCROLLBAR_HORIZ);
   }
   int cp = getJTextPane().getCaretPosition();
   settings.setProperty(PROPERTY_CARET_POSITION, "" + cp);
   return PropertiesUtils.serializeProperties(settings);
 }
Exemplo n.º 13
0
 /** Create a popup menu when mouse click */
 private void createPopupMenu(int x, int y) {
   Action[] popupMenuActions = getPopupMenuActions();
   JScrollBar vbar = getTreeTable().getVerticalScrollBar();
   myUIFacade.showPopupMenu(
       this,
       popupMenuActions,
       x
           - getTreeTable().getHorizontalScrollBar().getValue()
           + (vbar.isVisible() ? vbar.getWidth() : 0),
       y - vbar.getValue() + getTreeTable().getTable().getTableHeader().getHeight());
 }
Exemplo n.º 14
0
 private boolean doHorizontalScrolling(Component c, MouseWheelEvent me) {
   final JScrollBar scrollBar = findHorizontalScrollBar(c);
   if (scrollBar != null) {
     if (scrollBar.hashCode() != myLastHorScrolledComponentHash) {
       FeatureUsageTracker.getInstance().triggerFeatureUsed("ui.horizontal.scrolling");
       myLastHorScrolledComponentHash = scrollBar.hashCode();
     }
     scrollBar.setValue(scrollBar.getValue() + getScrollAmount(c, me, scrollBar));
     return true;
   }
   return false;
 }
  private void removeItem(Object obj, Field field, int index) {
    final JScrollBar sb = genericTagPropertiesEditPanelScrollPanel.getVerticalScrollBar();
    final int val = sb.getValue(); // save scroll top
    SWFType swfType = field.getAnnotation(SWFType.class);
    if (swfType != null
        && !swfType
            .countField()
            .isEmpty()) { // Fields with same countField must be removed from too
      Field[] fields = obj.getClass().getDeclaredFields();
      for (int f = 0; f < fields.length; f++) {
        SWFType fieldSwfType = fields[f].getAnnotation(SWFType.class);
        if (fieldSwfType != null && fieldSwfType.countField().equals(swfType.countField())) {
          ReflectionTools.removeFromField(obj, fields[f], index);
        }
      }
      try {
        // If countField exists, decrement, otherwise do nothing
        Field countField = obj.getClass().getDeclaredField(swfType.countField());
        int cnt = countField.getInt(obj);
        cnt--;
        countField.setInt(obj, cnt);
      } catch (NoSuchFieldException
          | SecurityException
          | IllegalArgumentException
          | IllegalAccessException ex) {
        // ignored
      }
    } else {
      ReflectionTools.removeFromField(obj, field, index);
    }

    generateEditControls(editedTag, false);

    // Restore scroll top after some time. TODO: Handle this better. I don't know how :-(.
    new Thread() {

      @Override
      public void run() {
        try {
          Thread.sleep(500);
        } catch (InterruptedException ex) {
          logger.log(Level.SEVERE, null, ex);
        }

        View.execInEventDispatch(
            () -> {
              genericTagPropertiesEditPanelScrollPanel.getVerticalScrollBar().setValue(val);
            });
      }
    }.start();
    revalidate();
    repaint();
  }
Exemplo n.º 16
0
  public JScrollBarExample() {
    jpnl = new JPanel();
    jpnl.setLayout(new FlowLayout());
    jsbR = new JScrollBar(JScrollBar.VERTICAL, 10, 0, 0, 255);
    jsbG = new JScrollBar(JScrollBar.VERTICAL, 20, 0, 0, 255);
    jsbB = new JScrollBar(JScrollBar.VERTICAL, 150, 0, 0, 255);

    Rtxt = new JLabel("R Value = " + jsbR.getValue());
    Gtxt = new JLabel("G Value = " + jsbG.getValue());
    Btxt = new JLabel("B Value = " + jsbB.getValue());

    jsbR.setPreferredSize(new Dimension(20, 200));
    jsbG.setPreferredSize(new Dimension(20, 200));
    jsbB.setPreferredSize(new Dimension(20, 200));

    jpnl.add(jsbR);
    jpnl.add(Rtxt);
    jpnl.add(jsbG);
    jpnl.add(Gtxt);
    jpnl.add(jsbB);
    jpnl.add(Btxt);

    jsbR.addAdjustmentListener(this);
    jsbG.addAdjustmentListener(this);
    jsbB.addAdjustmentListener(this);

    R = new Color(jsbR.getValue(), jsbG.getValue(), jsbB.getValue());
    jpnl.setBackground(R);

    add(jpnl);

    setSize(width, height);
    setVisible(true);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
Exemplo n.º 17
0
 public void keyPressed(KeyEvent ke) {
   switch (ke.getKeyCode()) {
     case KeyEvent.VK_UP:
       JScrollBar scrollBar = viewerScrollPane.getVerticalScrollBar();
       scrollBar.setValue(scrollBar.getValue() - scrollBar.getUnitIncrement(-1));
       ke.consume();
       break;
     case KeyEvent.VK_DOWN:
       scrollBar = viewerScrollPane.getVerticalScrollBar();
       scrollBar.setValue(scrollBar.getValue() + scrollBar.getUnitIncrement(1));
       ke.consume();
       break;
     case KeyEvent.VK_LEFT:
       scrollBar = viewerScrollPane.getHorizontalScrollBar();
       scrollBar.setValue(scrollBar.getValue() - scrollBar.getUnitIncrement(-1));
       ke.consume();
       break;
     case KeyEvent.VK_RIGHT:
       scrollBar = viewerScrollPane.getHorizontalScrollBar();
       scrollBar.setValue(scrollBar.getValue() + scrollBar.getUnitIncrement(1));
       ke.consume();
       break;
   }
 }
Exemplo n.º 18
0
  public void ecrire(String s) {
    JScrollBar scroll = jScrollPane1.getVerticalScrollBar();
    scrollMax = scroll.getMaximum();
    scrollVisible = scroll.isShowing();

    if (scroll.getValue() + scroll.getVisibleAmount() == scrollMax) {
      // enBas = false;
      scrollAuto = true;
      // scrollMax = scroll.getMaximum();
    } else {
      enBas = false;
      scrollAuto = false;
    }

    HTMLDocument d = (HTMLDocument) afficheurHTML.getStyledDocument();
    Element a = d.getParagraphElement(1);
    // Element a=d.getElement("conversation");
    try {
      if (!vide) {
        d.insertBeforeEnd(a, "<br />" + s);
      } else {
        d.insertBeforeEnd(a, s);
        vide = false;
      }
    } catch (BadLocationException | IOException ex) {
      Logger.getLogger(FenetreJeu.class.getName()).log(Level.SEVERE, null, ex);
    }

    /*
     * if (enBas) { while (scroll.getMaximum() == scrollMax) { try {
     * Thread.sleep(5);
     *
     *
     * } catch (InterruptedException ex) {
     * Logger.getLogger(FenetreJeu.class.getName()).log(Level.SEVERE, null,
     * ex); } } scroll.setValue(scroll.getMaximum() -
     * scroll.getVisibleAmount()); }
     */

    /*
     * if (jScrollPane1.getVerticalScrollBar().getValue() ==
     * jScrollPane1.getVerticalScrollBar().getMaximum()) {
     * afficheurHTML.setCaretPosition(afficheurHTML.getDocument().getLength());
     * }
     */
    // System.out.println(afficheurHTML.getText());
    // System.out.println(jScrollPane1.getVerticalScrollBar().getMaximum());
  }
 private void scrollOther(
     int scrollPosCorrected,
     final int maxColumnsOur,
     int maxColumnsOther,
     final List<ScrollingModel> models) {
   int pos2;
   if (myLeftScroll.getValue() == 0) {
     pos2 = 0;
   } else if ((scrollPosCorrected + myLeftScroll.getModel().getExtent()) >= maxColumnsOur) {
     pos2 = maxColumnsOther + 1;
   } else {
     pos2 = (int) (scrollPosCorrected * (((double) maxColumnsOther) / maxColumnsOur));
   }
   final int pointX2 = (int) myEditor.logicalPositionToXY(new LogicalPosition(0, pos2)).getX();
   for (ScrollingModel model : models) {
     model.scrollHorizontally(pointX2);
   }
 }
Exemplo n.º 20
0
  protected void textAreaAction(ActionEvent e) {
    JScrollBar scrollBar = textAreaScrollPane.getVerticalScrollBar();
    int extent = scrollBar.getModel().getExtent();
    boolean atBottom = scrollBar.getValue() + extent == scrollBar.getMaximum();

    if (atBottom) {
      caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    } else {
      caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    }

    if (mainWindow.notifyTextEntered(ChatArea.this, e.getActionCommand())) {
      appendText(
          "%s > %s%n",
          (mainWindow != null ? mainWindow.getChatDisplayName() : ""), e.getActionCommand());
      textField.setText("");
    }
  }
Exemplo n.º 21
0
  public void adjustmentValueChanged(AdjustmentEvent e) {
    R = new Color(jsbR.getValue(), jsbG.getValue(), jsbB.getValue());
    jpnl.setBackground(R);
    Rtxt.setText("R Value = " + jsbR.getValue());
    Gtxt.setText("G Value = " + jsbG.getValue());
    Btxt.setText("B Value = " + jsbB.getValue());

    if (R.getRed() < 100 || R.getGreen() < 100 || R.getBlue() < 100) {
      Rtxt.setForeground(R.WHITE);
      Gtxt.setForeground(R.WHITE);
      Btxt.setForeground(R.WHITE);
    } else {
      Rtxt.setForeground(R.BLACK);
      Gtxt.setForeground(R.BLACK);
      Btxt.setForeground(R.BLACK);
    }
  }
Exemplo n.º 22
0
  private void displayMessages(boolean friendSignedOff) {
    String chatDoc =
        ChatDocumentBuilder.buildChatText(
            messages, currentChatState, conversationName, friendSignedOff);
    LOG.debugf("Chat doc: {0}", chatDoc);
    final JScrollBar verticalScrollBar = conversationScroll.getVerticalScrollBar();
    final int scrollValue = verticalScrollBar.getValue();
    editor.setText(chatDoc);

    // LWC-2262: If the scroll bar was moved above the bottom of the scrollpane, reset the value of
    // the bar to where it was before the text was updated.  This needs to be issued to the end of
    // the
    // queue because the actual repainting/resizing of the scrollbar happens later in a
    // task added to the EDT by the plaf listener of the editor's document.
    // A better fix for this behavior may be possible
    if (verticalScrollBar.getMaximum()
        > (scrollValue + verticalScrollBar.getVisibleAmount() + PADDING)) {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              verticalScrollBar.setValue(scrollValue);
            }
          });
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              verticalScrollBar.setValue(verticalScrollBar.getMaximum());
            }
          });
    }

    decorateFileOfferButtons();

    chatWrapper.repaint();
  }
Exemplo n.º 23
0
  public void func_164247_a(
      final JTextArea p_164247_1_, final JScrollPane p_164247_2_, final String p_164247_3_) {
    try {
      latch.await();
    } catch (InterruptedException e) {
    } // Prevent logging until after constructor has ended.
    if (!SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              MinecraftServerGui.this.func_164247_a(p_164247_1_, p_164247_2_, p_164247_3_);
            }
          });
    } else {
      Document document = p_164247_1_.getDocument();
      JScrollBar jscrollbar = p_164247_2_.getVerticalScrollBar();
      boolean flag = false;

      if (p_164247_2_.getViewport().getView() == p_164247_1_) {
        flag =
            (double) jscrollbar.getValue()
                    + jscrollbar.getSize().getHeight()
                    + (double) (serverGuiFont.getSize() * 4)
                > (double) jscrollbar.getMaximum();
      }

      try {
        document.insertString(document.getLength(), p_164247_3_, (AttributeSet) null);
      } catch (BadLocationException var8) {;
      }

      if (flag) {
        jscrollbar.setValue(Integer.MAX_VALUE);
      }
    }
  }
Exemplo n.º 24
0
  protected void layoutHScrollbar(JScrollBar sb) {
    if (AbstractLookAndFeel.getTheme().isLinuxStyleScrollBarOn()) {
      Dimension sbSize = sb.getSize();
      Insets sbInsets = sb.getInsets();
      int sizeW = sbSize.width - sbInsets.left - sbInsets.right;

      /*
       * Height and top edge of the buttons and thumb.
       */
      int itemY = sbInsets.top;
      int itemH = sbSize.height - (sbInsets.top + sbInsets.bottom); // Math.min(itemW, sizeH / 2);
      int itemW = Math.min(itemH, sizeW / 2); // sbSize.width - (sbInsets.left + sbInsets.right);

      /* Nominal locations of the buttons, assuming their preferred
       * size will fit.
       */
      int decrButtonX = sbSize.width - sbInsets.right - itemW - itemW + 1;
      int incrButtonX = sbSize.width - sbInsets.right - itemW;

      /* Compute the width and origin of the thumb. The case
       * where the thumb is at the right edge is handled specially
       * to avoid numerical problems in computing thumbX.  Enforce
       * the thumbs min/max dimensions. If the thumb doesn't
       * fit in the track (trackW) we'll hide it later.
       */
      float trackW = sbSize.width - sbInsets.left - sbInsets.right - itemH - itemH + 1;
      float min = sb.getMinimum();
      float max = sb.getMaximum();
      float extent = sb.getVisibleAmount();
      float range = max - min;
      float value = sb.getValue();

      int maxThumbW = getMaximumThumbSize().width;
      int minThumbW = getMinimumThumbSize().width;
      int thumbW = (range <= 0) ? maxThumbW : (int) (trackW * (extent / range));
      thumbW = Math.max(thumbW, minThumbW);
      thumbW = Math.min(thumbW, maxThumbW);

      int thumbX = decrButtonX - thumbW;
      if (value < (max - extent)) {
        float thumbRange = trackW - thumbW;
        thumbX = (int) (0.5f + (thumbRange * ((value - min) / (range - extent))));
      }

      /* If the thumb isn't going to fit, zero it's bounds.  Otherwise
       * make sure it fits between the buttons.  Note that setting the
       * thumbs bounds will cause a repaint.
       */
      if (thumbW > trackW) {
        setThumbBounds(0, 0, 0, 0);
      } else {
        setThumbBounds(thumbX, itemY, thumbW, itemH);
      }
      decrButton.setBounds(decrButtonX, itemY, itemW, itemH);
      incrButton.setBounds(incrButtonX, itemY, itemW, itemH);

      /* Update the trackRect field.
       */
      trackRect.setBounds(0, itemY, (int) trackW, itemH);

    } else {
      super.layoutHScrollbar(sb);
    }
  }
Exemplo n.º 25
0
 public void adjustmentValueChanged(AdjustmentEvent e) {
   offset = scrollBar.getValue();
   table.tableChanged(cEvent);
 }
Exemplo n.º 26
0
  public ImageMontage(Model_Plate plate, int channelIndex, int fieldIndex) {
    scale = 0.1f;
    ThePlate = plate;
    Model_Well[][] wells = plate.getWells();
    getContentPane().setLayout(new BorderLayout());
    TheFrame = this;
    Dimension dim = new Dimension(1300, 868);
    setPreferredSize(dim);
    setSize(dim);
    ChannelSelected = channelIndex;
    FieldSelected = fieldIndex;
    imHeight = -1;
    imWidth = -1;
    MaxValueSlider = new JSlider(0, Model_Main.MAXPIXELVALUE, Model_Main.MAXPIXELVALUE);
    MinValueSlider = new JSlider(0, Model_Main.MAXPIXELVALUE, 0);
    // Adding the intensity sliders
    MaxValueSlider.setToolTipText("Maximum");
    MaxValueSlider.setName("Max");
    MaxValueSlider.setOrientation(JSlider.VERTICAL);
    SliderListener_RescaleDisplay listener = new SliderListener_RescaleDisplay();
    MaxValueSlider.addChangeListener(listener);

    MinValueSlider.setEnabled(false);
    MinValueSlider.setToolTipText("Minimum");
    MinValueSlider.setName("Min");
    MinValueSlider.setPaintTicks(false);
    MinValueSlider.setPaintLabels(false);
    MinValueSlider.setOrientation(JSlider.VERTICAL);
    MinValueSlider.addChangeListener(listener);
    setLayout(new BorderLayout());
    sliderPanel = new JPanel();
    sliderPanel.setLayout(new GridLayout(0, 2));
    sliderPanel.add(MinValueSlider, 0);
    sliderPanel.add(MaxValueSlider, 1);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(sliderPanel, BorderLayout.EAST);

    TheDisplayPanel = new DisplayPanel(wells, channelIndex, fieldIndex);
    TheScrollPane = new JScrollPane(TheDisplayPanel);

    JScrollBar verticalScrollBar = TheScrollPane.getVerticalScrollBar();
    JScrollBar horizScrollBar = TheScrollPane.getHorizontalScrollBar();
    lastScrollValueX = horizScrollBar.getValue();
    lastScrollValueY = verticalScrollBar.getValue();

    getContentPane().add(TheScrollPane, BorderLayout.CENTER);

    TheFrame.setVisible(true);
    addWindowListener(this);

    // Setting up the Menubar
    //
    JMenuBar TheMenuBar = new JMenuBar();
    JMenu FileMenu = new JMenu("File");
    JMenu OptionsMenu = new JMenu("Options");

    TheMenuBar.add(FileMenu);
    TheMenuBar.add(OptionsMenu);
    setJMenuBar(TheMenuBar);

    JMenuItem item = new JMenuItem("Close");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            killAll();
            setVisible(false);
          }
        });
    FileMenu.add(item);

    // Field Selection
    JMenu mItem = new JMenu("Field");
    OptionsMenu.add(mItem);
    ButtonGroup bg1 = new ButtonGroup();
    for (int i = 0; i < maxNumFields; i++) {
      item = new JCheckBoxMenuItem("Field_" + i);
      final int index = i;
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              FieldSelected = index;
              // TheDisplayPanel = new DisplayPanel(ThePlate.getWells(),
              // ChannelSelected, FieldSelected);
              TheDisplayPanel.initDisplay();
              TheDisplayPanel.repaint();
              TheFrame.validate();
              TheFrame.repaint();
            }
          });
      mItem.add(item);
      bg1.add(item);
      if (i == 0) item.setSelected(true);
    }
    item = new JCheckBoxMenuItem("All");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            FieldSelected = ALL;
            // TheDisplayPanel = new DisplayPanel(ThePlate.getWells(),
            // ChannelSelected, FieldSelected);
            TheDisplayPanel.initDisplay();
            TheDisplayPanel.repaint();
            TheFrame.validate();
            TheFrame.repaint();
          }
        });
    mItem.add(item);
    bg1.add(item);

    // Channel Selection
    mItem = new JMenu("Channel");
    ButtonGroup bg = new ButtonGroup();
    String[] names = models.Model_Main.getModel().getTheChannelNames();
    OptionsMenu.add(mItem);
    for (int i = 0; i < names.length; i++) {
      item = new JCheckBoxMenuItem("" + names[i]);
      final int index = i;
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {

              ChannelSelected = index;
              // TheDisplayPanel = new DisplayPanel(ThePlate.getWells(),
              // ChannelSelected, FieldSelected);
              TheDisplayPanel.initDisplay();
              TheDisplayPanel.repaint();
              TheFrame.validate();
              TheFrame.repaint();
            }
          });
      bg.add(item);
      mItem.add(item);
      if (i == 0) item.setSelected(true);
    }

    validate();
    repaint();
  }
Exemplo n.º 27
0
  /**
   * Scroll the vertical or horizontal scroll bar, if possible, using the given increment.
   *
   * @param increment The increment to apply on the vertical scroll bar.
   * @param vertical True: the vertical scroll bar is
   * @since 0.1
   */
  protected void scroll(final int increment, final boolean vertical) {
    final JScrollBar scrollbar = getScrollbar(vertical);

    if (scrollbar != null && scrollbar.isVisible())
      scrollbar.setValue(scrollbar.getValue() - increment);
  }
Exemplo n.º 28
0
  protected void alternateLayoutVScrollbar(JScrollBar sb) {
    Dimension sbSize = sb.getSize();
    Insets sbInsets = sb.getInsets();

    /*
     * Width and left edge of the buttons and thumb.
     */
    int itemW = sbSize.width - (sbInsets.left + sbInsets.right);
    int itemX = sbInsets.left;

    /* Nominal locations of the buttons, assuming their preferred
     * size will fit.
     */
    int incrButtonH = incrButton.getPreferredSize().height;
    int incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH);

    int decrButtonH = decrButton.getPreferredSize().height;
    int decrButtonY = incrButtonY - decrButtonH;

    /* The thumb must fit within the height left over after we
     * subtract the preferredSize of the buttons and the insets.
     */
    int sbInsetsH = sbInsets.top + sbInsets.bottom;
    int sbButtonsH = decrButtonH + incrButtonH;
    float trackH = sbSize.height - (sbInsetsH + sbButtonsH);

    /* Compute the height and origin of the thumb.   The case
     * where the thumb is at the bottom edge is handled specially
     * to avoid numerical problems in computing thumbY.  Enforce
     * the thumbs min/max dimensions.  If the thumb doesn't
     * fit in the track (trackH) we'll hide it later.
     */
    float min = sb.getMinimum();
    float extent = sb.getVisibleAmount();
    float range = sb.getMaximum() - min;
    float value = sb.getValue();

    int thumbH = (range <= 0) ? getMaximumThumbSize().height : (int) (trackH * (extent / range));
    thumbH = Math.max(thumbH, getMinimumThumbSize().height);
    thumbH = Math.min(thumbH, getMaximumThumbSize().height);

    int thumbY = decrButtonY - thumbH; // incrButtonY - thumbH;
    if (sb.getValue() < (sb.getMaximum() - sb.getVisibleAmount())) {
      float thumbRange = trackH - thumbH;
      thumbY = (int) (0.5f + (thumbRange * ((value - min) / (range - extent))));
      // thumbY +=  decrButtonY + decrButtonH;
    }

    /* If the buttons don't fit, allocate half of the available
     * space to each and move the lower one (incrButton) down.
     */
    int sbAvailButtonH = (sbSize.height - sbInsetsH);
    if (sbAvailButtonH < sbButtonsH) {
      incrButtonH = decrButtonH = sbAvailButtonH / 2;
      incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH);
    }
    decrButton.setBounds(itemX, decrButtonY, itemW, decrButtonH);
    incrButton.setBounds(itemX, incrButtonY, itemW, incrButtonH);

    /* Update the trackRect field.
     */
    int itrackY = sbInsets.top;
    int itrackH = decrButtonY - itrackY;
    trackRect.setBounds(itemX, itrackY, itemW, itrackH);

    /* If the thumb isn't going to fit, zero it's bounds.  Otherwise
     * make sure it fits between the buttons.  Note that setting the
     * thumbs bounds will cause a repaint.
     */
    if (thumbH >= (int) trackH) {
      setThumbBounds(0, 0, 0, 0);
    } else {
      if ((thumbY + thumbH) > decrButtonY) {
        thumbY = decrButtonY - thumbH;
      }
      /*	    if (thumbY  < (decrButtonY + decrButtonH)) {
      thumbY = decrButtonY + decrButtonH + 1;
      }*/
      setThumbBounds(itemX, thumbY, itemW, thumbH);
    }
  }
Exemplo n.º 29
0
  protected void alternateLayoutHScrollbar(JScrollBar sb) {
    Dimension sbSize = sb.getSize();
    Insets sbInsets = sb.getInsets();

    /* Height and top edge of the buttons and thumb.
     */
    int itemH = sbSize.height - (sbInsets.top + sbInsets.bottom);
    int itemY = sbInsets.top;

    /* Nominal locations of the buttons, assuming their preferred
     * size will fit.
     */
    int incrButtonW = incrButton.getPreferredSize().width;
    int incrButtonX = sbSize.width - (sbInsets.right + incrButtonW);

    int decrButtonW = decrButton.getPreferredSize().width;
    int decrButtonX = incrButtonX - decrButtonW;

    /* The thumb must fit within the width left over after we
     * subtract the preferredSize of the buttons and the insets.
     */
    int sbInsetsW = sbInsets.left + sbInsets.right;
    int sbButtonsW = decrButtonW + incrButtonW;
    float trackW = sbSize.width - (sbInsetsW + sbButtonsW);

    /* Compute the width and origin of the thumb.  Enforce
     * the thumbs min/max dimensions.  The case where the thumb
     * is at the right edge is handled specially to avoid numerical
     * problems in computing thumbX.  If the thumb doesn't
     * fit in the track (trackH) we'll hide it later.
     */
    float min = sb.getMinimum();
    float extent = sb.getVisibleAmount();
    float range = sb.getMaximum() - min;
    float value = sb.getValue();

    int thumbW = (range <= 0) ? getMaximumThumbSize().width : (int) (trackW * (extent / range));
    thumbW = Math.max(thumbW, getMinimumThumbSize().width);
    thumbW = Math.min(thumbW, getMaximumThumbSize().width);

    int thumbX = decrButtonX - thumbW;
    if (sb.getValue() < (sb.getMaximum() - sb.getVisibleAmount())) {
      float thumbRange = trackW - thumbW;
      thumbX = (int) (0.5f + (thumbRange * ((value - min) / (range - extent))));
      // thumbX +=  decrButtonX + decrButtonW;
    }

    /* If the buttons don't fit, allocate half of the available
     * space to each and move the right one (incrButton) over.
     */
    int sbAvailButtonW = (sbSize.width - sbInsetsW);
    if (sbAvailButtonW < sbButtonsW) {
      incrButtonW = decrButtonW = sbAvailButtonW / 2;
      incrButtonX = sbSize.width - (sbInsets.right + incrButtonW);
    }

    decrButton.setBounds(decrButtonX, itemY, decrButtonW, itemH);
    incrButton.setBounds(incrButtonX, itemY, incrButtonW, itemH);

    /* Update the trackRect field.
     */
    int itrackX = sbInsets.left; // decrButtonX + decrButtonW;
    int itrackW = decrButtonX - itrackX;
    trackRect.setBounds(itrackX, itemY, itrackW, itemH);

    /* Make sure the thumb fits between the buttons.  Note
     * that setting the thumbs bounds causes a repaint.
     */
    if (thumbW >= (int) trackW) {
      setThumbBounds(0, 0, 0, 0);
    } else {
      if (thumbX + thumbW > incrButtonX) {
        thumbX = incrButtonX - thumbW;
      }
      /*if (thumbX  < decrButtonX + decrButtonW) {
      thumbX = decrButtonX + decrButtonW + 1;
      }*/
      setThumbBounds(thumbX, itemY, thumbW, itemH);
    }
  }
Exemplo n.º 30
0
 private Rectangle getClip() {
   JScrollBar hsb = scrollPane.getHorizontalScrollBar();
   JScrollBar vsb = scrollPane.getVerticalScrollBar();
   return new Rectangle(
       hsb.getValue(), vsb.getValue(), hsb.getVisibleAmount(), vsb.getVisibleAmount());
 }