Esempio n. 1
0
  public TMapMainWindow(Frame parent) {
    //    Задаем менеджер размещения типа BorderLayout
    //    (ориентация распологаемых объектов на панели
    //    относительно рамки)
    setLayout(new BorderLayout());

    //    Создаем экземпляр объекта класса TDocWindow
    //    размещаем его в центре

    DocWindow = new TDocWindow(parent);
    DocWindow.init();
    DocWindow.start();
    DocWindow.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    add("Center", DocWindow);
    DocWindow.ObjectDialog.MainWindow = (TMapMainWindowBase) this; // 15/12/04

    //  Проектируем горизонтальный и вертикальный скроллинг
    ScrollBar1 = new Scrollbar(Scrollbar.HORIZONTAL);
    ScrollBar1.setUnitIncrement(10);
    ScrollBar1.setBlockIncrement(100);
    ScrollBar1.setValues(0, 0, 0, 0);
    add("South", ScrollBar1);
    ScrollBar1.setEnabled(false);
    ScrollBar2 = new Scrollbar(Scrollbar.VERTICAL);
    ScrollBar2.setUnitIncrement(10);
    ScrollBar2.setBlockIncrement(100);
    ScrollBar2.setValues(0, 0, 0, 0);
    add("East", ScrollBar2);
    ScrollBar2.setEnabled(false);
    ScrollBar1.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    ScrollBar2.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
  }
Esempio n. 2
0
 public void SetScrollBarsValues(int[] left, int[] top) // 15/12/04
     {
   int maxsize = ScrollBar1.getMaximum();
   if (left[0] < 0) left[0] = 0;
   else if (left[0] > maxsize) left[0] = maxsize;
   ScrollBar1.setValues(left[0], 30, 0, maxsize);
   maxsize = ScrollBar2.getMaximum();
   if (top[0] < 0) top[0] = 0;
   else if (top[0] > maxsize) top[0] = maxsize;
   ScrollBar2.setValues(top[0], 30, 0, maxsize);
 }
  /**
   * Sets the minimum value of this scroll bar.
   *
   * <p>When <code>setMinimum</code> is called, the minimum value is changed, and other values
   * (including the maximum, the visible amount, and the current scroll bar value) are changed to be
   * consistent with the new minimum.
   *
   * <p>Normally, a program should change a scroll bar's minimum value only by calling <code>
   * setValues</code>. The <code>setValues</code> method simultaneously and synchronously sets the
   * minimum, maximum, visible amount, and value properties of a scroll bar, so that they are
   * mutually consistent.
   *
   * <p>Note that setting the minimum value to <code>Integer.MAX_VALUE</code> will result in the new
   * minimum value being set to <code>Integer.MAX_VALUE - 1</code>.
   *
   * @param newMinimum the new minimum value for this scroll bar
   * @see java.awt.Scrollbar#setValues
   * @see java.awt.Scrollbar#setMaximum
   * @since JDK1.1
   */
  public void setMinimum(int newMinimum) {
    // No checks are necessary in this method since minimum is
    // the first variable checked in the setValues function.

    // Use setValues so that a consistent policy relating
    // minimum, maximum, visible amount, and value is enforced.
    setValues(value, visibleAmount, newMinimum, maximum);
  }
