コード例 #1
0
ファイル: Plasmid.java プロジェクト: autogene/Autogene
 /**
  * Sets the thickness of the arc used to draw the backbone.
  *
  * @param width "xxx-small", "xx-small", "x-small", "small", "medium", "large", "x-large",
  *     "xx-large", "xxx-large".
  */
 public void setBackboneThickness(String width) {
   try {
     backboneThickness = ((Float) BACKBONE_THICKNESSES.get(width)).floatValue();
   } catch (NullPointerException e) {
     backboneThickness = ((Float) BACKBONE_THICKNESSES.get("medium")).floatValue();
   }
 }
コード例 #2
0
ファイル: Plasmid.java プロジェクト: autogene/Autogene
 /**
  * Sets the thickness of the arc used to draw features.
  *
  * @param width "xxx-small", "xx-small", "x-small", "small", "medium", "large", "x-large",
  *     "xx-large", "xxx-large".
  */
 public void setFeatureThickness(String width) {
   try {
     featureThickness = ((Float) FEATURE_THICKNESSES.get(width)).floatValue();
   } catch (NullPointerException e) {
     featureThickness = ((Float) FEATURE_THICKNESSES.get("medium")).floatValue();
   }
 }
コード例 #3
0
ファイル: Plasmid.java プロジェクト: autogene/Autogene
  private Color getFeatureColor(String type) throws NullPointerException {

    Color colorToReturn = (Color) FEATURE_COLORS.get(type);

    if (colorScheme == REGULAR) {
      colorToReturn = (Color) FEATURE_COLORS.get(type);
    } else if (colorScheme == INVERSE) {
      colorToReturn = (Color) FEATURE_COLORS_INVERSE.get(type);
    }
    return colorToReturn;
  }
コード例 #4
0
ファイル: Installer.java プロジェクト: suever/CTP
 private static Hashtable<String, String> getManifestAttributes(Manifest manifest) {
   Hashtable<String, String> h = new Hashtable<String, String>();
   try {
     Attributes attrs = manifest.getMainAttributes();
     Iterator it = attrs.keySet().iterator();
     while (it.hasNext()) {
       String key = it.next().toString();
       h.put(key, attrs.getValue(key));
     }
   } catch (Exception ignore) {
   }
   return h;
 }
コード例 #5
0
ファイル: Plasmid.java プロジェクト: autogene/Autogene
  private int getFeatureDecoration(String type, int strand) throws NullPointerException {

    int decoration = DECORATION_STANDARD;
    if (!(useArrows)) {
      decoration = DECORATION_STANDARD;
    } else {
      if (strand == FORWARD) {
        decoration = ((Integer) FEATURE_DECORATIONS_DIRECT.get(type)).intValue();
      } else if (strand == NO_DIRECTION) {
        decoration = ((Integer) FEATURE_DECORATIONS_DIRECT.get(type)).intValue();
      } else {
        decoration = ((Integer) FEATURE_DECORATIONS_REVERSE.get(type)).intValue();
      }
    }

    return decoration;
  }
