public StringBuffer saveStringBuffer() {
   StringBuffer save = new StringBuffer();
   for (java.util.Enumeration<Editor> e = pageList.elements(); e.hasMoreElements(); ) {
     Editor page = e.nextElement();
     save.append(
         "<"
             + name
             + ".Page>\n"
             + "<Type>"
             + typeOfPage(page)
             + "</Type>\n"
             + "<Name>"
             + page.getName()
             + "</Name>\n"
             + "<Active>"
             + page.isActive()
             + "</Active>\n"
             + "<"
             + contentDelim
             + ">\n");
     save.append(page.saveStringBuffer());
     save.append("</" + contentDelim + ">\n" + "</" + name + ".Page>\n");
   }
   return save;
 }
 protected void setToolTip() {
   TileI currentTile =
       orUIManager.getGameUIManager().getGameManager().getTileManager().getTile(internalId);
   StringBuffer tt = new StringBuffer("<html>");
   tt.append("<b>Tile</b>: ").append(currentTile.getName()); // or
   // getId()
   if (currentTile.hasStations()) {
     // for (Station st : currentTile.getStations())
     int cityNumber = 0;
     // TileI has stations, but
     for (Station st : currentTile.getStations()) {
       cityNumber++; // = city.getNumber();
       tt.append("<br>  ")
           .append(st.getType())
           .append(" ")
           .append(cityNumber) // .append("/").append(st.getNumber())
           .append(": value ");
       tt.append(st.getValue());
       if (st.getBaseSlots() > 0) {
         tt.append(", ").append(st.getBaseSlots()).append(" slots");
       }
     }
   }
   tt.append("</html>");
   toolTip = tt.toString();
 }
Example #3
0
 @Override
 protected Index doInBackground() throws Exception {
   int binSize = IgvTools.LINEAR_BIN_SIZE;
   FeatureCodec codec =
       CodecFactory.getCodec(
           file.getAbsolutePath(), GenomeManager.getInstance().getCurrentGenome());
   if (codec != null) {
     try {
       Index index = IndexFactory.createLinearIndex(file, codec, binSize);
       if (index != null) {
         IgvTools.writeTribbleIndex(index, idxFile.getAbsolutePath());
       }
       return index;
     } catch (TribbleException.MalformedFeatureFile e) {
       StringBuffer buf = new StringBuffer();
       buf.append("<html>Files must be sorted by start position prior to indexing.<br>");
       buf.append(e.getMessage());
       buf.append(
           "<br><br>Note: igvtools can be used to sort the file, select \"File > Run igvtools...\".");
       MessageUtils.showMessage(buf.toString());
     }
   } else {
     throw new DataLoadException("Unknown File Type", file.getAbsolutePath());
   }
   return null;
 }
Example #4
0
  protected String getFeatureText() {
    String txt = "";
    try {
      txt = ((HTMLDocument) getDocument()).getText(0, getDocument().getLength()).trim();

      StringBuffer buff = new StringBuffer();
      StringTokenizer tok = new StringTokenizer(txt, "/");
      int ntok = 0;

      while (tok.hasMoreTokens()) {
        String tokTxt = "/" + tok.nextToken().trim();

        int ind = tokTxt.indexOf("=");

        if (ntok != 0 && ind > -1 && qualifier.contains(tokTxt.substring(0, ind + 1)))
          buff.append("\n" + tokTxt);
        else buff.append(tokTxt);

        ntok++;
      }

      txt = buff.toString();
    } catch (BadLocationException ble) {
      ble.printStackTrace();
    }

    return txt;
  }
 private static double readDouble(PushbackReader read) throws IOException {
   StringBuffer s = new StringBuffer();
   int count = -1;
   while (true) {
     char ch = (char) read.read();
     // skip spaces
     if (ch == ' ') continue;
     count++;
     // allow a - only if at the beginning
     if (ch == '-' && count == 0) {
       // u.p("negative number");
       s.append(ch);
       continue;
     }
     if ((ch >= '0' && ch <= '9') || ch == '.') {
       // u.p("got double part " + ch);
       s.append(ch);
     } else {
       if (ch != ',') {
         read.unread(ch);
       }
       break;
     }
   }
   return Double.parseDouble(s.toString());
 }
