########################################################################
#
#    Vision Network - Python source code - file generated by vision
#    Friday 13 April 2007 12:58:19 
#    
#       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.py,v 1.3 2007/08/29 20:37:16 vareille Exp $
#
# $Id: Legend_net.py,v 1.3 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_56 = ReadTable(constrkw = {}, name='ReadTable', library=stdlib)
    masterNet.addNode(ReadTable_56,232,7)
    ReadTable_56.inputPortByName['filename'].widget.set("Data/legend_data.dat", run=False)
    ReadTable_56.inputPortByName['sep'].widget.set(",", run=False)
    ReadTable_56.inputPortByName['datatype'].widget.set("float", run=False)
    apply(ReadTable_56.configure, (), {'expanded': True})
except:
    print "WARNING: failed to restore ReadTable named ReadTable in network masterNet"
    print_exc()
    ReadTable_56=None

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

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

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

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

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

try:
    ## saving node Set Matplotlib options ##
    from Vision.matplotlibNodes import MatPlotLibOptions
    Set_Matplotlib_options_62 = MatPlotLibOptions(constrkw = {}, name='Set Matplotlib options', library=matplotliblib)
    masterNet.addNode(Set_Matplotlib_options_62,16,504)
    Set_Matplotlib_options_62.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_62=None

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

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

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

try:
    ## saving node Plot ##
    from Vision.matplotlibNodes import PlotNE
    Plot_66 = PlotNE(constrkw = {}, name='Plot', library=matplotliblib)
    masterNet.addNode(Plot_66,522,341)
    apply(Plot_66.configure, (), {'expanded': True})
except:
    print "WARNING: failed to restore PlotNE named Plot in network masterNet"
    print_exc()
    Plot_66=None

try:
    ## saving node Draw Area ##
    from Vision.matplotlibNodes import MPLDrawAreaNE
    Draw_Area_67 = MPLDrawAreaNE(constrkw = {}, name='Draw Area', library=matplotliblib)
    masterNet.addNode(Draw_Area_67,192,296)
    Draw_Area_67.inputPortByName['xlimit'].widget.set("[0,3]", run=False)
    Draw_Area_67.inputPortByName['ylimit'].widget.set("[0,20]", run=False)
    Draw_Area_67.inputPortByName['autoscaleon'].widget.set(0, run=False)
except:
    print "WARNING: failed to restore MPLDrawAreaNE named Draw Area in network masterNet"
    print_exc()
    Draw_Area_67=None

try:
    ## saving node Index ##
    from Vision.StandardNodes import Index
    Index_68 = Index(constrkw = {}, name='Index', library=stdlib)
    masterNet.addNode(Index_68,49,168)
    apply(Index_68.configure, (), {'expanded': True})
except:
    print "WARNING: failed to restore Index named Index in network masterNet"
    print_exc()
    Index_68=None

masterNet.freeze()

## saving connections for network Legend ##
if ReadTable_56 is not None and Index_58 is not None:
    try:
        masterNet.connectNodes(
            ReadTable_56, Index_58, "data", "data", blocking=True)
    except:
        print "WARNING: failed to restore connection between ReadTable_56 and Index_58 in network masterNet"
if Index_58 is not None and Plot_57 is not None:
    try:
        masterNet.connectNodes(
            Index_58, Plot_57, "data", "y", blocking=True)
    except:
        print "WARNING: failed to restore connection between Index_58 and Plot_57 in network masterNet"
if ReadTable_56 is not None and Index_59 is not None:
    try:
        masterNet.connectNodes(
            ReadTable_56, Index_59, "data", "data", blocking=True)
    except:
        print "WARNING: failed to restore connection between ReadTable_56 and Index_59 in network masterNet"
if Index_59 is not None and Plot_60 is not None:
    try:
        masterNet.connectNodes(
            Index_59, Plot_60, "data", "y", blocking=True)
    except:
        print "WARNING: failed to restore connection between Index_59 and Plot_60 in network masterNet"
if Plot_57 is not None and MultiPlot_63 is not None:
    try:
        masterNet.connectNodes(
            Plot_57, MultiPlot_63, "plot", "multiplot", blocking=True)
    except:
        print "WARNING: failed to restore connection between Plot_57 and MultiPlot_63 in network masterNet"