コード例 #6
0
ファイル: Installer.java プロジェクト: suever/CTP
  /**
   * Class constructor; creates a new Installer object, displays a JFrame introducing the program,
   * allows the user to select an install directory, and copies files from the jar into the
   * directory.
   */
  public Installer(String args[]) {
    // Inputs are --install-dir INSTALL_DIR
    for (int k = 0; k < args.length; k = k + 2) {

      switch (args[k]) {
        case "--install-dir":
          directory = new File(args[k + 1]);
          System.out.println(directory);
          break;
        case "--port":
          port = Integer.parseInt(args[k + 1]);
          break;
      }
    }

    cp = new Stream();

    // Find the installer program so we can get to the files.
    installer = getInstallerProgramFile();
    String name = installer.getName();
    programName = (name.substring(0, name.indexOf("-"))).toUpperCase();

    // Get the installation information
    thisJava = System.getProperty("java.version");
    thisJavaBits = System.getProperty("sun.arch.data.model") + " bits";

    // Find the ImageIO Tools and get the version
    String javaHome = System.getProperty("java.home");
    File extDir = new File(javaHome);
    extDir = new File(extDir, "lib");
    extDir = new File(extDir, "ext");
    File clib = getFile(extDir, "clibwrapper_jiio", ".jar");
    File jai = getFile(extDir, "jai_imageio", ".jar");
    imageIOTools = (clib != null) && clib.exists() && (jai != null) && jai.exists();
    if (imageIOTools) {
      Hashtable<String, String> jaiManifest = getManifestAttributes(jai);
      imageIOVersion = jaiManifest.get("Implementation-Version");
    }

    // Get the CTP.jar parameters
    Hashtable<String, String> manifest = getJarManifestAttributes("/CTP/libraries/CTP.jar");
    programDate = manifest.get("Date");
    buildJava = manifest.get("Java-Version");

    // Get the util.jar parameters
    Hashtable<String, String> utilManifest = getJarManifestAttributes("/CTP/libraries/util.jar");
    utilJava = utilManifest.get("Java-Version");

    // Get the MIRC.jar parameters (if the plugin is present)
    Hashtable<String, String> mircManifest = getJarManifestAttributes("/CTP/libraries/MIRC.jar");
    if (mircManifest != null) {
      mircJava = mircManifest.get("Java-Version");
      mircDate = mircManifest.get("Date");
      mircVersion = mircManifest.get("Version");
    }

    // Set up the installation information for display
    if (imageIOVersion.equals("")) {
      imageIOVersion = "<b><font color=\"red\">not installed</font></b>";
    } else if (imageIOVersion.startsWith("1.0")) {
      imageIOVersion = "<b><font color=\"red\">" + imageIOVersion + "</font></b>";
    }
    if (thisJavaBits.startsWith("64")) {
      thisJavaBits = "<b><font color=\"red\">" + thisJavaBits + "</font></b>";
    }
    boolean javaOK = (thisJava.compareTo(buildJava) >= 0);
    javaOK &= (thisJava.compareTo(utilJava) >= 0);
    javaOK &= (thisJava.compareTo(mircJava) >= 0);
    if (!javaOK) {
      thisJava = "<b><font color=\"red\">" + thisJava + "</font></b>";
    }

    if (directory == null) exit();

    // Point to the parent of the directory in which to install the program.
    // so the copy process works correctly for directory trees.
    //
    // If the user has selected a directory named "CTP",
    // then assume that this is the directory in which
    // to install the program.
    //
    // If the directory is not CTP, see if it is called "RSNA" and contains
    // the Launcher program, in which case we can assume that it is an
    // installation that was done with Bill Weadock's all-in-one installer for Windows.
    //
    // If neither of those cases is true, then this is already the parent of the
    // directory in which to install the program
    if (directory.getName().equals("CTP")) {
      directory = directory.getParentFile();
    } else if (directory.getName().equals("RSNA")
        && (new File(directory, "Launcher.jar")).exists()) {
      suppressFirstPathElement = true;
    }

    // Cleanup old releases
    cleanup(directory);

    // Get a port for the server.
    if (port < 0) {
      if (checkServer(-port, false)) {
        System.err.println(
            "CTP appears to be running.\nPlease stop CTP and run the installer again.");
        System.exit(0);
      }
    }

    // Now install the files and report the results.
    int count =
        unpackZipFile(installer, "CTP", directory.getAbsolutePath(), suppressFirstPathElement);
    if (count > 0) {
      // Create the service installer batch files.
      updateWindowsServiceInstaller();
      updateLinuxServiceInstaller();

      // If this was a new installation, set up the config file and set the port
      installConfigFile(port);

      // Make any necessary changes in the config file to reflect schema evolution
      fixConfigSchema();

      System.out.println("Installation complete.");
      System.out.println(programName + " has been installed successfully.");
      System.out.println(count + " files were installed.");
    } else {
      System.err.println("Installation failed.");
      System.err.println(programName + " could not be fully installed.");
    }
    if (!programName.equals("ISN") && startRunner(new File(directory, "CTP"))) System.exit(0);
  }
コード例 #7
0
ファイル: Dashutil.java プロジェクト: vikrampatange/Nice-A
 public Hashtable processData(
     ServletInputStream is, String boundary, String saveInDir, int clength)
     throws IllegalArgumentException, IOException {
   if (is == null) throw new IllegalArgumentException("InputStream");
   if (boundary == null || boundary.trim().length() < 1)
     throw new IllegalArgumentException("\"" + boundary + "\" is an illegal boundary indicator");
   boundary = "--" + boundary;
   StringTokenizer stLine = null, stFields = null;
   FileInfo fileInfo = null;
   Hashtable dataTable = new Hashtable(5);
   String line = null, field = null, paramName = null;
   boolean saveFiles = (saveInDir != null && saveInDir.trim().length() > 0);
   boolean isFile = false;
   if (saveFiles) { // Create the required directory (including parent dirs)
     File f = new File(saveInDir);
     f.mkdirs();
   }
   line = getLine(is);
   if (line == null || !line.startsWith(boundary))
     throw new IOException("Boundary not found; boundary = " + boundary + ", line = " + line);
   while (line != null) {
     if (line == null || !line.startsWith(boundary)) return dataTable;
     line = getLine(is);
     if (line == null) return dataTable;
     stLine = new StringTokenizer(line, ";\r\n");
     if (stLine.countTokens() < 2) throw new IllegalArgumentException("Bad data in second line");
     line = stLine.nextToken().toLowerCase();
     if (line.indexOf("form-data") < 0)
       throw new IllegalArgumentException("Bad data in second line");
     stFields = new StringTokenizer(stLine.nextToken(), "=\"");
     if (stFields.countTokens() < 2)
       throw new IllegalArgumentException("Bad data in second line");
     fileInfo = new FileInfo();
     stFields.nextToken();
     paramName = stFields.nextToken();
     isFile = false;
     if (stLine.hasMoreTokens()) {
       field = stLine.nextToken();
       stFields = new StringTokenizer(field, "=\"");
       if (stFields.countTokens() > 1) {
         if (stFields.nextToken().trim().equalsIgnoreCase("filename")) {
           fileInfo.name = paramName;
           String value = stFields.nextToken();
           if (value != null && value.trim().length() > 0) {
             fileInfo.clientFileName = value;
             isFile = true;
           } else {
             line = getLine(is); // Skip "Content-Type:" line
             line = getLine(is); // Skip blank line
             line = getLine(is); // Skip blank line
             line = getLine(is); // Position to boundary line
             continue;
           }
         }
       } else if (field.toLowerCase().indexOf("filename") >= 0) {
         line = getLine(is); // Skip "Content-Type:" line
         line = getLine(is); // Skip blank line
         line = getLine(is); // Skip blank line
         line = getLine(is); // Position to boundary line
         continue;
       }
     }
     boolean skipBlankLine = true;
     if (isFile) {
       line = getLine(is);
       if (line == null) return dataTable;
       if (line.trim().length() < 1) skipBlankLine = false;
       else {
         stLine = new StringTokenizer(line, ": ");
         if (stLine.countTokens() < 2)
           throw new IllegalArgumentException("Bad data in third line");
         stLine.nextToken(); // Content-Type
         fileInfo.fileContentType = stLine.nextToken();
       }
     }
     if (skipBlankLine) {
       line = getLine(is);
       if (line == null) return dataTable;
     }
     if (!isFile) {
       line = getLine(is);
       if (line == null) return dataTable;
       dataTable.put(paramName, line);
       // If parameter is dir, change saveInDir to dir
       if (paramName.equals("dir")) saveInDir = line;
       line = getLine(is);
       continue;
     }
     try {
       UplInfo uplInfo = new UplInfo(clength);
       UploadMonitor.set(fileInfo.clientFileName, uplInfo);
       OutputStream os = null;
       String path = null;
       if (saveFiles)
         os = new FileOutputStream(path = getFileName(saveInDir, fileInfo.clientFileName));
       else os = new ByteArrayOutputStream(ONE_MB);
       boolean readingContent = true;
       byte previousLine[] = new byte[2 * ONE_MB];
       byte temp[] = null;
       byte currentLine[] = new byte[2 * ONE_MB];
       int read, read3;
       if ((read = is.readLine(previousLine, 0, previousLine.length)) == -1) {
         line = null;
         break;
       }
       while (readingContent) {
         if ((read3 = is.readLine(currentLine, 0, currentLine.length)) == -1) {
           line = null;
           uplInfo.aborted = true;
           break;
         }
         if (compareBoundary(boundary, currentLine)) {
           os.write(previousLine, 0, read - 2);
           line = new String(currentLine, 0, read3);
           break;
         } else {
           os.write(previousLine, 0, read);
           uplInfo.currSize += read;
           temp = currentLine;
           currentLine = previousLine;
           previousLine = temp;
           read = read3;
         } // end else
       } // end while
       os.flush();
       os.close();
       if (!saveFiles) {
         ByteArrayOutputStream baos = (ByteArrayOutputStream) os;
         fileInfo.setFileContents(baos.toByteArray());
       } else fileInfo.file = new File(path);
       dataTable.put(paramName, fileInfo);
       uplInfo.currSize = uplInfo.totalSize;
     } // end try
     catch (IOException e) {
       throw e;
     }
   }
   return dataTable;
 }
