public static void addRenderInformation(RenderLayoutPlugin rPlugin)
    {
        if (rPlugin == null)
        {
            Console.WriteLine("could not add render information!");
            Environment.Exit(4);
        }

        LocalRenderInformation rInfo = rPlugin.createLocalRenderInformation();

        rInfo.setId("info");
        rInfo.setName("Example Render Information");
        rInfo.setProgramName("RenderInformation Examples");
        rInfo.setProgramVersion("1.0");

        // add some colors
        ColorDefinition color = rInfo.createColorDefinition();

        color.setId("black");
        color.setColorValue("#000000");

        color = rInfo.createColorDefinition();
        color.setId("silver");
        color.setColorValue("#c0c0c0");

        color = rInfo.createColorDefinition();
        color.setId("white");
        color.setColorValue("#FFFFFF");

        // add a linear gradient from black to white to silver
        LinearGradient gradient = rInfo.createLinearGradientDefinition();

        gradient.setId("simpleGradient");
        gradient.setPoint1(new RelAbsVector(), new RelAbsVector());
        gradient.setPoint2(new RelAbsVector(0, 100), new RelAbsVector(0, 100));

        GradientStop stop = gradient.createGradientStop();

        stop.setOffset(new RelAbsVector());
        stop.setStopColor("white");

        stop = gradient.createGradientStop();
        stop.setOffset(new RelAbsVector(0, 100));
        stop.setStopColor("silver");

        // add a species style that represents them as ellipses with the gradient above
        Style style = rInfo.createStyle("ellipseStyle");

        style.getGroup().setFillColor("simpleGradient");
        style.getGroup().setStroke("black");
        style.getGroup().setStrokeWidth(2.0);
        style.addType("SPECIESGLYPH");

        Ellipse ellipse = style.getGroup().createEllipse();

        ellipse.setCenter2D(new RelAbsVector(0, 50), new RelAbsVector(0, 50));
        ellipse.setRadii(new RelAbsVector(0, 50), new RelAbsVector(0, 50));
    }
    public static void print_render_info(LocalRenderInformation info)
    {
        print_render_info((RenderInformationBase)info);

        // and finally the styles
        Console.WriteLine("\nStyles: ");
        for (int j = 0; j < info.getNumLocalStyles(); ++j)
        {
            LocalStyle style = info.getLocalStyle(j);
            print_style(style, j);
        }
    }
    public static int Main(string[] args)
    {
        if (args.Length != 1)
        {
            Console.WriteLine(" Usage:  printRenderInformation <input file> \n" +
                              "      prints a summary of the render information object.");
            return(1);
        }


        string inputFile = args[0];

        SBMLDocument doc = libsbml.readSBMLFromFile(inputFile);

        Console.WriteLine("Using libSBML: {0} supporting packages for:", libsbml.getLibSBMLDottedVersion());
        for (int i = 0; i < SBMLExtensionRegistry.getNumRegisteredPackages(); ++i)
        {
            Console.WriteLine("\t {0}", SBMLExtensionRegistry.getRegisteredPackageName(i));
        }

        Console.WriteLine("\nThe document is: level {0}, version {1}", doc.getLevel(), doc.getVersion());
        for (int i = 0; i < doc.getNumPlugins(); ++i)
        {
            Console.WriteLine("  doc uses package: {0}", doc.getPlugin(i).getElementNamespace());
        }

        Console.WriteLine("\n");

        long numErrors = doc.getNumErrors(libsbml.LIBSBML_SEV_ERROR);

        if (numErrors > 0)
        {
            Console.WriteLine("Encountered errors while reading the file. ");
            Console.WriteLine("Please correct the following errors and try again.");
            doc.printErrors();
            return(2);
        }

        Model model = doc.getModel();

        LayoutModelPlugin plugin = (LayoutModelPlugin)model.getPlugin("layout");

        if (plugin == null || plugin.getNumLayouts() == 0)
        {
            Console.WriteLine("The loaded model contains no layout information, please add these first.");
            return(3);
        }

        RenderListOfLayoutsPlugin lolPlugin = (RenderListOfLayoutsPlugin)plugin.getListOfLayouts().getPlugin("render");

        if (lolPlugin != null && lolPlugin.getNumGlobalRenderInformationObjects() > 0)
        {
            Console.WriteLine("The loaded model contains global Render information: ");

            for (int i = 0; i < lolPlugin.getNumGlobalRenderInformationObjects(); ++i)
            {
                GlobalRenderInformation info = lolPlugin.getRenderInformation(i);
                print_render_info(info);
            }
        }

        Layout layout = plugin.getLayout(0);

        RenderLayoutPlugin rPlugin = (RenderLayoutPlugin)layout.getPlugin("render");

        if (rPlugin != null && rPlugin.getNumLocalRenderInformationObjects() > 0)
        {
            Console.WriteLine("The loaded model contains local Render information. ");
            // here we would do the same as above for the local render information ...
            for (int i = 0; i < rPlugin.getNumLocalRenderInformationObjects(); ++i)
            {
                LocalRenderInformation info = rPlugin.getRenderInformation(i);
                print_render_info(info);
            }
        }

        return(0);
    }
Пример #4
0
    public static int Main(string[] args)
    {
        var doc = new SbgnDocument();

        var map = doc.createMap();

        map.setMetaId("map1");
        map.setLanguage("process description");

        var glyph = map.createGlyph();

        glyph.setId("glyph0");
        glyph.setClazz("macromolecule");

        var label = glyph.createLabel();

        label.setText("greek letter alpha: &#945;");

        var bbox = glyph.createBBox();

        bbox.setX(20);
        bbox.setY(20);
        bbox.setWidth(140);
        bbox.setHeight(60);

        var renderInfo = new LocalRenderInformation();

        renderInfo.setId("info1");
        renderInfo.setProgramName("libSBGN example");
        renderInfo.setProgramVersion("0.0.1");

        var color = renderInfo.createColorDefinition();

        color.setId("orange");
        color.setValue("#fa9e2fff");

        var gradient = renderInfo.createLinearGradientDefinition();

        gradient.setId("orangeGradient");
        var stop = gradient.createGradientStop();

        stop.setOffset("0%");
        stop.setStopColor("#ffffff");
        stop = gradient.createGradientStop();
        stop.setOffset("100%");
        stop.setStopColor("#fa9e2fff");

        var style = renderInfo.createLocalStyle();

        style.addId("glyph0");
        var group = style.createGroup();

        group.setStroke("orange");
        group.setStrokeWidth(2.0);
        group.setFill("orangeGradient");

        map.setRenderInformation(renderInfo);

        libsbgn.writeSBGNToFile(doc, "out.sbgn");

        return(0);
    }