Ejemplo n.º 1
0
  public DataSet loadDataSet(Vector<Integer> data) {
    int i;
    int j;
    double tempdata[] = new double[2 * data.size()];

    for (i = j = 0; i < data.size(); i++, j += 2) {
      tempdata[j] = i;
      tempdata[j + 1] = data.get(i);
    }

    return loadDataSet(tempdata, data.size());
  }
Ejemplo n.º 2
0
 public void write() {
   filename = "open/" + filename;
   try {
     BufferedWriter br = new BufferedWriter(new FileWriter(new File(filename)));
     br.write(precode);
     for (int i = 0; i < classes.size(); i++) {
       System.out.println("Jooifying " + (i + 1) + " out of " + classes.size() + 1);
       br.write(((Class) classes.get(i)).toString());
     }
     br.close();
     System.out.println("Written file " + filename);
   } catch (Exception e) {
     System.out.println("Exception " + e + " occured");
   }
 }
Ejemplo n.º 3
0
    public void actionPerformed(java.awt.event.ActionEvent arg0) {
      if (JTable1.getSelectedRowCount() != 1) {
        Utilities.errorMessage(resourceBundle.getString("Please select a view to delete"));
        return;
      }

      if (JOptionPane.showConfirmDialog(
              null,
              resourceBundle.getString("Are you sure you want to delete the selected view "),
              resourceBundle.getString("Warning!"),
              JOptionPane.YES_NO_OPTION,
              JOptionPane.WARNING_MESSAGE,
              null)
          == JOptionPane.NO_OPTION) return;

      Vector viewvec = model.getAllViews();
      for (int i = 0; i < viewvec.size(); i++) {
        String viewname = ((AuthViewWithOperations) viewvec.elementAt(i)).getAuthorizedViewName();
        if (JTable1.getValueAt(JTable1.getSelectedRow(), 0).toString().equals(viewname)) {
          AuthViewWithOperations avop = (AuthViewWithOperations) viewvec.elementAt(i);

          model.delViewOp(
              avop.getAuthorizedViewName(), avop.getViewProperties(), avop.getOperations());
        }
      }

      disableButtons();
    }
Ejemplo n.º 4
0
    public void actionPerformed(java.awt.event.ActionEvent arg0) {

      if (JTable1.getSelectedRowCount() != 1) {

        Utilities.errorMessage(resourceBundle.getString("Please select a view to edit"));
        return;
      }

      views = new ViewsWizard(ViewConfig.this, applet);
      views.setSecurityModel(model);
      Point p = JLabel1.getLocationOnScreen();
      views.setLocation(p);
      views.init();

      views.setState(false);
      Vector viewvec = model.getAllViews();
      for (int i = 0; i < viewvec.size(); i++) {
        String viewname = ((AuthViewWithOperations) viewvec.elementAt(i)).getAuthorizedViewName();
        if (JTable1.getValueAt(JTable1.getSelectedRow(), 0).toString().equals(viewname)) {
          views.setValues((AuthViewWithOperations) viewvec.elementAt(i));
        }
      }

      disableButtons();
      views.setVisible(true);
    }
Ejemplo n.º 5
0
  /** Calculate the rectangle occupied by the data */
  protected Rectangle getDataRectangle(Graphics g, Rectangle r) {
    Axis a;
    int waxis;
    int x = r.x;
    int y = r.y;
    int width = r.width;
    int height = r.height;

    for (int i = 0; i < axis.size(); i++) {
      a = ((Axis) axis.elementAt(i));

      waxis = a.getAxisWidth(g);

      switch (a.getAxisPos()) {
        case Axis.LEFT:
          x += waxis;
          width -= waxis;
          break;
        case Axis.RIGHT:
          width -= waxis;
          break;
        case Axis.TOP:
          y += waxis;
          height -= waxis;
          break;
        case Axis.BOTTOM:
          height -= waxis;
          break;
      }
    }

    return new Rectangle(x, y, width, height);
  }
