[Biococoa-dev] calculating symbols per column

Peter Schols peter.schols at bio.kuleuven.be
Thu Apr 27 04:35:08 EDT 2006


From: Alexander Griekspoor <mek at mekentosj.com>
Date: 27 april 2006 9:23:03 GMT+02:00
To: Koen van der Drift <kvddrift at earthlink.net>
Cc: BioCocoa Mailinglist <biococoa-dev at bioinformatics.org>
Subject: Re: [Biococoa-dev] calculating symbols per column


Hi Koen,

I have to tell a little secret, these were the things I did in first  
instance when I started with the textview column modifications, but  
indeed I found out that it didn't work, hence I decided to hardcode  
the wide. What I think goes wrong is that we miss things like  
paragraph style etc. Perhaps we should play with an attributed  
string, and/or ask/search the cocoadev list..
Cheers,
Alex

On 22-apr-2006, at 4:12, Koen van der Drift wrote:
Hi,

I have been puzzling a bit with some code to set the number of  
symbols per column in the BCSequenceView, right now it is hard coded  
to 10, but it would be nice if we make this flexible.  Instead of the  
number of symbols in a column, the textContainer for the sequenceView  
needs to know the actual width of that particular number of symbols.  
Assuming we are using a monospaced font and don't mix lower and  
uppercase strings, I came up with the following code. First get the  
width of each character, this can be done in two ways (I am not sure  
which ones of the two to choose):

	float		characterWidth = [[self font] boundingRectForFont].size.width;

	OR:

	float		characterWidth = [[self font] maximumAdvancement].width;
	
Then from that calculate the width of the column:

	float		columnWidth = (float) (symbolsPerColumn * characterWidth );

And pass it to the textContainer and layoutManager:

	[(BCSequenceViewContainer *) [self textContainer] setColumnWidth:  
columnWidth];
	[(BCSequenceViewLayoutManager *) [self layoutManager]  
setSymbolsPerColumn: symbolsPerColumn];


As you may have guessed, that doesn't work as expected, I get more  
than the expected number of symbols in a column. Also the selection  
code gets screwed up a bit.

Any suggestions/ideas?

cheers,

- Koen.

_______________________________________________
Biococoa-dev mailing list
Biococoa-dev at bioinformatics.org
https://bioinformatics.org/mailman/listinfo/biococoa-dev


**************************************************************
                         ** Alexander Griekspoor **
**************************************************************
                  The Netherlands Cancer Institute
                  Department of Tumorbiology (H4)
             Plesmanlaan 121, 1066 CX, Amsterdam
                        Tel:  + 31 20 - 512 2023
                        Fax:  + 31 20 - 512 2029
                       AIM: mekentosj at mac.com
                       E-mail: a.griekspoor at nki.nl
                    Web: http://www.mekentosj.com

MacOS X: The power of UNIX with the simplicity of the Mac

***************************************************************


*********************************************************
                     ** Alexander Griekspoor **
*********************************************************
               The Netherlands Cancer Institute
               Department of Tumorbiology (H4)
          Plesmanlaan 121, 1066 CX, Amsterdam
                     Tel:  + 31 20 - 512 2023
                     Fax:  + 31 20 - 512 2029
                     AIM: mekentosj at mac.com
                     E-mail: a.griekspoor at nki.nl
                 Web: http://www.mekentosj.com

Windows is a 32-bit patch to a 16-bit shell for an 8-bit
operating system, written for a 4-bit processor by a 2-
bit company without 1 bit of sense.

*********************************************************



Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm




More information about the Biococoa-dev mailing list