📄 primitive.java
字号:
rep.append( "]" ); rep.append( " bsize=" + this.getByteSize() ); return rep.toString(); }/* // Primitive( final Coord[] ) and Primitive( Category, final Coord[] ) // are VERY dangerous constructors because only references of Coord[] // are passed, so Coord[] of originating Primitive could be modified // in multiple objects!!!!! public Primitive( final Coord[] in_vertices ) { super( in_vertices ); vertices = in_vertices; last_vtx_idx = vertices.length - 1; super.setCategory( null ); } public Primitive( Category in_type, final Coord[] in_vertices ) { super( in_vertices ); vertices = in_vertices; last_vtx_idx = vertices.length - 1; super.setCategory( in_type ); } // Check clone() interface public static final void main( String[] args ) { Primitive prime, sobj; Category ctgy = new Category(); // incomplete category ctgy.setInfoKeys( "msg_tag\nmsg_size\n" ); prime = new Primitive( ctgy, new Coord[] { new Coord( 1.1, 1 ), new Coord( 2.2, 2 ) } ); prime.setInfoValue( 0, 10 ); prime.setInfoValue( 1, 1024 ); System.out.println( "prime = " + prime ); sobj = null; try { sobj = (Primitive) prime.clone(); } catch( CloneNotSupportedException cerr ) { cerr.printStackTrace(); System.exit( 1 ); } System.out.println( "\nAfter cloning" ); System.out.println( "prime = " + prime ); System.out.println( "sobj = " + sobj ); sobj.getStartVertex().time = 4.4; sobj.getFinalVertex().time = 5.5; sobj.setInfoValue( 0, 1000 ); System.out.println( "\nAfter modification of the clone" ); System.out.println( "prime = " + prime ); System.out.println( "sobj = " + sobj ); System.out.println( "This proves that clone() is useless for Shadow" ); }*/ public boolean isTimeOrdered() { if ( ! super.isTimeOrdered() ) { System.err.println( "**** Violation of Causality ****\n" + "Offending Primitive -> " + this ); return false; } for ( int idx = 0 ; idx <= last_vtx_idx ; idx++ ) { if ( ! super.contains( vertices[ idx ].time ) ) { System.err.println( "**** Out of Primitive Time Range ****\n" + "Offending Primitive -> " + this + "\n" + "\t time coordinate " + idx + " is out of range." ); return false; } } return true; } // Implementation of abstract methods. /* 0.0f < nesting_ftr <= 1.0f */ public int drawState( Graphics2D g, CoordPixelXform coord_xform, Map map_line2row, DrawnBoxSet drawn_boxes, ColorAlpha color ) { Coord start_vtx, final_vtx; start_vtx = this.getStartVertex(); final_vtx = this.getFinalVertex(); double tStart, tFinal; tStart = start_vtx.time; /* different from Shadow */ tFinal = final_vtx.time; /* different form Shadow */ int rowID; float nesting_ftr; /* assume RowID and NestingFactor have been calculated */ rowID = super.getRowID(); nesting_ftr = super.getNestingFactor(); // System.out.println( "\t" + this + " nestftr=" + nesting_ftr ); float rStart, rFinal; rStart = (float) rowID - nesting_ftr / 2.0f; rFinal = rStart + nesting_ftr; return State.draw( g, color, null, coord_xform, drawn_boxes.getLastStatePos( rowID ), tStart, rStart, tFinal, rFinal ); } // assume this Primitive overlaps with coord_xform.TimeBoundingBox public int drawArrow( Graphics2D g, CoordPixelXform coord_xform, Map map_line2row, DrawnBoxSet drawn_boxes, ColorAlpha color ) { Coord start_vtx, final_vtx; start_vtx = this.getStartVertex(); final_vtx = this.getFinalVertex(); double tStart, tFinal; tStart = start_vtx.time; tFinal = final_vtx.time; int iStart, iFinal; iStart = ( (Integer) map_line2row.get( new Integer(start_vtx.lineID) ) ).intValue(); iFinal = ( (Integer) map_line2row.get( new Integer(final_vtx.lineID) ) ).intValue(); return Arrow.draw( g, color, null, coord_xform, drawn_boxes.getLastArrowPos( iStart, iFinal ), tStart, (float) iStart, tFinal, (float) iFinal ); } public int drawEvent( Graphics2D g, CoordPixelXform coord_xform, Map map_line2row, DrawnBoxSet drawn_boxes, ColorAlpha color ) { Coord vtx; vtx = this.getStartVertex(); double tPoint; tPoint = vtx.time; /* different from Shadow */ int rowID; float rPeak, rStart, rFinal; rowID = ( (Integer) map_line2row.get( new Integer(vtx.lineID) ) ).intValue(); // rPeak = (float) rowID + NestingStacks.getHalfInitialNestingHeight(); rPeak = (float) rowID - 0.25f; rStart = (float) rowID - 0.5f; rFinal = rStart + 1.0f; return Event.draw( g, color, null, coord_xform, drawn_boxes.getLastEventPos( rowID ), tPoint, rPeak, rStart, rFinal ); } /* 0.0f < nesting_ftr <= 1.0f */ public boolean isPixelInState( CoordPixelXform coord_xform, Map map_line2row, Point pix_pt ) { Coord start_vtx, final_vtx; start_vtx = this.getStartVertex(); final_vtx = this.getFinalVertex(); double tStart, tFinal; tStart = start_vtx.time; /* different from Shadow */ tFinal = final_vtx.time; /* different form Shadow */ int rowID; float nesting_ftr; /* rowID = ( (Integer) map_line2row.get( new Integer(start_vtx.lineID) ) ).intValue(); */ /* assume RowID and NestingFactor have been calculated */ rowID = super.getRowID(); nesting_ftr = super.getNestingFactor(); // System.out.println( "\t" + this + " nestftr=" + nesting_ftr ); float rStart, rFinal; rStart = (float) rowID - nesting_ftr / 2.0f; rFinal = rStart + nesting_ftr; return State.containsPixel( coord_xform, pix_pt, tStart, rStart, tFinal, rFinal ); } // assume this Primitive overlaps with coord_xform.TimeBoundingBox public boolean isPixelOnArrow( CoordPixelXform coord_xform, Map map_line2row, Point pix_pt ) { Coord start_vtx, final_vtx; start_vtx = this.getStartVertex(); final_vtx = this.getFinalVertex(); double tStart, tFinal; tStart = start_vtx.time; tFinal = final_vtx.time; float rStart, rFinal; rStart = ( (Integer) map_line2row.get( new Integer(start_vtx.lineID) ) ).floatValue(); rFinal = ( (Integer) map_line2row.get( new Integer(final_vtx.lineID) ) ).floatValue(); return Line.containsPixel( coord_xform, pix_pt, tStart, rStart, tFinal, rFinal ); } public boolean isPixelAtEvent( CoordPixelXform coord_xform, Map map_line2row, Point pix_pt ) { Coord vtx; vtx = this.getStartVertex(); double tPoint; tPoint = vtx.time; /* different from Shadow */ int rowID; float rStart, rFinal; rowID = ( (Integer) map_line2row.get( new Integer(vtx.lineID) ) ).intValue(); rStart = (float) rowID - 0.5f; rFinal = rStart + 1.0f; return Event.containsPixel( coord_xform, pix_pt, tPoint, rStart, rFinal ); } public boolean containSearchable() { return super.getCategory().isVisiblySearchable(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -