Example #1
0
 /**
  * If the last diagram tab and it's undo history (=controller) is empty return true, else return
  * false
  */
 private boolean lastTabIsEmpty() {
   if (!this.diagrams.isEmpty()) {
     DiagramHandler lastDiagram = this.diagrams.get(diagrams.size() - 1);
     if (lastDiagram.getController().isEmpty()
         && lastDiagram.getDrawPanel().getAllEntities().isEmpty()) {
       return true;
     }
   }
   return false;
 }
Example #2
0
 private void setPropertyPanelToGridElementHelper(GridElement e) {
   editedGridElement = e;
   OwnSyntaxPane propertyPane = gui.getPropertyPane();
   if (e != null) propertyPane.setText(e.getPanelAttributes());
   else {
     DiagramHandler handler = this.getDiagramHandler();
     if (handler == null) propertyPane.setText("");
     else propertyPane.setText(handler.getHelpText());
   }
 }
 private void save(File saveToFile, boolean removeHandlerChanged)
     throws UnsupportedEncodingException, FileNotFoundException {
   String tmp = this.createStringToBeSaved();
   PrintWriter out =
       new PrintWriter(new OutputStreamWriter(new FileOutputStream(saveToFile), "UTF-8"));
   out.print(tmp);
   out.close();
   if (removeHandlerChanged) handler.setChanged(false);
 }
Example #4
0
 @Override
 public void execute(DiagramHandler handler) {
   super.execute(handler);
   if (this._entities == null) {
     this._entities = new Vector<GridElement>();
     this._entities.addAll(handler.getDrawPanel().getSelector().getSelectedEntities());
   }
   _group.setHandler(handler);
   _group.group(this._entities);
 }
Example #5
0
  public static void doConvert(String fileName, String format, String outputfilename) {
    File file = new File(fileName);
    if (!file.exists()) {
      printToConsole("File '" + file.getAbsolutePath() + "' not found.");
      return;
    }
    DiagramHandler handler = new DiagramHandler(file);
    if (outputfilename == null) {
      if (fileName.contains("." + Program.EXTENSION))
        fileName = fileName.substring(0, fileName.indexOf("." + Program.EXTENSION));
      outputfilename = fileName + "." + format;
    } else if (!outputfilename.endsWith("." + format)) outputfilename += "." + format;

    try {
      if (format != null) handler.getFileHandler().doExportAs(format, new File(outputfilename));
      printToConsole("Conversion finished");
    } catch (Exception e) {
      printUsage();
    }
  }
Example #6
0
 public Activity(DiagramHandler handler, String label, Graphics2D g, String id) {
   super(handler, g, (int) (Const.PAD * handler.getZoomFactor()), id == null ? label : id);
   this.label = new Label(handler, label, g, (int) (5 * getZoom()));
 }
Example #7
0
 public Fork(DiagramHandler handler, Graphics2D g, String id) {
   super(handler, g, (int) (Const.PAD * handler.getZoomFactor()), id == null ? "Fork" : id);
   this.setHeight(h + pad);
   this.setWidth(w);
 }
Example #8
0
  @Override
  public void paintEntity(Graphics g) {
    int a = Math.max(1, (getRectangle().width - 1) / 2);
    int b = (getRectangle().height - 1) / 2;
    boolean found = false;
    int x = (getRectangle().width - 1) / 9 * 4;
    int y = (int) Math.round(Math.sqrt((a * a * b * b - b * b * x * x * 1.0) / (a * a * 1.0)));
    int yPos = 0;
    int yPos1 = b;
    Graphics2D g2 = (Graphics2D) g;
    DiagramHandler handlerForElement = HandlerElementMap.getHandlerForElement(this);
    g2.setFont(handlerForElement.getFontHandler().getFont());
    Composite[] composites = colorize(g2); // enable colors
    g2.setColor(bgColor);

    g2.setComposite(composites[1]);
    g2.setColor(bgColor);
    g2.fillOval(0, 0, 2 * a, 2 * b);
    g2.setComposite(composites[0]);
    if (handlerForElement.getDrawPanel().getSelector().isSelected(this)) {
      g2.setColor(fgColor);
    } else {
      g2.setColor(fgColorBase);
    }

    Vector<String> tmp = new Vector<String>(getStringVector());
    if (tmp.contains("lt=.")) {
      tmp.remove("lt=.");
      g2.setStroke(Utils.getStroke(LineType.DASHED, 1));
    }
    g2.drawOval(0, 0, 2 * a, 2 * b);

    if (tmp.contains("--")) {
      yPos = (b - y) / 2;
      g2.drawLine(a - x, b - y, a + x, b - y);
      found = true;
    } else {
      yPos =
          getRectangle().height / 2
              - tmp.size()
                  * (int)
                      (handlerForElement.getFontHandler().getFontSize()
                          + handlerForElement.getFontHandler().getDistanceBetweenTexts())
                  / 2;
    }

    for (int i = 0; i < tmp.size(); i++) {
      String s = tmp.elementAt(i);
      if (s.equals("--") && found) {
        yPos = yPos1;
      } else if (found) {
        handlerForElement.getFontHandler().writeText(g2, s, a, yPos + 5, AlignHorizontal.CENTER);
        yPos += 5 * handlerForElement.getFontHandler().getDistanceBetweenTexts();

      } else {
        yPos += (int) handlerForElement.getFontHandler().getFontSize();
        handlerForElement
            .getFontHandler()
            .writeText(g2, s, getRectangle().width / 2.0, yPos, AlignHorizontal.CENTER);
        yPos += handlerForElement.getFontHandler().getDistanceBetweenTexts();
      }
    }
    g2.setStroke(Utils.getStroke(LineType.SOLID, 1));
  }