Exemple #1
0
  // returns prefered location for an edge -1 for left and 1 for right
  private int edgeBalance(Widget nodeWidget) {
    if (scene == null) return 1;

    Point nodeLocation = nodeWidget.getLocation();
    int left = 0, right = 0;

    Object node = scene.findObject(nodeWidget);

    for (Object e : scene.findNodeEdges(node, true, true)) { // inputedges
      ConnectionWidget cw = (ConnectionWidget) scene.findWidget(e);

      if (cw != this) {
        Widget targetNodeWidget = cw.getTargetAnchor().getRelatedWidget();

        Point location;
        if (targetNodeWidget == nodeWidget) {
          Widget sourceNodeWidget = cw.getSourceAnchor().getRelatedWidget();
          location = sourceNodeWidget.getLocation();
        } else {
          location = targetNodeWidget.getLocation();
        }

        if (location.x < nodeLocation.x) left++;
        else right++;
      }
    }
    if (left < right) return -1;
    else return 1;
  }
Exemple #2
0
    public void createConnection(Widget source, Widget target) {

      // Select necessary nodes only

      ConfigNode cnSource = (ConfigNode) findObject(source);
      ConfigNode cnTarget = (ConfigNode) findObject(target);

      String cnSourceIdType = cnSource.getId().substring(0, 2);
      String cnTargetIdType = cnTarget.getId().substring(0, 2);

      String type = "TEMPORAL";

      // filter relavent links only
      if ((cnSourceIdType.equals("L2") && cnTargetIdType.equals("L1"))
          || (cnSourceIdType.equals("L1") && cnTargetIdType.equals("L0"))
          || (cnSourceIdType.equals(cnTargetIdType))) {

        ConnectionWidget conn = new ConnectionWidget(GraphSceneImpl.this);
        conn.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);

        // Double arrow head for cross features
        if (cnSourceIdType.equals(cnTargetIdType)) {
          conn.setSourceAnchorShape(AnchorShape.TRIANGLE_FILLED);
          type = "CROSS";
        }

        //
        // conn.setRouter(RouterFactory.createOrthogonalSearchRouter(GraphSceneImpl.widgetCollector));
        conn.setTargetAnchor(AnchorFactory.createRectangularAnchor(target));
        conn.setSourceAnchor(AnchorFactory.createRectangularAnchor(source));
        connectionLayer.addChild(conn);
        edgeMap.add(new NodeLinks(type, cnSource.getId(), cnTarget.getId()));
      }
    }
 private void removeEdgeSelectionAction() {
   Collection<ConnectionWidget> edges = this.getEdges();
   for (Iterator i = edges.iterator(); i.hasNext(); ) {
     ConnectionWidget connection = (ConnectionWidget) i.next();
     connection.getActions().removeAction(createSelectAction());
   }
 }
 // giannisk
 private void deleteTargetConnection(Widget sourceWidget) {
   ReviewCorrespondences review = new ReviewCorrespondences();
   review.removeCorrespondence(caratteristiche.getValueCorrespondence());
   caratteristiche.setTargetWidget(null);
   ConnectionWidget connection = new ConnectionWidget(sourceWidget.getScene());
   connection.removeFromParent();
   StatusDisplayer.getDefault()
       .setStatusText(NbBundle.getMessage(Costanti.class, Costanti.DELETE_CONNECTION));
 }
 @Override
 public void createConnection(Widget source, Widget target) {
   ConnectionWidget conn = new ConnectionWidget(VisualScene.this);
   conn.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
   conn.setTargetAnchor(AnchorFactory.createRectangularAnchor(target));
   conn.setSourceAnchor(AnchorFactory.createRectangularAnchor(source));
   conn.getActions().addAction(createObjectHoverAction());
   conn.getActions().addAction(createSelectAction());
   connectionLayer.addChild(conn);
 }
