private String mostConnUsecase() { String s = ""; int high = 0; for (UMLUsecase umlu : umlulist) { ArrayList<DiagramObject> rol = umlu.getRelatedObjects(); if (rol.size() >= high) { int newHigh = 0; for (DiagramObject ro : rol) { if (ro.getClass() == UMLCRUD.class) { newHigh++; } } if (newHigh >= high) { if (newHigh > high) { high = newHigh; s = "" + umlu.getNaam(); } else { s = s + ", " + umlu.getNaam(); } } } } s = s + " (" + high + ")"; return s; }
public static void main(String[] args) { ModelDiagram md = new ModelDiagram(); UMLClass umlc = new UMLClass(); umlc.setNaam("Class 1"); md.addDiagramObject(umlc); umlc = new UMLClass(); umlc.setNaam("Class 2"); md.addDiagramObject(umlc); umlc = new UMLClass(); umlc.setNaam("Class 3"); md.addDiagramObject(umlc); UMLUsecase umluc = new UMLUsecase(); umluc.setNaam("Usecase 1"); UMLCRUD umlcrud = new UMLCRUD(umlc); umlcrud.setCreate(true); umlcrud.setRead(false); umlcrud.setUpdate(true); umlcrud.setDelete(true); umluc.addCRUD(umlcrud); md.addDiagramObject(umluc); umluc = new UMLUsecase(); umluc.setNaam("Usecase 2"); umlcrud = new UMLCRUD(umlc); umlcrud.setCreate(true); umlcrud.setRead(false); umlcrud.setUpdate(false); umlcrud.setDelete(false); umluc.addCRUD(umlcrud); md.addDiagramObject(umluc); umluc = new UMLUsecase(); umluc.setNaam("Usecase 3"); md.addDiagramObject(umluc); umluc = new UMLUsecase(); umluc.setNaam("Usecase 4"); md.addDiagramObject(umluc); JFrame frame = new JFrame(); frame.getContentPane().setBackground(Color.WHITE); frame.setSize(400, 480); frame.setVisible(true); CRUDReport cr = new CRUDReport(); JPanel buttonPannel = cr.createReport(md); frame.add(buttonPannel); }