コード例 #1
0
ファイル: GetDataFrame.java プロジェクト: akrherz/pals
  public GetDataFrame(PlayableApplet anApplet, AppletRecorder ar) {
    // call base class constructor
    super("Get Student Data");
    theApplet = anApplet;
    theAR = ar;

    resize(212, 206);
    start = new Button("Start");
    step = new Button("Step");
    step.disable();
    close = new Button("Cancel");

    makeSessionList();

    buttonsPanel = new Panel();
    buttonsPanel.add("West", start);
    buttonsPanel.add("Center", step);
    buttonsPanel.add("East", close);

    sessionsPanel = new Panel();
    sessionsPanel.resize(150, 150);
    sessionsPanel.add("Center", sessionList);

    add("North", new Label("Select a Session:", Label.LEFT));
    add("Center", sessionsPanel);
    add("South", buttonsPanel);

    show();
  }
コード例 #2
0
ファイル: GetDataFrame.java プロジェクト: akrherz/pals
  public boolean action(Event e, Object o) {
    int curCursorType;
    String session;
    Vector values;

    if (e.target == close) removeSelf();
    else if (e.target == start) {
      selection = sessionList.getSelectedIndex();

      if (selection < 0) {
        (new ErrorFrame()).showMsg("Please select a session.");
        return true;
      }

      session = sessionList.getSelectedItem();

      curCursorType = getCursorType();
      setCursor(Frame.WAIT_CURSOR);
      values = theAR.getValues(new Date(session));
      numSteps = values.size();
      setCursor(curCursorType);

      theApplet.playStart(values);

      step.enable();
      stepIndex = -1;

    } else if (e.target == step) {
      int newSelection = sessionList.getSelectedIndex();
      if (selection == newSelection) {
        stepIndex++;
        if (stepIndex < numSteps) theApplet.playStep(stepIndex);
        else {
          (new ErrorFrame())
              .showMsg(
                  "End of session has been reached.  Please select a new session or click cancel.");
          step.disable();
        }
      } else if (newSelection < 0) (new ErrorFrame()).showMsg("Please select a session.");
      else
        (new ErrorFrame())
            .showMsg(
                "A session must be selected and started before clicking step.  1) Select a session and press start OR 2) Reselect the session you were stepping through");
    }

    return true;
  }
