Beispiel #1
0
        protected internal virtual Shape makeShapeFromNode(ViewGraphNode act, LinkedList queue)
        {
            System.Drawing.Color bg       = getBackgroundColorForNode(act);
            System.Drawing.Color border   = getBorderColorForNode(act);
            System.String        desc     = "";
            BaseNode             reteNode = act.ReteNode;
            HashSet terminalNodes         = new HashSet();

            getCorrespondingTerminalNodes(act, terminalNodes);
            if (reteNode != null)
            {
                desc = reteNode.NodeId.ToString();
            }
            Shape s;

            if (reteNode == null)
            {
                // ROOT NODE
                s = new Ellipse();
            }
            else if (reteNode is BaseJoin || act.ReteNode is BaseAlpha2)
            {
                s = new Trapezoid();
            }
            else if (reteNode is TerminalNode)
            {
                s = new RoundedRectangle();
            }
            else if (reteNode is LIANode)
            {
                s = new Ellipse();
            }
            else
            {
                s = new Rectangle();
            }
            s.Bgcolor     = bg;
            s.Bordercolor = border;
            //UPGRADE_WARNING: Narrowing conversions may produce unexpected results in C#. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042"'
            int x = (spaceHorizontal / 2) + (int)((float)(act.X * (spaceHorizontal + nodeHorizontal)) / 2.0);
            int y = (spaceVertical / 2) + act.Y * (spaceVertical + nodeVertical);

            System.String key = x + "," + y;
            // if there is already a node at the given location, we shift it right
            while (this.coordinates.ContainsKey(key))
            {
                x   = x + ((spaceHorizontal + nodeHorizontal) * 2);
                key = x + "," + y;
            }
            SupportClass.PutElement(coordinates, key, s);
            s.X      = x;
            s.Y      = y;
            s.Width  = nodeHorizontal;
            s.Height = nodeVertical;
            System.String longdesc = "";
            if (reteNode == null)
            {
                longdesc = "Root Node";
            }
            else
            {
                longdesc  = "ID:" + reteNode.NodeId + "  NodeType:" + reteNode.GetType().FullName;
                longdesc += "  Details:" + reteNode.toPPString();
            }
            longdesc += "  Rules:";
            Iterator iter = terminalNodes.iterator();

            while (iter.hasNext())
            {
                TerminalNode t = (TerminalNode)iter.next();

                longdesc += t.Rule.Name;
                if (iter.hasNext())
                {
                    longdesc += ";";
                }
            }
            s.LongDescription = longdesc;
            if (reteNode is LIANode)
            {
                s.incWidth(-nodeHorizontal / 3);
            }
            s.Text    = desc;
            act.Shape = s;
            addPrimitive(s);
            for (Iterator it = act.Successors.iterator(); it.hasNext();)
            {
                ViewGraphNode n = (ViewGraphNode)it.next();
                queue.add(n);
            }
            return(s);
        }
Beispiel #2
0
        protected internal virtual Shape makeShapeFromNode(ViewGraphNode act, LinkedList queue)
        {
            System.Drawing.Color bg = getBackgroundColorForNode(act);
            System.Drawing.Color border = getBorderColorForNode(act);
            System.String desc = "";
            BaseNode reteNode = act.ReteNode;
            HashSet terminalNodes = new HashSet();
            getCorrespondingTerminalNodes(act, terminalNodes);
            if (reteNode != null)
                desc = reteNode.NodeId.ToString();
            Shape s;
            if (reteNode == null)
            {
                // ROOT NODE
                s = new Ellipse();
            }
            else if (reteNode is BaseJoin || act.ReteNode is BaseAlpha2)
            {
                s = new Trapezoid();
            }
            else if (reteNode is TerminalNode)
            {
                s = new RoundedRectangle();
            }
            else if (reteNode is LIANode)
            {
                s = new Ellipse();
            }
            else
            {
                s = new Rectangle();
            }
            s.Bgcolor = bg;
            s.Bordercolor = border;
            //UPGRADE_WARNING: Narrowing conversions may produce unexpected results in C#. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042"'
            int x = (spaceHorizontal / 2) + (int) ((float) (act.X * (spaceHorizontal + nodeHorizontal)) / 2.0);
            int y = (spaceVertical / 2) + act.Y * (spaceVertical + nodeVertical);
            System.String key = x + "," + y;
            // if there is already a node at the given location, we shift it right
            while (this.coordinates.ContainsKey(key))
            {
                x = x + ((spaceHorizontal + nodeHorizontal) * 2);
                key = x + "," + y;
            }
            SupportClass.PutElement(coordinates, key, s);
            s.X = x;
            s.Y = y;
            s.Width = nodeHorizontal;
            s.Height = nodeVertical;
            System.String longdesc = "";
            if (reteNode == null)
            {
                longdesc = "Root Node";
            }
            else
            {
                longdesc = "ID:" + reteNode.NodeId + "  NodeType:" + reteNode.GetType().FullName;
                longdesc += "  Details:" + reteNode.toPPString();
            }
            longdesc += "  Rules:";
            Iterator iter = terminalNodes.iterator();
            while (iter.hasNext())
            {
                TerminalNode t = (TerminalNode) iter.next();

                longdesc += t.Rule.Name;
                if (iter.hasNext())
                    longdesc += ";";
            }
            s.LongDescription = longdesc;
            if (reteNode is LIANode)
                s.incWidth(- nodeHorizontal / 3);
            s.Text = desc;
            act.Shape = s;
            addPrimitive(s);
            for (Iterator it = act.Successors.iterator(); it.hasNext(); )
            {
                ViewGraphNode n = (ViewGraphNode) it.next();
                queue.add(n);
            }
            return s;
        }
 /**
  * Returns a {@link Collection} containing the intersection
  * of the given {@link Collection}s.
  * <p>
  * The cardinality of each element in the returned {@link Collection}
  * will be equal to the minimum of the cardinality of that element
  * in the two given {@link Collection}s.
  *
  * @param a  the first collection, must not be null
  * @param b  the second collection, must not be null
  * @return the intersection of the two collections
  * @see Collection#retainAll
  * @see #containsAny
  */
 public static java.util.Collection<Object> intersection(java.util.Collection<Object> a, java.util.Collection<Object> b)
 {
     java.util.ArrayList<Object> list = new java.util.ArrayList<Object>();
     java.util.Map<Object, Object> mapa = getCardinalityMap(a);
     java.util.Map<Object, Object> mapb = getCardinalityMap(b);
     java.util.Set<Object> elts = new java.util.HashSet<Object>(a);
     elts.addAll(b);
     java.util.Iterator<Object> it = elts.iterator();
     while (it.hasNext())
     {
         Object obj = it.next();
         for (int i = 0, m = java.lang.Math.min(getFreq(obj, mapa), getFreq(obj, mapb)); i < m; i++)
         {
             list.add(obj);
         }
     }
     return list;
 }