Exemple #6
0
  public ActionsWithRoutingPolicyTest() {
    mainLayer = new LayerWidget(this);
    addChild(mainLayer);
    LayerWidget connLayer = new LayerWidget(this);
    addChild(connLayer);

    Widget source = createLabel("Source", 50, 200, Color.GREEN);
    Widget target = createLabel("Target", 450, 200, Color.GREEN);

    connection = new ConnectionWidget(this);
    connection.setSourceAnchor(
        AnchorFactory.createDirectionalAnchor(
            source, AnchorFactory.DirectionalAnchorKind.HORIZONTAL));
    connection.setTargetAnchor(
        AnchorFactory.createDirectionalAnchor(
            target, AnchorFactory.DirectionalAnchorKind.HORIZONTAL));
    connection.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    connection.setPaintControlPoints(true);
    connection.setControlPointShape(PointShape.SQUARE_FILLED_BIG);
    connection.setRouter(RouterFactory.createOrthogonalSearchRouter(mainLayer));
    connection
        .getActions()
        .addAction(
            ActionFactory.createAddRemoveControlPointAction(
                1.0, 5.0, ConnectionWidget.RoutingPolicy.UPDATE_END_POINTS_ONLY));
    connection
        .getActions()
        .addAction(
            ActionFactory.createMoveControlPointAction(
                ActionFactory.createFreeMoveControlPointProvider(),
                ConnectionWidget.RoutingPolicy.UPDATE_END_POINTS_ONLY));
    connLayer.addChild(connection);
  }
  @Override
  protected void paintWidget() {

    setLineColor(getCompetenciaLineColor());

    super.paintWidget();
  }
  public void createConnection(Widget sourceWidget, Widget targetWidget) {
    try {
      ConnectionWidget connection = new ConnectionWidget(sourceWidget.getScene());
      connection.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
      connection.setSourceAnchor(AnchorFactory.createRectangularAnchor(sourceWidget));
      connection.setTargetAnchor(AnchorFactory.createRectangularAnchor(targetWidget));
      Stroke stroke = Costanti.BASIC_STROKE;
      connection.setStroke(stroke);
      connection
          .getActions()
          .addAction(
              ActionFactory.createPopupMenuAction(
                  new MyPopupProviderConnectionFunc(
                      sourceWidget.getScene(), mainLayer, caratteristiche)));
      ConnectionInfo connectionInfo = new ConnectionInfo();
      connectionInfo.setTargetWidget(targetWidget);
      connectionInfo.setConnectionWidget(connection);
      caratteristiche.setTargetWidget((VMDPinWidgetTarget) targetWidget);

      creator.createCorrespondenceWithFunction(
          mainLayer, targetWidget, caratteristiche, connectionInfo);

      caratteristiche.setConnectionInfo(connectionInfo);
      connectionLayer.addChild(connection, connectionInfo);
    } catch (ExpressionSyntaxException e) {
      DialogDisplayer.getDefault()
          .notify(
              new NotifyDescriptor.Message(
                  NbBundle.getMessage(Costanti.class, Costanti.SYNTAX_WARNING)
                      + " : "
                      + e.getMessage(),
                  DialogDescriptor.WARNING_MESSAGE));
      // giannisk delete target connection if exception if caught
      deleteTargetConnection(sourceWidget);
    }
  }
