发布时间:2025-12-09 12:00:02 浏览次数:1
import org.sbml.jsbml.ext.layout.Layout; //导入依赖的package包/类public Layout getLayout() {if (sbmlLayout==null) {sbmlLayout = SBMLutilities.getLayoutModelPlugin(sbml.getModel());}Layout layout;if (sbmlLayout.getLayoutCount()>0) {layout = sbmlLayout.getLayout(0);if (!layout.getId().endsWith("iBioSim")) {convertLayout(layout);} } else {layout = sbmlLayout.createLayout();layout.createDimensions(0, 0, 0);}layout.setId("iBioSim");return layout;} import org.sbml.jsbml.ext.layout.Layout; //导入依赖的package包/类public void removeByMetaId(String metaId) {SBase sbase = SBMLutilities.getElementByMetaId(sbml.getModel(), metaId);if (sbase != null) {sbase.removeFromParent();for (int j = 0; j < sbmlCompModel.getListOfPorts().size(); j++) {Port port = sbmlCompModel.getListOfPorts().get(j);if (port.isSetMetaIdRef() && port.getMetaIdRef().equals(metaId)) {sbmlCompModel.getListOfPorts().remove(j);break;}}}Layout layout = getLayout();if (layout.getListOfAdditionalGraphicalObjects().get(GlobalConstants.GLYPH+"__"+metaId)!=null) {layout.getListOfAdditionalGraphicalObjects().remove(GlobalConstants.GLYPH+"__"+metaId);}if (layout.getTextGlyph(GlobalConstants.TEXT_GLYPH+"__"+metaId) != null) {layout.getListOfTextGlyphs().remove(GlobalConstants.TEXT_GLYPH+"__"+metaId);}} import org.sbml.jsbml.ext.layout.Layout; //导入依赖的package包/类public boolean checkCompartmentOverlap(String id,double x, double y, double w, double h) {for (int i = 0; i < sbml.getModel().getCompartmentCount(); i++) {Compartment c = sbml.getModel().getCompartment(i);if (c.getId().equals(id)) continue;Layout layout = getLayout();CompartmentGlyph compartmentGlyph = layout.getCompartmentGlyph(GlobalConstants.GLYPH+"__"+c.getId());double cx = compartmentGlyph.getBoundingBox().getPosition().getX();double cy = compartmentGlyph.getBoundingBox().getPosition().getY();double cw = compartmentGlyph.getBoundingBox().getDimensions().getWidth();double ch = compartmentGlyph.getBoundingBox().getDimensions().getHeight();if (x >= cx && y >= cy && x+w <= cx+cw && y+h <= cy+ch) continue;if (x <= cx && y <= cy && x+w >= cx+cw && y+h >= cy+ch) continue;if (x+w <= cx) continue;if (x >= cx+cw) continue;if (y+h <= cy) continue;if (y >= cy+ch) continue;return false;}return true;} import org.sbml.jsbml.ext.layout.Layout; //导入依赖的package包/类public void createRule(String id, float x, float y) {Layout layout = getLayout();GeneralGlyph generalGlyph = null;if (layout.getListOfAdditionalGraphicalObjects().get(GlobalConstants.GLYPH+"__"+id)!=null) {generalGlyph = (GeneralGlyph)layout.getListOfAdditionalGraphicalObjects().get(GlobalConstants.GLYPH+"__"+id);} else {generalGlyph = layout.createGeneralGlyph(GlobalConstants.GLYPH+"__"+id);generalGlyph.createBoundingBox();generalGlyph.getBoundingBox().createDimensions();generalGlyph.getBoundingBox().createPosition();generalGlyph.unsetReference();generalGlyph.setMetaidRef(id);}generalGlyph.getBoundingBox().getPosition().setX(x);generalGlyph.getBoundingBox().getPosition().setY(y);generalGlyph.getBoundingBox().getDimensions().setWidth(GlobalConstants.DEFAULT_RULE_WIDTH);generalGlyph.getBoundingBox().getDimensions().setHeight(GlobalConstants.DEFAULT_RULE_HEIGHT);TextGlyph textGlyph = layout.createTextGlyph(GlobalConstants.TEXT_GLYPH+"__"+id);textGlyph.createBoundingBox();textGlyph.getBoundingBox().createDimensions();textGlyph.getBoundingBox().createPosition();textGlyph.setGraphicalObject(GlobalConstants.GLYPH+"__"+id);textGlyph.setText(SBMLutilities.getArrayId(sbml,id));textGlyph.setBoundingBox(generalGlyph.getBoundingBox().clone());}