Ejemplo n.º 6
0
  /**
   * This paints the entire plot. It calls the draw methods of all the attached axis and data sets.
   * The order of drawing is - Axis first, data legends next, data last.
   *
   * @params g Graphics state.
   */
  public void paint(Graphics g) {
    int i;
    Graphics lg = g.create();
    Rectangle r = bounds();

    /* The r.x and r.y returned from bounds is relative to the
     ** parents space so set them equal to zero.
     */
    r.x = 0;
    r.y = 0;

    if (DefaultBackground == null) DefaultBackground = this.getBackground();
    if (DataBackground == null) DataBackground = this.getBackground();

    //        System.out.println("Graph2D paint method called!");

    if (!paintAll) return;

    r.x += borderLeft;
    r.y += borderTop;
    r.width -= borderLeft + borderRight;
    r.height -= borderBottom + borderTop;

    paintFirst(lg, r);

    if (!axis.isEmpty()) r = drawAxis(lg, r);
    else {
      if (clearAll) {
        Color c = g.getColor();
        g.setColor(DataBackground);
        g.fillRect(r.x, r.y, r.width, r.height);
        g.setColor(c);
      }
      drawFrame(lg, r.x, r.y, r.width, r.height);
    }

    paintBeforeData(lg, r);

    if (!dataset.isEmpty()) {

      datarect.x = r.x;
      datarect.y = r.y;
      datarect.width = r.width;
      datarect.height = r.height;

      for (i = 0; i < dataset.size(); i++) {
        ((DataSet) dataset.elementAt(i)).draw_data(lg, r);
      }
    }

    paintLast(lg, r);

    lg.dispose();
  }
Ejemplo n.º 7
0
  /** 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();
  }
Ejemplo n.º 8
0
  /**
   * Get the Maximum Y value of all attached DataSets.
   *
   * @return The maximum value
   */
  public double getYmax() {
    DataSet d;
    double max = 0.0;

    if (dataset == null | dataset.isEmpty()) return max;
    for (int i = 0; i < dataset.size(); i++) {
      d = ((DataSet) dataset.elementAt(i));
      if (i == 0) max = d.getYmax();
      else max = Math.max(max, d.getYmax());
    }

    return max;
  }
Ejemplo n.º 9
0
  /**
   * Get the Minimum Y value of all attached DataSets.
   *
   * @return The minimum value
   */
  public double getYmin() {
    DataSet d;
    double min = 0.0;

    if (dataset == null | dataset.isEmpty()) return min;
    for (int i = 0; i < dataset.size(); i++) {
      d = ((DataSet) dataset.elementAt(i));
      if (i == 0) min = d.getYmin();
      else min = Math.min(min, d.getYmin());
    }

    return min;
  }
Ejemplo n.º 10
0
 public void jooify() {
   // To jooify a file, we must include Joo objects
   precode = "import JooFrame.*;\n\n" + precode;
   precode = "import Joo.*;\n" + precode;
   precode = "import Field.*;\n" + precode;
   // We must add Joo functionality to all classes
   for (int i = 0; i < classes.size(); i++) {
     // System.out.println("Jooifying "+(i+1)+" out of "+classes.size()+1);
     ((Class) classes.get(i)).jooify();
   }
   /*    JavaParser tmp=new JavaParser("JooMainAdd.java");
   tmp.read();
   classes.add((Class)tmp.classes.get(0));*/
 }
