text-alignment

Print a data frame with columns aligned (as displayed in R)

北城余情 提交于 2019-11-30 08:19:42
问题 I have the following data frame in R: > dframe Mean Median Candidates 85.68 60 NonCands 9.21 4 Multi 27.48 17 Mono 4.43 3 Multi NonCands 22.23 15 I want to print it into a file and keep it nicely formatted and aligned just as shown above. I use: write.table(dframe,file="test",sep="\t", quote=F) which produces the following output: Mean Median Candidates 85.68 60 NonCands 9.21 4 Multi 27.48 17 Mono 4.43 3 Multi NonCands 22.23 15 Since the data is displayed properly formatted within the R

vertically align text in a CATextLayer?

若如初见. 提交于 2019-11-30 07:51:18
问题 I am working on a CATextLayer that I want to use in both Mac and iOS. Can I control the vertical alignment of the text within the layer? In this particular case, I want to center it vertically -- but information about other vertical alignments would also be of interest. EDIT: I found this, but I can't make it work. 回答1: The correct answer, as you've already found, is here in Objective-C and works for iOS . It works by subclassing the CATextLayer and overriding the drawInContext function.

Swift : align UILabel text in the top rather in the middle

廉价感情. 提交于 2019-11-30 04:17:50
I want the UILabel to start from the top even if the text is short it seems that NSTextAlignment doesn't work cell.textContent.text = comments[indexPath.row] cell.textContent.textAlignment = func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { //post's section == 0 if indexPath.section == 0 { let cell = tableView.dequeueReusableCellWithIdentifier("postCID", forIndexPath: indexPath) as! postCell cell.usernameLabel.text = "Steve Paul Jobs" cell.time.text = "9:42 PM" cell.commentsLabelCount.text = "12 Comments" cell.textContent.text = "Return

Align text in JLabel to the right

爷,独闯天下 提交于 2019-11-30 04:12:17
I have a JPanel with some JLabel added with the add() method of JPanel. I want to align the JLabel to the right like the image below but I don't know how to do that. Any Idea? Thanks! This can be done in two ways. JLabel Horizontal Alignment You can use the JLabel constructor : JLabel(String text, int horizontalAlignment) To align to the right: JLabel label = new JLabel("Telephone", SwingConstants.RIGHT); JLabel also has setHorizontalAlignment : label.setHorizontalAlignment(SwingConstants.RIGHT); This assumes the component takes up the whole width in the container. Using Layout A different

NSTextAlignmentJustified to UILable textAligment on iOS6 will crash

大憨熊 提交于 2019-11-30 03:18:58
问题 I am use Xcode4.5 and iOS6 now, the iOS6 have change the UILable's textAlignment, label.textAlignment = NSTextAlignmentJustified; The code will crash on iPhone 6.0 Simulator with ios6 SDK. but not crash on iPhone 5.0 Simulator with iOS6 SDK. The iOS6 support NSTextAlignmentJustified, but why will crash? 回答1: Edit 1: Using NSAttributedString we can justify text. NSMutableParagraphStyle *paragraphStyles = [[NSMutableParagraphStyle alloc] init]; paragraphStyles.alignment =

How to center a text using PDFBox

血红的双手。 提交于 2019-11-29 23:43:23
My question is very simple: how can I center a text on a PDF, using PDFBox ? I don't know the string in advance, I can't find the middle by trial. The string doesn't always have the same width. I need either: A method that can center the text, something like addCenteredString(myString) A method that can give me the width of the string in pixels. I can then calculate the center, for I know the dimensions of the PDF. Any help is welcome! SteeveDroz Ok, I found the answer myself. Here is how to center some text on a page: String title = "This is my wonderful title!"; // Or whatever title you want

How to (horizontally) align text of PDTextField in PDFBox?

不问归期 提交于 2019-11-29 16:06:36
I have a program that create TextFields inside a PDF-file so it can be used as a form. I would like to have the text I write in the TextFields I created to be centered though. How is that possible? My code currently looks like this: PDTextField textBox = new PDTextField(acroForm); textBox.setPartialName("Field " + j + " " + i); defaultAppearanceString = "/Helv 8 Tf 0 g"; //Textsize: 8 textBox.setDefaultAppearance(defaultAppearanceString); acroForm.getFields().add(textBox); PDAnnotationWidget widget = textBox.getWidgets().get(0); PDRectangle rect = new PDRectangle(inputField.getX(), inputField

text-align=“middle” _only_ in y-direction?

霸气de小男生 提交于 2019-11-29 12:37:32
I can use text-align="middle" on a text element to center text. Actually this only works nice for the x-direction. For the y-direction I use the hack of Ian G in question Aligning text in SVG . But what can I do, if a want to center a text in the y-direction, but want to left-align the text in x-direction? For example, I have a rect -element and a text -element positioned right of it. The text should be vertically aligned to appear centered in relation to the rect. Therefore I use the text-align="middle" property. But I want to left-align the text in the x-direction (since I want to display it

Python: String Formatter Align center

馋奶兔 提交于 2019-11-29 06:53:31
print('%24s' % "MyString") # prints right aligned print('%-24s' % "MyString") # prints left aligned How do I print it in the center? Is there a quick way to do this? I don't want the text to be in the center of my screen. I want it to be in the center of that 24 spaces. If I have to do it manually, what is the math behind adding the same no. of spaces before and after the text? Use the new-style format method instead of the old-style % operator, which doesn't have the centering functionality: print('{:^24s}'.format("MyString")) You can use str.center() method. In your case, it will be:

Print a data frame with columns aligned (as displayed in R)

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 06:43:47
I have the following data frame in R: > dframe Mean Median Candidates 85.68 60 NonCands 9.21 4 Multi 27.48 17 Mono 4.43 3 Multi NonCands 22.23 15 I want to print it into a file and keep it nicely formatted and aligned just as shown above. I use: write.table(dframe,file="test",sep="\t", quote=F) which produces the following output: Mean Median Candidates 85.68 60 NonCands 9.21 4 Multi 27.48 17 Mono 4.43 3 Multi NonCands 22.23 15 Since the data is displayed properly formatted within the R environment I thought it should be trivial to write it to a file with the same format. Apparently I was