コード例 #1
0
ファイル: NewClassDialog.java プロジェクト: cgddrd/UMLator
  public void addClass() {

    int varNo = listObject.getSize();
    int opNo = listMethod.getSize();

    ClassDiagData cDD = new ClassDiagData();

    cDD.setClassName(className.getText());

    for (int i = 0; i < varNo; i++) {

      cDD.addInstanceVar(
          listObject
              .get(i)
              .toString()); // Create new data input 'template' and populate with use inputted data
    }

    for (int i = 0; i < opNo; i++) {
      cDD.addMethod(
          listMethod
              .get(i)
              .toString()); // Create new data input 'template' and populate with use inputted data
    }

    cDD.setAccessModifier("+");

    ClassDiag e =
        new ClassDiag(x, y, varNo, opNo); // Create a new class object and set the details of it
    e.setData(cDD); // Set the associated data with from the cDD.

    canvasPanel.addDrawable(e);
    canvasPanel.repaint();
    canvasPanel.setStatus("Class Created Successfully");
  }
コード例 #2
0
ファイル: AddClassDialog.java プロジェクト: cgddrd/UMLator
  /**
   * Adds a newly created class to the Data Model and GUI layer classes to allow class data to be
   * saved and drawn on {@link uk.ac.aber.dcs.cs124.clg11.panel.CanvasPanel}
   */
  public void addClass() {

    // Retrieve number of variables/methods to be created
    int varNo = listObject.getSize();
    int opNo = listMethod.getSize();

    // Create new data model
    ClassDiagData cDD = new ClassDiagData();

    // Set the class name in the data model
    cDD.setClassName(className.getText());

    // Add all created variables to ArrayList in data model
    for (int i = 0; i < varNo; i++) {

      cDD.addInstanceVar(listObject.get(i).toString());
    }

    // Add all created variables to ArrayList in data model
    for (int i = 0; i < opNo; i++) {
      cDD.addMethod(listMethod.get(i).toString());
    }

    // Add class access modifier to data model
    cDD.setAccessModifier("+");

    // Create a new GUI layer of the new class
    ClassDiag e = new ClassDiag(x, y, varNo, opNo);

    // Load the new class data from the data model into the GUI layer to draw on screen
    e.setData(cDD); // Set the associated data with from the cDD.

    // Save the new GUI and data model layers to the VectorofDrawables
    canvasPanel.addDrawable(e);

    // Refresh the CanvasPanel to display the new class on screen
    canvasPanel.repaint();
  }