Ejemplo n.º 11
0
  /** 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();
  }
Ejemplo n.º 12
0
  public void Draw() {
    Graphics g;
    Color cl;
    int c;
    int xdiff, ydiff;

    g = parentarea.screen;
    if ((Resize) || (ResizeAll)) Calculate_Coors();

    c = ((int) activation) * 255 / 100;
    if (c < 0) c = 0;
    if (c > 255) c = 255;
    cl = new Color(c, c, c);

    if (oldclamp != clamp) {
      g.setColor(Color.white);
      g.fillRect(sx1, sy1, 1 + sx2 - sx1, 1 + sy2 - sy1);
    }

    g.setColor(cl);
    g.fillOval(sx1, sy1, sx2 - sx1, sy2 - sy1);
    g.setColor(Color.black);
    if (activation == (double) 100.0) g.setColor(Color.red);
    g.drawOval(sx1, sy1, sx2 - sx1, sy2 - sy1);

    if (clamp) {
      xdiff = (sx2 - sx1);
      ydiff = (sy2 - sy1);
      g.drawRect(sx1, sy1, xdiff, ydiff);
    }

    if ((Resize) || (ResizeAll)) CalculateSize(g);
    g.setFont(currfont);
    if (activation > 50.0) g.setColor(Color.black);
    else g.setColor(Color.white);
    if (foreground != null) g.setColor(foreground);
    g.drawString(short_name, sx1 + xoff, sy2 - yoff);
    Redraw = false;
    Resize = false;
    if (oldclamp != clamp) {
      // draw all bonds - as they will have been erased
      oldclamp = clamp;
      for (int x = 0; x < outgoing_links.size(); x++) {
        slipnet_link s = (slipnet_link) outgoing_links.elementAt(x);
        s.Draw();
      }
    }
  }
Ejemplo n.º 13
0
  public void setData() {
    /*
       if(model.getAllViews() == null)
    	{
            	return;
    }
    */
    for (int i = JTable1.getRowCount() - 1; i >= 0; i--) {
      ViewTableModel.removeRow(i);
    }

    Vector views = model.getAllViews();
    for (int j = 0; j < views.size(); j++) {
      AuthViewWithOperations view = (AuthViewWithOperations) views.elementAt(j);
      String viewNa = view.getAuthorizedViewName();
      ViewTableModel.addRow(new Object[] {viewNa});
    }
  }