コード例 #8
0
ファイル: Dashutil.java プロジェクト: vikrampatange/Nice-A
 static UplInfo getInfo(String fName) {
   UplInfo info = (UplInfo) uploadTable.get(fName);
   return info;
 }
コード例 #9
0
ファイル: Dashutil.java プロジェクト: vikrampatange/Nice-A
 static void remove(String fName) {
   uploadTable.remove(fName);
 }
コード例 #10
0
ファイル: Dashutil.java プロジェクト: vikrampatange/Nice-A
 static void set(String fName, UplInfo info) {
   uploadTable.put(fName, info);
 }
コード例 #11
0
ファイル: Plasmid.java プロジェクト: autogene/Autogene
  private void prepareToDraw() {

    if (forwardSlot0 != null) {
      forwardSlot0.setCgview(p);
      forwardSlot0.setFeatureThickness(featureThickness);
    }
    if (forwardSlot1 != null) {
      forwardSlot1.setCgview(p);
      forwardSlot1.setFeatureThickness(featureThickness);
    }
    if (forwardSlot2 != null) {
      forwardSlot2.setCgview(p);
      forwardSlot2.setFeatureThickness(featureThickness);
    }
    if (forwardSlot3 != null) {
      forwardSlot3.setCgview(p);
      forwardSlot3.setFeatureThickness(featureThickness);
    }
    if (forwardSlot4 != null) {
      forwardSlot4.setCgview(p);
      forwardSlot4.setFeatureThickness(featureThickness);
    }
    if (forwardSlot5 != null) {
      forwardSlot5.setCgview(p);
      forwardSlot5.setFeatureThickness(featureThickness);
    }
    if (forwardSlot6 != null) {
      forwardSlot6.setCgview(p);
      forwardSlot6.setFeatureThickness(featureThickness);
    }
    if (forwardSlot7 != null) {
      forwardSlot7.setCgview(p);
      forwardSlot7.setFeatureThickness(featureThickness);
    }

    if (reverseSlot0 != null) {
      reverseSlot0.setCgview(p);
      reverseSlot0.setFeatureThickness(featureThickness);
    }
    if (reverseSlot1 != null) {
      reverseSlot1.setCgview(p);
      reverseSlot1.setFeatureThickness(featureThickness);
    }
    if (reverseSlot2 != null) {
      reverseSlot2.setCgview(p);
      reverseSlot2.setFeatureThickness(featureThickness);
    }
    if (reverseSlot3 != null) {
      reverseSlot3.setCgview(p);
      reverseSlot3.setFeatureThickness(featureThickness);
    }
    if (reverseSlot4 != null) {
      reverseSlot4.setCgview(p);
      reverseSlot4.setFeatureThickness(featureThickness);
    }
    if (reverseSlot5 != null) {
      reverseSlot5.setCgview(p);
      reverseSlot5.setFeatureThickness(featureThickness);
    }
    if (reverseSlot6 != null) {
      reverseSlot6.setCgview(p);
      reverseSlot6.setFeatureThickness(featureThickness);
    }
    if (reverseSlot7 != null) {
      reverseSlot7.setCgview(p);
      reverseSlot7.setFeatureThickness(featureThickness);
    }

    if (restrictionSlot != null) {
      restrictionSlot.setCgview(p);
      restrictionSlot.setFeatureThickness(featureThickness);
    }

    // send settings to p
    if (showTitle) {
      p.setTitle(title);
    }
    p.setWidth(imageWidth);
    p.setHeight(imageHeight);
    p.setLabelsToKeep(MAXLABELS);
    p.setDrawTickMarks(drawTickMarks);
    p.setTitleFont(titleFont);
    p.setLabelFont(labelFont);
    p.setFeatureThickness(featureThickness);
    p.setBackboneThickness(backboneThickness);
    p.setFeatureSlotSpacing(featureSpacing);
    p.setLegendFont(legendFont);
    p.setTickLength(tickLength);
    p.setLabelLineLength(labelLineLength);
    p.setLabelPlacementQuality(labelPlacementQuality);
    p.setUseColoredLabelBackgrounds(useColoredLabelBackground);
    p.setShowBorder(showBorder);
    p.setShowShading(showShading);
    p.setShadingProportion(shadingProportion);
    p.setUseInnerLabels(useInnerLabels);
    p.setMoveInnerLabelsToOuter(moveInnerLabelsToOuter);
    p.setWarningFont(rulerFont);
    p.setRulerFont(rulerFont);

    // if not drawing labels, don't show message.
    if (!(showLabels)) {
      p.setShowWarning(false);
    }

    // set backboneRadius based on smallest image dimension
    int smallestDimension = Math.min(imageWidth, imageHeight);
    if (smallestDimension <= 750) {
      p.setBackboneRadius(0.50d * (double) smallestDimension / 2.0d);
    } else {
      p.setBackboneRadius(0.50d * 750.0d / 2.0d);
    }

    // check coloredLabels
    if (!(useColoredLabels)) {
      if (colorScheme == REGULAR) {
        p.setGlobalLabelColor((Color) MAP_ITEM_COLORS.get("titleFont"));
      } else if (colorScheme == INVERSE) {
        p.setGlobalLabelColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont"));
      }
    }

    // set map item colors
    if (colorScheme == REGULAR) {
      p.setLongTickColor((Color) MAP_ITEM_COLORS.get("tick"));
      p.setShortTickColor((Color) MAP_ITEM_COLORS.get("partialTick"));
      p.setZeroTickColor((Color) MAP_ITEM_COLORS.get("zeroLine"));
      p.setRulerFontColor((Color) MAP_ITEM_COLORS.get("rulerFont"));
      p.setBackboneColor((Color) MAP_ITEM_COLORS.get("backbone"));
      p.setTitleFontColor((Color) MAP_ITEM_COLORS.get("titleFont"));
      p.setWarningFontColor((Color) MAP_ITEM_COLORS.get("titleFont"));
      p.setBackgroundColor((Color) MAP_ITEM_COLORS.get("background"));
    } else if (colorScheme == INVERSE) {
      p.setLongTickColor((Color) MAP_ITEM_COLORS_INVERSE.get("tick"));
      p.setShortTickColor((Color) MAP_ITEM_COLORS_INVERSE.get("partialTick"));
      p.setZeroTickColor((Color) MAP_ITEM_COLORS_INVERSE.get("zeroLine"));
      p.setRulerFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("rulerFont"));
      p.setBackboneColor((Color) MAP_ITEM_COLORS_INVERSE.get("backbone"));
      p.setTitleFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont"));
      p.setWarningFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont"));
      p.setBackgroundColor((Color) MAP_ITEM_COLORS_INVERSE.get("background"));
    }

    // build legend
    if ((showLegend) && (DRAW_LEGEND_ITEMS.size() > 0)) {
      // create legend
      legend = new Legend(p);
      legend.setAllowLabelClash(allowLabelClashLegend);
      legend.setBackgroundOpacity(0.5f);
      legend.setFont(legendFont);
      legend.setPosition(legendPosition);
      if (colorScheme == REGULAR) {
        legend.setBackgroundColor((Color) MAP_ITEM_COLORS.get("background"));
        legend.setFontColor((Color) MAP_ITEM_COLORS.get("titleFont"));
      } else if (colorScheme == INVERSE) {
        legend.setBackgroundColor((Color) MAP_ITEM_COLORS_INVERSE.get("background"));
        legend.setFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont"));
      }

      LegendItem legendItem;

      Enumeration legendEntries = DRAW_LEGEND_ITEMS.keys();
      ArrayList list = new ArrayList();
      while (legendEntries.hasMoreElements()) {
        list.add(legendEntries.nextElement());
      }
      Collections.sort(list);
      Iterator i = list.iterator();

      while (i.hasNext()) {
        String key = (String) i.next();
        legendItem = new LegendItem(legend);
        legendItem.setDrawSwatch(SWATCH_SHOW);
        legendItem.setLabel((String) LEGEND_ITEM_NAMES.get(key));
        if (colorScheme == REGULAR) {
          legendItem.setSwatchColor((Color) FEATURE_COLORS.get(key));
        } else if (colorScheme == INVERSE) {
          legendItem.setSwatchColor((Color) FEATURE_COLORS_INVERSE.get(key));
        }
      }
    }

    // set message
    if (showMessage) {
      legend = new Legend(p);
      legend.setAllowLabelClash(false);
      legend.setBackgroundOpacity(0.5f);
      legend.setFont(messageFont);
      legend.setPosition(LEGEND_LOWER_RIGHT);
      LegendItem legendItem;

      if (colorScheme == REGULAR) {
        legend.setBackgroundColor((Color) MAP_ITEM_COLORS.get("background"));
        legend.setFontColor((Color) MAP_ITEM_COLORS.get("titleFont"));
        legendItem = new LegendItem(legend);
        legendItem.setLabel(message);
        legendItem.setDrawSwatch(SWATCH_NO_SHOW);
      } else if (colorScheme == INVERSE) {
        legend.setBackgroundColor((Color) MAP_ITEM_COLORS_INVERSE.get("background"));
        legend.setFontColor((Color) MAP_ITEM_COLORS_INVERSE.get("titleFont"));
        legendItem = new LegendItem(legend);
        legendItem.setLabel(message);
        legendItem.setDrawSwatch(SWATCH_NO_SHOW);
      }
    }
  }