if Plot_60 is not None and MultiPlot_63 is not None:
    try:
        masterNet.connectNodes(
            Plot_60, MultiPlot_63, "plot", "multiplot", blocking=True)
    except:
        print "WARNING: failed to restore connection between Plot_60 and MultiPlot_63 in network masterNet"
if Legend_61 is not None and MultiPlot_63 is not None:
    try:
        masterNet.connectNodes(
            Legend_61, MultiPlot_63, "drawAreaDef", "drawAreaDef", blocking=True)
    except:
        print "WARNING: failed to restore connection between Legend_61 and MultiPlot_63 in network masterNet"
if Set_Matplotlib_options_62 is not None and MultiPlot_63 is not None:
    try:
        masterNet.connectNodes(
            Set_Matplotlib_options_62, MultiPlot_63, "matplotlibOptions", "drawAreaDef", blocking=True)
    except:
        print "WARNING: failed to restore connection between Set_Matplotlib_options_62 and MultiPlot_63 in network masterNet"
if Draw_Area_64 is not None and MultiPlot_63 is not None:
    try:
        masterNet.connectNodes(
            Draw_Area_64, MultiPlot_63, "drawAreaDef", "drawAreaDef", blocking=True)
    except:
        print "WARNING: failed to restore connection between Draw_Area_64 and MultiPlot_63 in network masterNet"
if ReadTable_56 is not None and Index_65 is not None:
    try:
        masterNet.connectNodes(
            ReadTable_56, Index_65, "data", "data", blocking=True)
    except:
        print "WARNING: failed to restore connection between ReadTable_56 and Index_65 in network masterNet"
if Index_65 is not None and Plot_66 is not None:
    try:
        masterNet.connectNodes(
            Index_65, Plot_66, "data", "y", blocking=True)
    except:
        print "WARNING: failed to restore connection between Index_65 and Plot_66 in network masterNet"
if Draw_Area_67 is not None and Plot_66 is not None:
    try:
        masterNet.connectNodes(
            Draw_Area_67, Plot_66, "drawAreaDef", "drawAreaDef", blocking=True)
    except:
        print "WARNING: failed to restore connection between Draw_Area_67 and Plot_66 in network masterNet"
if Plot_66 is not None and MultiPlot_63 is not None:
    try:
        masterNet.connectNodes(
            Plot_66, MultiPlot_63, "plot", "multiplot", blocking=True)
    except:
        print "WARNING: failed to restore connection between Plot_66 and MultiPlot_63 in network masterNet"
if ReadTable_56 is not None and Index_68 is not None:
    try:
        masterNet.connectNodes(
            ReadTable_56, Index_68, "data", "data", blocking=True)
    except:
        print "WARNING: failed to restore connection between ReadTable_56 and Index_68 in network masterNet"
if Index_68 is not None and Plot_57 is not None:
    try:
        masterNet.connectNodes(
            Index_68, Plot_57, "data", "x", blocking=True)
    except:
        print "WARNING: failed to restore connection between Index_68 and Plot_57 in network masterNet"
if Index_68 is not None and Plot_60 is not None:
    try:
        masterNet.connectNodes(
            Index_68, Plot_60, "data", "x", blocking=True)
    except:
        print "WARNING: failed to restore connection between Index_68 and Plot_60 in network masterNet"
if Index_68 is not None and Plot_66 is not None:
    try:
        masterNet.connectNodes(
            Index_68, Plot_66, "data", "x", blocking=True)
    except:
        print "WARNING: failed to restore connection between Index_68 and Plot_66 in network masterNet"
if Draw_Area_67 is not None and Plot_60 is not None:
    try:
        masterNet.connectNodes(
            Draw_Area_67, Plot_60, "drawAreaDef", "drawAreaDef", blocking=True)
    except:
        print "WARNING: failed to restore connection between Draw_Area_67 and Plot_60 in network masterNet"
if Draw_Area_67 is not None and Plot_57 is not None:
    try:
        masterNet.connectNodes(
            Draw_Area_67, Plot_57, "drawAreaDef", "drawAreaDef", blocking=True)
    except:
        print "WARNING: failed to restore connection between Draw_Area_67 and Plot_57 in network masterNet"
masterNet.unfreeze()
#masterNet.run()