Exemple #9
0
  /**
   * if the edge is reflexive its painted as a cyclic edge if there are 2 controlpoints the
   * connection is painted as a straight line from the source to the targetanchor if there are more
   * as 2 controlpoints the connection path between 2 control points is painted as bezier curve
   */
  @Override
  protected void paintWidget() {

    List<Point> contrPoints = this.getControlPoints();
    int listSize = contrPoints.size();

    Graphics2D gr = getGraphics();

    if (listSize <= 2) {
      if (isReflexive()) { // special case for reflexive connection widgets
        Widget related = this.getTargetAnchor().getRelatedWidget();
        int position = this.edgeBalance(related);
        Rectangle bounds = related.convertLocalToScene(related.getBounds());
        gr.setColor(getLineColor());
        Point first = new Point();
        Point last = new Point();
        double centerX = bounds.getCenterX();
        first.x = (int) (centerX + bounds.width / 4);
        first.y = bounds.y + bounds.height;
        last.x = first.x;
        last.y = bounds.y;

        gr.setStroke(this.getStroke());

        double cutDistance = this.getTargetAnchorShape().getCutDistance();
        double anchorAngle = Math.PI / -3.0;
        double cutX = Math.abs(Math.cos(anchorAngle) * cutDistance);
        double cutY = Math.abs(Math.sin(anchorAngle) * cutDistance);
        int ydiff = first.y - last.y;
        int endy = -ydiff;
        double height = bounds.getHeight();
        double cy = height / 4.0;
        double cx = bounds.getWidth() / 5.0;
        double dcx = cx * 2;
        GeneralPath gp = new GeneralPath();
        gp.moveTo(0, 0);
        gp.quadTo(0, cy, cx, cy);
        gp.quadTo(dcx, cy, dcx, -height / 2.0);
        gp.quadTo(dcx, endy - cy, cy, -(cy + ydiff));
        gp.quadTo(cutX * 1.5, endy - cy, cutX, endy - cutY);

        AffineTransform af = new AffineTransform();
        AnchorShape anchorShape = this.getTargetAnchorShape();

        if (position < 0) {
          first.x = (int) (centerX - bounds.width / 4);
          af.translate(first.x, first.y);
          af.scale(-1.0, 1.0);
          last.x = first.x;
        } else {
          af.translate(first.x, first.y);
        }
        Shape s = gp.createTransformedShape(af);
        gr.draw(s);

        if (last != null) {
          AffineTransform previousTransform = gr.getTransform();
          gr.translate(last.x, last.y);

          if (position < 0) gr.rotate(Math.PI - anchorAngle);
          else gr.rotate(anchorAngle);

          anchorShape.paint(gr, false);
          gr.setTransform(previousTransform);
        }

      } else {
        super.paintWidget();
      }
      return;
    }

    // bezier curve...
    GeneralPath curvePath = new GeneralPath();
    Point lastControlPoint = null;
    double lastControlPointRotation = 0.0;

    Point prev = null;
    for (int i = 0; i < listSize - 1; i++) {
      Point cur = contrPoints.get(i);
      Point next = contrPoints.get(i + 1);
      Point nextnext = null;
      if (i < listSize - 2) {
        nextnext = contrPoints.get(i + 2);
      }

      double len = cur.distance(next);
      double scale = len * BEZIER_SCALE;
      Point bezierFrom = null; // first ControlPoint
      Point bezierTo = null; // second ControlPoint

      if (prev == null) {
        // first point
        curvePath.moveTo(cur.x, cur.y); // startpoint
        bezierFrom = cur;
      } else {
        bezierFrom = new Point(next.x - prev.x, next.y - prev.y);
        bezierFrom = scaleVector(bezierFrom, scale);
        bezierFrom.translate(cur.x, cur.y);
      }

      if (nextnext == null) { // next== last point (curve to)
        lastControlPoint = next;
        bezierTo = next; // set 2nd intermediate point to endpoint
        GeneralPath lastseg = this.subdivide(cur, bezierFrom, bezierTo, next);
        if (lastseg != null) curvePath.append(lastseg, true);
        break;
      } else {
        bezierTo = new Point(cur.x - nextnext.x, cur.y - nextnext.y);
        bezierTo = scaleVector(bezierTo, scale);
        bezierTo.translate(next.x, next.y);
      }

      curvePath.curveTo(
          bezierFrom.x, bezierFrom.y, // controlPoint1
          bezierTo.x, bezierTo.y, // controlPoint2
          next.x, next.y);
      prev = cur;
    }
    Point2D cur = curvePath.getCurrentPoint();
    Point next = lastControlPoint;

    lastControlPointRotation = // anchor anchorAngle
        Math.atan2(cur.getY() - next.y, cur.getX() - next.x);

    Color previousColor = gr.getColor();
    gr.setColor(getLineColor());
    Stroke s = this.getStroke();
    gr.setStroke(s);
    gr.setColor(this.getLineColor());
    gr.draw(curvePath);

    AffineTransform previousTransform = gr.getTransform();
    gr.translate(lastControlPoint.x, lastControlPoint.y);
    gr.rotate(lastControlPointRotation);
    AnchorShape targetAnchorShape = this.getTargetAnchorShape();
    targetAnchorShape.paint(gr, false);
    gr.setTransform(previousTransform);

    // paint ControlPoints if enabled
    if (isPaintControlPoints()) {
      int last = listSize - 1;
      for (int index = 0; index <= last; index++) {
        Point point = contrPoints.get(index);
        previousTransform = gr.getTransform();
        gr.translate(point.x, point.y);
        if (index == 0 || index == last) getEndPointShape().paint(gr);
        else getControlPointShape().paint(gr);
        gr.setTransform(previousTransform);
      }
    }
    gr.setColor(previousColor);
  }