コード例 #12
0
ファイル: Plasmid.java プロジェクト: autogene/Autogene
 private void addItemToLegend(String type, int strand) throws NullPointerException {
   if ((strand == NO_DIRECTION) || (strand == FORWARD) || (strand == REVERSE)) {
     DRAW_LEGEND_ITEMS.put(type, new Boolean(true));
   }
 }
コード例 #13
0
ファイル: Plasmid.java プロジェクト: autogene/Autogene
  /**
   * Add a feature to this map. Note that the start of the feature should be a smaller number than
   * the stop of the feature, regardless of the strand. The only case where start is larger than the
   * stop is when the feature runs across the start/stop boundary, for example 6899-10 on a 7000bp
   * plasmid.
   *
   * @param type one of the following: origin_of_replication, promoter, terminator,
   *     selectable_marker, regulatory_sequence, tag, other_gene, reporter_gene,
   *     unique_restriction_site, restriction_site.
   * @param name the name of the feature, such as EcoRI.
   * @param start the start position of the feature. Must be between 1 and the length of the
   *     plasmid.
   * @param stop the end position of the feature. Must be between 1 and the length of the plasmid.
   * @param strand the strand of the feature. Can be Plasmid.FORWARD, Plasmid.REVERSE, or
   *     Plasmid.NO_DIRECTION.
   */
  public void addFeature(String type, String name, int start, int stop, int strand) {
    // add the feature to the plasmid.
    int decoration;
    int label;
    Color color;
    // String slot;

    if (start > size) {
      start = size;
    }
    if (start < 1) {
      start = 1;
    }

    if (stop > size) {
      stop = size;
    }
    if (stop < 1) {
      stop = 1;
    }

    try {
      color = getFeatureColor(type);
      decoration = getFeatureDecoration(type, strand);
      label = getLabelType();
      addItemToLegend(type, strand);
    } catch (NullPointerException e) {
      color = new Color(0, 0, 128); // navy
      if (colorScheme == REGULAR) {
        color = new Color(0, 0, 128); // navy
      } else if (colorScheme == INVERSE) {
        color = new Color(0, 128, 128); // teal
      }
      decoration = DECORATION_STANDARD;
      label = LABEL;
    }

    // create a feature and a feature range
    // then figure out which feature slot to put the feature in.
    Feature feature = new Feature(showShading);
    FeatureRange featureRange = new FeatureRange(feature, start, stop);
    featureRange.setDecoration(decoration);
    featureRange.setColor(color);
    featureRange.setOpacity(opacity);
    featureRange.setShowLabel(label);
    if ((showPositions)
        && ((type.equalsIgnoreCase("restriction_site"))
            || (type.equalsIgnoreCase("unique_restriction_site")))) {
      featureRange.setLabel(name + " " + start);
    } else {
      if (addCategoryInfo) {
        try {
          featureRange.setLabel(name + (String) FEATURE_CATEGORIES.get(type));
        } catch (NullPointerException e) {
          featureRange.setLabel(name);
        }
      } else {
        featureRange.setLabel(name);
      }
    }

    if ((type.equalsIgnoreCase("restriction_site"))
        || (type.equalsIgnoreCase("unique_restriction_site"))) {
      if (restrictionSlot == null) {
        restrictionSlot = new FeatureSlot(DIRECT_STRAND, showShading);
        restrictionSlot.setFeatureThickness(1f);
      }
      feature.setFeatureSlot(restrictionSlot);
    } else if ((strand == NO_DIRECTION) || (strand == FORWARD)) {
      if (forwardSlot0 == null) {
        forwardSlot0 = new FeatureSlot(DIRECT_STRAND, showShading);
        feature.setFeatureSlot(forwardSlot0);
      } else if (forwardSlot0.isRoom(feature)) {
        feature.setFeatureSlot(forwardSlot0);
      } else if (forwardSlot1 == null) {
        forwardSlot1 = new FeatureSlot(DIRECT_STRAND, showShading);
        feature.setFeatureSlot(forwardSlot1);
      } else if (forwardSlot1.isRoom(feature)) {
        feature.setFeatureSlot(forwardSlot1);
      } else if (forwardSlot2 == null) {
        forwardSlot2 = new FeatureSlot(DIRECT_STRAND, showShading);
        feature.setFeatureSlot(forwardSlot2);
      } else if (forwardSlot2.isRoom(feature)) {
        feature.setFeatureSlot(forwardSlot2);
      } else if (forwardSlot3 == null) {
        forwardSlot3 = new FeatureSlot(DIRECT_STRAND, showShading);
        feature.setFeatureSlot(forwardSlot3);
      } else if (forwardSlot3.isRoom(feature)) {
        feature.setFeatureSlot(forwardSlot3);
      } else if (forwardSlot4 == null) {
        forwardSlot4 = new FeatureSlot(DIRECT_STRAND, showShading);
        feature.setFeatureSlot(forwardSlot4);
      } else if (forwardSlot4.isRoom(feature)) {
        feature.setFeatureSlot(forwardSlot4);
      } else if (forwardSlot5 == null) {
        forwardSlot5 = new FeatureSlot(DIRECT_STRAND, showShading);
        feature.setFeatureSlot(forwardSlot5);
      } else if (forwardSlot5.isRoom(feature)) {
        feature.setFeatureSlot(forwardSlot5);
      } else if (forwardSlot6 == null) {
        forwardSlot6 = new FeatureSlot(DIRECT_STRAND, showShading);
        feature.setFeatureSlot(forwardSlot6);
      } else if (forwardSlot6.isRoom(feature)) {
        feature.setFeatureSlot(forwardSlot6);
      } else if (forwardSlot7 == null) {
        forwardSlot7 = new FeatureSlot(DIRECT_STRAND, showShading);
        feature.setFeatureSlot(forwardSlot7);
      } else {
        feature.setFeatureSlot(forwardSlot7);
      }

    } else if (strand == REVERSE) {
      if (reverseSlot0 == null) {
        reverseSlot0 = new FeatureSlot(REVERSE_STRAND, showShading);
        feature.setFeatureSlot(reverseSlot0);
      } else if (reverseSlot0.isRoom(feature)) {
        feature.setFeatureSlot(reverseSlot0);
      } else if (reverseSlot1 == null) {
        reverseSlot1 = new FeatureSlot(REVERSE_STRAND, showShading);
        feature.setFeatureSlot(reverseSlot1);
      } else if (reverseSlot1.isRoom(feature)) {
        feature.setFeatureSlot(reverseSlot1);
      } else if (reverseSlot2 == null) {
        reverseSlot2 = new FeatureSlot(REVERSE_STRAND, showShading);
        feature.setFeatureSlot(reverseSlot2);
      } else if (reverseSlot2.isRoom(feature)) {
        feature.setFeatureSlot(reverseSlot2);
      } else if (reverseSlot3 == null) {
        reverseSlot3 = new FeatureSlot(REVERSE_STRAND, showShading);
        feature.setFeatureSlot(reverseSlot3);
      } else if (reverseSlot3.isRoom(feature)) {
        feature.setFeatureSlot(reverseSlot3);
      } else if (reverseSlot4 == null) {
        reverseSlot4 = new FeatureSlot(REVERSE_STRAND, showShading);
        feature.setFeatureSlot(reverseSlot4);
      } else if (reverseSlot4.isRoom(feature)) {
        feature.setFeatureSlot(reverseSlot4);
      } else if (reverseSlot5 == null) {
        reverseSlot5 = new FeatureSlot(REVERSE_STRAND, showShading);
        feature.setFeatureSlot(reverseSlot5);
      } else if (reverseSlot5.isRoom(feature)) {
        feature.setFeatureSlot(reverseSlot5);
      } else if (reverseSlot6 == null) {
        reverseSlot6 = new FeatureSlot(REVERSE_STRAND, showShading);
        feature.setFeatureSlot(reverseSlot6);
      } else if (reverseSlot6.isRoom(feature)) {
        feature.setFeatureSlot(reverseSlot6);
      } else if (reverseSlot7 == null) {
        reverseSlot7 = new FeatureSlot(REVERSE_STRAND, showShading);
        feature.setFeatureSlot(reverseSlot7);
      } else {
        feature.setFeatureSlot(reverseSlot7);
      }
    }
  }
