| 1 | package Bio::GMOD::Blast::Graph::MapUtils; | ||
| 2 | BEGIN { | ||
| 3 | $Bio::GMOD::Blast::Graph::MapUtils::AUTHORITY = 'cpan:RBUELS'; | ||
| 4 | } | ||
| 5 | BEGIN { | ||
| 6 | $Bio::GMOD::Blast::Graph::MapUtils::VERSION = '0.06'; | ||
| 7 | } | ||
| 8 | ##################################################################### | ||
| 9 | # | ||
| 10 | # Cared for by Shuai Weng <shuai@genome.stanford.edu> | ||
| 11 | # | ||
| 12 | # Originally created by John Slenk <jces@genome.stanford.edu> | ||
| 13 | # | ||
| 14 | # You may distribute this module under the same terms as perl itself | ||
| 15 | #----------------------------------------------------------------- | ||
| 16 | |||
| 17 | use Bio::GMOD::Blast::Graph::BaseObj; | ||
| 18 | use Bio::GMOD::Blast::Graph::MyUtils; | ||
| 19 | use Bio::GMOD::Blast::Graph::MyDebug qw( assert dmsg ); | ||
| 20 | use Bio::GMOD::Blast::Graph::MapDefs | ||
| 21 | qw( $imgWidth $imgHeight $fontWidth $fontHeight $imgTopBorder | ||
| 22 | $imgBottomBorder $imgLeftBorder $imgRightBorder $namesHorizBorder | ||
| 23 | $imgHorizBorder $imgVertBorder $arrowHeight $halfArrowHeight | ||
| 24 | $arrowWidth $halfArrowWidth $hspPosInit $hspArrowPad $hspHeight | ||
| 25 | $formFieldWidth $tickHeight $bottomDataOffset $topDataOffset | ||
| 26 | $kNumberOfPartitions $bucketZeroMax $bucketOneMax $bucketTwoMax | ||
| 27 | $bucketThreeMax $bucketFourMax ); | ||
| 28 | |||
| 29 | @ISA = qw( Bio::GMOD::Blast::Graph::BaseObj ); | ||
| 30 | |||
| 31 | my $kNamesP = | ||
| 32 | Bio::GMOD::Blast::Graph::MyUtils::makeVariableName( "names", "predicate" ); | ||
| 33 | my $kNamesHorizBorder = | ||
| 34 | Bio::GMOD::Blast::Graph::MyUtils::makeVariableName( "names", "horiz", "border" ); | ||
| 35 | my $kImgWidth = | ||
| 36 | Bio::GMOD::Blast::Graph::MyUtils::makeVariableName( "img", "width" ); | ||
| 37 | my $kQueryLeft = | ||
| 38 | Bio::GMOD::Blast::Graph::MyUtils::makeVariableName( "query", "left" ); | ||
| 39 | my $kQuerySpace = | ||
| 40 | Bio::GMOD::Blast::Graph::MyUtils::makeVariableName( "query", "space" ); | ||
| 41 | |||
| 42 | ################################################################### | ||
| 43 | sub init { | ||
| 44 | ################################################################### | ||
| 45 | my( $self, $pP ) = @_; | ||
| 46 | |||
| 47 | $self->putNamesP( $pP ); | ||
| 48 | $self->putNamesHorizBorder( $namesHorizBorder ); | ||
| 49 | $self->recalc(); | ||
| 50 | } | ||
| 51 | |||
| 52 | ################################################################### | ||
| 53 | sub recalc { | ||
| 54 | ################################################################### | ||
| 55 | my( $self ) = shift; | ||
| 56 | my( $pP ) = $self->getNamesP(); | ||
| 57 | my( $namesHorizBorder ) = $self->getNamesHorizBorder(); | ||
| 58 | my( $tmp ); | ||
| 59 | |||
| 60 | $tmp = $imgWidth; | ||
| 61 | if( $pP ) { $tmp += $namesHorizBorder; } | ||
| 62 | $self->{ $kImgWidth } = $tmp; | ||
| 63 | |||
| 64 | $tmp = $self->getImgWidth() - $imgHorizBorder; | ||
| 65 | if( $pP ) { $tmp -= $namesHorizBorder; } | ||
| 66 | $self->{ $kQuerySpace } = $tmp; | ||
| 67 | |||
| 68 | $tmp = $imgLeftBorder; | ||
| 69 | if( $pP ) { $tmp += $namesHorizBorder; } | ||
| 70 | $self->{ $kQueryLeft } = $tmp; | ||
| 71 | } | ||
| 72 | |||
| 73 | ################################################################### | ||
| 74 | sub putNamesP { | ||
| 75 | ################################################################### | ||
| 76 | my( $self, $pP ) = @_; | ||
| 77 | $self->{ $kNamesP } = $pP; | ||
| 78 | } | ||
| 79 | |||
| 80 | ################################################################### | ||
| 81 | sub getNamesP { | ||
| 82 | ################################################################### | ||
| 83 | my( $self ) = shift; | ||
| 84 | return( $self->{ $kNamesP } ); | ||
| 85 | } | ||
| 86 | |||
| 87 | ################################################################### | ||
| 88 | sub putNamesHorizBorder { | ||
| 89 | ################################################################### | ||
| 90 | my( $self ) = shift; | ||
| 91 | my( $phb ) = shift; | ||
| 92 | $self->{ $kNamesHorizBorder } = $phb; | ||
| 93 | $self->recalc(); | ||
| 94 | } | ||
| 95 | |||
| 96 | ################################################################### | ||
| 97 | sub getNamesHorizBorder { | ||
| 98 | ################################################################### | ||
| 99 | my( $self ) = shift; | ||
| 100 | return( $self->{ $kNamesHorizBorder } ); | ||
| 101 | } | ||
| 102 | |||
| 103 | ################################################################### | ||
| 104 | sub getImgWidth { | ||
| 105 | ################################################################### | ||
| 106 | my( $self ) = shift; | ||
| 107 | return( $self->{ $kImgWidth } ); | ||
| 108 | } | ||
| 109 | |||
| 110 | ################################################################### | ||
| 111 | sub getNoteLeft { | ||
| 112 | ################################################################### | ||
| 113 | my( $self ) = shift; | ||
| 114 | return( $imgLeftBorder ); | ||
| 115 | } | ||
| 116 | |||
| 117 | ################################################################### | ||
| 118 | sub getQueryLeft { | ||
| 119 | ################################################################### | ||
| 120 | my( $self ) = shift; | ||
| 121 | return( $self->{ $kQueryLeft } ); | ||
| 122 | } | ||
| 123 | |||
| 124 | ################################################################### | ||
| 125 | sub getQueryWidth { | ||
| 126 | ################################################################### | ||
| 127 | my( $self ) = shift; | ||
| 128 | return( $self->{ $kQuerySpace } ); | ||
| 129 | } | ||
| 130 | |||
| 131 | ################################################################### | ||
| 132 | sub getStringDimensions { | ||
| 133 | ################################################################### | ||
| 134 | my( $self, $str ) = @_; | ||
| 135 | my( $w, $h ); | ||
| 136 | |||
| 137 | $w = length( $str ) * $fontWidth; | ||
| 138 | $h = $fontHeight; | ||
| 139 | |||
| 140 | return( $w, $h ); | ||
| 141 | } | ||
| 142 | ################################################################### | ||
| 143 | 1; | ||
| 144 | ################################################################### | ||
| 145 | |||
| 146 | __END__ |