Exemple #10
0
  public ProxyAnchorExpandTest() {
    setBackground(Color.LIGHT_GRAY);

    // layer for widgets
    LayerWidget mainLayer = new LayerWidget(this);
    addChild(mainLayer);
    // layer for connections
    LayerWidget connLayer = new LayerWidget(this);
    addChild(connLayer);

    // outer widget
    Widget outerWidget = new Widget(this);
    outerWidget.setOpaque(true);
    outerWidget.setBackground(Color.WHITE);
    outerWidget.setBorder(BorderFactory.createLineBorder(10));
    outerWidget.setPreferredLocation(new Point(100, 100));
    outerWidget.setLayout(
        LayoutFactory.createVerticalFlowLayout(LayoutFactory.SerialAlignment.CENTER, 4));

    outerWidget.addChild(
        new LabelWidget(
            this, "The anchor switches based on a state in StateModel used by ProxyAnchor."));
    outerWidget.addChild(
        new LabelWidget(this, "ConnectionWidget has the same anchors assigned all the time."));

    // inner widget
    LabelWidget innerWidget = new LabelWidget(this, "Internal frame");
    innerWidget.setBorder(BorderFactory.createLineBorder());
    outerWidget.addChild(innerWidget);

    mainLayer.addChild(outerWidget);

    // the target widget
    Widget targetWidget =
        new LabelWidget(this, "Click here to switch the state in StateModel/anchor.");
    targetWidget.setOpaque(true);
    targetWidget.setBackground(Color.WHITE);
    targetWidget.setBorder(BorderFactory.createLineBorder(10));
    targetWidget.setPreferredLocation(new Point(450, 300));
    mainLayer.addChild(targetWidget);

    // an action for switching a state of a StateModel used by the ProxyAnchor to determinate an
    // active anchor
    WidgetAction switchAction = ActionFactory.createSelectAction(new SwitchProvider());
    targetWidget.getActions().addAction(switchAction);

    Anchor outerAnchor = AnchorFactory.createRectangularAnchor(outerWidget);
    Anchor innerAnchor = AnchorFactory.createRectangularAnchor(innerWidget);

    // a proxy anchor which acts like an one of the specified anchors.
    // The active anchor is defined by a state in the StateModel
    Anchor proxyAnchor = AnchorFactory.createProxyAnchor(model, outerAnchor, innerAnchor);

    // the connection widget
    ConnectionWidget conn = new ConnectionWidget(this);
    conn.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
    connLayer.addChild(conn);

    // the proxy anchor is used as a source
    conn.setSourceAnchor(proxyAnchor);
    // the target anchor is assigned to the targetWidget widget
    conn.setTargetAnchor(AnchorFactory.createRectangularAnchor(targetWidget));
  }