Ejemplo n.º 14
0
  /**
   * This method is called when the focused component (and none of its ancestors) want the key
   * event. This will look up the keystroke to see if any chidren (or subchildren) of the specified
   * container want a crack at the event. If one of them wants it, then it will "DO-THE-RIGHT-THING"
   */
  public boolean fireKeyboardAction(KeyEvent e, boolean pressed, Container topAncestor) {

    if (e.isConsumed()) {
      System.out.println("Acquired pre-used event!");
      Thread.dumpStack();
    }

    // There may be two keystrokes associated with a low-level key event;
    // in this case a keystroke made of an extended key code has a priority.
    KeyStroke ks;
    KeyStroke ksE = null;

    if (e.getID() == KeyEvent.KEY_TYPED) {
      ks = KeyStroke.getKeyStroke(e.getKeyChar());
    } else {
      if (e.getKeyCode() != e.getExtendedKeyCode()) {
        ksE = KeyStroke.getKeyStroke(e.getExtendedKeyCode(), e.getModifiers(), !pressed);
      }
      ks = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers(), !pressed);
    }

    Hashtable keyMap = containerMap.get(topAncestor);
    if (keyMap != null) { // this container isn't registered, so bail

      Object tmp = null;
      // extended code has priority
      if (ksE != null) {
        tmp = keyMap.get(ksE);
        if (tmp != null) {
          ks = ksE;
        }
      }
      if (tmp == null) {
        tmp = keyMap.get(ks);
      }

      if (tmp == null) {
        // don't do anything
      } else if (tmp instanceof JComponent) {
        JComponent c = (JComponent) tmp;
        if (c.isShowing() && c.isEnabled()) { // only give it out if enabled and visible
          fireBinding(c, ks, e, pressed);
        }
      } else if (tmp instanceof Vector) { // more than one comp registered for this
        Vector v = (Vector) tmp;
        // There is no well defined order for WHEN_IN_FOCUSED_WINDOW
        // bindings, but we give precedence to those bindings just
        // added. This is done so that JMenus WHEN_IN_FOCUSED_WINDOW
        // bindings are accessed before those of the JRootPane (they
        // both have a WHEN_IN_FOCUSED_WINDOW binding for enter).
        for (int counter = v.size() - 1; counter >= 0; counter--) {
          JComponent c = (JComponent) v.elementAt(counter);
          // System.out.println("Trying collision: " + c + " vector = "+ v.size());
          if (c.isShowing() && c.isEnabled()) { // don't want to give these out
            fireBinding(c, ks, e, pressed);
            if (e.isConsumed()) return true;
          }
        }
      } else {
        System.out.println("Unexpected condition in fireKeyboardAction " + tmp);
        // This means that tmp wasn't null, a JComponent, or a Vector.  What is it?
        Thread.dumpStack();
      }
    }

    if (e.isConsumed()) {
      return true;
    }
    // if no one else handled it, then give the menus a crack
    // The're handled differently.  The key is to let any JMenuBars
    // process the event
    if (keyMap != null) {
      Vector v = (Vector) keyMap.get(JMenuBar.class);
      if (v != null) {
        Enumeration iter = v.elements();
        while (iter.hasMoreElements()) {
          JMenuBar mb = (JMenuBar) iter.nextElement();
          if (mb.isShowing() && mb.isEnabled()) { // don't want to give these out
            boolean extended = (ksE != null) && !ksE.equals(ks);
            if (extended) {
              fireBinding(mb, ksE, e, pressed);
            }
            if (!extended || !e.isConsumed()) {
              fireBinding(mb, ks, e, pressed);
            }
            if (e.isConsumed()) {
              return true;
            }
          }
        }
      }
    }

    return e.isConsumed();
  }
  /** Method declaration */
  void showResultInText() {

    String col[] = gResult.getHead();
    int width = col.length;
    int size[] = new int[width];
    Vector data = gResult.getData();
    String row[];
    int height = data.size();

    for (int i = 0; i < width; i++) {
      size[i] = col[i].length();
    }

    for (int i = 0; i < height; i++) {
      row = (String[]) data.elementAt(i);

      for (int j = 0; j < width; j++) {
        int l = row[j].length();

        if (l > size[j]) {
          size[j] = l;
        }
      }
    }

    StringBuffer b = new StringBuffer();

    for (int i = 0; i < width; i++) {
      b.append(col[i]);

      for (int l = col[i].length(); l <= size[i]; l++) {
        b.append(' ');
      }
    }

    b.append(NL);

    for (int i = 0; i < width; i++) {
      for (int l = 0; l < size[i]; l++) {
        b.append('-');
      }

      b.append(' ');
    }

    b.append(NL);

    for (int i = 0; i < height; i++) {
      row = (String[]) data.elementAt(i);

      for (int j = 0; j < width; j++) {
        b.append(row[j]);

        for (int l = row[j].length(); l <= size[j]; l++) {
          b.append(' ');
        }
      }

      b.append(NL);
    }

    b.append(NL + height + " row(s) in " + lTime + " ms");
    txtResult.setText(b.toString());
  }
  /** Method declaration */
  private void refreshTree() {

    tTree.removeAll();

    try {
      int color_table = Color.yellow.getRGB();
      int color_column = Color.orange.getRGB();
      int color_index = Color.red.getRGB();

      tTree.addRow("", dMeta.getURL(), "-", 0);

      String usertables[] = {"TABLE"};
      ResultSet result = dMeta.getTables(null, null, null, usertables);
      Vector tables = new Vector();

      // sqlbob@users Added remarks.
      Vector remarks = new Vector();

      while (result.next()) {
        tables.addElement(result.getString(3));
        remarks.addElement(result.getString(5));
      }

      result.close();

      for (int i = 0; i < tables.size(); i++) {
        String name = (String) tables.elementAt(i);
        String key = "tab-" + name + "-";

        tTree.addRow(key, name, "+", color_table);

        // sqlbob@users Added remarks.
        String remark = (String) remarks.elementAt(i);

        if ((remark != null) && !remark.trim().equals("")) {
          tTree.addRow(key + "r", " " + remark);
        }

        ResultSet col = dMeta.getColumns(null, null, name, null);

        while (col.next()) {
          String c = col.getString(4);
          String k1 = key + "col-" + c + "-";

          tTree.addRow(k1, c, "+", color_column);

          String type = col.getString(6);

          tTree.addRow(k1 + "t", "Type: " + type);

          boolean nullable = col.getInt(11) != DatabaseMetaData.columnNoNulls;

          tTree.addRow(k1 + "n", "Nullable: " + nullable);
        }

        col.close();
        tTree.addRow(key + "ind", "Indices", "+", 0);

        ResultSet ind = dMeta.getIndexInfo(null, null, name, false, false);
        String oldiname = null;

        while (ind.next()) {
          boolean nonunique = ind.getBoolean(4);
          String iname = ind.getString(6);
          String k2 = key + "ind-" + iname + "-";

          if ((oldiname == null || !oldiname.equals(iname))) {
            tTree.addRow(k2, iname, "+", color_index);
            tTree.addRow(k2 + "u", "Unique: " + !nonunique);

            oldiname = iname;
          }

          String c = ind.getString(9);

          tTree.addRow(k2 + "c-" + c + "-", c);
        }

        ind.close();
      }

      tTree.addRow("p", "Properties", "+", 0);
      tTree.addRow("pu", "User: "******"pr", "ReadOnly: " + cConn.isReadOnly());
      tTree.addRow("pa", "AutoCommit: " + cConn.getAutoCommit());
      tTree.addRow("pd", "Driver: " + dMeta.getDriverName());
      tTree.addRow("pp", "Product: " + dMeta.getDatabaseProductName());
      tTree.addRow("pv", "Version: " + dMeta.getDatabaseProductVersion());
    } catch (SQLException e) {
      tTree.addRow("", "Error getting metadata:", "-", 0);
      tTree.addRow("-", e.getMessage());
      tTree.addRow("-", e.getSQLState());
    }

    tTree.update();
  }
