コード例 #1
0
ファイル: NCCPConnection.java プロジェクト: WU-ARL/RLI
 public void setConnected(boolean b, boolean process_pending) {
   if (b && state != ConnectionEvent.CONNECTION_OPENED) {
     if (host.length() > 0)
       ExpCoordinator.print(
           "NCCPConnection open connection to ipaddress " + host + " port " + port);
     state = ConnectionEvent.CONNECTION_OPENED;
     // connected = true;
     fireEvent(new ConnectionEvent(this, state));
     ExpCoordinator.printer.print("NCCPConnection.setConnected " + b + " event fired", 8);
     if (process_pending) {
       int max = pendingMessages.size();
       ExpCoordinator.printer.print(new String("   pendingMessages " + max + " elements"), 8);
       for (int i = 0; i < max; ++i) {
         sendMessage((NCCP.Message) pendingMessages.elementAt(i));
       }
       pendingMessages.removeAllElements();
     }
   } else {
     if (!b
         && (state != ConnectionEvent.CONNECTION_CLOSED
             || state != ConnectionEvent.CONNECTION_FAILED)) {
       if (host.length() > 0)
         ExpCoordinator.print(
             new String(
                 "NCCPConnection.setConnected -- Closed control socket for " + host + "." + port));
       state = ConnectionEvent.CONNECTION_CLOSED;
       fireEvent(new ConnectionEvent(this, state));
     }
   }
 }
コード例 #2
0
ファイル: Graph2D.java プロジェクト: corywalker/simuconomy
  /** Detach All attached Axes. */
  public void detachAxes() {
    int i;

    if (axis == null | axis.isEmpty()) return;

    for (i = 0; i < axis.size(); i++) {
      ((Axis) axis.elementAt(i)).detachAll();
      ((Axis) axis.elementAt(i)).g2d = null;
    }

    axis.removeAllElements();
  }
コード例 #3
0
ファイル: Graph2D.java プロジェクト: corywalker/simuconomy
  /** Detach All the DataSets from the class. */
  public void detachDataSets() {
    DataSet d;
    int i;

    if (dataset == null | dataset.isEmpty()) return;

    for (i = 0; i < dataset.size(); i++) {
      d = ((DataSet) dataset.elementAt(i));
      if (d.xaxis != null) d.xaxis.detachDataSet(d);
      if (d.yaxis != null) d.yaxis.detachDataSet(d);
    }

    dataset.removeAllElements();
  }
コード例 #4
0
ファイル: Population.java プロジェクト: RubelAhmed57/KEEL
  /**
   * It sets the useful parameter to those classifiers int the population having the best value of
   * numerosity * prediction. It's is used by the Strong version of the Dixon's reduction algorithm.
   */
  void setUsefulAccurateClassifier(boolean value) {
    double max = (double) set[0].getNumerosity() * set[0].getPrediction();
    Vector bestCls = new Vector();
    bestCls.add((Classifier) set[0]);

    for (int i = 1; i < macroClSum; i++) {

      if ((double) set[i].getNumerosity() * set[i].getPrediction() > max) {
        max = (double) set[i].getNumerosity() * set[i].getPrediction();
        bestCls.removeAllElements();
        bestCls.add(set[i]);
      } else if ((double) set[i].getNumerosity() * set[i].getPrediction() == max) {
        bestCls.add(set[i]);
      }
    }

    for (int i = 0; i < bestCls.size(); i++) {
      ((Classifier) bestCls.get(i)).setUseful(value);
    }
  } // end setUsefulAccurateClassifier
コード例 #5
0
ファイル: TextLine.java プロジェクト: mytnyk/PRIAMUS
  /**
   * parse the text. When the text is parsed the width, height, leading are all calculated. The text
   * will only be truly parsed if the graphics context has changed or the text has changed or the
   * font has changed. Otherwise nothing is done when this method is called.
   *
   * @param g Graphics context.
   */
  public void parseText(Graphics g) {
    FontMetrics fm;
    TextState current = new TextState();
    char ch;
    Stack state = new Stack();
    int w = 0;

    if (lg != g) parse = true;
    lg = g;

    if (!parse) return;

    parse = false;
    width = 0;
    leading = 0;
    ascent = 0;
    descent = 0;
    height = 0;
    maxAscent = 0;
    maxDescent = 0;

    if (text == null || g == null) return;

    list.removeAllElements();

    if (font == null) current.f = g.getFont();
    else current.f = font;

    state.push(current);
    list.addElement(current);

    fm = g.getFontMetrics(current.f);

    for (int i = 0; i < text.length(); i++) {
      ch = text.charAt(i);

      switch (ch) {
        case '$':
          i++;
          if (i < text.length()) current.s.append(text.charAt(i));
          break;
          /*
           **                    Push the current state onto the state stack
           **                    and start a new storage string
           */
        case '{':
          w = current.getWidth(g);
          if (!current.isEmpty()) {
            current = current.copyState();
            list.addElement(current);
          }

          state.push(current);
          current.x += w;
          break;
          /*
           **                    Pop the state off the state stack and set the current
           **                    state to the top of the state stack
           */
        case '}':
          w = current.x + current.getWidth(g);
          state.pop();
          current = ((TextState) state.peek()).copyState();
          list.addElement(current);
          current.x = w;
          break;
        case '^':
          w = current.getWidth(g);
          if (!current.isEmpty()) {
            current = current.copyState();
            list.addElement(current);
          }
          current.f = getScriptFont(current.f);
          current.x += w;
          current.y -= (int) ((double) (current.getAscent(g)) * sup_offset + 0.5);
          break;
        case '_':
          w = current.getWidth(g);
          if (!current.isEmpty()) {
            current = current.copyState();
            list.addElement(current);
          }
          current.f = getScriptFont(current.f);
          current.x += w;
          current.y += (int) ((double) (current.getDescent(g)) * sub_offset + 0.5);
          break;

        default:
          current.s.append(ch);
          break;
      }
    }

    for (int i = 0; i < list.size(); i++) {
      current = ((TextState) (list.elementAt(i)));

      if (!current.isEmpty()) {
        width += current.getWidth(g);
        ascent = Math.max(ascent, Math.abs(current.y) + current.getAscent(g));
        descent = Math.max(descent, Math.abs(current.y) + current.getDescent(g));
        leading = Math.max(leading, current.getLeading(g));

        maxDescent = Math.max(maxDescent, Math.abs(current.y) + current.getMaxDescent(g));
        maxAscent = Math.max(maxAscent, Math.abs(current.y) + current.getMaxAscent(g));
      }
    }

    height = ascent + descent + leading;

    return;
  }