コード例 #1
0
ファイル: Subtree.java プロジェクト: siwells/monkeypuzzle
  /**
   * Build a shape for the entire subtree by joining together the shapes for each of its edges.
   * Vertices included since needed for FullTextPanel.
   */
  public Shape constructInternalShape(DiagramBase diagram, boolean includeVertices) {
    GeneralPath shape = new GeneralPath();
    Enumeration edges = m_edgeList.elements();
    while (edges.hasMoreElements()) {
      TreeEdge edge = (TreeEdge) edges.nextElement();
      Shape edgeShape = edge.getSchemeShape(diagram);
      PathIterator path = edgeShape.getPathIterator(null);
      shape.append(path, false);

      if (includeVertices) {
        Shape vertexShape;
        if (!edge.getSourceVertex().isVirtual()) {
          vertexShape = edge.getSourceVertex().getShape(diagram);
          path = vertexShape.getPathIterator(null);
          shape.append(path, false);
        }
        if (!edge.getDestVertex().isVirtual()) {
          vertexShape = edge.getDestVertex().getShape(diagram);
          path = vertexShape.getPathIterator(null);
          shape.append(path, false);
        }
      }
    }
    BasicStroke stroke =
        new BasicStroke(
            diagram.getSubtreeLineWidth() - DiagramBase.EDGE_OUTLINE_WIDTH + 1,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_MITER);
    internalShapeTable.put(diagram, stroke.createStrokedShape(shape));
    return (Shape) internalShapeTable.get(diagram);
  }
コード例 #2
0
 void drawAllROIs(Graphics g) {
   RoiManager rm = RoiManager.getInstance();
   if (rm == null) {
     rm = Interpreter.getBatchModeRoiManager();
     if (rm != null && rm.getList().getItemCount() == 0) rm = null;
   }
   if (rm == null) {
     // if (showAllList!=null)
     //	overlay = showAllList;
     showAllROIs = false;
     repaint();
     return;
   }
   initGraphics(g, null, showAllColor);
   Hashtable rois = rm.getROIs();
   java.awt.List list = rm.getList();
   boolean drawLabels = rm.getDrawLabels();
   currentRoi = null;
   int n = list.getItemCount();
   if (IJ.debugMode) IJ.log("paint: drawing " + n + " \"Show All\" ROIs");
   if (labelRects == null || labelRects.length != n) labelRects = new Rectangle[n];
   if (!drawLabels) showAllList = new Overlay();
   else showAllList = null;
   if (imp == null) return;
   int currentImage = imp.getCurrentSlice();
   int channel = 0, slice = 0, frame = 0;
   boolean hyperstack = imp.isHyperStack();
   if (hyperstack) {
     channel = imp.getChannel();
     slice = imp.getSlice();
     frame = imp.getFrame();
   }
   drawNames = Prefs.useNamesAsLabels;
   for (int i = 0; i < n; i++) {
     String label = list.getItem(i);
     Roi roi = (Roi) rois.get(label);
     if (roi == null) continue;
     if (showAllList != null) showAllList.add(roi);
     if (i < 200 && drawLabels && roi == imp.getRoi()) currentRoi = roi;
     if (Prefs.showAllSliceOnly && imp.getStackSize() > 1) {
       if (hyperstack && roi.getPosition() == 0) {
         int c = roi.getCPosition();
         int z = roi.getZPosition();
         int t = roi.getTPosition();
         if ((c == 0 || c == channel) && (z == 0 || z == slice) && (t == 0 || t == frame))
           drawRoi(g, roi, drawLabels ? i : -1);
       } else {
         int position = roi.getPosition();
         if (position == 0) position = getSliceNumber(roi.getName());
         if (position == 0 || position == currentImage) drawRoi(g, roi, drawLabels ? i : -1);
       }
     } else drawRoi(g, roi, drawLabels ? i : -1);
   }
   ((Graphics2D) g).setStroke(Roi.onePixelWide);
   drawNames = false;
 }
コード例 #3
0
ファイル: CityMap.java プロジェクト: bhipple/topcoder
  public String getLegend(String[] cityMap, int[] POIs) {
    char[] ans = new char[POIs.length];

    Hashtable hash = new Hashtable();

    for (int i = 0; i < cityMap.length; i++) {
      for (int j = 0; j < cityMap[i].length(); j++) {
        char cur = cityMap[i].charAt(j);
        int k = 1;
        if (!hash.containsKey(cur)) {
          hash.put(cur, k);
        } else {
          int prev = (int) hash.get(cur);
          hash.remove(cur);
          hash.put(cur, prev + 1);
        }
      }
    }

    Enumeration vals = hash.keys();
    while (vals.hasMoreElements()) {
      char c = (char) vals.nextElement();

      for (int i = 0; i < POIs.length; i++) {
        if (hash.get(c) == POIs[i]) {
          ans[i] = c;
        }
      }
    }

    String str = new String(ans);

    return str;
  }