Example #6
0
  protected String gettitle(String strFreq) {
    StringBuffer sbufTitle = new StringBuffer().append("VnmrJ  ");
    String strPath = FileUtil.openPath(FileUtil.SYS_VNMR + "/vnmrrev");
    BufferedReader reader = WFileUtil.openReadFile(strPath);
    String strLine;
    String strtype = "";
    if (reader == null) return sbufTitle.toString();

    try {
      while ((strLine = reader.readLine()) != null) {
        strtype = strLine;
      }
      strtype = strtype.trim();
      if (strtype.equals("merc")) strtype = "Mercury";
      else if (strtype.equals("mercvx")) strtype = "Mercury-Vx";
      else if (strtype.equals("mercplus")) strtype = "MERCURY plus";
      else if (strtype.equals("inova")) strtype = "INOVA";
      String strHostName = m_strHostname;
      if (strHostName == null) strHostName = "";
      sbufTitle.append("    ").append(strHostName);
      sbufTitle.append("    ").append(strtype);
      sbufTitle.append(" - ").append(strFreq);
      reader.close();
    } catch (Exception e) {
      // e.printStackTrace();
      Messages.logError(e.toString());
    }

    return sbufTitle.toString();
  }
  /** Add import statements to the current tab for all of packages inside the specified jar file. */
  public void handleImportLibrary(String jarPath) {
    // make sure the user didn't hide the sketch folder
    sketch.ensureExistence();

    // import statements into the main sketch file (code[0])
    // if the current code is a .java file, insert into current
    // if (current.flavor == PDE) {
    if (mode.isDefaultExtension(sketch.getCurrentCode())) {
      sketch.setCurrentCode(0);
    }

    // could also scan the text in the file to see if each import
    // statement is already in there, but if the user has the import
    // commented out, then this will be a problem.
    String[] list = Base.packageListFromClassPath(jarPath);
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < list.length; i++) {
      buffer.append("import ");
      buffer.append(list[i]);
      buffer.append(".*;\n");
    }
    buffer.append('\n');
    buffer.append(getText());
    setText(buffer.toString());
    setSelection(0, 0); // scroll to start
    sketch.setModified(true);
  }
 private void traverseToLeaves(
     final PackageDependenciesNode treeNode,
     final StringBuffer denyRules,
     final StringBuffer allowRules) {
   final Enumeration enumeration = treeNode.breadthFirstEnumeration();
   while (enumeration.hasMoreElements()) {
     PsiElement childPsiElement =
         ((PackageDependenciesNode) enumeration.nextElement()).getPsiElement();
     if (myIllegalDependencies.containsKey(childPsiElement)) {
       final Map<DependencyRule, Set<PsiFile>> illegalDeps =
           myIllegalDependencies.get(childPsiElement);
       for (final DependencyRule rule : illegalDeps.keySet()) {
         if (rule.isDenyRule()) {
           if (denyRules.indexOf(rule.getDisplayText()) == -1) {
             denyRules.append(rule.getDisplayText());
             denyRules.append("\n");
           }
         } else {
           if (allowRules.indexOf(rule.getDisplayText()) == -1) {
             allowRules.append(rule.getDisplayText());
             allowRules.append("\n");
           }
         }
       }
     }
   }
 }
    public String nextToken() {
      StringBuffer token = new StringBuffer();

      while (skipChar((char) getChar(1))) {
        nextChar();
      }

      while (nextChar()) {
        char c = getChar();

        if (c == '"') {
          token.append(parseString());
          break;
        }

        if (isWordChar(c)) {
          token.append(c);
        } else {
          if (token.length() == 0) token.append(c);
          else position--;
          break;
        }
      }

      if (token.length() == 0) return null;
      else return token.toString();
    }
Example #10
0
  /**
   * Get the Lincese text from a text file specified in the PropertyBox.
   *
   * @return String - License text.
   */
  public String getLicenseText() {
    StringBuffer textBuffer = new StringBuffer();
    try {
      String fileName = RuntimeProperties.GPL_EN_LICENSE_FILE_NAME;
      if (cbLang != null
          && cbLang.getSelectedItem() != null
          && cbLang.getSelectedItem().toString().equalsIgnoreCase("Eesti")) {
        fileName = RuntimeProperties.GPL_EE_LICENSE_FILE_NAME;
      }

      InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName);

      if (is == null) return "";

      BufferedReader in = new BufferedReader(new InputStreamReader(is));
      String str;
      while ((str = in.readLine()) != null) {
        textBuffer.append(str);
        textBuffer.append("\n");
      }
      in.close();
    } catch (IOException e) {
      logger.error(null, e);
    }
    return textBuffer.toString();
  } // getLicenseText
