Package base.drawable

Examples of base.drawable.Primitive


    {
        Class           state_class;
        Method          start_fn = null, final_fn = null;
        Class[]         typelist;
        ObjMethod       evt_pairing, obj_meth1, obj_meth2;
        Primitive       obj;
        int             def_idx;
        int             raw_etype;
        int             Nmatched = 0;

        typelist = new Class[] { RecHeader.class, RecRaw.class };
        System.out.println( "\n\t Completed Objects : " );
        clog_ins  = new logformat.clog.InputLog( filename );

        total_bytesize = 0;
        blk_ins = clog_ins.getBlockStream();
        while ( blk_ins != null ) {
            rectype = logformat.clog.Const.AllType.UNDEF;
            while rectype != logformat.clog.Const.RecType.ENDBLOCK
                  && rectype != logformat.clog.Const.RecType.ENDLOG ) {
                bytes_read = header.readFromDataStream( blk_ins );
                total_bytesize += bytes_read;
   
                rectype = header.getRecType();
                switch ( rectype ) {
                    case RecDefState.RECTYPE:
                        bytes_read = def.readFromDataStream( blk_ins );
                        total_bytesize += bytes_read;

                        obj_meth1 = (ObjMethod) evtdefs.get( def.startetype );
                        obj_meth2 = (ObjMethod) evtdefs.get( def.endetype );
                        if ( obj_meth1 == null || obj_meth2 == null ) {
                            stateform = new Topo_State();
                            def_idx = ObjDef.getNextCategoryIndex();
                            objdef = new ObjDef( def_idx, def, stateform, 1 );
                            stateform.setCategory( objdef );
                            objdefs.add( objdef.getIndex(), objdef );
                            state_class = stateform.getClass();
                            try {
                                start_fn = state_class .getMethod(
                                           "matchStartEvent", typelist );
                                final_fn = state_class.getMethod(
                                           "matchFinalEvent", typelist );
                            } catch ( NoSuchMethodException err ) {
                                err.printStackTrace();
                                System.exit( 1 );
                            }

                            obj_fn = new ObjMethod();
                            obj_fn.obj = stateform;
                            obj_fn.method = start_fn;
                            evtdefs.put( objdef.start_evt, obj_fn );

                            obj_fn = new ObjMethod();
                            obj_fn.obj = stateform;
                            obj_fn.method = final_fn;
                            evtdefs.put( objdef.final_evt, obj_fn );
                        }
                        else // i.e. obj_meth1 != null && obj_meth2 != null
                            if ( obj_meth1.obj == obj_meth2.obj ) {
                                stateform = ( Topo_State ) obj_meth1.obj;
                                objdef = ( ObjDef ) stateform.getCategory();
                                objdef.setName( def.description );
                                objdef.setColor(
                                   ColorNameMap.getColorAlpha( def.color ) );
                            }
                            else {
                                System.err.println( "**** Error! "
                                                  + obj_meth1.obj + "!="
                                                  + obj_meth2.obj );
                            }
                        }
                        break;
                    case RecRaw.RECTYPE:
                        bytes_read = raw.readFromDataStream( blk_ins );
                        total_bytesize += bytes_read;

                        raw_etype = raw.etype.intValue();
                        if (    raw_etype != Const.EvtType.CONSTDEF
                             && raw_etype != Const.AllType.UNDEF ) {
                             evt_pairing = (ObjMethod) evtdefs.get( raw.etype );
                            Object[] arglist = new Object[] { header, raw };
                            obj = null;
                            try {
                                obj = (Primitive) evt_pairing.method
                                                 .invoke( evt_pairing.obj,
                                                          arglist );
                            } catch ( IllegalAccessException err ) {
                                err.printStackTrace();
                                System.err.println( "Offending rec_raw = "
                                                  + raw );
                            // catching NoMatchingEventException
                            } catch ( InvocationTargetException err ) {
                                err.printStackTrace();
                            } catch ( NullPointerException nullerr ) {
                                nullerr.printStackTrace();
                                System.err.println( "Offending rec_header = "
                                                  + header );
                                System.err.println( "Offending rec_raw = "
                                                  + raw );
                                System.exit(1);
                            }

                            if ( obj != null ) {
                                System.out.println( (++Nmatched) + ", "
                                                  + obj.toString() );
                            }
                        }
                        break;
                    case RecColl.RECTYPE:
                        bytes_read = coll.skipBytesFromDataStream( blk_ins );
View Full Code Here


    public static final void createPrimitives()
    {
        Object[]        arglist;
        ObjMethod       evt_pairing;
        Primitive       drawobj;
        int             bare_etype, cargo_etype, msg_etype;
        int             Nmatched = 0;

        arglist   = new Object[ 2 ];

        System.out.println( "\n\t Completed Objects : " );
        clog_ins  = new logformat.clog2.InputLog( filename );

        total_bytesize = 0;
        while ( ( blk_ins = clog_ins.getBlockStream() ) != null ) {
            rectype = logformat.clog2.Const.AllType.UNDEF;
            while rectype != logformat.clog2.Const.RecType.ENDBLOCK
                  && rectype != logformat.clog2.Const.RecType.ENDLOG ) {
                bytes_read = header.readFromDataStream( blk_ins );
                total_bytesize += bytes_read;
   
                rectype = header.getRecType();
                switch ( rectype ) {
                    case RecDefState.RECTYPE:
                        bytes_read
                        = staterec.skipBytesFromDataStream( blk_ins );
                        total_bytesize += bytes_read;
                        break;
                    case RecDefEvent.RECTYPE:
                        bytes_read
                        = eventrec.skipBytesFromDataStream( blk_ins );
                        total_bytesize += bytes_read;
                        break;
                    case RecDefConst.RECTYPE:
                        bytes_read
                        = constrec.skipBytesFromDataStream( blk_ins );
                        total_bytesize += bytes_read;
                        break;
                    case RecBare.RECTYPE:
                        bytes_read = bare.readFromDataStream( blk_ins );
                        total_bytesize += bytes_read;
                        bare_etype = bare.etype.intValue();
                        if ( bare_etype != Const.AllType.UNDEF ) {
                            evt_pairing = (ObjMethod) evtdefs.get( bare.etype );
                            // Object[] arglist = new Object[] { header, bare };
                            arglist[ 0 ] = header;
                            arglist[ 1 ] = null;
                            drawobj = null;
                            try {
                                drawobj = (Primitive) evt_pairing.method
                                                     .invoke( evt_pairing.obj,
                                                              arglist );
                            } catch ( IllegalAccessException err ) {
                                err.printStackTrace();
                                System.err.println( "Offending RecBare = "
                                                  + bare );
                            // catching NoMatchingEventException
                            } catch ( InvocationTargetException err ) {
                                err.printStackTrace();
                            } catch ( NullPointerException nullerr ) {
                                nullerr.printStackTrace();
                                System.err.println( "Offending RecHeader = "
                                                  + header );
                                System.err.println( "Offending RecBare = "
                                                  + bare );
                                System.exit(1);
                            }

                            if ( drawobj != null )
                                System.out.println( (Nmatched++) + ", "
                                                  + drawobj.toString() );
                        }

                        break;
                    case RecCargo.RECTYPE:
                        bytes_read = cargo.readFromDataStream( blk_ins );
                        total_bytesize += bytes_read;

                        cargo_etype = cargo.etype.intValue();
                        if ( cargo_etype != Const.AllType.UNDEF ) {
                            evt_pairing = (ObjMethod)
                                          evtdefs.get( cargo.etype );
                            // arglist = new Object[] { header, cargo };
                            arglist[ 0 ] = header;
                            arglist[ 1 ] = cargo;
                            drawobj = null;
                            try {
                                drawobj = (Primitive) evt_pairing.method
                                                     .invoke( evt_pairing.obj,
                                                              arglist );
                            } catch ( IllegalAccessException err ) {
                                err.printStackTrace();
                                System.err.println( "Offending RecCargo = "
                                                  + cargo );
                            // catching NoMatchingEventException
                            } catch ( InvocationTargetException err ) {
                                err.printStackTrace();
                            } catch ( NullPointerException nullerr ) {
                                nullerr.printStackTrace();
                                System.err.println( "Offending RecHeader = "
                                                  + header );
                                System.err.println( "Offending RecCargo = "
                                                  + cargo );
                                System.exit(1);
                            }

                            if ( drawobj != null )
                                System.out.println( (Nmatched++) + ", "
                                                  + drawobj.toString() );
                        }
                        break;
                    case RecMsg.RECTYPE:
                        bytes_read = msg.readFromDataStream( blk_ins );
                        total_bytesize += bytes_read;

                        msg_etype = msg.etype.intValue();
                        if ( msg_etype != Const.AllType.UNDEF ) {
                            evt_pairing = (ObjMethod) evtdefs.get( msg.etype );
                            // Object[] arglist = new Object[] { header, msg };
                            arglist[ 0 ] = header;
                            arglist[ 1 ] = msg;
                            drawobj = null;
                            try {
                                drawobj = (Primitive) evt_pairing.method
                                                     .invoke( evt_pairing.obj,
                                                              arglist );
                            } catch ( IllegalAccessException err ) {
                                err.printStackTrace();
                                System.err.println( "Offending RecMsg = "
                                                  + msg );
                            // catching NoMatchingEventException
                            } catch ( InvocationTargetException err ) {
                                err.printStackTrace();
                            } catch ( NullPointerException nullerr ) {
                                nullerr.printStackTrace();
                                System.err.println( "Offending RecHeader = "
                                                  + header );
                                System.err.println( "Offending RecMsg = "
                                                  + msg );
                                System.exit(1);
                            }

                            if ( drawobj != null )
                                System.out.println( (Nmatched++) + ", "
                                                  + drawobj.toString() );
                        }
                        break;
                    case RecColl.RECTYPE:
                        bytes_read = coll.skipBytesFromDataStream( blk_ins );
                        total_bytesize += bytes_read;
View Full Code Here

        CategoryMap        objdefs;   // Drawable def'n
        Map                shadefs;   // Shadow   def'n
        Category           objdef;
        LineIDMapList      lineIDmaps;
        LineIDMap          lineIDmap;
        Primitive          prime_obj;
        Composite          cmplx_obj;
        long               Nobjs;

        TreeTrunk          treetrunk;
        double             prev_dobj_endtime;
        double             curr_dobj_endtime;
        long               offended_Nobjs;
        Drawable           offended_dobj;



        //  Initialize prev_dobj_endtime to avoid complaint by compiler
        prev_dobj_endtime = Double.NEGATIVE_INFINITY;
        offended_Nobjs    = Integer.MIN_VALUE;
        offended_dobj     = null;

        out_filename      = null;
        del_iobjdefs      = null;
        parseCmdLineArgs( args );
        if ( out_filename == null )
            out_filename  = TraceName.getDefaultSLOG2Name( in_filename );

        objdefs       = new CategoryMap();
        shadefs       = new HashMap();
        lineIDmaps    = new LineIDMapList();
        Nobjs         = 0;

        // Initialize the SLOG-2 file for piped-input, output for this program.
        dobj_ins   = new PipedInputLog( in_filename );
        if ( dobj_ins == null ) {
            System.err.println( "Null input logfile!" );
            System.exit( 1 );
        }
        if ( ! dobj_ins.isSLOG2() ) {
            System.err.println( in_filename + " is NOT SLOG-2 file!." );
            System.exit( 1 );
        }
        String err_msg;
        if ( (err_msg = dobj_ins.getCompatibleHeader()) != null ) {
            System.err.print( err_msg );
            PipedInputLog.stdoutConfirmation();
        }
        dobj_ins.initialize();

        /* */    Date time1 = new Date();
        slog_outs  = new OutputLog( out_filename );

        //  Set Tree properties, !optional!
        //  TreeNode's minimum size, without any drawable/shadow, is 38 bytes.
        //  Drawable;s minimum size is 32 bytes, whether it is state/arrow.
        //  Arrow( with 2 integer infovalues ) is 40 bytes long.
        //  So, for 1 state primitive leaf, the size is 38 + 40 = 78 .
        if ( leaf_bytesize > 0 )
            slog_outs.setTreeLeafByteSize( leaf_bytesize );
        else
            slog_outs.setTreeLeafByteSize( dobj_ins.getTreeLeafByteSize() );
        if ( num_children_per_node > 0 )
            slog_outs.setNumChildrenPerNode( num_children_per_node );
        else
            slog_outs.setNumChildrenPerNode( dobj_ins.getNumChildrenPerNode() );

        treetrunk = new TreeTrunk( slog_outs, shadefs );
        /* */    Date time2 = new Date();
        while ( ( next_kind = dobj_ins.peekNextKind() ) != Kind.EOF ) {
            if ( next_kind == Kind.TOPOLOGY ) {
                topo = dobj_ins.getNextTopology();
                // Put in the default Shadow categories in case the original
                // does not have any shadow categories, i.e no shadows.
                objdef = Category.getShadowCategory( topo );
                objdefs.put( new Integer( objdef.getIndex() ), objdef );
                shadefs.put( topo, objdef );
            }
            else if ( next_kind == Kind.YCOORDMAP ) {
                lineIDmap = new LineIDMap( dobj_ins.getNextYCoordMap() );
                lineIDmaps.add( lineIDmap );
            }
            else if ( next_kind == Kind.CATEGORY ) {
                objdef = dobj_ins.getNextCategory();
                if ( objdef.isShadowCategory() ) {
                    objdefs.put( new Integer( objdef.getIndex() ), objdef );
                    shadefs.put( objdef.getTopology(), objdef );
                }
                // Category can be removed here for efficiency reason.
                // Instead let CategoryMap.removeUnusedCategories() do the work.
                // if ( isCategoryToBeRemoved( objdef.getIndex() ) )
                //     continue;
                objdefs.put( new Integer( objdef.getIndex() ), objdef );
                objdef.setUsed( false );
            }
            else if ( next_kind == Kind.PRIMITIVE ) {
                prime_obj = dobj_ins.getNextPrimitive();
                // Undo InfoBox.resolveCategory() when the Drawable is read.
                prime_obj.releaseCategory();
                if ( isCategoryToBeRemoved( prime_obj.getCategoryIndex() ) ) {
                    // System.out.println( "Removing ... " + prime_obj );
                    continue;
                }
                prime_obj.resolveCategory( objdefs );
                // postponed, wait till on-demand decoding of InfoBuffer
                // prime_obj.decodeInfoBuffer();
                Nobjs++;
                // System.out.println( Nobjs + " : " + prime_obj );
                if ( enable_endtime_check ) {
                    if ( ! prime_obj.isTimeOrdered() ) {
                        System.out.println( "**** Primitive Time Error ****" );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    curr_dobj_endtime = prime_obj.getLatestTime();
                    if ( prev_dobj_endtime > curr_dobj_endtime ) {
                        System.err.println( "**** Violation of "
                                          + "Increasing Endtime Order ****\n"
                                          + "\t Offended Drawable -> "
                                          + offended_Nobjs + " : "
View Full Code Here

        Class           state_class;
        Method          start_fn = null, final_fn = null;
        Class[]         typelist;
        Object[]        arglist;
        ObjMethod       evt_pairing, obj_meth1, obj_meth2;
        Primitive       drawobj;
        int             def_idx;
        int             bare_etype, cargo_etype, msg_etype;
        int             Nmatched = 0;

        typelist  = new Class[] { RecHeader.class, RecBare.class };
        arglist   = new Object[ 2 ];

        System.out.println( "\n\t Completed Objects : " );

        total_bytesize = 0;
        blk_ins = clog_ins.getBlockStream();
        while ( blk_ins != null ) {
            rectype = logformat.clog2.Const.AllType.UNDEF;
            while rectype != logformat.clog2.Const.RecType.ENDBLOCK
                  && rectype != logformat.clog2.Const.RecType.ENDLOG ) {
                bytes_read = header.readFromDataStream( blk_ins );
                total_bytesize += bytes_read;
   
                rectype = header.getRecType();
                switch ( rectype ) {
                    case RecDefState.RECTYPE:
                        bytes_read = staterec.readFromDataStream( blk_ins );
                        total_bytesize += bytes_read;

                        obj_meth1 = (ObjMethod)
                                    evtdefs.get( staterec.startetype );
                        obj_meth2 = (ObjMethod)
                                    evtdefs.get( staterec.finaletype );
                        if ( obj_meth1 == null || obj_meth2 == null ) {
                            stateform = new Topo_State();
                            def_idx = ObjDef.getNextCategoryIndex();
                            objdef = new ObjDef( def_idx, staterec,
                                                 stateform, 1 );
                            stateform.setCategory( objdef );
                            objdefs.add( objdef.getIndex(), objdef );
                            state_class = stateform.getClass();
                            try {
                                start_fn = state_class .getMethod(
                                           "matchStartEvent", typelist );
                                final_fn = state_class.getMethod(
                                           "matchFinalEvent", typelist );
                            } catch ( NoSuchMethodException err ) {
                                err.printStackTrace();
                                System.exit( 1 );
                            }

                            obj_fn = new ObjMethod();
                            obj_fn.obj = stateform;
                            obj_fn.method = start_fn;
                            evtdefs.put( objdef.start_evt, obj_fn );

                            obj_fn = new ObjMethod();
                            obj_fn.obj = stateform;
                            obj_fn.method = final_fn;
                            evtdefs.put( objdef.final_evt, obj_fn );
                        }
                        else // i.e. obj_meth1 != null && obj_meth2 != null
                            if ( obj_meth1.obj == obj_meth2.obj ) {
                                stateform = ( Topo_State ) obj_meth1.obj;
                                objdef = ( ObjDef ) stateform.getCategory();
                                objdef.setName( staterec.name );
                                objdef.setColor(
                                 ColorNameMap.getColorAlpha( staterec.color ) );
                            }
                            else {
                                System.err.println( "**** Error! "
                                                  + obj_meth1.obj + "!="
                                                  + obj_meth2.obj );
                            }
                        }
                        break;
                    case RecDefEvent.RECTYPE:
                        bytes_read
                        = eventrec.skipBytesFromDataStream( blk_ins );
                        total_bytesize += bytes_read;
                        break;
                    case RecDefConst.RECTYPE:
                        bytes_read
                        = constrec.skipBytesFromDataStream( blk_ins );
                        total_bytesize += bytes_read;
                        break;
                    case RecBare.RECTYPE:
                        bytes_read = bare.readFromDataStream( blk_ins );
                        total_bytesize += bytes_read;

                        bare_etype = bare.etype.intValue();
                        if ( bare_etype != Const.AllType.UNDEF ) {
                             evt_pairing = (ObjMethod) evtdefs.get( bare.etype );
                            // Object[] arglist = new Object[] { header, bare };
                            arglist[ 0 ] = header;
                            arglist[ 1 ] = null;
                            drawobj = null;
                            try {
                                drawobj = (Primitive) evt_pairing.method
                                                     .invoke( evt_pairing.obj,
                                                              arglist );
                            } catch ( IllegalAccessException err ) {
                                err.printStackTrace();
                                System.err.println( "Offending RecBare = "
                                                  + bare );
                            // catching NoMatchingEventException
                            } catch ( InvocationTargetException err ) {
                                err.printStackTrace();
                            } catch ( NullPointerException nullerr ) {
                                nullerr.printStackTrace();
                                System.err.println( "Offending RecHeader = "
                                                  + header );
                                System.err.println( "Offending RecBare = "
                                                  + bare );
                                System.exit(1);
                            }

                            if ( drawobj != null )
                                System.out.println( (++Nmatched) + ", "
                                                  + drawobj.toString() );
                        }
                        break;
                    case RecCargo.RECTYPE:
                        bytes_read = cargo.readFromDataStream( blk_ins );
                        total_bytesize += bytes_read;

                        cargo_etype = cargo.etype.intValue();
                        if ( cargo_etype != Const.AllType.UNDEF ) {
                            evt_pairing = (ObjMethod)
                                          evtdefs.get( cargo.etype );
                            // arglist = new Object[] { header, cargo };
                            arglist[ 0 ] = header;
                            arglist[ 1 ] = cargo;
                            drawobj = null;
                            try {
                                drawobj = (Primitive) evt_pairing.method
                                                     .invoke( evt_pairing.obj,
                                                              arglist );
                            } catch ( IllegalAccessException err ) {
                                err.printStackTrace();
                                System.err.println( "Offending RecCargo = "
                                                  + cargo );
                            // catching NoMatchingEventException
                            } catch ( InvocationTargetException err ) {
                                err.printStackTrace();
                            } catch ( NullPointerException nullerr ) {
                                nullerr.printStackTrace();
                                System.err.println( "Offending RecHeader = "
                                                  + header );
                                System.err.println( "Offending RecCargo = "
                                                  + cargo );
                                System.exit(1);
                            }

                            if ( drawobj != null )
                                System.out.println( (++Nmatched) + ", "
                                                  + drawobj.toString() );
                        }
                        break;
                    case RecMsg.RECTYPE:
                        bytes_read = msg.readFromDataStream( blk_ins );
                        total_bytesize += bytes_read;

                        msg_etype = msg.etype.intValue();
                        if ( msg_etype != Const.AllType.UNDEF ) {
                            evt_pairing = (ObjMethod) evtdefs.get( msg.etype );
                            // Object[] arglist = new Object[] { header, msg };
                            arglist[ 0 ] = header;
                            arglist[ 1 ] = msg;
                            drawobj = null;
                            try {
                                drawobj = (Primitive) evt_pairing.method
                                                     .invoke( evt_pairing.obj,
                                                              arglist );
                            } catch ( IllegalAccessException err ) {
                                err.printStackTrace();
                                System.err.println( "Offending RecMsg = "
                                                  + msg );
                            // catching NoMatchingEventException
                            } catch ( InvocationTargetException err ) {
                                err.printStackTrace();
                            } catch ( NullPointerException nullerr ) {
                                nullerr.printStackTrace();
                                System.err.println( "Offending RecHeader = "
                                                  + header );
                                System.err.println( "Offending RecMsg = "
                                                  + msg );
                                System.exit(1);
                            }

                            if ( drawobj != null )
                                System.out.println( (++Nmatched) + ", "
                                                  + drawobj.toString() );
                        }
                        break;
                    case RecColl.RECTYPE:
                        bytes_read = coll.skipBytesFromDataStream( blk_ins );
                        total_bytesize += bytes_read;
View Full Code Here

    }

    public static final void createPrimitives()
    {
        ObjMethod       evt_pairing;
        Primitive       obj;
        int             raw_etype;
        int             Nmatched = 0;

        System.out.println( "\n\t Completed Objects : " );
        clog_ins  = new logformat.clog.InputLog( filename );

        total_bytesize = 0;
        while ( ( blk_ins = clog_ins.getBlockStream() ) != null ) {
            rectype = logformat.clog.Const.AllType.UNDEF;
            while rectype != logformat.clog.Const.RecType.ENDBLOCK
                  && rectype != logformat.clog.Const.RecType.ENDLOG ) {
                bytes_read = header.readFromDataStream( blk_ins );
                total_bytesize += bytes_read;
   
                rectype = header.getRecType();
                switch ( rectype ) {
                    case RecDefState.RECTYPE:
                        bytes_read = def.skipBytesFromDataStream( blk_ins );
                        total_bytesize += bytes_read;
                        break;
                    case RecRaw.RECTYPE:
                        bytes_read = raw.readFromDataStream( blk_ins );
                        total_bytesize += bytes_read;
                        raw_etype = raw.etype.intValue();
                        if (    raw_etype != Const.EvtType.CONSTDEF
                             && raw_etype != Const.AllType.UNDEF ) {
                            evt_pairing = (ObjMethod) evtdefs.get( raw.etype );
                            Object[] arglist = new Object[] { header, raw };
                            obj = null;
                            try {
                                obj = (Primitive) evt_pairing.method
                                                 .invoke( evt_pairing.obj,
                                                          arglist );
                            } catch ( IllegalAccessException err ) {
                                err.printStackTrace();
                                System.err.println( "Offending rec_raw = "
                                                  + raw );
                            // catching NoMatchingEventException
                            } catch ( InvocationTargetException err ) {
                                err.printStackTrace();
                            } catch ( NullPointerException nullerr ) {
                                nullerr.printStackTrace();
                                System.err.println( "Offending RecHeader = "
                                                  + header );
                                System.err.println( "Offending RecRaw = "
                                                  + raw );
                                System.exit(1);
                            }

                            if ( obj != null ) {
                                System.out.println( (Nmatched++) + ", "
                                                  + obj.toString() );
                            }
                        }

                        break;
                    case RecColl.RECTYPE:
View Full Code Here

    private Primitive getNextInQueue()
    {
        Drawable   itr_dobj;
        Composite  itr_cmplx;
        Primitive  next_prime;

        next_prime = null;
        while ( drawables_itr.hasNext() ) {
            itr_dobj = (Drawable) drawables_itr.next();
            if ( itr_dobj.overlaps( timeframe ) ) {
View Full Code Here

        return next_primitive != null;
    }

    public Object next()
    {
        Primitive  returning_prime;

        returning_prime = next_primitive;
        next_primitive  = this.getNextInQueue();
        return returning_prime;
    }
View Full Code Here

    }

    public void readObject( MixedDataInput ins, final Map categorymap )
    throws java.io.IOException
    {
        Primitive  prime;
        Composite  cmplx;
        byte       dobj_type;
        int        Nobjs, idx;

        super.readObject( ins );   // BufForObjects.readObject( ins )
           
        // assume buf4nestless contains only primitives, e.g. arrow/event
        Nobjs = ins.readInt();
        buf4nestless = new ArrayList( Nobjs );
        for ( idx = 0; idx < Nobjs; idx++ ) {
            dobj_type = ins.readByte();
            switch ( dobj_type ) {
                case PRIMITIVE_ID:
                    prime = new Primitive( ins );
                    prime.resolveCategory( categorymap );
                    buf4nestless.add( prime );
                    total_bytesize += ( prime.getByteSize() + 1 );
                    break;
                case COMPOSITE_ID:
                    cmplx = new Composite( ins );
                    cmplx.resolveCategory( categorymap );
                    buf4nestless.add( cmplx );
                    total_bytesize += ( cmplx.getByteSize() + 1 );
                    break;
                default:
                    System.err.println( "BufForDrawables: Error! "
                                      + "Unknown drawable type = "
                                      + dobj_type );
            }
        }

        // assume buf4nestable contains both primitives and composites.
        Nobjs = ins.readInt();
        buf4nestable = new ArrayList( Nobjs );
        for ( idx = 0; idx < Nobjs; idx++ ) {
            dobj_type = ins.readByte();
            switch ( dobj_type ) {
                case PRIMITIVE_ID:
                    prime = new Primitive( ins );
                    prime.resolveCategory( categorymap );
                    buf4nestable.add( prime );
                    total_bytesize += ( prime.getByteSize() + 1 );
                    break;
                case COMPOSITE_ID:
                    cmplx = new Composite( ins );
                    cmplx.resolveCategory( categorymap );
                    buf4nestable.add( cmplx );
View Full Code Here

    }

    public Primitive getNextPrimitive()
    {
        old_base.drawable.Primitive  old_prime;
        Primitive                    new_prime;

        old_prime  = old_dobj_ins.getNextPrimitive();
        new_prime  = new Primitive();
        updateObject( old_prime, new_prime );

        return new_prime;
    }
View Full Code Here

        CategoryMap        objdefs;   // Drawable def'n
        Map                shadefs;   // Shadow   def'n
        Category           objdef;
        LineIDMapList      lineIDmaps;
        LineIDMap          lineIDmap;
        Primitive          prime_obj;
        Composite          cmplx_obj;
        long               Nobjs;

        TreeTrunk          treetrunk;
        double             prev_dobj_endtime;
        double             curr_dobj_endtime;
        long               offended_Nobjs;
        Drawable           offended_dobj;



        //  Initialize prev_dobj_endtime to avoid complaint by compiler
        prev_dobj_endtime = Double.NEGATIVE_INFINITY;
        offended_Nobjs    = Integer.MIN_VALUE;
        offended_dobj     = null;

        out_filename      = null;
        del_iobjdefs      = null;
        parseCmdLineArgs( args );
        if ( out_filename == null )
            out_filename  = TraceName.getDefaultSLOG2Name( in_filename );

        objdefs       = new CategoryMap();
        shadefs       = new HashMap();
        lineIDmaps    = new LineIDMapList();
        Nobjs         = 0;

        // Initialize the SLOG-2 file for piped-input, output for this program.
        dobj_ins   = new WrappedInputLog( in_filename );
        if ( dobj_ins == null ) {
            System.err.println( "Null input logfile!" );
            System.exit( 1 );
        }
        if ( ! dobj_ins.isSLOG2() ) {
            System.err.println( in_filename + " is NOT SLOG-2 file!." );
            System.exit( 1 );
        }
        String err_msg;
        if ( (err_msg = dobj_ins.getCompatibleHeader()) != null ) {
            System.err.print( err_msg );
            WrappedInputLog.stdoutConfirmation();
        }
        dobj_ins.initialize();

        /* */    Date time1 = new Date();
        slog_outs  = new OutputLog( out_filename );

        //  Set Tree properties, !optional!
        //  TreeNode's minimum size, without any drawable/shadow, is 38 bytes.
        //  Drawable;s minimum size is 32 bytes, whether it is state/arrow.
        //  Arrow( with 2 integer infovalues ) is 40 bytes long.
        //  So, for 1 state primitive leaf, the size is 38 + 40 = 78 .
        if ( leaf_bytesize > 0 )
            slog_outs.setTreeLeafByteSize( leaf_bytesize );
        else
            slog_outs.setTreeLeafByteSize( dobj_ins.getTreeLeafByteSize() );
        if ( num_children_per_node > 0 )
            slog_outs.setNumChildrenPerNode( num_children_per_node );
        else
            slog_outs.setNumChildrenPerNode( dobj_ins.getNumChildrenPerNode() );

        treetrunk = new TreeTrunk( slog_outs, shadefs );
        /* */    Date time2 = new Date();
        while ( ( next_kind = dobj_ins.peekNextKind() ) != Kind.EOF ) {
            if ( next_kind == Kind.TOPOLOGY ) {
                topo = dobj_ins.getNextTopology();
                // Put in the default Shadow categories in case the original
                // does not have any shadow categories, i.e no shadows.
                objdef = Category.getShadowCategory( topo );
                objdefs.put( new Integer( objdef.getIndex() ), objdef );
                shadefs.put( topo, objdef );
            }
            else if ( next_kind == Kind.YCOORDMAP ) {
                lineIDmap = new LineIDMap( dobj_ins.getNextYCoordMap() );
                lineIDmaps.add( lineIDmap );
            }
            else if ( next_kind == Kind.CATEGORY ) {
                objdef = dobj_ins.getNextCategory();
                if ( objdef.isShadowCategory() ) {
                    objdefs.put( new Integer( objdef.getIndex() ), objdef );
                    shadefs.put( objdef.getTopology(), objdef );
                }
                // Category can be removed here for efficiency reason.
                // Instead let CategoryMap.removeUnusedCategories() do the work.
                // if ( isCategoryToBeRemoved( objdef.getIndex() ) )
                //     continue;
                objdefs.put( new Integer( objdef.getIndex() ), objdef );
                objdef.setUsed( false );
            }
            else if ( next_kind == Kind.PRIMITIVE ) {
                prime_obj = dobj_ins.getNextPrimitive();
                // Undo InfoBox.resolveCategory() when the Drawable is read.
                prime_obj.releaseCategory();
                if ( isCategoryToBeRemoved( prime_obj.getCategoryIndex() ) ) {
                    // System.out.println( "Removing ... " + prime_obj );
                    continue;
                }
                prime_obj.resolveCategory( objdefs );
                // postponed, wait till on-demand decoding of InfoBuffer
                // prime_obj.decodeInfoBuffer();
                Nobjs++;
                // System.out.println( Nobjs + " : " + prime_obj );
                if ( enable_endtime_check ) {
                    if ( ! prime_obj.isTimeOrdered() ) {
                        System.out.println( "**** Primitive Time Error ****" );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    curr_dobj_endtime = prime_obj.getLatestTime();
                    if ( prev_dobj_endtime > curr_dobj_endtime ) {
                        System.err.println( "**** Violation of "
                                          + "Increasing Endtime Order ****\n"
                                          + "\t Offended Drawable -> "
                                          + offended_Nobjs + " : "
View Full Code Here

TOP

Related Classes of base.drawable.Primitive

Copyright © 2018 www.massapicom. 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.