########################################################################
#
#    Vision Network - Python source code - file generated by vision
#    Thursday 12 April 2007 13:48:35 
#    
#       The Scripps Research Institute (TSRI)
#       Molecular Graphics Lab
#       La Jolla, CA 92037, USA
#
# Copyright: Daniel Stoffler, Michel Sanner and TSRI
#   
# revision: Guillaume Vareille
#  
#########################################################################
#
# $Header: /opt/cvs/python/packages/share1.5/Vision/doc/Examples/matplotlib/Legend_net_1.py,v 1.2 2007/08/29 20:37:16 vareille Exp $
#
# $Id: Legend_net_1.py,v 1.2 2007/08/29 20:37:16 vareille Exp $
#

from traceback import print_exc
## loading libraries ##
from Vision.matplotlibNodes import matplotliblib
masterNet.getEditor().addLibraryInstance(matplotliblib,"Vision.matplotlibNodes", "matplotliblib")

from Vision.StandardNodes import stdlib
masterNet.getEditor().addLibraryInstance(stdlib,"Vision.StandardNodes", "stdlib")

try:
    ## saving node ReadTable ##
    from Vision.StandardNodes import ReadTable
    ReadTable_0 = ReadTable(constrkw = {}, name='ReadTable', library=stdlib)
    masterNet.addNode(ReadTable_0,138,9)
    ReadTable_0.inputPortByName['filename'].widget.set("Vision/Examples/matplotlib/Data/legend_data.dat", run=False)
    ReadTable_0.inputPortByName['sep'].widget.set(",", run=False)
    ReadTable_0.inputPortByName['datatype'].widget.set("float", run=False)
    apply(ReadTable_0.configure, (), {'expanded': True})
except:
    print "WARNING: failed to restore ReadTable named ReadTable in network masterNet"
    print_exc()
    ReadTable_0=None

try:
    ## saving node Plot ##
    from Vision.matplotlibNodes import PlotNE
    Plot_1 = PlotNE(constrkw = {}, name='Plot', library=matplotliblib)
    masterNet.addNode(Plot_1,4,321)
    Plot_1.inputPortByName['lineStyle'].widget.set("dotted", run=False)
    apply(Plot_1.configure, (), {'expanded': True})
except:
    print "WARNING: failed to restore PlotNE named Plot in network masterNet"
    print_exc()
    Plot_1=None

try:
    ## saving node Index ##
    from Vision.StandardNodes import Index
    Index_2 = Index(constrkw = {}, name='Index', library=stdlib)
    masterNet.addNode(Index_2,17,153)
    apply(Index_2.inputPortByName['index'].widget.configure, (), {'max': 3})
    Index_2.inputPortByName['index'].widget.set(2, run=False)
    apply(Index_2.configure, (), {'expanded': True})
except:
    print "WARNING: failed to restore Index named Index in network masterNet"
    print_exc()
    Index_2=None

try:
    ## saving node Index ##
    from Vision.StandardNodes import Index
    Index_3 = Index(constrkw = {}, name='Index', library=stdlib)
    masterNet.addNode(Index_3,173,151)
    apply(Index_3.inputPortByName['index'].widget.configure, (), {'max': 3})
    Index_3.inputPortByName['index'].widget.set(3, run=False)
    apply(Index_3.configure, (), {'expanded': True})
except:
    print "WARNING: failed to restore Index named Index in network masterNet"
    print_exc()
    Index_3=None

try:
    ## saving node Plot ##
    from Vision.matplotlibNodes import PlotNE
    Plot_4 = PlotNE(constrkw = {}, name='Plot', library=matplotliblib)
    masterNet.addNode(Plot_4,172,320)
    Plot_4.inputPortByName['lineStyle'].widget.set("dashed", run=False)
    apply(Plot_4.configure, (), {'expanded': True})
except:
    print "WARNING: failed to restore PlotNE named Plot in network masterNet"
    print_exc()
    Plot_4=None