コード例 #4
0
ファイル: Subtree.java プロジェクト: siwells/monkeypuzzle
 /** Build a shape for the entire subtree by joining together the shapes for each of its edges. */
 public Shape constructShape(DiagramBase diagram) {
   GeneralPath shape = new GeneralPath();
   Enumeration edges = m_edgeList.elements();
   while (edges.hasMoreElements()) {
     TreeEdge edge = (TreeEdge) edges.nextElement();
     if (!edge.visible) {
       continue;
     }
     Shape edgeShape = edge.getSchemeShape(diagram);
     PathIterator path = edgeShape.getPathIterator(null);
     shape.append(path, false);
   }
   BasicStroke stroke =
       new BasicStroke(
           diagram.getSubtreeLineWidth(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER);
   shapeTable.put(diagram, stroke.createStrokedShape(shape));
   return (Shape) shapeTable.get(diagram);
 }
コード例 #5
0
  /** replaces the font (PS name) if necessary and returns the new name */
  private static String replacePSFont(String font) {
    String result;

    result = font;

    // do we have to replace it? -> same style, size
    if (m_PSFontReplacement.containsKey(font)) {
      result = m_PSFontReplacement.get(font).toString();
      if (DEBUG)
        System.out.println(
            Messages.getInstance().getString("PostscriptGraphics_ReplacePSFont_Text_First")
                + font
                + Messages.getInstance().getString("PostscriptGraphics_ReplacePSFont_Text_Second")
                + result
                + Messages.getInstance().getString("PostscriptGraphics_ReplacePSFont_Text_Third"));
    }

    return result;
  }
コード例 #6
0
  /** output if we're in debug mode */
  static {
    if (DEBUG)
      System.err.println(
          PostscriptGraphics.class.getName()
              + Messages.getInstance().getString("PostscriptGraphics_Error_Text"));

    // get font replacements
    m_PSFontReplacement = new Hashtable();
    m_PSFontReplacement.put(
        "SansSerif.plain", "Helvetica.plain"); // SansSerif.plain is displayed as Courier in GV???
    m_PSFontReplacement.put(
        "Dialog.plain",
        "Helvetica.plain"); // dialog is a Sans Serif font, but GV displays it as Courier???
    m_PSFontReplacement.put(
        "Microsoft Sans Serif",
        "Helvetica.plain"); // MS Sans Serif is a Sans Serif font (hence the name!), but GV displays
                            // it as Courier???
    m_PSFontReplacement.put(
        "MicrosoftSansSerif",
        "Helvetica.plain"); // MS Sans Serif is a Sans Serif font (hence the name!), but GV displays
                            // it as Courier???
  }
コード例 #7
0
ファイル: Subtree.java プロジェクト: siwells/monkeypuzzle
 /** Build a shape for the entire subtree by joining together the shapes for each of its edges. */
 public Shape constructFullTextShape(DiagramBase diagram) {
   GeneralPath shape = new GeneralPath();
   Enumeration edges = m_edgeList.elements();
   while (edges.hasMoreElements()) {
     TreeEdge edge = (TreeEdge) edges.nextElement();
     if (!edge.visible) {
       continue;
     }
     Shape edgeShape = edge.getSchemeShape(diagram);
     PathIterator path = edgeShape.getPathIterator(null);
     shape.append(path, false);
     TreeVertex vertex = edge.getSourceVertex();
     if (!vertex.isVirtual()) {
       shape.append(vertex.getShape(diagram).getPathIterator(null), false);
     }
     vertex = edge.getDestVertex();
     if (!vertex.isVirtual()) {
       shape.append(vertex.getShape(diagram).getPathIterator(null), false);
     }
   }
   BasicStroke stroke = new BasicStroke(20, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER);
   shapeTable.put(diagram, stroke.createStrokedShape(shape));
   return (Shape) shapeTable.get(diagram);
 }
コード例 #8
0
ファイル: Subtree.java プロジェクト: siwells/monkeypuzzle
 public Shape getCqBoxShape(DiagramBase diagram) {
   return (Shape) cqBoxTable.get(diagram);
 }
コード例 #9
0
ファイル: Subtree.java プロジェクト: siwells/monkeypuzzle
 public Shape getInternalShape(DiagramBase diagram) {
   return (Shape) internalShapeTable.get(diagram);
 }
コード例 #10
0
ファイル: Subtree.java プロジェクト: siwells/monkeypuzzle
 public Shape getShape(DiagramBase diagram) {
   return (Shape) shapeTable.get(diagram);
 }
コード例 #11
0
 /**
  * adds the PS font name to replace and its replacement in the replacement hashtable
  *
  * @param replace the PS font name to replace
  * @param with the PS font name to replace the font with
  */
 public static void addPSFontReplacement(String replace, String with) {
   m_PSFontReplacement.put(replace, with);
 }