Esempio n. 1
1
  /**
   * Uses a Vector of TransformerHandlers to pipe XML input document through a series of 1 or more
   * transformations. Called by {@link #pipeDocument}.
   *
   * @param vTHandler Vector of Transformation Handlers (1 per stylesheet).
   * @param source absolute URI to XML input
   * @param target absolute path to transformation output.
   */
  public void usePipe(Vector vTHandler, String source, String target)
      throws TransformerException, TransformerConfigurationException, FileNotFoundException,
          IOException, SAXException, SAXNotRecognizedException {
    XMLReader reader = XMLReaderFactory.createXMLReader();
    TransformerHandler tHFirst = (TransformerHandler) vTHandler.firstElement();
    reader.setContentHandler(tHFirst);
    reader.setProperty("http://xml.org/sax/properties/lexical-handler", tHFirst);
    for (int i = 1; i < vTHandler.size(); i++) {
      TransformerHandler tHFrom = (TransformerHandler) vTHandler.elementAt(i - 1);
      TransformerHandler tHTo = (TransformerHandler) vTHandler.elementAt(i);
      tHFrom.setResult(new SAXResult(tHTo));
    }
    TransformerHandler tHLast = (TransformerHandler) vTHandler.lastElement();
    Transformer trans = tHLast.getTransformer();
    Properties outputProps = trans.getOutputProperties();
    Serializer serializer = SerializerFactory.getSerializer(outputProps);

    FileOutputStream out = new FileOutputStream(target);
    try {
      serializer.setOutputStream(out);
      tHLast.setResult(new SAXResult(serializer.asContentHandler()));
      reader.parse(source);
    } finally {
      // Always clean up the FileOutputStream,
      // even if an exception was thrown in the try block
      if (out != null) out.close();
    }
  }
Esempio n. 2
1
 private void fillItems(String[] sArray) {
   int index;
   for (int i = 0, k = subCategories.size(); i < items.size(); i++) {
     index = ((Integer) items.elementAt(i)).intValue();
     sArray[k + i] = ((Item) itemsIndex.elementAt(index)).title;
   }
 }
Esempio n. 3
1
    @Override
    public boolean onContextItemSelected(MenuItem item) {

      int posn = (int) ((AdapterContextMenuInfo) item.getMenuInfo()).position;
      Codec c = codecs.elementAt(posn);
      if (item.getItemId() == MENU_UP) {
        if (posn == 0) return super.onContextItemSelected(item);
        Codec tmp = codecs.elementAt(posn - 1);
        codecs.set(posn - 1, c);
        codecs.set(posn, tmp);
      } else if (item.getItemId() == MENU_DOWN) {
        if (posn == codecs.size() - 1) return super.onContextItemSelected(item);
        Codec tmp = codecs.elementAt(posn + 1);
        codecs.set(posn + 1, c);
        codecs.set(posn, tmp);
      }
      PreferenceScreen ps = getPreferenceScreen();
      SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext);
      String v = "";
      SharedPreferences.Editor e = sp.edit();

      for (Codec d : codecs) v = v + d.number() + " ";
      e.putString(Settings.PREF_CODECS, v);
      e.commit();
      ps.removeAll();
      addPreferences(ps);
      return super.onContextItemSelected(item);
    }
Esempio n. 4
0
  /**
   * Add a Condition to the form's Collection.
   *
   * @param condition the condition to be set
   */
  public Triggerable addTriggerable(Triggerable t) {
    int existingIx = triggerables.indexOf(t);
    if (existingIx >= 0) {
      // one node may control access to many nodes; this means many nodes effectively have the same
      // condition
      // let's identify when conditions are the same, and store and calculate it only once

      // note, if the contextRef is unnecessarily deep, the condition will be evaluated more times
      // than needed
      // perhaps detect when 'identical' condition has a shorter contextRef, and use that one
      // instead?
      return (Triggerable) triggerables.elementAt(existingIx);
    } else {
      triggerables.addElement(t);
      triggerablesInOrder = false;

      Vector triggers = t.getTriggers();
      for (int i = 0; i < triggers.size(); i++) {
        TreeReference trigger = (TreeReference) triggers.elementAt(i);
        if (!triggerIndex.containsKey(trigger)) {
          triggerIndex.put(trigger, new Vector());
        }
        Vector triggered = (Vector) triggerIndex.get(trigger);
        if (!triggered.contains(t)) {
          triggered.addElement(t);
        }
      }

      return t;
    }
  }