コード例 #3
0
ファイル: Notebook.java プロジェクト: kent74cn/processdash
  public void paint(Graphics g) {
    Rectangle r = bounds();

    // paint the box
    int width = r.width - TF_LEFT + TF_RIGHT;
    if (width < 0) width = 0;
    int height = r.height - TF_TOP + TF_BOTTOM;
    if (height < 0) height = 0;

    if (r.width > lastWidth) firstVisibleTab = 0;
    lastWidth = r.width;

    int col = TF_LEFT;
    int row;

    Color c = g.getColor();
    g.setColor(getBackground());
    g.fillRect(0, 0, r.width, r.height);

    if (iTabsPosition == TOP) row = TF_TOP;
    else row = TF_TOP - TF_BTN_HEIGHT;

    // draw border
    g.setColor(Color.white);
    g.drawLine(col, row, (col + width - 1), row);
    g.drawLine(col, row, col, (row + height - 1));

    g.setColor(Color.gray);
    g.drawLine((col + 2), (row + height - 2), (col + width - 2), (row + height - 2));
    g.drawLine((col + width - 2), (row + 2), (col + width - 2), (row + height - 2));

    g.setColor(Color.black);
    g.drawLine((col + 1), (row + height - 1), (col + width - 1), (row + height - 1));
    g.drawLine((col + width - 1), (row + 1), (col + width - 1), (row + height - 1));

    // paint the tabs, and record areas
    int x1;
    int x2 = TF_LEFT + 8;
    int y1;
    int y2;
    int x3 = 0;
    int x4 = TF_LEFT;

    int sze = pages.size();
    String sLabel;

    Font f = g.getFont();
    FontMetrics fm = getFontMetrics(fReg);
    FontMetrics fms = getFontMetrics(fSel);
    int labelWidth = 0;
    Polygon p;

    int w;
    NotebookPage[] npages = new NotebookPage[sze];
    for (w = 0; w < sze; ++w) {
      npages[w] = (NotebookPage) pages.elementAt(w);
      npages[w].poly = nullPoly;
    }

    // make sure there is a polygon for each tab
    if (firstVisibleTab > 0) x4 += 2;
    int xStep = 1;

    for (w = firstVisibleTab; w < sze; w++) {
      int fheight = fm.getHeight() - fms.getDescent();
      if (w == curIndex) fheight = fms.getHeight() - fms.getDescent();

      p = new Polygon();
      if (npages[w].hidden) {
        y1 = TF_TOP - TF_BTN_HEIGHT;
        y2 = TF_TOP - 1;
        x1 = x4 - 1;
        x2 = x1 + 1;
        x3 = x1;
        x4 = x2;
        p.addPoint(x1, y1);
        p.addPoint(x1, y2);
        p.addPoint(x2, y2);
        p.addPoint(x2, y1);
        npages[w].poly = p;
        //          xStep++;
        continue;
      }
      try {
        sLabel = npages[w].label;
        if (w == curIndex) labelWidth = fms.stringWidth(sLabel);
        else labelWidth = fm.stringWidth(sLabel);

        if (npages[w].img != null) labelWidth += IMAGE_SIZE;

        if (iTabsPosition == TOP) {
          y1 = TF_TOP - TF_BTN_HEIGHT;
          y2 = TF_TOP - 1;
        } else {
          y1 = r.height + TF_BOTTOM + 1;
          y2 = r.height + TF_BOTTOM - TF_BTN_HEIGHT;
        }

        if (iTabsStyle == ROUNDED) {
          x1 = x4 + 2;
          x2 = x1 + labelWidth + 13;
        } else {
          x1 = x2 - 7;
          x2 = x1 + labelWidth + 28;
        }

        // check to see if this tab would draw too far
        if ((x2 + 36 - TF_RIGHT) > r.width) break;

        // draw the outside edge of the tab
        if (iTabsPosition == TOP) {
          // if current tab, it extends further
          if (w == curIndex) {
            y1 -= 3;
            x1 -= 2;
          }
          g.setColor(Color.white);
          g.drawLine(x1 + 2, y1, x2, y1);

          // draw the border between tabs if not covered by the current one
          g.drawLine(x1, y1 + 2, x1, y2);
          x3 = x1;

          g.drawLine(x1 + 1, y1 + 1, x1 + 1, y1 + 1);

          g.setColor(Color.gray);
          g.drawLine(x2, y1, x2, y2);
          g.setColor(Color.black);
          g.drawLine(x2 + 1, y1 + 2, x2 + 1, y2);
          x4 = x2;
        } else {
          if (iTabsStyle == SQUARE) {
            g.setColor(Color.gray);
            g.drawLine(x1 + 9, y1, x2 - 9, y1);

            g.setColor(Color.black);
            // left \ slanted line
            if (w == 0 || w == curIndex) {
              g.drawLine(x1, y2, x1 + 9, y1);
              p.addPoint(x1, y2);
            } else {
              g.drawLine(x1 + 4, y1 - 9, x1 + 9, y1);
              p.addPoint(x1 + 9, y2);
              p.addPoint(x1 + 4, y1 - 9);
            }
            p.addPoint(x1 + 9, y1);
            p.addPoint(x2 - 9, y1);

            if ((w + xStep) == curIndex) {
              g.drawLine(x2 - 5, y1 - 9, x2 - 9, y1);
              p.addPoint(x2 - 5, y1);
              p.addPoint(x2 - 9, y2);
            } else {
              g.drawLine(x2, y2, x2 - 9, y1);
              p.addPoint(x2, y2);
            }

            if (w == 1 || w == curIndex) p.addPoint(x1, y2);
            else p.addPoint(x1 + 9, y2);
          } else {
            // if current tab, it extends further
            if (w == curIndex) {
              y1 += 3;
              x1 -= 2;
            }
            g.setColor(Color.white);
            if (curIndex == (w + xStep)) g.drawLine(x1 + 2, y1, x2 - 2, y1);
            else g.drawLine(x1 + 2, y1, x2, y1);

            // draw the border between tabs if not covered by the current one
            if (curIndex != (w - xStep)) {
              g.drawLine(x1, y1 - 2, x1, y2);
              x3 = x1;
            } else x3 = x1 + 1;

            g.drawLine(x1 + 1, y1 - 1, x1 + 1, y1 - 1);

            if (curIndex != (w + xStep)) {
              g.setColor(Color.gray);
              g.drawLine(x2, y1, x2, y2);
              g.setColor(Color.black);
              g.drawLine(x2 + 1, y1 - 2, x2 + 1, y2);
              x4 = x2;
            } else x4 = x2 - 1;
          }
        }

        // draw the inside edge of the tab
        if (w == curIndex) {
          if (iTabsPosition == TOP) ++y2;
          else --y2;
          g.setColor(getBackground());
          g.drawLine(x1 + 1, y2, x2, y2);
          if (iTabsPosition == BOTTOM) g.drawLine(x1 + 1, y2 - 1, x2, y2 - 1);

          g.setFont(fSel);
        } else g.setFont(fReg);

        // if (iTabsPosition == TOP)
        if (iTabsStyle == ROUNDED) {
          p.addPoint(x3 - 1, y2 + 1);
          p.addPoint(x4 + 1, y2 + 1);
          p.addPoint(x4 + 1, y1 - 1);
          p.addPoint(x3 + 2, y1 - 1);
          p.addPoint(x3 - 1, y1 + 2);
          p.addPoint(x3 - 1, y2 + 1);
        }
        npages[w].poly = p;

        g.setColor(npages[w].color);
        Polygon p2 = justPolygon(p, iTabsPosition == TOP);
        g.fillPolygon(p2);

        // Boolean bool = (Boolean) vEnabled.elementAt(w);
        // if (bool.booleanValue())
        g.setColor(caption);
        // else
        //     g.setColor(Color.gray);

        int dx = (npages[w].img == null) ? 0 : IMAGE_SIZE;

        int xx = x1 + 8 + dx;
        int yy = y1 + 15;

        if (iTabsStyle == TOP) {
        } else if (iTabsStyle == ROUNDED) {
          yy = y1 - 6;
        } else {
          xx = x1 + 14 + dx;
          yy = y1 - 4;
        }

        int imgy = yy - fheight / 2;

        if (npages[w].img != null) {
          int imgH = npages[w].img.getHeight(this);
          int imgW = npages[w].img.getWidth(this);
          imgy = imgy - imgH / 2 + 1;
          g.drawImage(npages[w].img, xx - IMAGE_SIZE - 2, imgy, imgW, imgH, this);
        }

        g.drawString(sLabel, xx, yy);
      } catch (ArrayIndexOutOfBoundsException e) {
      }
      xStep = 1;
    }

    // do I need to show arrows because there are too many tabs???
    if ((firstVisibleTab > 0) || (w < sze)) {
      dbLeft.show();
      dbRight.show();
      if (firstVisibleTab > 0) dbLeft.enable();
      else dbLeft.disable();

      if (w < sze) dbRight.enable();
      else dbRight.disable();
    } else {
      dbLeft.hide();
      dbRight.hide();
    }
    g.setFont(f);
    g.setColor(c);

    if (mark && curIndex >= 0) drawMark(g, npages[curIndex].poly);

    npages = null;
  }