Example #11
0
  public Properties internalToProperties() {
    Properties props = new Properties();

    StringBuffer st = new StringBuffer();
    st.append(" ");
    for (int i = 0; i < visibleViewIds.size(); i++) {
      st.append(" " + Constants.cpNames[((Integer) visibleViewIds.elementAt(i)).intValue()]);
    }
    // System.out.println(" visibleViewIds: " + st.toString());

    props.setProperty("ndedit.visibleViewIds", st.toString());

    props.setProperty("ndedit.cutPanelSizeW", (new Integer(cutPanelSize.width).toString()));
    props.setProperty("ndedit.cutPanelSizeH", (new Integer(cutPanelSize.height).toString()));
    props.setProperty("ndedit.cutPanelWMin", (new Integer(cutPanelMinSize.width).toString()));
    props.setProperty("ndedit.cutPanelHMin", (new Integer(cutPanelMinSize.height).toString()));
    props.setProperty("ndedit.cutPanelWMax", (new Integer(cutPanelMaxSize.width).toString()));
    props.setProperty("ndedit.cutPanelHMax", (new Integer(cutPanelMaxSize.height).toString()));
    props.setProperty("ndedit.lonReference", (new Double(lonReference).toString()));
    props.setProperty("ndedit.geoDisplayFormat", (new Integer(geoDisplayFormat).toString()));
    props.setProperty("ndedit.timeDisplayFormat", (new Integer(timeDisplayFormat).toString()));
    props.setProperty("ndedit.timeAxisMode", (new Integer(timeAxisMode).toString()));
    props.setProperty("ndedit.timeAxisReference", (new Double(timeAxisReference).toString()));
    String dpa = new Boolean(displayPanelAxes).toString();
    props.setProperty("ndedit.displayPanelAxes", dpa);
    dpa = new Boolean(independentHandles).toString();
    props.setProperty("ndedit.independentHandles", dpa);
    return props;
  }
Example #12
0
  private Pattern getCurrentPattern() {
    String pattern = getFindTextField().getText();
    int flags = Pattern.DOTALL;

    if (!getRegexButton().isSelected()) {
      StringBuffer newpattern = new StringBuffer();

      // 'quote' the pattern
      for (int i = 0; i < pattern.length(); i++) {
        if ("\\[]^$&|().*+?{}".indexOf(pattern.charAt(i)) >= 0) {
          newpattern.append('\\');
        }
        newpattern.append(pattern.charAt(i));
      }
      pattern = newpattern.toString();

      // make "*" .* and "?" .
      if (getWildCardsButton().isSelected()) {
        pattern = pattern.replaceAll("\\\\\\*", ".+?");
        pattern = pattern.replaceAll("\\\\\\?", ".");
      }
    }
    if (!getCaseSensitiveCheckBox().isSelected()) {
      flags |= Pattern.CASE_INSENSITIVE;
    }
    if (getWholeWordCheckBox().isSelected()) {
      pattern = "\\b" + pattern + "\\b";
    }
    return Pattern.compile(pattern, flags);
  }
  public static void main(String[] args) {

    StringBuffer result = new StringBuffer("<html><body><h1>Fibonacci Sequence</h1><ol>");

    long f1 = 0;
    long f2 = 1;

    for (int i = 0; i < 50; i++) {
      result.append("<li>");
      result.append(f1);
      long temp = f2;
      f2 = f1 + f2;
      f1 = temp;
    }

    result.append("</ol></body></html>");

    JEditorPane jep = new JEditorPane("text/html", result.toString());
    jep.setEditable(false);

    //  new FibonocciRectangles().execute();
    JScrollPane scrollPane = new JScrollPane(jep);
    JFrame f = new JFrame("Fibonacci Sequence");
    f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    f.setContentPane(scrollPane);
    f.setSize(512, 342);
    EventQueue.invokeLater(new FrameShower(f));
  }
    /* (non-Javadoc)
     * @see org.jdesktop.swingworker.SwingWorker#doInBackground()
     */
    @Override
    protected Void doInBackground() throws Exception {

      if (errorInfo != null) {
        Throwable t = errorInfo.getErrorException();
        String osMessage =
            "An error occurred on "
                + System.getProperty("os.name")
                + " version "
                + System.getProperty("os.version");
        StringBuffer message = new StringBuffer();
        message.append("System Info : ").append(osMessage).append(NEW_LINE_CHAR);
        message.append("Message : ").append(t.toString()).append(NEW_LINE_CHAR);
        message.append("Level : ").append(errorInfo.getErrorLevel()).append(NEW_LINE_CHAR);
        message.append("Stack Trace : ").append(NEW_LINE_CHAR);
        message.append(stackTraceToString(t));

        // copy error message to system clipboard
        StringSelection stringSelection = new StringSelection(message.toString());
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(stringSelection, null);

        // open errorReportingURL
        OpenBrowserAction openBrowserAction = new OpenBrowserAction(errorReportingURL);
        openBrowserAction.actionPerformed(null);
      }

      return null;
    }