Esempio n. 5
0
  private void evaluateTriggerables(Vector tv, TreeReference anchorRef) {
    // add all cascaded triggerables to queue
    for (int i = 0; i < tv.size(); i++) {
      Triggerable t = (Triggerable) tv.elementAt(i);
      if (t.canCascade()) {
        for (int j = 0; j < t.getTargets().size(); j++) {
          TreeReference target = (TreeReference) t.getTargets().elementAt(j);
          Vector triggered = (Vector) triggerIndex.get(target);
          if (triggered != null) {
            for (int k = 0; k < triggered.size(); k++) {
              Triggerable u = (Triggerable) triggered.elementAt(k);
              if (!tv.contains(u)) tv.addElement(u);
            }
          }
        }
      }
    }

    // 'triggerables' is topologically-ordered by dependencies, so evaluate the triggerables in 'tv'
    // in the order they appear in 'triggerables'
    for (int i = 0; i < triggerables.size(); i++) {
      Triggerable t = (Triggerable) triggerables.elementAt(i);
      if (tv.contains(t)) {
        evaluateTriggerable(t, anchorRef);
      }
    }
  }
 public Object clone() {
   FigForkState figClone = (FigForkState) super.clone();
   Vector v = figClone.getFigs();
   figClone._bigPort = (FigRect) v.elementAt(0);
   figClone._head = (FigRect) v.elementAt(1);
   return figClone;
 }
Esempio n. 7
0
  /**
   * Set an attribute. This replaces an attribute of the same name. To set the zeroth attribute (the
   * tag name), use setTagName().
   *
   * @param attribute The attribute to set.
   */
  public void setAttribute(Attribute attribute) {
    boolean replaced;
    Vector attributes;
    int length;
    String name;
    Attribute test;
    String test_name;

    replaced = false;
    attributes = getAttributesEx();
    length = attributes.size();
    if (0 < length) {
      name = attribute.getName();
      for (int i = 1; i < attributes.size(); i++) {
        test = (Attribute) attributes.elementAt(i);
        test_name = test.getName();
        if (null != test_name)
          if (test_name.equalsIgnoreCase(name)) {
            attributes.setElementAt(attribute, i);
            replaced = true;
          }
      }
    }
    if (!replaced) {
      // add whitespace between attributes
      if ((0 != length) && !((Attribute) attributes.elementAt(length - 1)).isWhitespace())
        attributes.addElement(new Attribute(" "));
      attributes.addElement(attribute);
    }
  }
