@@ -128,6 +128,23 @@ export default class Target{
128128 return "" ;
129129 } ) ;
130130
131+ // Add images for inline & reverse complements
132+ let linksEnter2 = svg . selectAll ( ".link" )
133+ . data ( graph . links . filter ( link => link . hasReverseOrient ) )
134+ . enter ( ) ;
135+
136+ let reverseImgs = linksEnter2 . append ( "svg:image" )
137+ . attr ( "height" , sbolImgSize )
138+ . attr ( "width" , sbolImgSize )
139+ . attr ( "href" , ( d ) => {
140+ if ( d . hasOwnProperty ( "componentRoles" ) ) {
141+ if ( d [ "componentRoles" ] . length > 0 ) {
142+ return getSBOLImage ( d [ "componentRoles" ] [ 0 ] ) ;
143+ }
144+ }
145+ return "" ;
146+ } ) ;
147+
131148 //place tooltip on the SVG images
132149 $ ( '.sboltip' ) . tooltipster ( {
133150 theme : 'tooltipster-shadow'
@@ -162,17 +179,33 @@ export default class Target{
162179
163180 // Position SBOL images
164181 images . attr ( "x" , function ( d ) {
165- return ( d . source . x + d . target . x ) / 2 - sbolImgSize / 2 ;
182+ if ( d . hasReverseOrient ) {
183+ return ( d . source . x + d . target . x ) / 2 - sbolImgSize ;
184+ }
185+ return ( d . source . x + d . target . x ) / 2 - sbolImgSize / 2 ;
186+ } )
187+ . attr ( "y" , function ( d ) {
188+ return ( d . source . y + d . target . y ) / 2 - sbolImgSize / 2 ;
189+ } )
190+ . attr ( 'transform' , function ( d ) {
191+ //transform 180 if the orientation is REVERSE_COMPLEMENT
192+ if ( d . orientation === "REVERSE_COMPLEMENT" && ! d . hasReverseOrient ) {
193+ let x1 = ( d . source . x + d . target . x ) / 2 ; //the center x about which you want to rotate
194+ let y1 = ( d . source . y + d . target . y ) / 2 ; //the center y about which you want to rotate
195+ return `rotate(180, ${ x1 } , ${ y1 } )` ;
196+ }
197+ } ) ;
198+
199+ reverseImgs . attr ( "x" , function ( d ) {
200+ return ( d . source . x + d . target . x ) / 2 - sbolImgSize ;
166201 } )
167202 . attr ( "y" , function ( d ) {
168203 return ( d . source . y + d . target . y ) / 2 - sbolImgSize / 2 ;
169204 } )
170205 . attr ( 'transform' , function ( d ) {
171- if ( d . orientation === "REVERSE_COMPLEMENT" ) {
172- let x1 = ( d . source . x + d . target . x ) / 2 ; //the center x about which you want to rotate
173- let y1 = ( d . source . y + d . target . y ) / 2 ; //the center y about which you want to rotate
174- return `rotate(180, ${ x1 } , ${ y1 } )` ;
175- }
206+ let x1 = ( d . source . x + d . target . x ) / 2 ; //the center x about which you want to rotate
207+ let y1 = ( d . source . y + d . target . y ) / 2 ; //the center y about which you want to rotate
208+ return `rotate(180, ${ x1 } , ${ y1 } )` ;
176209 } ) ;
177210 } ) ;
178211 }
0 commit comments