Example #15
0
  /** Capture an image for all ViewManagers */
  public void captureAll() {
    List vms = getViewManagers();

    String filename = FileManager.getWriteFile(FileManager.FILTER_IMAGE, FileManager.SUFFIX_JPG);
    if (filename == null) {
      return;
    }
    String root = IOUtil.stripExtension(filename);
    String ext = IOUtil.getFileExtension(filename);

    StringBuffer sb = new StringBuffer("<html>");
    sb.append("Since there were multiple images they were written out as:<ul>");
    for (int i = 0; i < vms.size(); i++) {
      ViewManager vm = (ViewManager) vms.get(i);
      String name = vm.getName();
      if ((name == null) || (name.trim().length() == 0)) {
        name = "" + (i + 1);
      }
      if (vms.size() != 1) {
        filename = root + name + ext;
      }

      sb.append("<li> " + filename);
      vm.writeImage(filename);
    }
    sb.append("</ul></html>");
    if (vms.size() > 1) {
      GuiUtils.showDialog("Captured Images", GuiUtils.inset(new JLabel(sb.toString()), 5));
    }
  }
    /**
     * Create a Transferable to use as the source for a data transfer.
     *
     * @param c The component holding the data to be transfered. This argument is provided to enable
     *     sharing of TransferHandlers by multiple components.
     * @return The representation of the data to be transfered.
     */
    protected Transferable createTransferable(JComponent c) {
      Object[] values = null;
      if (c instanceof JList) {
        values = ((JList) c).getSelectedValues();
      } else if (c instanceof JTable) {
        JTable table = (JTable) c;
        int[] rows = table.getSelectedRows();
        if (rows != null) {
          values = new Object[rows.length];
          for (int i = 0; i < rows.length; i++) {
            values[i] = table.getValueAt(rows[i], 0);
          }
        }
      }
      if (values == null || values.length == 0) {
        return null;
      }

      StringBuffer plainBuf = new StringBuffer();
      StringBuffer htmlBuf = new StringBuffer();

      htmlBuf.append("<html>\n<body>\n<ul>\n");

      for (Object obj : values) {
        String val = ((obj == null) ? "" : obj.toString());
        plainBuf.append(val + "\n");
        htmlBuf.append("  <li>" + val + "\n");
      }

      // remove the last newline
      plainBuf.deleteCharAt(plainBuf.length() - 1);
      htmlBuf.append("</ul>\n</body>\n</html>");

      return new FileTransferable(plainBuf.toString(), htmlBuf.toString(), values);
    }
Example #17
0
 /**
  * A utility method to make a name=value part of the adde request string
  *
  * @param buf The buffer to append to
  * @param name The property name
  * @param value The value
  */
 protected void appendKeyValue(StringBuffer buf, String name, String value) {
   if ((buf.length() == 0) || (buf.charAt(buf.length() - 1) != '?')) {
     buf.append("&");
   }
   buf.append(name);
   buf.append("=");
   buf.append(value);
 }
Example #18
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(this.key);
   if (this.hasValue()) {
     sb.append("=").append(this.val);
   }
   return sb.toString();
 }
Example #19
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(this.key);
   String v = this.val;
   if ((v != null) && !v.equals("")) {
     sb.append("=").append(v);
   }
   return sb.toString();
 }
 {
   StringBuffer sb = new StringBuffer();
   StringTokenizer st = new StringTokenizer(cfg.REQPARAM_CONTACT_LIST_LOGIN_IDS, ",");
   while (st.hasMoreTokens()) {
     sb.append(st.nextToken());
     if (st.hasMoreTokens()) sb.append("\n");
   }
   contactList.setText(sb.toString());
 }
Example #21
0
 public String getName() {
   StringBuffer buf = new StringBuffer();
   buf.append("(");
   if (getLeftComponent() != null) buf.append(getLeftComponent().getName());
   buf.append("/");
   if (getRightComponent() != null) buf.append(getRightComponent().getName());
   buf.append(")");
   return buf.toString();
 }