Esempio n. 8
0
  public void showCategory(int selectedCategory) {
    if (selectedCategory == PARENT_CATEGORY_ROOT_FILE) {
      level = ROOT_FILE;
      selectedCategory = PARENT_CATEGORY_TOP;
    }
    if (level == ROOT_FILE) {
      setRootContent();
      displayedCategory = (Category) categoriesIndex.elementAt(0);
      level = NON_ROOT_FILE;
      lastSelectedCategoryIndex = PARENT_CATEGORY_TOP;
    } else if (level == NON_ROOT_FILE) {
      createContentObjectAndInitCategory(selectedCategory);
      level = IN_NON_ROOT_FILE;
      lastSelectedCategoryIndex = PARENT_CATEGORY_TOP;
    } else if (level == IN_NON_ROOT_FILE) {
      displayedCategory = (Category) categoriesIndex.elementAt(selectedCategory);
      lastSelectedCategoryIndex = selectedCategory;
    }
    subCategories = displayedCategory.subcategories;
    items = displayedCategory.items;

    String[] sArray = new String[subCategories.size() + items.size()];
    fillCategories(sArray);
    fillItems(sArray);
    List tmpList = showList(tr.t("CATEGORIES"), sArray);
    tmpList.setSelectedIndex(displayedCategory.lastSelectedPosition, true);

    display.setCurrent(tmpList);
  }
  protected void doAction(Object param) {
    NedListModel categoriesList = (NedListModel) param;

    int quantity = 0;
    for (int i = 0; i < categoriesList.getSize(); i++) {
      Content categoryItem = (Content) categoriesList.getItemAt(i);
      Vector catalogList = XmlManager.getContentChilds(categoryItem.getId(), null);
      for (int j = 0; j < catalogList.size(); j++) {
        Content catalogItem = (Content) catalogList.elementAt(j);
        Vector mediaItemList = XmlManager.getContentChilds(catalogItem.getId(), null);
        for (int k = 0; k < mediaItemList.size(); k++) {
          Content mediaItem = (Content) mediaItemList.elementAt(k);
          if (!mediaItem.isDownloaded()) {
            AddToDownloadQueueCommand.getInstance().execute(mediaItem);
            ++quantity;
          }
        }
      }
    }
    if (quantity > 0) {
      Object[] params = {String.valueOf(quantity)};
      String msg = Localization.getMessage(NedResources.ITEM_ADDED_TO_QUEUE, params);
      GeneralAlert.show(msg, GeneralAlert.INFO);
    } else {
      GeneralAlert.show(NedResources.ALL_FILES_DOWNLOADED, GeneralAlert.INFO);
    }
  }
 /**
  * {@collect.stats} Invokes the <code>getAccessibleChild</code> method on each UI handled by this
  * object.
  *
  * @return the value obtained from the first UI, which is the UI obtained from the default <code>
  *     LookAndFeel</code>
  */
 public Accessible getAccessibleChild(JComponent a, int b) {
   Accessible returnValue = ((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a, b);
   for (int i = 1; i < uis.size(); i++) {
     ((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a, b);
   }
   return returnValue;
 }
Esempio n. 11
0
  public void fillMenuOptions(Menu menu, int instance) {
    boolean haveContext = false;
    boolean hasMiniMenu = false;

    if ((instance == Menu.INSTANCE_CONTEXT) || (pushMiniMenu)) {
      for (int i = 0; i < m_MiniMenuItems.size(); ++i) {
        MenuItem item = (MenuItem) m_MiniMenuItems.elementAt(i);
        if (item != null) {
          menu.add(item);
          hasMiniMenu = true;
        }
      }
    }

    if (!hasMiniMenu) {
      for (int i = 0; i < m_contextMenuItems.size(); ++i) {
        MenuItem item = (MenuItem) m_contextMenuItems.elementAt(i);
        if (item != null) {
          menu.add(item);
          haveContext = true;
        }
      }
    }

    if (((!haveContext) && (!hasMiniMenu))) {
      for (int i = 0; i < m_menuItems.size(); ++i) {
        menu.add((MenuItem) m_menuItems.elementAt(i));
      }
    }
  }
 /**
  * {@collect.stats} Invokes the <code>getMaximumSize</code> method on each UI handled by this
  * object.
  *
  * @return the value obtained from the first UI, which is the UI obtained from the default <code>
  *     LookAndFeel</code>
  */
 public Dimension getMaximumSize(JComponent a) {
   Dimension returnValue = ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
   for (int i = 1; i < uis.size(); i++) {
     ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
   }
   return returnValue;
 }
 /**
  * {@collect.stats} Invokes the <code>getAccessibleChildrenCount</code> method on each UI handled
  * by this object.
  *
  * @return the value obtained from the first UI, which is the UI obtained from the default <code>
  *     LookAndFeel</code>
  */
 public int getAccessibleChildrenCount(JComponent a) {
   int returnValue = ((ComponentUI) (uis.elementAt(0))).getAccessibleChildrenCount(a);
   for (int i = 1; i < uis.size(); i++) {
     ((ComponentUI) (uis.elementAt(i))).getAccessibleChildrenCount(a);
   }
   return returnValue;
 }
Esempio n. 14
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();
    }
Esempio n. 15
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);
    }
  /**
   * INTERNAL: Returns the first field from each of the owned tables, used for fine-grained
   * pessimistic locking.
   */
  protected Vector getForUpdateOfFields() {
    Vector allFields = getFields();
    int expected = getTableAliases().size();
    Vector firstFields = new Vector(expected);
    DatabaseTable lastTable = null;
    DatabaseField field = null;
    int i = 0;

    // The following loop takes O(n*m) time.  n=# of fields. m=#tables.
    // However, in the m=1 case this will take one pass only.
    // Also assuming that fields are generally sorted by table, this will
    // take O(n) time.
    // An even faster way may be to go getDescriptor().getAdditionalPrimaryKeyFields.
    while ((i < allFields.size()) && (firstFields.size() < expected)) {
      field = (DatabaseField) allFields.elementAt(i++);
      if ((lastTable == null) || !field.getTable().equals(lastTable)) {
        lastTable = field.getTable();
        int j = 0;
        while (j < firstFields.size()) {
          if (lastTable.equals(((DatabaseField) firstFields.elementAt(j)).getTable())) {
            break;
          }
          j++;
        }
        if (j == firstFields.size()) {
          firstFields.addElement(field);
        }
      }
    }
    return firstFields;
  }
