Examples of BaseVertex


Examples of org.drools.eclipse.reteoo.BaseVertex

        while ( curRow < rowList.getDepth() ) {
            final List<BaseVertex> rowVertices = rowList.get( curRow ).getVertices();

            for ( final Iterator<BaseVertex> rowNodeIter = rowVertices.iterator(); rowNodeIter.hasNext(); ) {
                final BaseVertex rowNode = rowNodeIter.next();

                final List<Connection> edges = rowNode.getSourceConnections();

                for ( final Iterator<Connection> edgeIter = edges.iterator(); edgeIter.hasNext(); ) {

                    final Connection edge = edgeIter.next();
                    final BaseVertex destNode = edge.getOpposite( rowNode );

                    if ( !seenVertices.contains( destNode ) ) {
                        rowList.add( curRow + 1,
                                     destNode );
                        seenVertices.add( destNode );
View Full Code Here

Examples of org.drools.eclipse.reteoo.BaseVertex

            if ( monitor.isCanceled() ) {
                throw new InterruptedException();
            }

            monitor.subTask( "Calculating RETE Tree Layout" );
            BaseVertex rootVertex = visitor.getRootVertex();
            RowList rowList = ReteooLayoutFactory.calculateReteRows( rootVertex );
            ReteooLayoutFactory.layoutRowList( newDiagram,
                                               rowList );
            zeroBaseDiagram( newDiagram );
            monitor.worked( 20 );
View Full Code Here

Examples of org.drools.eclipse.reteoo.BaseVertex

        int delta = (x - (maxx - minx + 20)) / 2;
        minx = minx - (delta);

        final Iterator<BaseVertex> nodeIter2 = graph.getChildren().iterator();
        while ( nodeIter2.hasNext() ) {
            final BaseVertex vertex = nodeIter2.next();
            Point loc = vertex.getLocation();
            vertex.setLocation( new Point( loc.x - minx,
                                           loc.y - miny ) );
        }
    }
View Full Code Here

Examples of org.drools.eclipse.reteoo.BaseVertex

        final LinkedList<BaseVertex> optimized = new LinkedList<BaseVertex>();

        boolean front = false;

        for ( final Iterator<BaseVertex> vertexIter = sorted.iterator(); vertexIter.hasNext(); ) {
            final BaseVertex vertex = vertexIter.next();

            if ( front ) {
                optimized.addFirst( vertex );
            } else {
                optimized.addLast( vertex );
View Full Code Here

Examples of org.drools.eclipse.reteoo.BaseVertex

    @Test
    public void testCalculateReteRows() throws IOException,
                                             PackageIntegrationException,
                                             DroolsParserException {
        ReteGraph graph = new ReteGraph();
        BaseVertex root = loadRete( graph );
        final RowList rows = ReteooLayoutFactory.calculateReteRows( root );

        int rownum = rows.getDepth();

        assertEquals( 6,
View Full Code Here

Examples of org.drools.eclipse.reteoo.BaseVertex

    @Test
    public void testLayoutRowList() throws IOException,
                                         PackageIntegrationException,
                                         DroolsParserException {
        ReteGraph graph = new ReteGraph();
        BaseVertex root = loadRete( graph );
        final RowList rows = ReteooLayoutFactory.calculateReteRows( root );

        ReteooLayoutFactory.layoutRowList( graph,
                                           rows );

        final List nodes = graph.getChildren();

        BaseVertex[] yOrder = (BaseVertex[]) nodes.toArray( new BaseVertex[0] );
        Arrays.sort( yOrder,
                     new Comparator() {
                         public int compare(Object o1,
                                            Object o2) {
                             BaseVertex v1 = (BaseVertex) o1;
                             BaseVertex v2 = (BaseVertex) o2;
                             int y1 = v1.getLocation().y;
                             int y2 = v2.getLocation().y;
                             return new Integer( y1 ).compareTo( new Integer( y2 ) );
                         }

                     } );

        Class[] expectedTypes = new Class[]{ReteVertex.class, EntryPointNodeVertex.class,
            ObjectTypeNodeVertex.class, AlphaNodeVertex.class, AlphaNodeVertex.class,
            LeftInputAdapterNodeVertex.class, LeftInputAdapterNodeVertex.class,
            RuleTerminalNodeVertex.class, RuleTerminalNodeVertex.class};

        for ( int i = 0; i < yOrder.length; i++ ) {
            assertEquals( expectedTypes[i],
                          yOrder[i].getClass() );
            if ( i > 0 ) {
                // If current vertex has same type as previous then
                // y-pos should match and x-pos should not match.               
                // If type is different then y-pos should *not* match.

                BaseVertex current = yOrder[i];
                BaseVertex previous = yOrder[i - 1];
                if ( current.getClass().equals( previous.getClass() ) ) {
                    assertEquals( current.getLocation().y,
                                  previous.getLocation().y );
                    assertNotSame( new Integer( current.getLocation().x ),
                                   new Integer( previous.getLocation().x ) );
                } else {
                    assertNotSame( new Integer( current.getLocation().y ),
                                   new Integer( previous.getLocation().y ) );
                }
            }
        }

    }
View Full Code Here

Examples of org.drools.eclipse.reteoo.BaseVertex

        ruleBase.addPackage(pkg);

        final ReteooVisitor visitor = new ReteooVisitor( graph );
        visitor.visit( ruleBase );

        BaseVertex root = visitor.getRootVertex();
        return root;
    }
View Full Code Here

Examples of org.drools.eclipse.reteoo.BaseVertex

    @Test
    public void testCalculateReteRows() throws IOException,
                                             PackageIntegrationException,
                                             DroolsParserException {
        ReteGraph graph = new ReteGraph();
        BaseVertex root = loadRete( graph );
        final RowList rows = ReteooLayoutFactory.calculateReteRows( root );

        int rownum = rows.getDepth();

        assertEquals( 6,
View Full Code Here

Examples of org.drools.eclipse.reteoo.BaseVertex

    @Test
    public void testLayoutRowList() throws IOException,
                                         PackageIntegrationException,
                                         DroolsParserException {
        ReteGraph graph = new ReteGraph();
        BaseVertex root = loadRete( graph );
        final RowList rows = ReteooLayoutFactory.calculateReteRows( root );

        ReteooLayoutFactory.layoutRowList( graph,
                                           rows );

        final List nodes = graph.getChildren();

        BaseVertex[] yOrder = (BaseVertex[]) nodes.toArray( new BaseVertex[0] );
        Arrays.sort( yOrder,
                     new Comparator() {
                         public int compare(Object o1,
                                            Object o2) {
                             BaseVertex v1 = (BaseVertex) o1;
                             BaseVertex v2 = (BaseVertex) o2;
                             int y1 = v1.getLocation().y;
                             int y2 = v2.getLocation().y;
                             return new Integer( y1 ).compareTo( new Integer( y2 ) );
                         }

                     } );

        Class[] expectedTypes = new Class[]{ReteVertex.class, EntryPointNodeVertex.class,
            ObjectTypeNodeVertex.class, AlphaNodeVertex.class, AlphaNodeVertex.class,
            LeftInputAdapterNodeVertex.class, LeftInputAdapterNodeVertex.class,
            RuleTerminalNodeVertex.class, RuleTerminalNodeVertex.class};

        for ( int i = 0; i < yOrder.length; i++ ) {
            assertEquals( expectedTypes[i],
                          yOrder[i].getClass() );
            if ( i > 0 ) {
                // If current vertex has same type as previous then
                // y-pos should match and x-pos should not match.               
                // If type is different then y-pos should *not* match.

                BaseVertex current = yOrder[i];
                BaseVertex previous = yOrder[i - 1];
                if ( current.getClass().equals( previous.getClass() ) ) {
                    assertEquals( current.getLocation().y,
                                  previous.getLocation().y );
                    assertNotSame( new Integer( current.getLocation().x ),
                                   new Integer( previous.getLocation().x ) );
                } else {
                    assertNotSame( new Integer( current.getLocation().y ),
                                   new Integer( previous.getLocation().y ) );
                }
            }
        }

    }
View Full Code Here

Examples of org.drools.eclipse.reteoo.BaseVertex

        ruleBase.addPackage(pkg);

        final ReteooVisitor visitor = new ReteooVisitor( graph );
        visitor.visit( ruleBase );

        BaseVertex root = visitor.getRootVertex();
        return root;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.