コード例 #14
0
ファイル: Plasmid.java プロジェクト: autogene/Autogene
  /**
   * Create a new Plasmid. Note that a constructor accepting a title and length is also available.
   *
   * @param size the size of the plasmid in base pairs.
   */
  public Plasmid(int size) {
    this.size = size;

    COLORS = new Hashtable();

    MAP_ITEM_COLORS = new Hashtable();
    MAP_ITEM_COLORS_INVERSE = new Hashtable();

    FEATURE_COLORS = new Hashtable();
    FEATURE_COLORS_INVERSE = new Hashtable();

    FEATURE_DECORATIONS_DIRECT = new Hashtable();
    FEATURE_DECORATIONS_REVERSE = new Hashtable();

    FEATURE_CATEGORIES = new Hashtable();

    FEATURE_THICKNESSES = new Hashtable();
    BACKBONE_THICKNESSES = new Hashtable();

    DRAW_LEGEND_ITEMS = new Hashtable();
    LEGEND_ITEM_NAMES = new Hashtable();

    COLORS.put(
        "black",
        new Color(0, 0, 0)); // tickmark defaults //rulerFontColor default //titleFontColor default
    COLORS.put("silver", new Color(192, 192, 192));
    COLORS.put(
        "gray",
        new Color(128, 128, 128)); // backbone default //partial tickmark default //zeroline default
    COLORS.put("white", new Color(255, 255, 255)); // background default
    COLORS.put("maroon", new Color(128, 0, 0));
    COLORS.put("red", new Color(255, 0, 0));
    COLORS.put("pink", new Color(255, 153, 204));
    COLORS.put("purple", new Color(128, 0, 128));
    COLORS.put("fuchsia", new Color(255, 0, 255));
    COLORS.put("orange", new Color(255, 153, 0));
    COLORS.put("green", new Color(0, 128, 0));
    COLORS.put("spring", new Color(204, 255, 204));
    COLORS.put("lime", new Color(0, 255, 0));
    COLORS.put("olive", new Color(128, 128, 0));
    COLORS.put("yellow", new Color(255, 255, 0));
    COLORS.put("navy", new Color(0, 0, 128));
    COLORS.put("blue", new Color(0, 0, 255));
    COLORS.put("azure", new Color(51, 153, 255));
    COLORS.put("lightBlue", new Color(102, 204, 255));
    COLORS.put("teal", new Color(153, 255, 204));
    COLORS.put("aqua", new Color(0, 255, 255));

    MAP_ITEM_COLORS.put("tick", COLORS.get("black"));
    MAP_ITEM_COLORS.put("rulerFont", COLORS.get("black"));
    MAP_ITEM_COLORS.put("titleFont", COLORS.get("black"));
    MAP_ITEM_COLORS.put("messageFont", COLORS.get("black"));
    MAP_ITEM_COLORS.put("backbone", COLORS.get("gray"));
    MAP_ITEM_COLORS.put("partialTick", COLORS.get("gray"));
    MAP_ITEM_COLORS.put("zeroLine", COLORS.get("gray"));
    MAP_ITEM_COLORS.put("background", COLORS.get("white"));

    MAP_ITEM_COLORS_INVERSE.put("tick", COLORS.get("white"));
    MAP_ITEM_COLORS_INVERSE.put("rulerFont", COLORS.get("white"));
    MAP_ITEM_COLORS_INVERSE.put("titleFont", COLORS.get("white"));
    MAP_ITEM_COLORS_INVERSE.put("messageFont", COLORS.get("white"));
    MAP_ITEM_COLORS_INVERSE.put("backbone", COLORS.get("white"));
    MAP_ITEM_COLORS_INVERSE.put("partialTick", COLORS.get("white"));
    MAP_ITEM_COLORS_INVERSE.put("zeroLine", COLORS.get("white"));
    MAP_ITEM_COLORS_INVERSE.put("background", COLORS.get("black"));

    FEATURE_COLORS.put("origin_of_replication", COLORS.get("black"));
    FEATURE_COLORS.put("promoter", COLORS.get("green"));
    FEATURE_COLORS.put("terminator", COLORS.get("maroon"));
    FEATURE_COLORS.put("selectable_marker", COLORS.get("orange"));
    FEATURE_COLORS.put("regulatory_sequence", COLORS.get("olive"));
    FEATURE_COLORS.put("tag", COLORS.get("silver"));
    FEATURE_COLORS.put("other_gene", COLORS.get("fuchsia"));
    FEATURE_COLORS.put("reporter_gene", COLORS.get("purple"));
    FEATURE_COLORS.put("unique_restriction_site", COLORS.get("blue"));
    FEATURE_COLORS.put("restriction_site", COLORS.get("red"));
    FEATURE_COLORS.put("open_reading_frame", COLORS.get("pink"));

    FEATURE_COLORS_INVERSE.put("origin_of_replication", COLORS.get("white"));
    FEATURE_COLORS_INVERSE.put("promoter", COLORS.get("lime"));
    FEATURE_COLORS_INVERSE.put("terminator", COLORS.get("yellow"));
    FEATURE_COLORS_INVERSE.put("selectable_marker", COLORS.get("orange"));
    FEATURE_COLORS_INVERSE.put("regulatory_sequence", COLORS.get("azure"));
    FEATURE_COLORS_INVERSE.put("tag", COLORS.get("silver"));
    FEATURE_COLORS_INVERSE.put("other_gene", COLORS.get("fuchsia"));
    FEATURE_COLORS_INVERSE.put("reporter_gene", COLORS.get("teal"));
    FEATURE_COLORS_INVERSE.put("unique_restriction_site", COLORS.get("lightBlue"));
    FEATURE_COLORS_INVERSE.put("restriction_site", COLORS.get("pink"));
    FEATURE_COLORS_INVERSE.put("open_reading_frame", COLORS.get("red"));

    FEATURE_DECORATIONS_DIRECT.put("origin_of_replication", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_DIRECT.put("promoter", new Integer(DECORATION_CLOCKWISE_ARROW));
    FEATURE_DECORATIONS_DIRECT.put("terminator", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_DIRECT.put("selectable_marker", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_DIRECT.put("regulatory_sequence", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_DIRECT.put("tag", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_DIRECT.put("other_gene", new Integer(DECORATION_CLOCKWISE_ARROW));
    FEATURE_DECORATIONS_DIRECT.put("reporter_gene", new Integer(DECORATION_CLOCKWISE_ARROW));
    FEATURE_DECORATIONS_DIRECT.put("unique_restriction_site", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_DIRECT.put("restriction_site", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_DIRECT.put("open_reading_frame", new Integer(DECORATION_CLOCKWISE_ARROW));

    FEATURE_DECORATIONS_REVERSE.put("origin_of_replication", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_REVERSE.put("promoter", new Integer(DECORATION_COUNTERCLOCKWISE_ARROW));
    FEATURE_DECORATIONS_REVERSE.put("terminator", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_REVERSE.put("selectable_marker", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_REVERSE.put("regulatory_sequence", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_REVERSE.put("tag", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_REVERSE.put("other_gene", new Integer(DECORATION_COUNTERCLOCKWISE_ARROW));
    FEATURE_DECORATIONS_REVERSE.put(
        "reporter_gene", new Integer(DECORATION_COUNTERCLOCKWISE_ARROW));
    FEATURE_DECORATIONS_REVERSE.put("unique_restriction_site", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_REVERSE.put("restriction_site", new Integer(DECORATION_STANDARD));
    FEATURE_DECORATIONS_REVERSE.put(
        "open_reading_frame", new Integer(DECORATION_COUNTERCLOCKWISE_ARROW));

    FEATURE_CATEGORIES.put("origin_of_replication", new String(" origin"));
    FEATURE_CATEGORIES.put("promoter", new String(" prom"));
    FEATURE_CATEGORIES.put("terminator", new String(" term"));
    FEATURE_CATEGORIES.put("selectable_marker", new String(" marker"));
    FEATURE_CATEGORIES.put("regulatory_sequence", new String(" reg"));
    FEATURE_CATEGORIES.put("tag", new String(" tag"));
    FEATURE_CATEGORIES.put("other_gene", new String(" gene"));
    FEATURE_CATEGORIES.put("reporter_gene", new String(" gene"));
    FEATURE_CATEGORIES.put("unique_restriction_site", new String(""));
    FEATURE_CATEGORIES.put("restriction_site", new String(""));
    FEATURE_CATEGORIES.put("open_reading_frame", new String(""));

    LEGEND_ITEM_NAMES.put("origin_of_replication", "Origin of replication");
    LEGEND_ITEM_NAMES.put("promoter", "Promoter");
    LEGEND_ITEM_NAMES.put("terminator", "Terminator");
    LEGEND_ITEM_NAMES.put("selectable_marker", "Selectable marker");
    LEGEND_ITEM_NAMES.put("regulatory_sequence", "Regulatory sequence");
    LEGEND_ITEM_NAMES.put("tag", "Tag");
    LEGEND_ITEM_NAMES.put("other_gene", "Other gene");
    LEGEND_ITEM_NAMES.put("reporter_gene", "Reporter gene");
    LEGEND_ITEM_NAMES.put("unique_restriction_site", "Unique restriction site");
    LEGEND_ITEM_NAMES.put("restriction_site", "Restriction site");
    LEGEND_ITEM_NAMES.put("open_reading_frame", "Open reading frame");

    FEATURE_THICKNESSES.put("xxx-small", new Float(4.0f));
    FEATURE_THICKNESSES.put("xx-small", new Float(5.0f));
    FEATURE_THICKNESSES.put("x-small", new Float(6.0f));
    FEATURE_THICKNESSES.put("small", new Float(7.0f));
    FEATURE_THICKNESSES.put("medium", new Float(8.0f)); // default for featureThickness
    FEATURE_THICKNESSES.put("large", new Float(9.0f));
    FEATURE_THICKNESSES.put("x-large", new Float(10.0f));
    FEATURE_THICKNESSES.put("xx-large", new Float(11.0f));
    FEATURE_THICKNESSES.put("xxx-large", new Float(12.0f));

    BACKBONE_THICKNESSES.put("xxx-small", new Float(4.0f));
    BACKBONE_THICKNESSES.put("xx-small", new Float(5.0f));
    BACKBONE_THICKNESSES.put("x-small", new Float(6.0f));
    BACKBONE_THICKNESSES.put("small", new Float(7.0f));
    BACKBONE_THICKNESSES.put("medium", new Float(8.0f)); // default for backboneThickness
    BACKBONE_THICKNESSES.put("large", new Float(9.0f));
    BACKBONE_THICKNESSES.put("x-large", new Float(10.0f));
    BACKBONE_THICKNESSES.put("xx-large", new Float(11.0f));
    BACKBONE_THICKNESSES.put("xxx-large", new Float(12.0f));

    p = new Cgview(size);
  }
コード例 #15
0
  /** initializes internal hash tables with Jar file resources. */
  private byte[] read(String name) {
    try {
      // extracts just sizes only.
      ZipFile zf = new ZipFile(jarFileName);
      Enumeration e = zf.entries();
      while (e.hasMoreElements()) {
        ZipEntry ze = (ZipEntry) e.nextElement();
        if (debugOn) {
          System.out.println(dumpZipEntry(ze));
        }
        htSizes.put(ze.getName(), new Integer((int) ze.getSize()));
      }
      zf.close();

      // extract resources and put them into the hashtable.
      FileInputStream fis = new FileInputStream(jarFileName);
      BufferedInputStream bis = new BufferedInputStream(fis);
      ZipInputStream zis = new ZipInputStream(bis);
      ZipEntry ze = null;
      while ((ze = zis.getNextEntry()) != null) {
        if (ze.isDirectory()) {
          continue;
        }
        if (debugOn) {
          System.out.println("ze.getName()=" + ze.getName() + "," + "getSize()=" + ze.getSize());
        }
        int size = (int) ze.getSize();
        // -1 means unknown size.
        if (size == -1) {
          size = ((Integer) htSizes.get(ze.getName())).intValue();
        }
        byte[] b = new byte[(int) size];
        int rb = 0;
        int chunk = 0;
        while (((int) size - rb) > 0) {
          chunk = zis.read(b, rb, (int) size - rb);
          if (chunk == -1) {
            break;
          }
          rb += chunk;
        }

        if (debugOn) {
          System.out.println(
              ze.getName() + "  rb=" + rb + ",size=" + size + ",csize=" + ze.getCompressedSize());
        }

        if (ze.getName().equals(name)) {
          return b;
        }
      }
    } catch (NullPointerException e) {
      System.out.println("done.");
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    return null;
  }
コード例 #16
0
ファイル: JarResources.java プロジェクト: iwoj/Maui
// =============================================================================