Ejemplo n.º 17
0
 public slipnode category() {
   if (category_links.size() == 0) return null;
   slipnet_link sl = (slipnet_link) category_links.elementAt(0);
   return sl.to_node;
 }
Ejemplo n.º 18
0
  /**
   * Draw the Axis. As each axis is drawn and aligned less of the canvas is avaliable to plot the
   * data. The returned Rectangle is the canvas area that the data is plotted in.
   */
  protected Rectangle drawAxis(Graphics g, Rectangle r) {
    Axis a;
    int waxis;
    Rectangle dr;
    int x;
    int y;
    int width;
    int height;

    if (square) r = ForceSquare(g, r);

    dr = getDataRectangle(g, r);

    x = dr.x;
    y = dr.y;
    width = dr.width;
    height = dr.height;

    if (clearAll) {
      Color c = g.getColor();
      g.setColor(DataBackground);
      g.fillRect(x, y, width, height);
      g.setColor(c);
    }

    // Draw a frame around the data area (If requested)
    if (frame) drawFrame(g, x, y, width, height);

    // Now draw the axis in the order specified aligning them with the final
    // data area.
    for (int i = 0; i < axis.size(); i++) {
      a = ((Axis) axis.elementAt(i));

      a.data_window = new Dimension(width, height);

      switch (a.getAxisPos()) {
        case Axis.LEFT:
          r.x += a.width;
          r.width -= a.width;
          a.positionAxis(r.x, r.x, y, y + height);
          if (r.x == x) {
            a.gridcolor = gridcolor;
            a.drawgrid = drawgrid;
            a.zerocolor = zerocolor;
            a.drawzero = drawzero;
          }

          a.drawAxis(g);

          a.drawgrid = false;
          a.drawzero = false;

          break;
        case Axis.RIGHT:
          r.width -= a.width;
          a.positionAxis(r.x + r.width, r.x + r.width, y, y + height);
          if (r.x + r.width == x + width) {
            a.gridcolor = gridcolor;
            a.drawgrid = drawgrid;
            a.zerocolor = zerocolor;
            a.drawzero = drawzero;
          }

          a.drawAxis(g);

          a.drawgrid = false;
          a.drawzero = false;

          break;
        case Axis.TOP:
          r.y += a.width;
          r.height -= a.width;
          a.positionAxis(x, x + width, r.y, r.y);
          if (r.y == y) {
            a.gridcolor = gridcolor;
            a.drawgrid = drawgrid;
            a.zerocolor = zerocolor;
            a.drawzero = drawzero;
          }

          a.drawAxis(g);

          a.drawgrid = false;
          a.drawzero = false;

          break;
        case Axis.BOTTOM:
          r.height -= a.width;
          a.positionAxis(x, x + width, r.y + r.height, r.y + r.height);
          if (r.y + r.height == y + height) {
            a.gridcolor = gridcolor;
            a.drawgrid = drawgrid;
            a.zerocolor = zerocolor;
            a.drawzero = drawzero;
          }

          a.drawAxis(g);

          a.drawgrid = false;
          a.drawzero = false;

          break;
      }
    }

    return r;
  }