Exemple #11
0
  public static void serialize(PaletteScene scene, Element rootElement) {
    Element pluginsElement = new Element("plugins");
    Element thisPluginElement;
    Point loc;
    AbstractPlugin plugin;
    for (PluginNode node : scene.getNodes()) {
      Widget widget = scene.findWidget(node);
      loc = widget.getPreferredLocation();

      plugin = node.getPlugin();
      thisPluginElement = new Element("plugin");
      thisPluginElement.setAttribute(ATT_PLUGIN_ID, plugin.getPluginKey().getUniqueID());
      thisPluginElement.setAttribute(ATT_PLUGIN_NAME, node.getName());
      thisPluginElement.setAttribute(ATT_PLUGIN_X, Integer.toString(loc.x));
      thisPluginElement.setAttribute(ATT_PLUGIN_Y, Integer.toString(loc.y));
      thisPluginElement.setAttribute(
          ATT_PLUGIN_HIDDEN, String.valueOf(plugin.isParameterPanelHidden()));
      boolean isHudOpen = plugin.getHudContainer() != null && plugin.getHudContainer().isOpened();
      thisPluginElement.setAttribute(ATT_HUD_VISIBLE, String.valueOf(isHudOpen));

      if (plugin instanceof IParameterPanel) {
        Element parameterPanelElement = ((IParameterPanel) plugin).createWorkspaceParameters();
        if (parameterPanelElement != null) {
          thisPluginElement.addContent(new Element("parameters").addContent(parameterPanelElement));
        }
      }
      pluginsElement.addContent(thisPluginElement);
    }
    rootElement.addContent(pluginsElement);

    Element connectionsElement = new Element("connections");
    Element thisConnectionElement;
    for (ConnectorEdge edge : scene.getEdges()) {
      thisConnectionElement = new Element("connection");
      thisConnectionElement.setAttribute(ATT_EDGE_ID, edge.getName());

      PluginNode sourceNode = scene.getEdgeSource(edge);
      if (sourceNode != null) {
        thisConnectionElement.setAttribute(ATT_EDGE_SOURCE, sourceNode.getName());
      }

      PluginNode targetNode = scene.getEdgeTarget(edge);
      if (targetNode != null) {
        thisConnectionElement.setAttribute(ATT_EDGE_TARGET, targetNode.getName());
      }

      ConnectionWidget cw = (ConnectionWidget) scene.findWidget(edge);
      thisConnectionElement.setAttribute(
          ATT_EDGE_ROUTER, cw.getRouter().getClass().getSimpleName());
      List<Point> pts = cw.getControlPoints();
      if (pts != null && !pts.isEmpty()) {
        Element vertsElement = new Element("verts");
        Element thisVertexElement;
        for (Point pt : cw.getControlPoints()) {
          thisVertexElement = new Element("vert");
          thisVertexElement.setAttribute(ATT_VERT_X, Integer.toString(pt.x));
          thisVertexElement.setAttribute(ATT_VERT_Y, Integer.toString(pt.y));
          vertsElement.addContent(thisVertexElement);
        }
        thisConnectionElement.addContent(vertsElement);
      }
      connectionsElement.addContent(thisConnectionElement);
    }
    rootElement.addContent(connectionsElement);

    // Save I/O connections
    Element ioConnectionsElement = new Element("ioConnections");
    for (String ioc : scene.getDefaultPaletteModel().getConnections()) {
      ioConnectionsElement.addContent(new Element("io").setAttribute("name", ioc));
    }
    rootElement.addContent(ioConnectionsElement);

    Element annotationsElement = new Element("annotations");
    Element thisAnnotation;
    AnnotationWidget aw;
    Font font;
    for (Widget w : scene.getChildren()) {
      if (!(w instanceof AnnotationWidget)) continue;
      aw = (AnnotationWidget) w;

      thisAnnotation = new Element("entry");
      thisAnnotation.setAttribute("text", aw.getLabel());

      font = aw.getFont();
      thisAnnotation.setAttribute("font", String.valueOf(font.getName()));
      thisAnnotation.setAttribute("fontSize", String.valueOf(font.getSize()));
      thisAnnotation.setAttribute("fontStyle", String.valueOf(font.getStyle()));

      loc = aw.getPreferredLocation();
      thisAnnotation.setAttribute("xLoc", String.valueOf(loc.x));
      thisAnnotation.setAttribute("yLoc", String.valueOf(loc.y));

      thisAnnotation.setAttribute(
          "fore", "#" + Integer.toHexString(aw.getForeground().getRGB()).substring(1));
      thisAnnotation.setAttribute(
          "back", "#" + Integer.toHexString(((Color) aw.getBackground()).getRGB()).substring(1));
      thisAnnotation.setAttribute("orient", aw.getOrientation().name());
      annotationsElement.addContent(thisAnnotation);
    }
    rootElement.addContent(annotationsElement);
  }
