Package org.sbml.jsbml.ext.layout

Examples of org.sbml.jsbml.ext.layout.Layout


      model.setVersion(version);
     
      // Get LayoutModel
      LayoutModelPlugin layoutModel = LayoutExtension.getOrCreateLayoutModel(doc);
      // Add the layout
      Layout layout = createSBMLLayoutForView(view, model);
      layoutModel.add(layout);
    }
    return doc;
  }
View Full Code Here


  }
 
  private static Layout createSBMLLayoutForView(CyNetworkView view, Model model){
    int level = model.getLevel();
    int version = model.getVersion();
    Layout layout = new Layout(level, version);
    String layoutId = view.getIdentifier();
    layout.setId(layoutId);
    layout.setName(layoutId);
   
    CyNetwork network = view.getNetwork();
      @SuppressWarnings("unchecked")
    List<CyNode> nodes = network.nodesList();
      CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
     
      for (CyNode node : nodes){
        NodeView nodeView = view.getNodeView(node);
        // Test if reaction or species node
        String nodeId = node.getIdentifier();
        String nodeType = (String) nodeAttributes.getAttribute(nodeId, CySBMLConstants.ATT_TYPE);
        if (nodeType!=null){
          if (nodeType.equals(CySBMLConstants.NODETYPE_REACTION) || nodeType.equals(CySBMLConstants.NODETYPE_SPECIES)){
           
            double xpos = nodeView.getXPosition();
          double ypos = nodeView.getYPosition();
          double zpos = 0.0;
          double height = nodeView.getHeight();
          double width = nodeView.getWidth();
          double depth = 0.0;
          Dimensions dim = new Dimensions(width, height, depth, level, version);
          Point point = new Point(xpos, ypos, zpos, level, version);
         
          BoundingBox box = new BoundingBox();
          box.setLevel(level);
          box.setVersion(version);
          box.setPosition(point);
          box.setDimensions(dim);
         
          if (nodeType.equals(CySBMLConstants.NODETYPE_SPECIES)){
            SpeciesGlyph sGlyph = new SpeciesGlyph();
            sGlyph.setId(nodeId);
            sGlyph.setVersion(version);
            sGlyph.setLevel(level);
            sGlyph.setBoundingBox(box);
            sGlyph.setSpecies(nodeId);
            layout.addSpeciesGlyph(sGlyph);
           
          }
          else if (nodeType.equals(CySBMLConstants.NODETYPE_REACTION)){
            ReactionGlyph rGlyph = new ReactionGlyph();
            rGlyph.setVersion(version);
            rGlyph.setLevel(level);
            rGlyph.setId(nodeId);
            rGlyph.setBoundingBox(box);
            rGlyph.setReaction(nodeId);
           
            //write the speciesReferences
            /*
            ListOf<SpeciesReferenceGlyph> listOfSpeciesReferencesGlyph = new ListOf<SpeciesReferenceGlyph>();
            Reaction reaction = model.getReaction(nodeId);
            for (SpeciesReference sRef : reaction.getListOfProducts()){
              SpeciesReferenceGlyph sRefGlyph =
              listOfSpeciesReferencesGlyph.add(new SpeciesReferenceGlyph(sRef.getId()));
            }
            for (SpeciesReference sRef : reaction.getListOfReactants()){
              listOfSpeciesReferencesGlyph.add(new SpeciesReferenceGlyph(sRef.getId()));
            }
            rGlyph.setListOfSpeciesReferencesGlyph(listOfSpeciesReferencesGlyph);
            */
            layout.addReactionGlyph(rGlyph);
          }
          }
        }
      }
      return layout;
View Full Code Here

  private void generateLayoutNetworks(CyNetwork network){
    if (LayoutExtension.existLayoutInSBMLDocument(document)){
      CySBML.LOGGER.info("Create additional networks for layouts.");
      ListOf<Layout> layoutList = LayoutExtension.getLayoutsInSBMLDocument(document);
      for (int k=0; k<layoutList.size(); ++k){
        Layout layout = layoutList.get(k);
        // Create the layout networks
        try {
          Cytoscape.createNetwork(
            new SBMLLayoutGraphReader(document, network, layout), true, null);
        } catch (Exception e){
View Full Code Here

    System.out.println("Model extension objects: " + model.getExtension(LAYOUT_NAMESPACE));
    LayoutModelPlugin extendedModel = (LayoutModelPlugin) model.getExtension(LAYOUT_NAMESPACE);

    System.out.println("Nb Layouts = " + extendedModel.getListOfLayouts().size());

    Layout layout = extendedModel.getLayout(0);

    // System.out.println("Group sboTerm, id = " + group.getSBOTermID() + ", " + group.getId()); print dimension
    System.out.println("Nb SpeciesGlyphs = " + layout.getListOfSpeciesGlyphs().size());

    SpeciesGlyph  speciesGlyph = layout.getSpeciesGlyph(0);

    // System.out.println("Member(0).symbol = " + member.getSymbol());

  }
View Full Code Here

        listOfLayouts.registerChild(newElement);
        return newElement;
      }
    }
    else if (contextObject instanceof Layout) {
      Layout layout = (Layout) contextObject;
      SBase newElement = null;

      if (elementName.equals(RenderConstants.listOfLocalRenderInformation)) {
        RenderLayoutPlugin renderPlugin = new RenderLayoutPlugin(layout);
        layout.addExtension(RenderConstants.namespaceURI, renderPlugin);
        newElement = renderPlugin.getListOfLocalRenderInformation();
      }
      if (newElement != null) {
        layout.registerChild(newElement);
        return newElement;
      }
    }
    else if (contextObject instanceof RenderInformationBase) {
      RenderInformationBase renderInformation = (RenderInformationBase) contextObject;
View Full Code Here

        return layoutModel.getListOfLayouts();
      }
    }
    else if (contextObject instanceof Layout) {
      Layout layout = (Layout) contextObject;
      SBase newElement = null;

      if (elementName.equals(listOfCompartmentGlyphs)) {

        newElement = layout.getListOfCompartmentGlyphs();
      }
      else if (elementName.equals(listOfSpeciesGlyphs)) {

        newElement = layout.getListOfSpeciesGlyphs();
      }
      else if (elementName.equals(listOfReactionGlyphs)) {

        newElement = layout.getListOfReactionGlyphs();
      }
      else if (elementName.equals(listOfTextGlyphs)) {

        newElement = layout.getListOfTextGlyphs();
      }
      else if (elementName.equals(listOfAdditionalGraphicalObjects)) {

        newElement = layout.getListOfAdditionalGraphicalObjects();
      }
      else if (elementName.equals(dimensions)) {
        Dimensions dimension = new Dimensions();
        layout.setDimensions(dimension);

        newElement = dimension;
      }

      if (newElement != null) {
        return newElement;
      }
    }
    else if (contextObject instanceof GraphicalObject) {
      GraphicalObject graphicalObject = (GraphicalObject) contextObject;

      if (elementName.equals(boundingBox)) {
        BoundingBox bbox = new BoundingBox();
        graphicalObject.setBoundingBox(bbox);

        return bbox;
      }

      if (graphicalObject instanceof ReactionGlyph)
      {
        ReactionGlyph reactionGlyph = (ReactionGlyph) graphicalObject;

        if (elementName.equals(curve)) {
          Curve curve = new Curve();
          reactionGlyph.setCurve(curve);

          return curve;
        }
        else if (elementName.equals(listOfSpeciesReferenceGlyphs))
        {
          ListOf<SpeciesReferenceGlyph> list = reactionGlyph.getListOfSpeciesReferenceGlyphs();
          return list;
        }

      }
      else if (graphicalObject instanceof SpeciesReferenceGlyph)
      {
        SpeciesReferenceGlyph speciesRefGlyph = (SpeciesReferenceGlyph) contextObject;

        if (elementName.equals(curve)) {
          Curve curve = new Curve();
          speciesRefGlyph.setCurve(curve);

          return curve;
        }

      }
      else if (graphicalObject instanceof GeneralGlyph)
      {
        GeneralGlyph generalGlyph = (GeneralGlyph) graphicalObject;

        if (elementName.equals(curve)) {
          Curve curve = new Curve();
          generalGlyph.setCurve(curve);

          return curve;
        }
        else if (elementName.equals(listOfSubGlyphs))
        {
          ListOf<GraphicalObject> list = generalGlyph.getListOfSubGlyphs();
          return list;
        }
        else if (elementName.equals(listOfReferenceGlyphs))
        {
          ListOf<ReferenceGlyph> list = generalGlyph.getListOfReferenceGlyphs();
          return list;
        }

      }
      else if (graphicalObject instanceof ReferenceGlyph)
      {
        ReferenceGlyph refGlyph = (ReferenceGlyph) contextObject;

        if (elementName.equals(curve)) {
          Curve curve = new Curve();
          refGlyph.setCurve(curve);

          return curve;
        }
      }

    }
    else if (contextObject instanceof BoundingBox)
    {
      BoundingBox bbox = (BoundingBox) contextObject;

      if (elementName.equals(position)) {
        Position position = new Position();
        bbox.setPosition(position);

        return position;
      }
      else if (elementName.equals(dimensions)) {
        Dimensions dimension = new Dimensions();
        bbox.setDimensions(dimension);

        return dimension;
      }
    }
    else if (contextObject instanceof Curve) {
      Curve curve = (Curve) contextObject;
      SBase newElement = null;

      if (elementName.equals(listOfCurveSegments)) {

        newElement = curve.getListOfCurveSegments();
      }

      if (newElement != null) {
        return newElement;
      }
    }
    else if (contextObject instanceof CurveSegment) {
      CubicBezier curveSegment = (CubicBezier) contextObject;

      if (elementName.equals(start)) {
        Start point = new Start();
        curveSegment.setStart(point);

        return point;
      }
      else if (elementName.equals(end)) {
        End point = new End();
        curveSegment.setEnd(point);

        return point;
      }
      else if (elementName.equals(basePoint1)) {
        BasePoint1 point = new BasePoint1();
        curveSegment.setBasePoint1(point);

        return point;
      }
      else if (elementName.equals(basePoint2)) {
        BasePoint2 point = new BasePoint2();
        curveSegment.setBasePoint2(point);

        return point;
      }

    }
    else if (contextObject instanceof ListOf<?>) {
      ListOf<SBase> listOf = (ListOf<SBase>) contextObject;
      SBase newElement = null;

      if (elementName.equals(layout)) {
        newElement = new Layout();
      }
      else if (elementName.equals(compartmentGlyph)) {
        newElement = new CompartmentGlyph();
      }
      else if (elementName.equals(speciesGlyph)) {
View Full Code Here

              listOfElementsToWrite.add(element);
            }
          }
        }
      } else if (sbase instanceof Layout) {
        Layout layout = (Layout) sbase;

        if (layout.isSetListOfSpeciesGlyphs()) {
          listOfElementsToWrite.add(layout.getListOfSpeciesGlyphs());
          ListOf<SpeciesGlyph> listOfSpeciesGlyph = layout
              .getListOfSpeciesGlyphs();
          log4jLogger.debug("found list of species glyph");
          log4jLogger.debug("list of species glyph: "
              + listOfSpeciesGlyph.getElementName());
        } else if (layout.isSetListOfCompartmentGlyphs()) {
          listOfElementsToWrite.add(layout
            .getListOfCompartmentGlyphs());
        } else if (layout.isSetListOfReactionGlyphs()) {
          listOfElementsToWrite.add(layout.getListOfReactionGlyphs());
        } else if (layout.isSetListOfTextGlyphs()) {
          listOfElementsToWrite.add(layout.getListOfTextGlyphs());
        }
      } else if (sbase instanceof Point) {
        Point point = (Point) sbase;
        SBase parent = point.getParentSBMLObject();
        if (parent instanceof CurveSegment) {
View Full Code Here

          ListOf<?> listOf = (ListOf<?>) contextObject;
          if (listOf.getParentSBMLObject() instanceof Model) {
            if (elementName.equals("layout")
                && groupList.equals(LayoutList.listOfLayouts)) {
              ListOf<Layout> listOflayouts = (ListOf<Layout>) listOf;
              Layout layout = (Layout) newContextObject;
              setNamespace(layout, namespaceURI);
              listOflayouts.add(layout);
              return layout;
            }
          } else if (listOf.getParentSBMLObject() instanceof Layout) {
            if (elementName.equals("compartmentGlyph")
                && groupList.equals(LayoutList.listOfCompartmentGlyphs)) {
              ListOf<CompartmentGlyph> listOfCompartmentGlyph = (ListOf<CompartmentGlyph>) contextObject;
              CompartmentGlyph compartmentGlyph = (CompartmentGlyph) newContextObject;
              setNamespace(listOfCompartmentGlyph, namespaceURI);
              setNamespace(compartmentGlyph, namespaceURI);
              listOfCompartmentGlyph.add(compartmentGlyph);
              groupList = LayoutList.listOfCompartmentGlyphs;
              return compartmentGlyph;
            } else if (elementName.equals("textGlyph")
                && groupList.equals(LayoutList.listOfTextGlyphs)) {
              ListOf<TextGlyph> listOfTextGlyph = (ListOf<TextGlyph>) contextObject;
              TextGlyph textGlyph = (TextGlyph) newContextObject;
              setNamespace(listOfTextGlyph, namespaceURI);
              setNamespace(textGlyph, namespaceURI);
              listOfTextGlyph.add(textGlyph);
              groupList = LayoutList.listOfTextGlyphs;
              return textGlyph;
            } else if (elementName.equals("speciesGlyph")
                && groupList.equals(LayoutList.listOfSpeciesGlyphs)) {
              ListOf<SpeciesGlyph> listOfSpeciesGlyph = (ListOf<SpeciesGlyph>) contextObject;
              SpeciesGlyph speciesGlyph = (SpeciesGlyph) newContextObject;
              setNamespace(listOfSpeciesGlyph, namespaceURI);
              setNamespace(speciesGlyph, namespaceURI);
              listOfSpeciesGlyph.add(speciesGlyph);
              groupList = LayoutList.listOfSpeciesGlyphs;
              return speciesGlyph;
            } else if (elementName.equals("reactionGlyph")
                && groupList.equals(LayoutList.listOfReactionGlyphs)) {
              ListOf<ReactionGlyph> listOfReactionGlyph = (ListOf<ReactionGlyph>) contextObject;
              ReactionGlyph reactionGlyph = (ReactionGlyph) newContextObject;
              setNamespace(listOfReactionGlyph, namespaceURI);
              setNamespace(reactionGlyph, namespaceURI);
              listOfReactionGlyph.add(reactionGlyph);
              groupList = LayoutList.listOfReactionGlyphs;
              return reactionGlyph;
            } else if (elementName.equals("boundingBox")
                && groupList.equals(LayoutList.listOfCompartmentGlyphs)) {
              CompartmentGlyph compartmentGlyph = (CompartmentGlyph) contextObject;
              BoundingBox boundingBox = (BoundingBox) newContextObject;
              setNamespace(boundingBox, namespaceURI);
              compartmentGlyph.setBoundingBox(boundingBox);
              return boundingBox;
            }
          } else if (listOf.getParentSBMLObject() instanceof ReactionGlyph) {
            if (elementName.equals("speciesReferenceGlyph")
                && groupList.equals(LayoutList.listOfSpeciesReferenceGlyphs)) {
              SpeciesReferenceGlyph speciesReferenceGlyph = (SpeciesReferenceGlyph) newContextObject;
              setNamespace(speciesReferenceGlyph, namespaceURI);
              ListOf<SpeciesReferenceGlyph> listOfSpeciesReferenceGlyph = (ListOf<SpeciesReferenceGlyph>) contextObject;
              listOfSpeciesReferenceGlyph
              .add(speciesReferenceGlyph);
              return speciesReferenceGlyph;
            }
          } else if (elementName.equals("curveSegment")
              && groupList.equals(LayoutList.listOfCurveSegments)) {
            ListOf<CurveSegment> listOfLineSegment = (ListOf<CurveSegment>) contextObject;
            CubicBezier lineSegment = (CubicBezier) newContextObject;
            setNamespace(lineSegment, namespaceURI);
            listOfLineSegment.add(lineSegment);
            groupList = LayoutList.listOfCurveSegments;
            return lineSegment;
          } else if (listOf.getParentSBMLObject() instanceof Curve) {

            if (elementName.equals("curveSegment") || elementName.equals("cubicBezier")
                || elementName.equals("lineSegment"))
            {
              ListOf<CurveSegment> listOfLineSegment = (ListOf<CurveSegment>) contextObject;
              CubicBezier lineSegment = (CubicBezier) newContextObject;
              setNamespace(lineSegment, namespaceURI);
              listOfLineSegment.add(lineSegment);
              return lineSegment;
            }
          }

        } else if (contextObject instanceof Layout) {
          Layout layout = (Layout) contextObject;
          groupList = LayoutList.listOfLayouts;
          if (elementName.equals("dimensions")
              && groupList.equals(LayoutList.listOfLayouts)) {
            Dimensions dimensions = (Dimensions) newContextObject;
            setNamespace(dimensions, namespaceURI);
            layout.setDimensions(dimensions);
            return dimensions;
          } else if (elementName.equals("listOfCompartmentGlyphs")
              && groupList.equals(LayoutList.listOfLayouts)) {
            ListOf<CompartmentGlyph> listOfCompartmentGlyphs = (ListOf<CompartmentGlyph>) newContextObject;
            listOfCompartmentGlyphs.setSBaseListType(ListOf.Type.other);
            layout.setListOfCompartmentGlyphs(listOfCompartmentGlyphs);
            groupList = LayoutList.listOfCompartmentGlyphs;
            return listOfCompartmentGlyphs;
          } else if (elementName.equals("listOfSpeciesGlyphs")
              && groupList.equals(LayoutList.listOfLayouts)) {
            ListOf<SpeciesGlyph> listofSpeciesGlyph = (ListOf<SpeciesGlyph>) newContextObject;
            listofSpeciesGlyph.setSBaseListType(ListOf.Type.other);
            layout.setListOfSpeciesGlyphs(listofSpeciesGlyph);
            groupList = LayoutList.listOfSpeciesGlyphs;
            return listofSpeciesGlyph;
          } else if (elementName.equals("listOfReactionGlyphs")
              && groupList.equals(LayoutList.listOfLayouts)) {
            ListOf<ReactionGlyph> listOfReactionGlyphs = (ListOf<ReactionGlyph>) newContextObject;
            listOfReactionGlyphs.setSBaseListType(ListOf.Type.other);
            layout.setListOfReactionGlyphs(listOfReactionGlyphs);
            groupList = LayoutList.listOfReactionGlyphs;
            return listOfReactionGlyphs;
          } else if (elementName.equals("listOfTextGlyphs")
              && groupList.equals(LayoutList.listOfLayouts)) {
            ListOf<TextGlyph> listOfTextGlyphs = (ListOf<TextGlyph>) newContextObject;
            listOfTextGlyphs.setSBaseListType(ListOf.Type.other);
            layout.setListOfTextGlyphs(listOfTextGlyphs);
            groupList = LayoutList.listOfTextGlyphs;
            return listOfTextGlyphs;
          }
        } else if (contextObject instanceof ReactionGlyph) {
          ReactionGlyph reactionGlyph = (ReactionGlyph) contextObject;
View Full Code Here

  public static void main(String[] args) throws SBMLException, XMLStreamException {
    SBMLDocument doc = new SBMLDocument(3, 1);
    Model m = doc.createModel("m1");
    LayoutModelPlugin elm = new LayoutModelPlugin(m);
    m.addExtension(LayoutConstants.getNamespaceURI(m.getLevel(), m.getVersion()), elm);
    Layout l1 = elm.createLayout("l1");
    l1.createCompartmentGlyph("test");
    RenderLayoutPlugin rlp = new RenderLayoutPlugin(l1);
    rlp.createLocalRenderInformation("info1");
    l1.addExtension(RenderConstants.namespaceURI, rlp);

    SBMLWriter.write(doc, System.out, ' ', (short) 2);
  }
View Full Code Here

TOP

Related Classes of org.sbml.jsbml.ext.layout.Layout

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.