Example #1
0
 /**
  * Test if all of the <CODE>NumberField</CODE>s on this <CODE>Floor</CODE> are superfields of
  * <CODE>n</CODE>
  *
  * @param n A number field for which we wish to determine if all members of this floor are
  *     superfields
  * @return <CODE>true</CODE> iff all number fields belonging to this floor are subfields of
  *     <CODE>n</CODE>; <CODE>false</CODE> otherwise
  */
 public boolean allSuperFieldsOf(NumberField n) {
   Component[] all = getComponents();
   for (int i = 0; i < all.length; i++) {
     NumberField maybeSuper = (NumberField) all[i];
     // DEBUG:
     // System.err.println("\tSuperfield Test:" + maybeSuper.getPoly() + ", " + n.getPoly());
     if (!maybeSuper.hasSubfield(n)) return false;
   }
   return true;
 }
Example #2
0
      /**
       * Test if all of the <CODE>NumberField</CODE>s on this <CODE>Floor</CODE> are subfields of
       * <CODE>n</CODE>
       *
       * @param n A number field for which we wish to determine if all members of this floor are
       *     subfields
       * @return <CODE>true</CODE> iff all number fields belonging to this floor are subfields of
       *     <CODE>n</CODE>; <CODE>false</CODE> otherwise
       */
      public boolean allSubfieldsOf(NumberField n) {

        Component[] all = getComponents();
        for (int i = 0; i < all.length; i++) {
          NumberField maybeSub = (NumberField) all[i];

          if (!n.hasSubfield(maybeSub)) return false;
        }
        return true;
      }
Example #3
0
  /**
   * Determine the subfields of <CODE>n</CODE> and store the results there as well.
   *
   * @param n The NumberField whose subfields we are after
   */
  private void determineSubfields(NumberField n) {
    // Progress Bar
    GiANT.gui.appendConsoleText(
        "\nDetermining sub- and superfield relations for new field" + ELL, false);
    GiANT.gui.showProgressBar(true);

    // DEBUG
    // System.err.println("subfields start for " + n.getName());
    int i = 0;
    final float size = (float) allFields.size();
    final int max = GiANT.gui.getProgressMax();

    Iterator it = allFields.iterator();
    while (it.hasNext()) {
      // Progress Bar
      float index = (float) i++;
      int progress = (int) (max * (index / size));
      // DEBUG
      // System.err.println("\tprogress=" + progress);
      GiANT.gui.setProgress(progress);

      NumberField test = (NumberField) it.next();

      if (n.hasSubfield(test) || test.hasSubfield(n)) {
        // do nothing
      } else if (GiANT.gui.kash.isSubfield(test, n)) {
        n.addSubfield(test); // also adds all subfields of test to subfields of this
        if (test.getDegree() == n.getDegree()) {
          test.addSubfield(n);
        }
      } else if (GiANT.gui.kash.isSubfield(n, test)) {
        test.addSubfield(n); // also adds all subfields of n to subfields of this
      }
    }
    // Progress Bar
    GiANT.gui.showProgressBar(false);
    GiANT.gui.appendConsoleText("done.\n", false);
    // System.err.println("subfields end for " + n.getName());
  }
Example #4
0
  /**
   * Draw the lines connecting fields on the desktop. These lines represent super-/subfield
   * relations.
   *
   * @param g The Graphics context on which to draw the lines
   * @see #linesLayer
   */
  private void drawLines(Graphics g) {
    java.awt.Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(
        java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);

    final Point Q = getCenterLocation(QLabel);

    for (int i = 0; i < towers.size(); i++) {
      Tower t = (Tower) towers.get(i);
      g2.setColor(COLORS[i % COLORS.length]);
      boolean bottom = false;
      for (int j = 0; j < t.floors.size(); j++) {
        if (j == t.floors.size() - 1) bottom = true;
        Tower.Floor f = (Tower.Floor) t.getFloor(j);
        // iterate over all fields this floor
        Component[] fields = f.getComponents();
        for (int k = 0; k < fields.length; k++) {
          NumberField a = (NumberField) fields[k]; // line origin
          Point p1 = getCenterLocation(a.getCenterComponent()); // get center

          for (int l = 0; l < towers.size(); l++) {
            if (i == l) // use different colors for drawing within/without towers
            g2.setStroke(IN_LINE);
            else g2.setStroke(OUT_LINE);
            Tower t2 = (Tower) towers.get(l);
            // pen color changes according to destination tower
            // that way all 'sets of subsets' are monochrome
            // g2.setColor(COLORS[l % COLORS.length]);
            floors:
            for (int m = 0; m < t2.floors.size(); m++) {
              Tower.Floor f2 = (Tower.Floor) t2.getFloor(m);
              // iterate over all fields this floor
              boolean done = false;
              Component[] fields2 = f2.getComponents();
              for (int n = 0; n < fields2.length; n++) {
                NumberField b = (NumberField) fields2[n]; // line destination
                if (i == l & j == m) { // we are within a floor{
                  if (k == n) ; // do nothing (don't draw to yourself)
                  else { // to do, maybe have different lines for isomorphy?
                    Point p2 = getCenterLocation(b.getCenterComponent()); // get center
                    g2.drawLine(p1.x, p1.y, p2.x, p2.y);
                    done = true;
                  }
                } else if (a.hasSubfield(b) && !a.subfieldHasProperSubfield(b)) {
                  Point p2 = getCenterLocation(b.getCenterComponent()); // get center
                  g2.drawLine(p1.x, p1.y, p2.x, p2.y);
                  done = true;
                }
              }
              // go to the next tower; only need to draw to ONE floor per tower
              if (done) break floors;
            }
          }
          if (bottom && a.hasNoProperSubfields()) { // bottom of tower, no lines out of tower...
            g2.setColor(COLORS[i % COLORS.length]);
            g2.setStroke(IN_LINE);
            g2.drawLine(p1.x, p1.y, Q.x, Q.y); // then draw to Q!
          }
        }
      }
    }
  }