Exemple #1
0
 private void generateMapFile(
     Diagram diagram, TextHandler textHandler, String mapName, File target) throws IOException {
   String encoding = ConfigurationManager.getGlobalConfiguration().getFileEncoding();
   FileOutputStream fos = new FileOutputStream(target);
   OutputStreamWriter osw = new OutputStreamWriter(fos, encoding);
   PrintWriter pw = new PrintWriter(osw);
   pw.println("<!-- Generated by Quick Sequence Diagram Editor -->");
   pw.println("<!-- encoding: " + encoding + " -->");
   pw.println(
       "<!-- You may append '#!href=\"<url>\"' to an object declaration\nin order to set"
           + " the 'href' attribute of an AREA tag -->");
   pw.println("<map id=\"" + mapName + "\" name=\"" + mapName + "\">");
   for (Lifeline lifeline : diagram.getAllLifelines()) {
     String annotation = textHandler.getAnnotation(lifeline);
     String file = lifeline.getName();
     if (annotation != null) {
       String href[] = Grep.parse("^.*?href=\"(.*?)\".*$", annotation);
       if (href != null) {
         file = href[0];
       }
     }
     Drawable drawable = lifeline.getHead();
     int x1 = drawable.getLeft();
     int y1 = drawable.getTop();
     int x2 = drawable.getRight();
     int y2 = drawable.getBottom();
     String coords = x1 + "," + y1 + "," + x2 + "," + y2;
     pw.println("  <area shape=\"rect\" coords=\"" + coords + "\"" + " href=\"" + file + "\"/>");
   }
   pw.println("</map>");
   pw.flush();
   pw.close();
 }
 public LabeledBox(
     Lifeline lifeline, String _label, int y, boolean anonymous, boolean underlined) {
   setTop(y);
   this.underlined = underlined;
   this.lifeline = lifeline;
   if (lifeline.isExternal()) {
     label = "";
   } else if (!_label.equals("")) {
     label = _label;
   } else if (anonymous) {
     label = ":" + lifeline.getType();
   } else {
     label = lifeline.getName() + ":" + lifeline.getType();
   }
   Configuration conf = lifeline.getDiagram().getConfiguration();
   headWidth = conf.getHeadWidth();
   headHeight = conf.getHeadHeight();
   padding = conf.getHeadLabelPadding();
   textWidth = lifeline.getDiagram().getPaintDevice().getTextWidth(label);
   shouldDrawShadow = conf.getShouldShadowParticipants();
   if (lifeline.isExternal()) {
     setWidth(lifeline.getDiagram().mainLifelineWidth);
   } else {
     setWidth(2 + Math.max(2 * padding + textWidth, headWidth));
   }
   stroke = lifeline.isAlwaysActive() ? thick : solid;
   setHeight(headHeight + 4);
 }