Esempio n. 17
0
  // {{{ createMacrosMenu() method
  private void createMacrosMenu(JMenu menu, Vector vector, int start) {
    Vector<JMenuItem> menuItems = new Vector<JMenuItem>();
    int maxItems = jEdit.getIntegerProperty("menu.spillover", 20);
    JMenu subMenu = null;
    for (int i = start; i < vector.size(); i++) {
      if (i != start && i % maxItems == 0) {
        subMenu = new JMenu(jEdit.getProperty("common.more"));
        createMacrosMenu(subMenu, vector, i);
        break;
      }
      Object obj = vector.elementAt(i);
      if (obj instanceof String) {
        menuItems.add(
            new EnhancedMenuItem(
                jEdit.getProperty(obj + ".label"), (String) obj, jEdit.getActionContext()));
      } else if (obj instanceof Vector) {
        Vector subvector = (Vector) obj;
        String name = (String) subvector.elementAt(0);
        JMenu submenu = new JMenu(jEdit.getProperty("macros.folder." + name + ".label", name));
        createMacrosMenu(submenu, subvector, 1);
        if (submenu.getMenuComponentCount() != 0) menuItems.add(submenu);
      }
    }

    Collections.sort(menuItems, new MenuItemTextComparator());

    if (subMenu != null) menuItems.add(subMenu);

    for (int i = 0; i < menuItems.size(); i++) {
      menu.add(menuItems.get(i));
    }
  } // }}}
 /**
  * {@collect.stats} Invokes the <code>contains</code> method on each UI handled by this object.
  *
  * @return the value obtained from the first UI, which is the UI obtained from the default <code>
  *     LookAndFeel</code>
  */
 public boolean contains(JComponent a, int b, int c) {
   boolean returnValue = ((ComponentUI) (uis.elementAt(0))).contains(a, b, c);
   for (int i = 1; i < uis.size(); i++) {
     ((ComponentUI) (uis.elementAt(i))).contains(a, b, c);
   }
   return returnValue;
 }
Esempio n. 19
0
 /**
  * Returns a matrix containing the line dimensions of this text element. The rows in this matrix
  * represent the lines, the two columns represent respectively the width and the height of the
  * corresponding line.
  *
  * @return line dimension matrix
  */
 public float[][] getLineDimensions() {
   float lineDimensions[][] = new float[0][0];
   if (getTaintMode() == TAINTED) {
     int lines = 1;
     if (tspanVector.size() > 0) lines = tspanVector.lastElement().getLine() + 1;
     lineDimensions = new float[lines][2];
     lineDimensions[0][0] = 0.0f;
     lineDimensions[0][1] = 0.0f;
     for (int i = 0; i < lines; i++) {
       float h = 0.0f;
       float w = 0.0f;
       for (int x = 0; x < tspanVector.size(); x++) {
         if (tspanVector.elementAt(x).getLine() == i) {
           h = Math.max(h, tspanVector.elementAt(x).getHeight());
           w += tspanVector.elementAt(x).getWidth();
         }
         lineDimensions[i][0] = w;
         lineDimensions[i][1] = 0.5f * h; // bug in batik?!
       }
     }
     cachedLineDimensions = lineDimensions;
   }
   if (getTaintMode() == UNTAINTED) lineDimensions = cachedLineDimensions;
   return lineDimensions;
 }