Esempio n. 4
0
  // Called to update the scrollbar properties.
  private void updateScrollbars() {
    final DjVuImage image = getImage();
    if (image != null) {
      final Dimension viewportSize = getViewportSize();
      final Dimension imageSize = image.getSize();
      final Point scrollPosition = getScrollPosition();
      final Scrollbar hScroll = getScrollbar(Scrollbar.HORIZONTAL);
      final Scrollbar vScroll = getScrollbar(Scrollbar.VERTICAL);

      if (hScroll != null) {
        hScroll.setValues(scrollPosition.x, viewportSize.width, 0, imageSize.width);
      }

      if (vScroll != null) {
        vScroll.setValues(scrollPosition.y, viewportSize.height, 0, imageSize.height);
      }
    }
  }
  /**
   * Constructs a new scroll bar with the specified orientation, initial value, page size, and
   * minimum and maximum values.
   *
   * <p>The <code>orientation</code> argument must take one of the two values <code>
   * Scrollbar.HORIZONTAL</code>, or <code>Scrollbar.VERTICAL</code>, indicating a horizontal or
   * vertical scroll bar, respectively.
   *
   * <p>The parameters supplied to this constructor are subject to the constraints described in
   * {@link #setValues(int, int, int, int)}.
   *
   * @param orientation indicates the orientation of the scroll bar.
   * @param value the initial value of the scroll bar
   * @param visible the visible amount of the scroll bar, typically represented by the size of the
   *     bubble
   * @param minimum the minimum value of the scroll bar
   * @param maximum the maximum value of the scroll bar
   * @exception IllegalArgumentException when an illegal value for the <code>orientation</code>
   *     argument is supplied
   * @see #setValues
   */
  public Scrollbar(int orientation, int value, int visible, int minimum, int maximum) {
    switch (orientation) {
      case HORIZONTAL:
      case VERTICAL:
        this.orientation = orientation;
        break;

      default:
        throw new IllegalArgumentException("illegal scrollbar orientation");
    }
    setValues(value, visible, minimum, maximum);
  }
  /**
   * Sets the maximum value of this scroll bar.
   *
   * <p>When <code>setMaximum</code> is called, the maximum value is changed, and other values
   * (including the minimum, the visible amount, and the current scroll bar value) are changed to be
   * consistent with the new maximum.
   *
   * <p>Normally, a program should change a scroll bar's maximum value only by calling <code>
   * setValues</code>. The <code>setValues</code> method simultaneously and synchronously sets the
   * minimum, maximum, visible amount, and value properties of a scroll bar, so that they are
   * mutually consistent.
   *
   * <p>Note that setting the maximum value to <code>Integer.MIN_VALUE</code> will result in the new
   * maximum value being set to <code>Integer.MIN_VALUE + 1</code>.
   *
   * @param newMaximum the new maximum value for this scroll bar
   * @see java.awt.Scrollbar#setValues
   * @see java.awt.Scrollbar#setMinimum
   * @since JDK1.1
   */
  public void setMaximum(int newMaximum) {
    // minimum is checked first in setValues, so we need to
    // enforce minimum and maximum checks here.
    if (newMaximum == Integer.MIN_VALUE) {
      newMaximum = Integer.MIN_VALUE + 1;
    }

    if (minimum >= newMaximum) {
      minimum = newMaximum - 1;
    }

    // Use setValues so that a consistent policy relating
    // minimum, maximum, visible amount, and value is enforced.
    setValues(value, visibleAmount, minimum, newMaximum);
  }
Esempio n. 7
0
  public void goTo(int where) {
    try {
      if (where < 1) {
        return;
      }
      if (where > db.getRecordCount()) {
        return;
      }
      db.gotoRecord(where);
      crl.setText("Record " + db.getCurrentRecordNumber());
      delCB.setState(db.deleted());

      Field f;
      LogicalField lf;
      Checkbox c;
      TextField t;

      int i;

      for (i = 1; i <= db.getFieldCount(); i++) {
        f = db.getField(i);
        if (f.isMemoField()) {
        } else if (f.getType() == 'L') {
          lf = (LogicalField) f;
          c = (Checkbox) fldObjects.elementAt(i - 1);
          c.setState(lf.getBoolean());
        } else {
          t = (TextField) fldObjects.elementAt(i - 1);
          t.setText(f.get().trim());
        }
      }

      Next.setEnabled(!(db.getCurrentRecordNumber() == db.getRecordCount()));
      nextRecord.setEnabled(!(db.getCurrentRecordNumber() == db.getRecordCount()));

      Prev.setEnabled(!(db.getCurrentRecordNumber() == 1));
      prevRecord.setEnabled(!(db.getCurrentRecordNumber() == 1));

      firstRecord.setEnabled(db.getRecordCount() > 0);
      lastRecord.setEnabled(db.getRecordCount() > 0);

      SBrecpos.setValues(db.getCurrentRecordNumber(), 1, 0, db.getRecordCount());
    } // try
    catch (Exception e1) {
      System.out.println(e1);
      System.exit(2);
    }
  }
Esempio n. 8
0
  /**
   * Create a instance of this check entry and set the configuration entry that is used to setup
   * this class.
   *
   * @param usedEntry the entry used to setup this class, the entry needs to pass the check with the
   *     static method
   */
  @SuppressWarnings("nls")
  public NumberEntryAwt(final ConfigEntry usedEntry) {
    super(new BorderLayout(10, 0));

    if (!isUsableEntry(usedEntry)) {
      throw new IllegalArgumentException("ConfigEntry type illegal.");
    }
    entry = (NumberEntry) usedEntry;

    currentValue = entry.getValue();

    display = new Label(Integer.toString(currentValue));
    add(display, BorderLayout.EAST);

    final Scrollbar scroll = new Scrollbar();
    scroll.setOrientation(Scrollbar.HORIZONTAL);
    scroll.setValues(currentValue, 1, entry.getRange().getMin(), entry.getRange().getMax() + 1);
    scroll.addAdjustmentListener(new NumberEntryScrollListener(this));
    add(scroll, BorderLayout.CENTER);

    setMinimumSize(new Dimension(300, 10));
  }