Ejemplo n.º 19
0
 public void read() {
   System.out.println("Reading file " + filename);
   Vector ls = readlinesfromfile(filename);
   int i = 0;
   while (i < ls.size()
       && !((String) ls.get(i)).startsWith("class")
       && !((String) ls.get(i)).startsWith("public class")) {
     precode += (String) ls.get(i) + "\n";
     i++;
   }
   while (i < ls.size()) {
     JString l = new JString((String) ls.get(i));
     // System.out.println("Looking for a class in "+l);
     boolean pubclass = false;
     if (l.starts("public ")) {
       pubclass = true;
       l = l.after(" ");
     }
     if (l.starts("class ")) {
       // Parse class
       // Parse first line
       l = l.after("class ");
       Class c = new Class(pubclass, l.before(" ").toString());
       l = l.after(" ");
       l = l.removeall(",");
       if (l.starts("extends ")) {
         l = l.after("extends ");
         while (!l.starts("{") && !l.starts("implements")) {
           c.extended.add(l.before(" "));
           l = l.after(" ");
         }
       }
       if (l.starts("implements ")) {
         l = l.after("implements ");
         while (!l.starts("{")) {
           c.implemented.add(l.before(" "));
           l = l.after(" ");
         }
       }
       l = l.expect("{");
       i++;
       l = new JString((String) ls.get(i));
       while (!l.r.equals("}")) {
         // System.out.println("Parsing class "+c.name+" at "+l);
         if (l.r.length() == 0) i++;
         else {
           // Parse a constructor, field or method
           String type = "";
           boolean priv = true;
           boolean stat = false;
           boolean fin = false;
           boolean con = false;
           String a = l.getalphanum().toString();
           // System.out.println("Comparing >"+a+"< to class name >"+c.name+"<");
           // System.out.println("Line now "+l);
           if (a.equals(c.name)) { // Constructor
             con = true;
             // System.out.println("hello\n");
           } else {
             type = l.before(" ").toString();
             l = l.after(" ");
             if (type.equals("public")) {
               priv = false;
               type = l.before(" ").toString();
               l = l.after(" ");
             }
             if (type.equals("private")) {
               priv = true;
               type = l.before(" ").toString();
               l = l.after(" ");
             }
             if (type.equals("static")) {
               stat = true;
               type = l.before(" ").toString();
               l = l.after(" ");
             }
             // System.out.println("Checking "+type+" for \"final\"");
             if (type.equals("final")) { // Should this be before static?
               fin = true;
               type = l.before(" ").toString();
               l = l.after(" ");
             }
           }
           String name = l.getalphanum().toString();
           // System.out.println("Got name "+name+" in line "+l);
           l = l.after(name);
           l.r = l.r.trim();
           // Is it a variable (field) ?
           // Are there more than one?
           // System.out.println("Looking for = or ; in "+l);
           while (l.starts(",")) {
             // ***
             Field f = new Field(type, name, "");
             c.fields.add(f);
             l = l.after(",");
             name = l.getalphanum().toString();
             l = l.after(name);
             l.r = l.r.trim();
           }
           // Is this the last one?
           if (l.starts("=") || l.starts(";")) {
             // System.out.println("Starts = or ;");
             String init = "";
             if (l.starts("=")) {
               init = l.after("=").before(";").toString();
             }
             Field f = new Field(priv, stat, fin, type, name, init);
             c.fields.add(f);
             i++;
             // System.out.println("Added field "+f);
           } else { // It must be a method
             l = l.expect("(");
             Method m = new Method(con, !priv, stat, type, name);
             while (!l.starts(")")) {
               String atype = l.before(" ").toString();
               l = l.from(" ");
               String aname; // Is it last?
               if (l.r.indexOf(",") != -1) {
                 aname = l.before(",").toString();
                 l = l.after(",");
               } else {
                 aname = l.before(")").toString();
                 l = l.after(aname);
               }
               m.args.add(new Argument(atype, aname));
             }
             l = l.expect(")");
             l.r = l.r.trim();
             l.expect("{");
             // Read code
             i++;
             int curlycount = 1;
             while (curlycount > 0) {
               l = new JString((String) ls.get(i));
               for (int j = 0; j < l.r.length(); j++) {
                 if (l.r.charAt(j) == '{') curlycount++;
                 if (l.r.charAt(j) == '}') curlycount--;
               }
               if (curlycount > 0) {
                 String ind = "  ";
                 for (int ib = 1; ib <= curlycount; ib++) ind += "  ";
                 m.code += ind + l + "\n";
                 // System.out.println("Adding code "+l);
               }
               i++;
               // System.out.println("Ended on line "+(String)ls.get(i));
             }
             c.methods.add(m);
           }
         }
         // System.out.println("Got so far with class "+c);
         //        i++;
         l = new JString((String) ls.get(i));
         // System.out.println("Checking line "+l);
       }
       classes.add(c);
     } else {
       //        precode+=(String)ls.get(i)+"\n";
       i++;
     }
   }
   System.out.println("Found " + classes.size() + " classes.");
 }