Esempio n. 20
0
 private void fillCategories(String[] sArray) {
   int index;
   for (int i = 0; i < subCategories.size(); i++) {
     index = ((Integer) subCategories.elementAt(i)).intValue();
     sArray[i] = ((Category) categoriesIndex.elementAt(index)).title;
   }
 }
Esempio n. 21
0
  /** paint */
  public void paint(Graphics g) {
    g.setFont(MainCanvas.nameFont);

    g.setColor(255, 255, 255);
    g.fillRect(0, 0, getWidth(), getHeight());
    UIPainter.paintBackground(g);

    int i;
    for (i = 0; i < myTools.size(); i++) {
      if (se == i) {
        g.setColor(0, 0, 0);
        g.fillRect(
            0, i * MainCanvas.nameFont.getHeight(), getWidth(), MainCanvas.nameFont.getHeight());
        g.setColor(255, 255, 255);
        g.drawString(
            "" + JustPaint.c.brs[((Integer) myTools.elementAt(i)).intValue()],
            5,
            i * MainCanvas.nameFont.getHeight(),
            Graphics.LEFT | Graphics.TOP);
      } else {
        g.setColor(0, 0, 0);
        g.drawString(
            "" + JustPaint.c.brs[((Integer) myTools.elementAt(i)).intValue()],
            5,
            i * MainCanvas.nameFont.getHeight(),
            Graphics.LEFT | Graphics.TOP);
      }
    }

    UIPainter.paintLeftSoft(g, "Добавить");
    UIPainter.paintRightSoft(g, "Отмена");
  }
Esempio n. 22
0
  /** Add nodes from under "dir" into curTop. Highly recursive. */
  DefaultMutableTreeNode addNodes(DefaultMutableTreeNode curTop, File dir) {

    String curPath = dir.getPath();
    DefaultMutableTreeNode curDir = new DefaultMutableTreeNode(curPath);
    if (curTop != null) { // should only be null at root
      curTop.add(curDir);
    }
    Vector<String> ol = new Vector<String>();
    String[] tmp = dir.list();

    for (String aTmp : tmp) ol.addElement(aTmp);

    Collections.sort(ol, String.CASE_INSENSITIVE_ORDER);
    File f;
    Vector<String> files = new Vector<String>();
    // Make two passes, one for Dirs and one for Files. This is #1.
    for (int i = 0; i < ol.size(); i++) {
      String thisObject = ol.elementAt(i);
      String newPath;
      if (curPath.equals(".")) newPath = thisObject;
      else newPath = curPath + File.separator + thisObject;
      if ((f = new File(newPath)).isDirectory()) addNodes(curDir, f);
      else files.addElement(thisObject);
    }
    // Pass two: for files.
    for (int fnum = 0; fnum < files.size(); fnum++)
      curDir.add(new DefaultMutableTreeNode(files.elementAt(fnum)));
    return curDir;
  }
  protected void sort() {
    if (set.size() > 1) {
      boolean swapped = true;
      int lastSwap = set.size() - 1;

      while (swapped) {
        int index = 0;
        int swapIndex = 0;
        byte[] a = getEncoded((DEREncodable) set.elementAt(0));

        swapped = false;

        while (index != lastSwap) {
          byte[] b = getEncoded((DEREncodable) set.elementAt(index + 1));

          if (lessThanOrEqual(a, b)) {
            a = b;
          } else {
            Object o = set.elementAt(index);

            set.setElementAt(set.elementAt(index + 1), index);
            set.setElementAt(o, index + 1);

            swapped = true;
            swapIndex = index;
          }

          index++;
        }

        lastSwap = swapIndex;
      }
    }
  }
Esempio n. 24
0
 protected void playMultiNote(
     MultiNote multiNote,
     int indexInScore,
     KeySignature currentKey,
     long reference,
     Track track,
     Music staff)
     throws InvalidMidiDataException {
   Vector notesVector = multiNote.getNotesAsVector();
   for (int j = 0; j < notesVector.size(); j++) {
     Note note = (Note) (notesVector.elementAt(j));
     if (!note.isRest() && !note.isEndingTie())
       addNoteOnEventsFor(track, reference, getNoteOneMessageFor(note, currentKey));
   }
   for (int j = 0; j < notesVector.size(); j++) {
     Note note = (Note) (notesVector.elementAt(j));
     // TODO needs to be improved to take into account multi notes with different notes length
     long noteDuration = getNoteLengthInTicks(multiNote, staff);
     if (!note.isRest() && !note.isEndingTie())
       addNoteOffEventsFor(
           track, reference + noteDuration, getNoteOffMessageFor(note, currentKey));
   }
   for (int j = 0; j < notesVector.size(); j++)
     updateKey(currentKey, (Note) notesVector.elementAt(j));
 }