try:
    ## saving node add ##
    from Vision.StandardNodes import Operator2
    add_5 = Operator2(constrkw = {}, name='add', library=stdlib)
    masterNet.addNode(add_5,338,221)
    add_5.inputPortByName['operation'].widget.set("add", run=False)
    add_5.inputPortByName['applyToElements'].widget.set(1, run=False)
except:
    print "WARNING: failed to restore Operator2 named add in network masterNet"
    print_exc()
    add_5=None

try:
    ## saving node Legend ##
    from Vision.matplotlibNodes import LegendNE
    Legend_8 = LegendNE(constrkw = {}, name='Legend', library=matplotliblib)
    masterNet.addNode(Legend_8,497,482)
    Legend_8.inputPortByName['label'].widget.set("Model length,Data length,Total message length", run=False)
    Legend_8.inputPortByName['location'].widget.set("upper center", run=False)
    apply(Legend_8.configure, (), {'expanded': True})
except:
    print "WARNING: failed to restore LegendNE named Legend in network masterNet"
    print_exc()
    Legend_8=None

try:
    ## saving node Set Matplotlib options ##
    from Vision.matplotlibNodes import MatPlotLibOptions
    Set_Matplotlib_options_9 = MatPlotLibOptions(constrkw = {}, name='Set Matplotlib options', library=matplotliblib)
    masterNet.addNode(Set_Matplotlib_options_9,256,530)
    Set_Matplotlib_options_9.inputPortByName['matplotlibOptions'].widget.set({'legend.shadow': 1}, run=False)
except:
    print "WARNING: failed to restore MatPlotLibOptions named Set Matplotlib options in network masterNet"
    print_exc()
    Set_Matplotlib_options_9=None

try:
    ## saving node MultiPlot ##
    from Vision.matplotlibNodes import MultiPlotNE
    MultiPlot_10 = MultiPlotNE(constrkw = {}, name='MultiPlot', library=matplotliblib)
    masterNet.addNode(MultiPlot_10,52,548)
except:
    print "WARNING: failed to restore MultiPlotNE named MultiPlot in network masterNet"
    print_exc()
    MultiPlot_10=None

try:
    ## saving node Draw Area ##
    from Vision.matplotlibNodes import MPLDrawAreaNE
    Draw_Area_11 = MPLDrawAreaNE(constrkw = {}, name='Draw Area', library=matplotliblib)
    masterNet.addNode(Draw_Area_11,410,526)
    Draw_Area_11.inputPortByName['title'].widget.set("Minimum Message Length", run=False)
    Draw_Area_11.inputPortByName['xlabel'].widget.set("Model complexity -->", run=False)
    Draw_Area_11.inputPortByName['ylabel'].widget.set("Message Length -->", run=False)
except:
    print "WARNING: failed to restore MPLDrawAreaNE named Draw Area in network masterNet"
    print_exc()
    Draw_Area_11=None

try:
    ## saving node Plot ##
    from Vision.matplotlibNodes import PlotNE
    Plot_12 = PlotNE(constrkw = {}, name='Plot', library=matplotliblib)
    masterNet.addNode(Plot_12,410,364)
except:
    print "WARNING: failed to restore PlotNE named Plot in network masterNet"
    print_exc()
    Plot_12=None

try:
    ## saving node Draw Area ##
    from Vision.matplotlibNodes import MPLDrawAreaNE
    Draw_Area_13 = MPLDrawAreaNE(constrkw = {}, name='Draw Area', library=matplotliblib)
    masterNet.addNode(Draw_Area_13,564,274)
    Draw_Area_13.inputPortByName['ylimit'].widget.set("[-1,20]", run=False)
except:
    print "WARNING: failed to restore MPLDrawAreaNE named Draw Area in network masterNet"
    print_exc()
    Draw_Area_13=None

masterNet.freeze()

## saving connections for network Legend ##
if ReadTable_0 is not None and Index_2 is not None:
    try:
        masterNet.connectNodes(
            ReadTable_0, Index_2, "data", "data", blocking=True)
    except:
        print "WARNING: failed to restore connection between ReadTable_0 and Index_2 in network masterNet"