Exemple #12
0
  public static Element deserialize(PaletteScene scene, Element rootElement) {
    HashMap<String, PluginNode> registeredNodeMap = new HashMap<String, PluginNode>();
    Element pluginsElement = rootElement.getChild("plugins");
    List plugins = pluginsElement.getChildren("plugin");

    ArrayList<AbstractPlugin> addedPlugins = new ArrayList<AbstractPlugin>();
    PluginUtilities pm = PluginUtilities.getDefault();
    String pluginID, pluginName, isHudVisible, isParameterPanelHidden;
    Element pluginElement;
    for (Object plugin : plugins) {
      pluginElement = (Element) plugin;
      pluginID = pluginElement.getAttributeValue(ATT_PLUGIN_ID);
      pluginName = pluginElement.getAttributeValue(ATT_PLUGIN_NAME);

      isHudVisible = pluginElement.getAttributeValue(ATT_HUD_VISIBLE);
      isHudVisible = isHudVisible == null ? "false" : isHudVisible;

      isParameterPanelHidden = pluginElement.getAttributeValue(ATT_PLUGIN_HIDDEN);
      isParameterPanelHidden = isParameterPanelHidden == null ? "false" : isParameterPanelHidden;

      AbstractPlugin p = pm.instantiate(pluginID, pluginName, scene.getDefaultPaletteModel());
      p.setParameterPanelHidden(Boolean.parseBoolean(isParameterPanelHidden));

      if (p instanceof IParameterPanel) {
        ((IParameterPanel) p).loadSavedWorkspaceParameters(pluginElement.getChild("parameters"));
      }

      if (p instanceof HudInterface && Boolean.parseBoolean(isHudVisible)) {
        actionShowHUD(p);
      }
      addedPlugins.add(p);

      PluginNode thisNode = new PluginNode(p);
      registeredNodeMap.put(thisNode.getName(), thisNode);
      Widget nodeWidget = scene.addNode(thisNode);
      int x = Integer.parseInt(pluginElement.getAttributeValue(ATT_PLUGIN_X));
      int y = Integer.parseInt(pluginElement.getAttributeValue(ATT_PLUGIN_Y));
      // nodeWidget.setPreferredLocation(new Point(x, y));
      nodeWidget.setPreferredLocation(new Point(x, y));
    }
    scene.revalidate();

    Lookup.Result<IPluginsAdded> pluginsAdded =
        LatizLookup.getDefault().lookupResult(IPluginsAdded.class);
    for (IPluginsAdded ipa : pluginsAdded.allInstances()) {
      ipa.pluginsAdded(scene, addedPlugins);
    }

    List connections = rootElement.getChild("connections").getChildren("connection");
    Element connectionElement;
    for (Object connection : connections) {
      connectionElement = (Element) connection;
      ConnectorEdge edge = new ConnectorEdge(connectionElement.getAttributeValue(ATT_EDGE_ID));
      PluginNode sourceNode =
          registeredNodeMap.get(connectionElement.getAttributeValue(ATT_EDGE_SOURCE));
      PluginNode targetNode =
          registeredNodeMap.get(connectionElement.getAttributeValue(ATT_EDGE_TARGET));

      // Create connection panels.
      Lookup.Result<IPluginConnection> pcis =
          LatizLookup.getDefault().lookupResult(IPluginConnection.class);
      for (IPluginConnection pci : pcis.allInstances()) {
        pci.connectionMade(scene, sourceNode.getPlugin(), targetNode.getPlugin());
      }

      scene.addEdge(edge);
      scene.setEdgeSource(edge, sourceNode);
      scene.setEdgeTarget(edge, targetNode);

      // Apply vertices
      ArrayList<Point> controlPoints = new ArrayList<Point>();
      List verts = connectionElement.getChild("verts").getChildren();
      Element vertElement;
      for (Object vert : verts) {
        vertElement = (Element) vert;
        int x = Integer.parseInt(vertElement.getAttributeValue(ATT_VERT_X));
        int y = Integer.parseInt(vertElement.getAttributeValue(ATT_VERT_Y));
        controlPoints.add(new Point(x, y));
      }

      ConnectionWidget cw = (ConnectionWidget) scene.findWidget(edge);
      String router = connectionElement.getAttributeValue(ATT_EDGE_ROUTER);
      if (router.equals("FreeRouter")) {
        cw.setRouter(RouterFactory.createFreeRouter());
      } else if (router.equals("DirectRouter")) {
        cw.setRouter(RouterFactory.createDirectRouter());
      } else if (router.equals("OrthogonalSearchRouter")) {
        cw.setRouter(RouterFactory.createOrthogonalSearchRouter(scene.getMainLayer()));
      }
      cw.setControlPoints(controlPoints, true);
    }

    // Deserialize I/O connections
    Element ioConnectionsElement = rootElement.getChild("ioConnections");
    if (ioConnectionsElement == null) {
      return rootElement;
    }
    List<String> ioConnections = scene.getDefaultPaletteModel().getConnections();
    ioConnections.clear();
    for (Object o : ioConnectionsElement.getChildren()) {
      ioConnections.add(((Element) o).getAttributeValue("name"));
    }

    // Annotations
    Element annotationsElement = rootElement.getChild("annotations");
    Element annotationElement;
    AnnotationWidget aw;
    if (annotationsElement != null) {
      for (Object o : annotationsElement.getChildren()) {
        annotationElement = (Element) o;
        aw = new AnnotationWidget(scene, annotationElement.getAttributeValue("text"));

        String fontName = annotationElement.getAttributeValue("font");
        int fontSize = Integer.parseInt(annotationElement.getAttributeValue("fontSize"));
        int fontStyle = Integer.parseInt(annotationElement.getAttributeValue("fontStyle"));
        Font font = new Font(fontName, fontStyle, fontSize);
        aw.setFont(font);

        int xLoc = Integer.parseInt(annotationElement.getAttributeValue("xLoc"));
        int yLoc = Integer.parseInt(annotationElement.getAttributeValue("yLoc"));
        aw.setPreferredLocation(new Point(xLoc, yLoc));
        aw.setForeground(Color.decode(annotationElement.getAttributeValue("fore")));
        aw.setBackground(Color.decode(annotationElement.getAttributeValue("back")));
        aw.setOrientation(Orientation.valueOf(annotationElement.getAttributeValue("orient")));
        scene.addChild(aw);
      }
    }
    scene.validate();

    // Removed all Plugin Selection Cookies.
    LatizLookup.getDefault().removeAllFromLookup(PluginSelectionCookie.class);

    return rootElement;
  }