Esempio n. 25
0
  /**
   * @param elements
   * @param multiplicities
   * @return
   */
  public TreeReference getChildInstanceRef(Vector elements, Vector multiplicities) {
    if (elements.size() == 0) return null;

    // get reference for target element
    TreeReference ref =
        FormInstance.unpackReference(((IFormElement) elements.lastElement()).getBind()).clone();
    for (int i = 0; i < ref.size(); i++) {
      // There has to be a better way to encapsulate this
      if (ref.getMultiplicity(i) != TreeReference.INDEX_ATTRIBUTE) {
        ref.setMultiplicity(i, 0);
      }
    }

    // fill in multiplicities for repeats along the way
    for (int i = 0; i < elements.size(); i++) {
      IFormElement temp = (IFormElement) elements.elementAt(i);
      if (temp instanceof GroupDef && ((GroupDef) temp).getRepeat()) {
        TreeReference repRef = FormInstance.unpackReference(temp.getBind());
        if (repRef.isParentOf(ref, false)) {
          int repMult = ((Integer) multiplicities.elementAt(i)).intValue();
          ref.setMultiplicity(repRef.size() - 1, repMult);
        } else {
          return null; // question/repeat hierarchy is not consistent
          // with instance instance and bindings
        }
      }
    }

    return ref;
  }
Esempio n. 26
0
  public void draw(Graphics g) {
    // System.err.println("hpos=" + parent.hpos + "/vpos="+parent.vpos);
    for (Enumeration e = prop.keys(); e.hasMoreElements(); ) {
      int key = ((Integer) e.nextElement()).intValue();
      switch (key) {
        case CanvasProp.FILL:
          g.setColor((Color) prop.get(key));
          break;
        case CanvasProp.WIDTH:
          // NYI
          break;
        case CanvasProp.TAG:
          // nothing to do here
          break;
        default:
          throw new Error("Unknown property key " + key);
      }
    }

    for (int i = 0; i < coords.size() - 3; i += 2) {
      // System.err.println(((Integer)coords.elementAt(i  )).intValue() + (500-parent.hpos) + " " +
      // (((Integer)coords.elementAt(i+1)).intValue() + (350-parent.vpos)));
      g.drawLine(
          ((Integer) coords.elementAt(i)).intValue() + (500 - parent.hpos),
          ((Integer) coords.elementAt(i + 1)).intValue() + (350 - parent.vpos),
          ((Integer) coords.elementAt(i + 2)).intValue() + (500 - parent.hpos),
          ((Integer) coords.elementAt(i + 3)).intValue() + (350 - parent.vpos));
    }
  }
Esempio n. 27
0
 private void calculate() {
   // 计算表达式
   String res = "";
   String res1 = "";
   String res2 = "";
   int index = 0; // 要运算的操作符所在的位置
   int size = expVector.size();
   String temp = ""; // 保存运算符
   while (index < size) {
     temp = (String) expVector.elementAt(index);
     if (isSingleSign(temp) || isDoubleSign(temp)) {
       // 如果检测到运算符则要进行运算
       if (temp.equals("!")) {
         res1 = (String) expVector.elementAt(index - 1);
         res = operation.operate(temp, res1, "");
         expVector.setElementAt(res, index - 1);
         expVector.removeElementAt(index);
       } else {
         res1 = (String) expVector.elementAt(index - 2);
         res2 = (String) expVector.elementAt(index - 1);
         res = operation.operate(temp, res1, res2);
         expVector.setElementAt(res, index - 2);
         expVector.removeElementAt(index - 1);
         expVector.removeElementAt(index - 1);
       }
       calculate();
       break;
     } else {
       index++;
     }
   }
 }