if Index_2 is not None and Plot_1 is not None:
    try:
        masterNet.connectNodes(
            Index_2, Plot_1, "data", "y", blocking=True)
    except:
        print "WARNING: failed to restore connection between Index_2 and Plot_1 in network masterNet"
if ReadTable_0 is not None and Index_3 is not None:
    try:
        masterNet.connectNodes(
            ReadTable_0, Index_3, "data", "data", blocking=True)
    except:
        print "WARNING: failed to restore connection between ReadTable_0 and Index_3 in network masterNet"
if Index_3 is not None and Plot_4 is not None:
    try:
        masterNet.connectNodes(
            Index_3, Plot_4, "data", "y", blocking=True)
    except:
        print "WARNING: failed to restore connection between Index_3 and Plot_4 in network masterNet"
if Index_2 is not None and add_5 is not None:
    try:
        masterNet.connectNodes(
            Index_2, add_5, "data", "data1", blocking=True)
    except:
        print "WARNING: failed to restore connection between Index_2 and add_5 in network masterNet"
if Index_3 is not None and add_5 is not None:
    try:
        masterNet.connectNodes(
            Index_3, add_5, "data", "data2", blocking=True)
    except:
        print "WARNING: failed to restore connection between Index_3 and add_5 in network masterNet"
if Plot_1 is not None and MultiPlot_10 is not None:
    try:
        masterNet.connectNodes(
            Plot_1, MultiPlot_10, "plot", "multiplot", blocking=True)
    except:
        print "WARNING: failed to restore connection between Plot_1 and MultiPlot_10 in network masterNet"
if Plot_4 is not None and MultiPlot_10 is not None:
    try:
        masterNet.connectNodes(
            Plot_4, MultiPlot_10, "plot", "multiplot", blocking=True)
    except:
        print "WARNING: failed to restore connection between Plot_4 and MultiPlot_10 in network masterNet"
if Legend_8 is not None and MultiPlot_10 is not None:
    try:
        masterNet.connectNodes(
            Legend_8, MultiPlot_10, "drawAreaDef", "drawAreaDef", blocking=True)
    except:
        print "WARNING: failed to restore connection between Legend_8 and MultiPlot_10 in network masterNet"
if Set_Matplotlib_options_9 is not None and MultiPlot_10 is not None:
    try:
        masterNet.connectNodes(
            Set_Matplotlib_options_9, MultiPlot_10, "matplotlibOptions", "drawAreaDef", blocking=True)
    except:
        print "WARNING: failed to restore connection between Set_Matplotlib_options_9 and MultiPlot_10 in network masterNet"
if Draw_Area_11 is not None and MultiPlot_10 is not None:
    try:
        masterNet.connectNodes(
            Draw_Area_11, MultiPlot_10, "drawAreaDef", "drawAreaDef", blocking=True)
    except:
        print "WARNING: failed to restore connection between Draw_Area_11 and MultiPlot_10 in network masterNet"
if add_5 is not None and Plot_12 is not None:
    try:
        masterNet.connectNodes(
            add_5, Plot_12, "result", "y", blocking=True)
    except:
        print "WARNING: failed to restore connection between add_5 and Plot_12 in network masterNet"
if Plot_12 is not None and MultiPlot_10 is not None:
    try:
        masterNet.connectNodes(
            Plot_12, MultiPlot_10, "plot", "drawAreaDef", blocking=True)
    except:
        print "WARNING: failed to restore connection between Plot_12 and MultiPlot_10 in network masterNet"
if Draw_Area_13 is not None and Plot_12 is not None:
    try:
        masterNet.connectNodes(
            Draw_Area_13, Plot_12, "drawAreaDef", "drawAreaDef", blocking=True)
    except:
        print "WARNING: failed to restore connection between Draw_Area_13 and Plot_12 in network masterNet"
masterNet.unfreeze()
#masterNet.run()