Example #22
0
 /**
  * ** Returns the bean method name for the specified field ** @param prefix Either "get" or "set"
  * ** @param fieldName The field name ** @return The 'getter'/'setter' method name
  */
 protected static String _beanMethodName(String prefix, String fieldName) {
   if ((prefix != null) && (fieldName != null)) {
     StringBuffer sb = new StringBuffer(prefix);
     sb.append(fieldName.substring(0, 1).toUpperCase());
     sb.append(fieldName.substring(1));
     return sb.toString();
   } else {
     return "";
   }
 }
 /**
  * cleanStringMWS.
  *
  * @return a {@link java.lang.String} object.
  * @param in a {@link java.lang.String} object.
  */
 public static String cleanStringMWS(String in) {
   StringBuffer out = new StringBuffer();
   char c;
   for (int i = 0; i < in.length(); i++) {
     c = in.charAt(i);
     if (c == '"' || c == '/') out.append("");
     else out.append(c);
   }
   return out.toString();
 }
 private String bigIntToHexString(BigInteger bi) {
   StringBuffer buf = new StringBuffer();
   buf.append("0x");
   String val = bi.toString(16);
   for (int i = 0; i < ((2 * addressSize) - val.length()); i++) {
     buf.append('0');
   }
   buf.append(val);
   return buf.toString();
 }
Example #25
0
  /**
   * Adds the matching block end.
   *
   * @param offset the offset
   * @return the string after adding the matching block end
   * @throws BadLocationException if the offset is invalid
   */
  protected String addMatchingBlockEnd(int offset) throws BadLocationException {
    StringBuffer result;
    StringBuffer whiteSpace = new StringBuffer();
    int line = m_RootElement.getElementIndex(offset);
    int i = m_RootElement.getElement(line).getStartOffset();

    while (true) {
      String temp = m_Self.getText(i, 1);

      if (temp.equals(" ") || temp.equals("\t")) {
        whiteSpace.append(temp);
        i++;
      } else {
        break;
      }
    }

    // assemble string
    result = new StringBuffer();
    result.append(m_BlockStart);
    result.append("\n");
    result.append(whiteSpace.toString());
    if (m_UseBlanks) result.append(m_Indentation);
    else result.append("\t");
    result.append("\n");
    result.append(whiteSpace.toString());
    result.append(m_BlockEnd);

    return result.toString();
  }
  /**
   * Return the number of characters that will be printed when the specified character is echoed to
   * the screen. Adapted from cat by Torbjorn Granlund, as repeated in stty by David MacKenzie.
   */
  StringBuffer getPrintableCharacters(char ch) {
    StringBuffer sbuff = new StringBuffer();

    if (ch >= 32) {
      if (ch < 127) {
        sbuff.append(ch);
      } else if (ch == 127) {
        sbuff.append('^');
        sbuff.append('?');
      } else {
        sbuff.append('M');
        sbuff.append('-');

        if (ch >= (128 + 32)) {
          if (ch < (128 + 127)) {
            sbuff.append((char) (ch - 128));
          } else {
            sbuff.append('^');
            sbuff.append('?');
          }
        } else {
          sbuff.append('^');
          sbuff.append((char) (ch - 128 + 64));
        }
      }
    } else {
      sbuff.append('^');
      sbuff.append((char) (ch + 64));
    }

    return sbuff;
  }
 void setTextFromTile(TileI tile) {
   StringBuffer text = new StringBuffer();
   if (Util.hasValue(tile.getExternalId())) {
     text.append("<HTML><BODY>" + tile.getExternalId());
     if (tile.countFreeTiles() != -1) {
       text.append("<BR> (" + tile.countFreeTiles() + ")");
     }
     text.append("</BODY></HTML>");
   }
   this.setText(text.toString());
 }
Example #28
0
  public String getSelectedRobotsAsString() {
    StringBuffer sb = new StringBuffer();

    for (int i = 0; i < selectedRobots.size(); i++) {
      if (i != 0) {
        sb.append(',');
      }
      sb.append(selectedRobots.get(i).getItem().getUniqueFullClassNameWithVersion());
    }
    return sb.toString();
  }
Example #29
0
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(POLYGON).append("[\n");
   for (Point2D pt : point2Ds) {
     sb.append("\t");
     sb.append(pt);
     sb.append("\n");
   }
   sb.append("]");
   return sb.toString();
 }
Example #30
0
 /**
  * ** Returns a String representation of all key/values ** @param sbuff The StringBuffer to write
  * the key/values to, or null ** for a new one ** @return A String representation of all
  * key/values
  */
 public StringBuffer getArgString(StringBuffer sbuff) {
   StringBuffer sb = (sbuff != null) ? sbuff : new StringBuffer();
   for (Iterator i = this.getKeyValList().iterator(); i.hasNext(); ) {
     KeyVal kv = (KeyVal) i.next();
     sb.append(kv.toString());
     if (i.hasNext()) {
       sb.append("&");
     }
   }
   return sb;
 }