Esempio n. 28
0
 public DVector parseLootPolicyFor(MOB mob) {
   if (mob == null) return new DVector(3);
   Vector lootPolicy =
       (!mob.isMonster())
           ? new Vector()
           : CMParms.parseCommas(CMProps.getVar(CMProps.SYSTEM_ITEMLOOTPOLICY), true);
   DVector policies = new DVector(3);
   for (int p = 0; p < lootPolicy.size(); p++) {
     String s = ((String) lootPolicy.elementAt(p)).toUpperCase().trim();
     if (s.length() == 0) continue;
     Vector compiledMask = null;
     int maskDex = s.indexOf("MASK=");
     if (maskDex >= 0) {
       s = s.substring(0, maskDex).trim();
       compiledMask =
           CMLib.masking()
               .maskCompile(((String) lootPolicy.elementAt(p)).substring(maskDex + 5).trim());
     } else compiledMask = new Vector();
     Vector parsed = CMParms.parse(s);
     int pct = 100;
     for (int x = 0; x < parsed.size(); x++)
       if (CMath.isInteger((String) parsed.elementAt(x)))
         pct = CMath.s_int((String) parsed.elementAt(x));
       else if (CMath.isPct((String) parsed.elementAt(x)))
         pct = (int) Math.round(CMath.s_pct((String) parsed.elementAt(x)) * 100.0);
     int flags = 0;
     if (parsed.contains("RUIN")) flags |= CMMiscUtils.LOOTFLAG_RUIN;
     else if (parsed.contains("LOSS")) flags |= CMMiscUtils.LOOTFLAG_LOSS;
     if (flags == 0) flags |= CMMiscUtils.LOOTFLAG_LOSS;
     if (parsed.contains("WORN")) flags |= CMMiscUtils.LOOTFLAG_WORN;
     else if (parsed.contains("UNWORN")) flags |= CMMiscUtils.LOOTFLAG_UNWORN;
     policies.addElement(Integer.valueOf(pct), Integer.valueOf(flags), compiledMask);
   }
   return policies;
 }
Esempio n. 29
0
 /**
  * PDF has a wacky grammar which must be a legacy of PostScript's postfix syntax. A keyword of R
  * means that the two previous objects are really part of an indirect object reference. This means
  * that when a vector of objects is complete, it has to be read backwards so that indirect object
  * references can be collapsed out. In the case of a dictionary, this has to be done before the
  * content can be interpreted as key-value pairs.
  */
 private void collapseObjectVector(Vector v) throws PdfException {
   for (int i = v.size() - 1; i >= 2; i--) {
     PdfObject obj = (PdfObject) v.elementAt(i);
     if (obj instanceof PdfSimpleObject) {
       Token tok = ((PdfSimpleObject) obj).getToken();
       if (tok instanceof Keyword) {
         if ("R".equals(((Keyword) tok).getValue())) {
           // We're in the key of 'R'.  The two previous tokens
           // had better be Numerics.  Three objects in the Vector
           // are replaced by one.
           try {
             PdfSimpleObject nobj = (PdfSimpleObject) v.elementAt(i - 2);
             Numeric ntok = (Numeric) nobj.getToken();
             int objNum = ntok.getIntegerValue();
             nobj = (PdfSimpleObject) v.elementAt(i - 1);
             ntok = (Numeric) nobj.getToken();
             int genNum = ntok.getIntegerValue();
             v.set(i - 2, new PdfIndirectObj(objNum, genNum, _objectMap));
             v.removeElementAt(i);
             v.removeElementAt(i - 1);
             i -= 2;
           } catch (Exception e) {
             throw new PdfMalformedException("Malformed indirect object reference");
           }
         }
       }
     }
   }
 }
Esempio n. 30
-1
  public void clearFields() {
    Field f;

    Checkbox c;
    TextField t;

    int i;

    for (i = 1; i <= db.getFieldCount(); i++) {
      try {
        f = db.getField(i);
        if (f.isMemoField()) {
          f.put("");
        } else if (f.getType() == 'L') {
          c = (Checkbox) fldObjects.elementAt(i - 1);
          c.setState(false);
        } else {
          t = (TextField) fldObjects.elementAt(i - 1);
          t.setText("");
        }
      } catch (Exception e1) {
        System.out.println(e1);
        System.exit(3);
      }
    }
  }