Esempio n. 9
0
  public void actionPerformed(ActionEvent event) {
    if (event.getSource() == firstRecord) {
      goTo(1);
      return;
    }
    if (event.getSource() == lastRecord) {
      goTo(db.getRecordCount());
      return;
    }
    if (event.getSource() == Next || event.getSource() == nextRecord) {
      if (db.getCurrentRecordNumber() < db.getRecordCount()) {
        goTo(db.getCurrentRecordNumber() + 1);
      }
      return;
    }

    if (event.getSource() == Prev || event.getSource() == prevRecord) {
      if (db.getCurrentRecordNumber() > 1) {
        goTo(db.getCurrentRecordNumber() - 1);
      }
      return;
    }

    if (event.getSource() == Add || event.getSource() == addRecord) {
      addRec();
      return;
    }
    if (event.getSource() == Update || event.getSource() == updateRecord) {
      updateRec();
      return;
    }
    if (event.getSource() == Clear || event.getSource() == clearRecord) {
      clearFields();
      return;
    }

    if (event.getSource() == opener) {
      FileDialog fd = new FileDialog(this, "dbfShow", FileDialog.LOAD);
      fd.setFile("*.DBF");
      fd.pack();
      fd.setVisible(true);
      String DBFname = fd.getFile();
      String dirname = fd.getDirectory();
      if (DBFname == null) {
        return;
      }
      if (DBFname.length() < 1) {
        return;
      }
      String dbname = new String(dirname + DBFname);
      try {
        setupDBFields(dbname);
      } catch (Exception e1) {
        System.out.println(e1);
        System.exit(4);
      }
      pack();
      setVisible(true);
      return;
    }

    if (event.getSource() == packer) {
      packer.setEnabled(false);
      try {
        db.pack();
        trl.setText(" of " + db.getRecordCount());
      } catch (Exception e1) {
        e1.printStackTrace();
      }
      if (db.getRecordCount() == 0) {
        Update.setEnabled(false);
        Next.setEnabled(false);
        updateRecord.setEnabled(false);
        nextRecord.setEnabled(false);
        SBrecpos.setValues(0, 1, 0, 0);
      } else {
        goTo(1);
      }
      packer.setEnabled(true);
      return;
    }

    if (event.getSource() == quiter) {
      System.exit(0);
      return;
    }

    if (event.getSource() instanceof Button) {
      int i;
      Field f;
      for (i = 1; i <= db.getFieldCount(); i++) {
        try {
          f = db.getField(i);
          if (f.isMemoField()) {
            if (event.getActionCommand().equals(f.getName())) {
              md = new memoDialog(this, f);
              md.setVisible(true);
              return;
            }
          }
        } catch (Exception e1) {
          System.out.println(e1);
        }
      }
    }
  }
 /**
  * Sets the visible amount of this scroll bar.
  *
  * <p>When a scroll bar is used to select a range of values, the visible amount is used to
  * represent the range of values that are currently visible. The size of the scroll bar's bubble
  * (also called a thumb or scroll box), usually gives a visual representation of the relationship
  * of the visible amount to the range of the scroll bar.
  *
  * <p>The scroll bar's bubble may not be displayed when it is not moveable (e.g. when it takes up
  * the entire length of the scroll bar's track, or when the scroll bar is disabled). Whether the
  * bubble is displayed or not will not affect the value returned by <code>getVisibleAmount</code>.
  *
  * <p>If the visible amount supplied is less than <code>one</code> or greater than the current
  * <code>maximum - minimum</code>, then either <code>one</code> or <code>maximum - minimum</code>
  * is substituted, as appropriate.
  *
  * <p>Normally, a program should change a scroll bar's value only by calling <code>setValues
  * </code>. The <code>setValues</code> method simultaneously and synchronously sets the minimum,
  * maximum, visible amount, and value properties of a scroll bar, so that they are mutually
  * consistent.
  *
  * @param newAmount the new visible amount
  * @see java.awt.Scrollbar#getVisibleAmount
  * @see java.awt.Scrollbar#setValues
  * @since JDK1.1
  */
 public void setVisibleAmount(int newAmount) {
   // Use setValues so that a consistent policy relating
   // minimum, maximum, visible amount, and value is enforced.
   setValues(value, newAmount, minimum, maximum);
 }