public static InformalArgument_c[] getManyMSG_IAsOnR1013( MessageArgument_c[] targets, ClassQueryInterface_c test, boolean loadComponent) { if (targets == null || targets.length == 0 || targets[0] == null) return new InformalArgument_c[0]; ModelRoot modelRoot = targets[0].getModelRoot(); InstanceList instances = modelRoot.getInstanceList(InformalArgument_c.class); Vector matches = new Vector(); for (int i = 0; i < targets.length; i++) { InformalArgument_c source = (InformalArgument_c) targets[i].backPointer_IsSubtypeInformalArgumentIsSubtype_R1013; if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } if (matches.size() > 0) { InformalArgument_c[] ret_set = new InformalArgument_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new InformalArgument_c[0]; } }
public static ComponentInComponent_c[] getManyCN_CICsOnR4202( Component_c target, ClassQueryInterface_c test, boolean loadComponent) { if (target == null) return new ComponentInComponent_c[0]; ModelRoot modelRoot = target.getModelRoot(); Vector matches = new Vector(); synchronized (target.backPointer_CanNestComponentInComponentCanNest_R4202) { for (int i = 0; i < target.backPointer_CanNestComponentInComponentCanNest_R4202.size(); ++i) { ComponentInComponent_c source = (ComponentInComponent_c) target.backPointer_CanNestComponentInComponentCanNest_R4202.get(i); if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } } if (matches.size() > 0) { ComponentInComponent_c[] ret_set = new ComponentInComponent_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new ComponentInComponent_c[0]; } }
public static ElementInMove_c[] getManyGD_EIMsOnR25( GraphicalElement_c[] targets, ClassQueryInterface_c test, boolean loadComponent) { if (targets == null || targets.length == 0 || targets[0] == null) return new ElementInMove_c[0]; ModelRoot modelRoot = targets[0].getModelRoot(); InstanceList instances = modelRoot.getInstanceList(ElementInMove_c.class); Vector matches = new Vector(); for (int i = 0; i < targets.length; i++) { synchronized (targets[i].backPointer_IsMovingInElementInMoveIsMovingIn_R25) { for (int j = 0; j < targets[i].backPointer_IsMovingInElementInMoveIsMovingIn_R25.size(); ++j) { ElementInMove_c source = (ElementInMove_c) targets[i].backPointer_IsMovingInElementInMoveIsMovingIn_R25.get(j); if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } } } if (matches.size() > 0) { ElementInMove_c[] ret_set = new ElementInMove_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new ElementInMove_c[0]; } }
public static ElementInMove_c[] getManyGD_EIMsOnR25( Model_c target, ClassQueryInterface_c test, boolean loadComponent) { if (target == null) return new ElementInMove_c[0]; ModelRoot modelRoot = target.getModelRoot(); Vector matches = new Vector(); synchronized (target.backPointer_IsMovingElementInMoveIsMoving_R25) { for (int i = 0; i < target.backPointer_IsMovingElementInMoveIsMoving_R25.size(); ++i) { ElementInMove_c source = (ElementInMove_c) target.backPointer_IsMovingElementInMoveIsMoving_R25.get(i); if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } } if (matches.size() > 0) { ElementInMove_c[] ret_set = new ElementInMove_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new ElementInMove_c[0]; } }
public Matrix matrix(boolean centered) { String[] genes = genes(); Matrix matrix = new Matrix(genes.length, coefs.size()); for (int j = 0; j < coefs.size(); j++) { Map<String, Double> values = coefs.get(j).geneValues(args.compare); double sum = 0.0; for (int i = 0; i < genes.length; i++) { Double value = values.get(genes[i]); if (value != null) { matrix.set(i, j, value); sum += value; } else { matrix.set(i, j, 0.0); } } if (centered) { sum /= (double) genes.length; for (int i = 0; i < genes.length; i++) { matrix.set(i, j, matrix.get(i, j) - sum); } } } return matrix; }
public static BridgeInvocation_c[] getManyACT_BRGsOnR674( Bridge_c[] targets, ClassQueryInterface_c test, boolean loadComponent) { if (targets == null || targets.length == 0 || targets[0] == null) return new BridgeInvocation_c[0]; ModelRoot modelRoot = targets[0].getModelRoot(); InstanceList instances = modelRoot.getInstanceList(BridgeInvocation_c.class); Vector matches = new Vector(); for (int i = 0; i < targets.length; i++) { synchronized (targets[i].backPointer_BridgeInvocation_R674) { for (int j = 0; j < targets[i].backPointer_BridgeInvocation_R674.size(); ++j) { BridgeInvocation_c source = (BridgeInvocation_c) targets[i].backPointer_BridgeInvocation_R674.get(j); if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } } } if (matches.size() > 0) { BridgeInvocation_c[] ret_set = new BridgeInvocation_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new BridgeInvocation_c[0]; } }
public static InstanceStateMachine_c[] getManySM_ISMsOnR518( ModelClass_c[] targets, ClassQueryInterface_c test, boolean loadComponent) { if (targets == null || targets.length == 0 || targets[0] == null) return new InstanceStateMachine_c[0]; ModelRoot modelRoot = targets[0].getModelRoot(); if (loadComponent) { // Containment Relation PersistableModelComponent[] pmcs = new PersistableModelComponent[targets.length]; for (int i = 0; i < targets.length; i++) { pmcs[i] = targets[i].getPersistableComponent(); } PersistenceManager.ensureAllChildInstancesLoaded( pmcs, modelRoot, InstanceStateMachine_c.class); } InstanceList instances = modelRoot.getInstanceList(InstanceStateMachine_c.class); Vector matches = new Vector(); for (int i = 0; i < targets.length; i++) { InstanceStateMachine_c source = (InstanceStateMachine_c) targets[i].backPointer_InstanceStateMachine_R518; if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } if (matches.size() > 0) { InstanceStateMachine_c[] ret_set = new InstanceStateMachine_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new InstanceStateMachine_c[0]; } }
public static TransientValueReference_c[] getManyV_TVLsOnR801( Value_c[] targets, ClassQueryInterface_c test, boolean loadComponent) { if (targets == null || targets.length == 0 || targets[0] == null) return new TransientValueReference_c[0]; ModelRoot modelRoot = targets[0].getModelRoot(); InstanceList instances = modelRoot.getInstanceList(TransientValueReference_c.class); Vector matches = new Vector(); for (int i = 0; i < targets.length; i++) { TransientValueReference_c source = (TransientValueReference_c) targets[i].backPointer_IsSubtypeTransientValueReferenceIsSubtype_R801; if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } if (matches.size() > 0) { TransientValueReference_c[] ret_set = new TransientValueReference_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new TransientValueReference_c[0]; } }
public static AssignToMember_c[] getManyACT_AIsOnR603( Statement_c[] targets, ClassQueryInterface_c test, boolean loadComponent) { if (targets == null || targets.length == 0 || targets[0] == null) return new AssignToMember_c[0]; ModelRoot modelRoot = targets[0].getModelRoot(); InstanceList instances = modelRoot.getInstanceList(AssignToMember_c.class); Vector matches = new Vector(); for (int i = 0; i < targets.length; i++) { AssignToMember_c source = (AssignToMember_c) targets[i].backPointer_IsSubtypeAssignToMemberIsSubtype_R603; if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } if (matches.size() > 0) { AssignToMember_c[] ret_set = new AssignToMember_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new AssignToMember_c[0]; } }
public static ComponentResultSet_c[] getManyPE_CRSsOnR8007( Component_c target, ClassQueryInterface_c test, boolean loadComponent) { if (target == null) return new ComponentResultSet_c[0]; ModelRoot modelRoot = target.getModelRoot(); Vector matches = new Vector(); synchronized (target.backPointer_HoldsComponentResultSetHolds_R8007) { for (int i = 0; i < target.backPointer_HoldsComponentResultSetHolds_R8007.size(); ++i) { ComponentResultSet_c source = (ComponentResultSet_c) target.backPointer_HoldsComponentResultSetHolds_R8007.get(i); if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } } if (matches.size() > 0) { ComponentResultSet_c[] ret_set = new ComponentResultSet_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new ComponentResultSet_c[0]; } }
public static ComponentInComponent_c[] getManyCN_CICsOnR4202( Component_c[] targets, ClassQueryInterface_c test, boolean loadComponent) { if (targets == null || targets.length == 0 || targets[0] == null) return new ComponentInComponent_c[0]; ModelRoot modelRoot = targets[0].getModelRoot(); InstanceList instances = modelRoot.getInstanceList(ComponentInComponent_c.class); Vector matches = new Vector(); for (int i = 0; i < targets.length; i++) { synchronized (targets[i].backPointer_CanNestComponentInComponentCanNest_R4202) { for (int j = 0; j < targets[i].backPointer_CanNestComponentInComponentCanNest_R4202.size(); ++j) { ComponentInComponent_c source = (ComponentInComponent_c) targets[i].backPointer_CanNestComponentInComponentCanNest_R4202.get(j); if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } } } if (matches.size() > 0) { ComponentInComponent_c[] ret_set = new ComponentInComponent_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new ComponentInComponent_c[0]; } }
public static TransientValueReference_c[] getManyV_TVLsOnR805( Variable_c target, ClassQueryInterface_c test, boolean loadComponent) { if (target == null) return new TransientValueReference_c[0]; ModelRoot modelRoot = target.getModelRoot(); Vector matches = new Vector(); synchronized (target.backPointer_TransientValueReference_R805) { for (int i = 0; i < target.backPointer_TransientValueReference_R805.size(); ++i) { TransientValueReference_c source = (TransientValueReference_c) target.backPointer_TransientValueReference_R805.get(i); if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } } if (matches.size() > 0) { TransientValueReference_c[] ret_set = new TransientValueReference_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new TransientValueReference_c[0]; } }
public static DataTypeInPackage_c[] getManyS_DIPsOnR39( DataType_c[] targets, ClassQueryInterface_c test, boolean loadComponent) { if (targets == null || targets.length == 0 || targets[0] == null) return new DataTypeInPackage_c[0]; ModelRoot modelRoot = targets[0].getModelRoot(); InstanceList instances = modelRoot.getInstanceList(DataTypeInPackage_c.class); Vector matches = new Vector(); for (int i = 0; i < targets.length; i++) { synchronized (targets[i].backPointer_IsContainedInDataTypeInPackageIsContainedIn_R39) { for (int j = 0; j < targets[i].backPointer_IsContainedInDataTypeInPackageIsContainedIn_R39.size(); ++j) { DataTypeInPackage_c source = (DataTypeInPackage_c) targets[i].backPointer_IsContainedInDataTypeInPackageIsContainedIn_R39.get(j); if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } } } if (matches.size() > 0) { DataTypeInPackage_c[] ret_set = new DataTypeInPackage_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new DataTypeInPackage_c[0]; } }
public void save(File f) throws IOException { PrintStream ps = new PrintStream(new FileOutputStream(f)); String[] genes = genes(); Vector<Map<String, Double>> maps = new Vector<Map<String, Double>>(); for (int j = 0; j < coefs.size(); j++) { maps.add(coefs.get(j).geneValues(args.compare)); } ps.print("gene"); for (int i = 0; i < coefs.size(); i++) { ps.print(" " + keys.get(i)); } ps.println(); for (int i = 0; i < genes.length; i++) { ps.print(String.format("%s", genes[i])); for (int j = 0; j < coefs.size(); j++) { Map<String, Double> map = maps.get(j); Double value = map.containsKey(genes[i]) ? map.get(genes[i]) : null; ps.print(String.format(" %s", value != null ? String.format("%.2f", value) : "N/A")); } ps.println(); } ps.println(); ps.close(); }
public static BridgeInvocation_c[] getManyACT_BRGsOnR674( Bridge_c target, ClassQueryInterface_c test, boolean loadComponent) { if (target == null) return new BridgeInvocation_c[0]; ModelRoot modelRoot = target.getModelRoot(); Vector matches = new Vector(); synchronized (target.backPointer_BridgeInvocation_R674) { for (int i = 0; i < target.backPointer_BridgeInvocation_R674.size(); ++i) { BridgeInvocation_c source = (BridgeInvocation_c) target.backPointer_BridgeInvocation_R674.get(i); if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } } if (matches.size() > 0) { BridgeInvocation_c[] ret_set = new BridgeInvocation_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new BridgeInvocation_c[0]; } }
public boolean checkEvents(BundleEvent[] expevents) { boolean res = true; for (int i = 0; i < 20; i++) { try { Thread.sleep(100); } catch (InterruptedException ignore) { } if (events.size() == expevents.length) { break; } } if (events.size() == expevents.length) { for (int i = 0; i < events.size(); i++) { BundleEvent be = (BundleEvent) events.elementAt(i); if (!(be.getBundle().equals(expevents[i].getBundle()) && be.getType() == expevents[i].getType())) { res = false; } } } else { res = false; } if (!res) { out.println("Real events"); for (int i = 0; i < events.size(); i++) { BundleEvent be = (BundleEvent) events.elementAt(i); out.println("Event " + be.getBundle() + ", Type " + be.getType()); } out.println("Expected events"); for (int i = 0; i < expevents.length; i++) { out.println("Event " + expevents[i].getBundle() + ", Type " + expevents[i].getType()); } } return res; }
public static DescriptionQuery_c[] getManySQU_DEsOnR9600( Query_c[] targets, ClassQueryInterface_c test, boolean loadComponent) { if (targets == null || targets.length == 0 || targets[0] == null) return new DescriptionQuery_c[0]; ModelRoot modelRoot = targets[0].getModelRoot(); InstanceList instances = modelRoot.getInstanceList(DescriptionQuery_c.class); Vector matches = new Vector(); for (int i = 0; i < targets.length; i++) { DescriptionQuery_c source = (DescriptionQuery_c) targets[i].backPointer_IsSubtypeDescriptionQueryIsSubtype_R9600; if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } if (matches.size() > 0) { DescriptionQuery_c[] ret_set = new DescriptionQuery_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new DescriptionQuery_c[0]; } }
public static DataTypeInPackage_c[] getManyS_DIPsOnR39( DataTypePackage_c target, ClassQueryInterface_c test, boolean loadComponent) { if (target == null) return new DataTypeInPackage_c[0]; ModelRoot modelRoot = target.getModelRoot(); Vector matches = new Vector(); synchronized (target.backPointer_ContainsDataTypeInPackageContains_R39) { for (int i = 0; i < target.backPointer_ContainsDataTypeInPackageContains_R39.size(); ++i) { DataTypeInPackage_c source = (DataTypeInPackage_c) target.backPointer_ContainsDataTypeInPackageContains_R39.get(i); if (source != null && (test == null || test.evaluate(source))) { matches.add(source); } } } if (matches.size() > 0) { DataTypeInPackage_c[] ret_set = new DataTypeInPackage_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new DataTypeInPackage_c[0]; } }
public static final void fireEvent(GenericEvent e, Method m, Vector listeners) throws PropertyVetoException { Object[] snapshot = null; synchronized (listeners) { snapshot = new Object[listeners.size()]; listeners.copyInto(snapshot); } // leighd 04/14/99 - modified for event debugging if (gDebugEvents) Engine.debugLog("Event : " + e.toString()); Object params[] = new Object[] {e}; for (int i = 0; i < snapshot.length; i++) { if ((e instanceof Consumable) && ((Consumable) e).isConsumed()) { // leighd 04/14/99 // note that we don't catch the consumption of the // event until we've passed through the loop again, // so we reference i-1 if (gDebugEvents) Engine.debugLog("Consumed By : " + snapshot[i - 1]); return; } try { m.invoke(snapshot[i], params); } catch (IllegalAccessException iae) { iae.printStackTrace(); } catch (InvocationTargetException ite) { Throwable t = ite.getTargetException(); if (t instanceof PropertyVetoException) throw ((PropertyVetoException) t); else t.printStackTrace(); } } }
public Class[] getClassesFromClass(Class c) { Vector cList = new Vector(); Class cTemp; Class[] aList; cTemp = c; while ((cTemp = cTemp.getSuperclass()) != null) { cList.addElement(cTemp); } aList = new Class[cList.size()]; for (int i = 0; i < cList.size(); i++) { aList[i] = (Class) cList.elementAt(i); } return aList; }
public void remove(int index) { if (activeEditors.size() == 0) return; // it can get a bit excitable about removing element 0 ... PluggableEditor ed = (PluggableEditor) activeEditors.remove(index); ed.unload(); super.remove(index); }
/** * Not all editors are capable of displaying new entries. This whips through and removes all * editors that can't. */ private void trimNonNewEntryEditors() { int size = activeEditors.size(); for (int i = size - 1; i >= 0; i--) { if (((DataSink) activeEditors.get(i)).canCreateEntry() == false) { remove(i); } } suggestTableEditor(); // use table editor as default for new entries... }
/** * Remove the first null element found in the specified vector. Return true if a null element was * found and removed. Return false if a null element was not found. */ private boolean removeNullElement(Vector v) { for (int i = 0; i < v.size(); i++) { if (v.elementAt(i) == null) { v.removeElementAt(i); return true; } } return false; }
protected void fireHPubReqCompleteEvent(RequestCompleteEvent evt) { Vector currentListenerList = null; synchronized (this) { currentListenerList = (Vector) listenerList.clone(); } for (int i = 0; i < currentListenerList.size(); i++) { HPubReqCompleteListener listener = (HPubReqCompleteListener) currentListenerList.elementAt(i); listener.hPubReqComplete(evt); } }
public static Graphnode_c[] GraphnodeInstances( ModelRoot modelRoot, ClassQueryInterface_c test, boolean loadComponent) { InstanceList instances = modelRoot.getInstanceList(Graphnode_c.class); Vector matches = new Vector(); synchronized (instances) { for (int i = 0; i < instances.size(); ++i) { Graphnode_c x = (Graphnode_c) instances.get(i); if (test == null || test.evaluate(x)) { matches.add(x); } } if (matches.size() > 0) { Graphnode_c[] ret_set = new Graphnode_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new Graphnode_c[0]; } } }
/** If a purpose written pluggable editor is available, switch to that, */ public boolean suggestPluggableEditor() { for (int i = activeEditors.size() - 1; i >= 0; i--) { // try to set to the first 'user written' pluggable editor // that can be found... PluggableEditor ed = (PluggableEditor) activeEditors.get(i); if ((ed != templateDisplay) && (ed != tableDisplay)) { setCurrentEditor(ed); return true; } } return false; }
/** * Assert that the elements in two vectors are equal. If they are not, throw an * AssertionFailedError. The order of the elements is ignored. * * @param message the error message * @param expected the expected value of an vector * @param actual the actual value of an vector */ protected void assertUnorderedElementsEqual(String message, Vector expected, Vector actual) { if (expected == actual) { return; } if (expected.size() != actual.size()) { this.assertTrue(this.notEqualsMessage(message, expected, actual), false); } Vector temp = (Vector) actual.clone(); for (int i = 0; i < expected.size(); i++) { Object e1 = expected.elementAt(i); if (e1 == null) { // avoid null pointer exception if (!this.removeNullElement(temp)) { this.assertTrue(this.notEqualsMessage(message, expected, actual), false); } } else { if (!temp.removeElement(e1)) { this.assertTrue(this.notEqualsMessage(message, expected, actual), false); } } } }
/** * Assert that the elements in two vectors are equal. If they are not, throw an * AssertionFailedError. Order of the elements is significant. * * @param message the error message * @param expected the expected value of an vector * @param actual the actual value of an vector */ protected void assertElementsEqual(String message, Vector expected, Vector actual) { if (expected == actual) { return; } if (expected.size() != actual.size()) { this.assertTrue(this.notEqualsMessage(message, expected, actual), false); } for (int i = 0; i < expected.size(); i++) { Object e1 = expected.elementAt(i); Object e2 = actual.elementAt(i); if (e1 == null) { // avoid null pointer exception if (e2 != null) { this.assertTrue(this.notEqualsMessage(message, expected, actual), false); } } else { if (!e1.equals(e2)) { this.assertTrue(this.notEqualsMessage(message, expected, actual), false); } } } }
public static InformalArgument_c[] InformalArgumentInstances( ModelRoot modelRoot, ClassQueryInterface_c test, boolean loadComponent) { if (loadComponent) { PersistenceManager.ensureAllInstancesLoaded(modelRoot, InformalArgument_c.class); } InstanceList instances = modelRoot.getInstanceList(InformalArgument_c.class); Vector matches = new Vector(); synchronized (instances) { for (int i = 0; i < instances.size(); ++i) { InformalArgument_c x = (InformalArgument_c) instances.get(i); if (test == null || test.evaluate(x)) { if (x.ensureLoaded(loadComponent)) matches.add(x); } } if (matches.size() > 0) { InformalArgument_c[] ret_set = new InformalArgument_c[matches.size()]; matches.copyInto(ret_set); return ret_set; } else { return new InformalArgument_c[0]; } } }
/** * This can be used to register Swing components that may be used by sub editors to affect the * outside environment. */ public void registerComponents( JMenuBar menu, JToolBar buttons, JTree tree, JPopupMenu treeMenu, JFrame jxplorer) { registerMenu = menu; registerButtons = buttons; registerTree = tree; registerTreeMenu = treeMenu; registerJX = jxplorer; // reset the sub editors as well. for (int i = 0; i < activeEditors.size(); i++) { ((PluggableEditor) activeEditors.get(i)) .registerComponents(menu, buttons, tree, treeMenu, jxplorer); } }