Ejemplo n.º 20
0
  /**
   * Force the plot to have an aspect ratio of 1 by forcing the axes to have the same range. If the
   * range of the axes are very different some extremely odd things can occur. All axes are forced
   * to have the same range, so more than 2 axis is pointless.
   */
  protected Rectangle ForceSquare(Graphics g, Rectangle r) {
    Axis a;
    Rectangle dr;
    int x = r.x;
    int y = r.y;
    int width = r.width;
    int height = r.height;

    double xmin;
    double xmax;
    double ymin;
    double ymax;

    double xrange = 0.0;
    double yrange = 0.0;
    double range;

    double aspect;

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

    /*
     **          Force all the axis to have the same range. This of course
     **          means that anything other than one xaxis and one yaxis
     **          is a bit pointless.
     */
    for (int i = 0; i < axis.size(); i++) {
      a = (Axis) axis.elementAt(i);
      range = a.maximum - a.minimum;
      if (a.isVertical()) {
        yrange = Math.max(range, yrange);
      } else {
        xrange = Math.max(range, xrange);
      }
    }

    if (xrange <= 0 | yrange <= 0) return r;

    if (xrange > yrange) range = xrange;
    else range = yrange;

    for (int i = 0; i < axis.size(); i++) {
      a = (Axis) axis.elementAt(i);
      a.maximum = a.minimum + range;
    }
    /*
     **          Get the new data rectangle
     */
    dr = getDataRectangle(g, r);
    /*
     **          Modify the data rectangle so that it is square.
     */
    if (dr.width > dr.height) {
      x += (dr.width - dr.height) / 2.0;
      width -= dr.width - dr.height;
    } else {
      y += (dr.height - dr.width) / 2.0;
      height -= dr.height - dr.width;
    }

    return new Rectangle(x, y, width, height);
  }
Ejemplo n.º 21
0
  void refresh() {

    JPanel4.showCard("router"); // No Internationalisation
    if (routerobject != null) {
      ((com.adventnet.nms.examples.routermap.RouterDetails) JPanel4.getCard("router"))
          .setValues((Properties) routerobject.elementAt(0)); // No Internationalisation
      Properties prop = (Properties) routerobject.elementAt(0);
      RouterBtn.setBackground(
          SeverityInfo.getInstance()
              .getColor(Integer.parseInt(prop.getProperty("status")))); // No Internationalisation
      RouterBtn.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
      JLabel1.setText(
          NmsClientUtil.GetString("Router details  :  ")
              + prop.getProperty("name")); // No Internationalisation
    }
    if (routerobject.size() >= 2) {
      one.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(1);
      one.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      one.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 3) {
      two.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(2);
      two.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      two.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 4) {
      three.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(3);
      three.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      three.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 5) {
      four.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(4);
      four.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      four.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 6) {
      five.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(5);
      five.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      five.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 7) {
      six.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(6);
      six.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      six.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 8) {
      seven.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(7);
      seven.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      seven.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 9) {
      eight.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(8);
      eight.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      eight.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 10) {
      nine.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(9);
      nine.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      nine.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
    if (routerobject.size() >= 11) {
      ten.setVisible(true);
      Properties prop = (Properties) routerobject.elementAt(10);
      ten.setValues(
          SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))),
          prop.getProperty("ipAddress")); // No Internationalisation
      ten.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation
    }
  }