How to draw text vertically, or in an angle
please help me how to draw text vertically, or in an angle
I robbed the framework from Dr Las or 74phillip (don't remember which) ...
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.*;
public class AngleText extends JPanel {
private int degrees = 16;
private JSpinner degreesSpinner;
public AngleText () {
setBackground ( Color.WHITE );
} // AngleText constructor
protected void paintComponent ( Graphics _g ) {
super.paintComponent ( _g );
Graphics2D g = (Graphics2D)_g;
g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
AffineTransform at = AffineTransform.getRotateInstance ( Math.toRadians ( degrees ) );
Font f = g.getFont();
g.setFont ( f.deriveFont ( at ) );
g.drawString ( "Rotating Text!", getWidth()/2, getHeight()/2 );
g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
} // paintComponent
public JPanel getUIPanel () {
SpinnerModel degreesModel = new SpinnerNumberModel (
degrees // initial
,0 // min
,360 // max
,2 // step
degreesSpinner = new JSpinner ( degreesModel );
degreesSpinner.addChangeListener ( new DegreesTracker() );
JPanel panel = new JPanel();
panel.add ( degreesSpinner );
return panel;
} // getUIPanel
// DegreesTracker
private class DegreesTracker implements ChangeListener {
public void stateChanged ( ChangeEvent e ) {
Integer i = (Integer)((JSpinner)e.getSource()).getValue();
degrees = i.intValue ();
repaint();
} // DegreesTracker
// main
public static void main ( String[] args ) {
JFrame f = new JFrame ( "AngleText" );
f.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
AngleText app = new AngleText();
f.getContentPane().add ( app );
f.getContentPane().add ( app.getUIPanel(), BorderLayout.SOUTH );
f.setSize ( 200, 200 );
f.setVisible ( true );
} // main
} // AngleText
Similar Messages
-
How to draw a vertical string?
I use Graphics2D to draw a 2D graph with x-axis and y-axis. I would like to put the name of the y-axis vertically along the y-axis. This means I need to rotate my drawString 90 degrees. How can we do that? I would be very thankful if anyone can help me out.
Thank youI had the same problem when I started developing JFreeChart:
http://www.object-refinery.com/jfreechart/index.html
Here is the code I use:
* A utility method for drawing rotated text.
* <P>
* A common rotation is -Math.PI/2 which draws text 'vertically' (with the top of the
* characters on the left).
* @param text The text.
* @param g2 The graphics device.
* @param x The x-coordinate.
* @param y The y-coordinate.
* @param rotation The clockwise rotation (in radians).
public static void drawRotatedString(String text, Graphics2D g2,
float x, float y, double rotation) {
AffineTransform saved = g2.getTransform();
AffineTransform rotate = AffineTransform.getRotateInstance(rotation, x, y);
g2.transform(rotate);
g2.drawString(text, x, y);
g2.setTransform(saved);
}Regards,
Dave Gilbert
JFreeChart Project Leader -
How to print text vertically in smart forms
hi,
Can any one tell how to print text vertically in smartforms
ADVANCE THANKS
GUHAPRIYANHI,
Chk out this thread.Maybe it proves helpful.
Re: vertical writing in smartforms
Regards,
Gayathri -
How to display TEXT vertically in SMART FORM
Hai,
I need to display the column name of a table vertically (readable from bottom to top) in smart form.
Could any one please tell me how to do this?
Thanks & Best Regards,
Maniyam Bhaskar.Hi,
Go through these threads for the discussions happened on similar issue... hope it helps you..
how to print text vertically in smart forms
vertical and horizontal printing in same page with smartforms or sapscript
Good luck
Narin -
How to justify text vertically in multi-column frame
How do I justify text vertically in a multi-column frame but within the baseline grid?
Working at a very busy publication, fitting text evenly in multi-column text boxes are crucial to be done quickly! I understand that it can be done manually by adjusting the tracking in order to force the text to end evenly on bottom. However I'm looking to achieve that result automatically, pretty much like the "Justify Vertically" feature except by doing so it spreads the last column lines out, but I need to keep the text on the grid.You can ask over in scripting: InDesign Scripting
-
How to align text vertically?
This seems like it should be really easy: On a simple text slide, how do I align multiple lines of text vertically? Do I have to eyeball it, or is there a way to fix it exactly in the center, top to bottom?
Hi -
There is no automatic way, but there is a way to make it slightly easier.
After you enter your text, grab the clip of type and move it to a portion of the timeline where there are no other clips.
In the Canvas click on the button on the top right and select Checkerboard:
!http:/www.spotsbeforeyoureyes.com/CanvasCheckerboardBG.jpg!
This will make the background a checkerboard so you can count the squares to verify the top and bottom line are equidistant from the TV Safe Guidelines:
!http://www.spotsbeforeyoureyes.com/CanvasCheckerBoardExample.jpg!
When you are done positioning the type, grab the clip and place it above the clip you originally wanted it to appear over.
You can either leave the Canvas set to display a checkerboard when there is no video present, or switch it back to Black.
Hope this helps. -
I need to add text vertically in a word document outside the margins. How can I do this with Microsoft.Office.Interop.Word and C#?
Leonard Swarczinski Software Developer Postal Center InternationalHi Leonard,
According to your description, do you want to add text vertically into Page Header/Footer? I wrote a sample for you.
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Word;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AddTextToWord
class Program
static void Main(string[] args)
CreateNewDocument();
Console.ReadLine();
private static void CreateNewDocument()
Object oMissing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Application oWord;
Microsoft.Office.Interop.Word.Document oDoc;
oWord = new Microsoft.Office.Interop.Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
String HeaderText = "Hello everyone!";
WdParagraphAlignment wdAlign = WdParagraphAlignment.wdAlignParagraphCenter;
AddHeader1(oWord, HeaderText, wdAlign);
private static void AddHeader1(Application WordApp, string HeaderText, WdParagraphAlignment wdAlign)
Object oMissing = System.Reflection.Missing.Value;
WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
Microsoft.Office.Interop.Word.Shape textBox = WordApp.ActiveDocument.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationVertical, 150, 10, 40, 40);
textBox.TextFrame.TextRange.Text = HeaderText;
WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;
If I misunderstood or anything wrong, please let me know and you can get more information from below articles.
Office development in Visual Studio
http://msdn.microsoft.com/en-us/office/hh133430.aspx
Abhout: AddTextbox Method
http://msdn.microsoft.com/en-us/library/office/aa171543(v=office.11).aspx
How to: Programmatically Insert Text into Word Documents
http://msdn.microsoft.com/en-us/library/vstudio/6b9478cs.aspx -
How to draw text to scale in actual inches?
When I set my document to draw text in inches and then outline the text, its usually smaller than what it was supposed to be. How do I set it to draw to an accurate size while still in edit mode (not outlined)?
It is exactly the size it is supposed to be. When you enter a type size, it is not the height of the capital letters, it's the distance from the tallest ascender to the lowest descender.
all the text below is 12 point
the only way to get what you want is to figure out the point size at which the capitals will equal .5 inches - as you can see, this point size will vary depending on the font. -
How to Draw a vertical line in flex
I was just wondering the simplest way to draw a vertical line , preferably dashed.
You could always just use the graphics class of your chart component. Just access its graphics object, set the line style/thickness, move to the start point, and line to the end point. Something like this,
this.graphics.lineStyle(1, 0x000000);
this.graphics.moveTo(startX, startY);
this.graphics.lineTo(endX, endY); -
How to draw only straight line instead of angled one??
Dear friends,
I saw a very good code posted by guru here(I think is camickr),
But I tried to change it and I hope to draw only straight line instead of angled one, can you help how to do it??
Thanks so much.
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class DrawingArea extends JPanel
Vector angledLines;
Point startPoint = null;
Point endPoint = null;
Graphics g;
public DrawingArea()
angledLines = new Vector();
setPreferredSize(new Dimension(500,500));
MyMouseListener ml = new MyMouseListener();
addMouseListener(ml);
addMouseMotionListener(ml);
setBackground(Color.white);
public void paintComponent(Graphics g)
// automatically called when repaint
super.paintComponent(g);
g.setColor(Color.black);
AngledLine line;
if (startPoint != null && endPoint != null)
// draw the current dragged line
g.drawLine(startPoint.x, startPoint.y, endPoint.x,endPoint.y);
for (Enumeration e = angledLines.elements(); e.hasMoreElements();)
// draw all the angled lines
line = (AngledLine)e.nextElement();
g.drawPolyline(line.xPoints, line.yPoints, line.n);
class MyMouseListener extends MouseInputAdapter
public void mousePressed(MouseEvent e)
if (SwingUtilities.isLeftMouseButton(e))
startPoint = e.getPoint();
public void mouseReleased(MouseEvent e)
if (SwingUtilities.isLeftMouseButton(e))
if (startPoint != null)
AngledLine line = new AngledLine(startPoint, e.getPoint(), true);
angledLines.add(line);
startPoint = null;
repaint();
public void mouseDragged(MouseEvent e)
if (SwingUtilities.isLeftMouseButton(e))
if (startPoint != null)
endPoint = e.getPoint();
repaint();
public void mouseClicked( MouseEvent e )
if (g == null)
g = getGraphics();
g.drawRect(10,10,20,20);
class AngledLine
// inner class for angled lines
public int[] xPoints, yPoints;
public int n = 3;
public AngledLine(Point startPoint, Point endPoint, boolean left)
xPoints = new int[n];
yPoints = new int[n];
xPoints[0] = startPoint.x;
xPoints[2] = endPoint.x;
yPoints[0] = startPoint.y;
yPoints[2] = endPoint.y;
if (left)
xPoints[1] = startPoint.x;
yPoints[1] = endPoint.y;
else
xPoints[1] = endPoint.x;
yPoints[1] = startPoint.y;
public static void main(String[] args)
JFrame frame = new JFrame("Test angled lines");
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
DrawingArea d = new DrawingArea();
frame.getContentPane().add( d );
frame.pack();
frame.setVisible(true);
}Change the AngledLine class to store two points instead of 3 points (I would rename the class to be StraightLine). The code is much simpler because you just store the starting and ending points and you don't need to calculate the middle point.
-
How to get text vertically centred in Li box
I am updating our company website in another area of the system which is why you'll see a tf in the web address I am about to give.
http://www.essentialfinance.net/tf/products/reconciling/accruals_manager.asp
Now, the problem I have is that the options in the boxes are aligned to the top.
I have had quite a problem understanding how to get these boxes to work so that they highlight when hovered etc, but eventually got there through some tutorial which seems to create a nav class hanging off the ul.
I have tried altering everything in the ul.nav, ul.nav li, ul.nav a regarding getting the text to vertical align centred but no success.
The css file is here:
http://www.essentialfinance.net/tf/main.css
I put that link in since someone may be able to pick out my faults.
I have only put a link to # (goes nowhere) to get the <a> code initialised.....
By the way - don't worry about the colour scheme... it's only temporary to test the functionality.
And I would not wander anywhere else in the site - it's a shambles which is why i'm looking at it.
Can anyone please advise? Thank you very much in advance for any feedback.
TerryThese forums are getting worse by the day. Try this link for the last time:
<http://www.mytechnet.talktalk.net/sidebar.txt>
If it works, it works otherwise tough luck. -
How to write text vertically in an table cell?
Is it possible to make a table cell where the
text would be written along a vertical base line?
I found how to make a text box and rotate it
vertically.
How may I place such a text box in a table cell?
danHello daniel,
if the table will not be resized or repositioned a lot, the best way to display what you want to have is to create a textbox with the styles and adjustments you need, rotate it and place it over the table cell. Be sure to make the cell big enough to pretend the text of the textbox would be inside of it. The textbox has to be a fix positioned object in the top layer.
It's only a work-around, but the best you can achieve.
Frank. -
How to create text vertically in ADOBE FORMS?
Hi all,
I need to create text in vertical position in ADOBE FORMS? How to do this..
<< Removed >>
Thanks
Devinder
Edited by: Rob Burbank on Mar 3, 2010 1:40 PMI will recommend you to use smart forms ...
the link below has the said topic discussed for smart forms ...
Printing vertical text in Smartform
Also there is a New tool called Adobe Flex whose integration with SAP is being discussed and worked upon in experimental stage .. the said tool has vertical text capability
but its not recommended because of lack of extensive testing with regards to Association with SAP
BR
Manthan.
PS it can be done in sapscript too but i will not recommend the same bcoz of the obvious trouble in doing the same.
also if u still want to stick to sapscript
Simple way is to use layout format like "X_65_80" or "X_90_120"
Edited by: Manthan_R on Mar 4, 2010 6:24 AM -
How to draw string vertically?
Hi,
The java drawString() method draws string horizontally by default, but I want to draw the string vertically, see an example below: I want to draw the string "abcdef" as below format:
a
b
c
d
e
f
so, I thought of the AffineTransform, but I can not work it out.
Who can help me? If you have other ways, they are welcome too.
Thanks. Robinimport java.awt.*;
import java.awt.font.*;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import javax.swing.*;
public class VText {
public static void main(String[] args) {
int w = 200, h = 300;
BufferedImage image = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setBackground(UIManager.getColor("OptionPane.background"));
g2.clearRect(0,0,w,h);
g2.setPaint(Color.black);
Font font = g2.getFont().deriveFont(18f);
g2.setFont(font);
FontRenderContext frc = g2.getFontRenderContext();
String text = "Hello World";
g2.drawString(text, 50, h - 25);
String[] s = text.split("(?<=[\\w\\s])");
float y = 25f;
for(int j = 0; j < s.length; j++) {
float width = (float)font.getStringBounds(s[j], frc).getWidth();
LineMetrics lm = font.getLineMetrics(s[j], frc);
float x = (w - width)/2;
AffineTransform at = AffineTransform.getTranslateInstance(x, y);
g2.setFont(font.deriveFont(at));
g2.drawString(s[j], 0, 0);
y += lm.getAscent();// - lm.getDescent();
g2.dispose();
JOptionPane.showMessageDialog(null, new ImageIcon(image), "",
JOptionPane.PLAIN_MESSAGE);
} -
How to delete text vertically in Pages
I have a log of text messages that me and my friend have had, and I want to delete the time informations from it. The example below will help you understand the situation.
2012/7/16 4:30, Me : Blah blah
2012/7/16 4:31, A : Blah blah
2012/7/16 4:32, Me : Blah blah
2012/7/16 4:33, Me : Blah blah
2012/7/17 9:34, A : Blah blah
2012/7/17 12:35, Me : Blah blah
2012/7/18 1:36, A : Blah blah
Now I want to delete the blue bits from the original text.
Thanks in advance.I was unaware that you couldn't Option-Click-Drag a selection in TextEdit. When I do it, it seems to work:
The screen shot shows that the text is RTF (Option to change to Plain Text is showing in Format menu).
Your observation regarding Pages allowing the selection and reformatting the text, but not allowing deletion, should mean that there isn't much of a code gap in that aspect of the app. I'll submit a Feedback enhancement request.
Jerry
Maybe you are looking for
-
TAX val determination code.
Hi experts, I hope someone can help me on where part VF01 did the value of tax value in accounting came from or computed.. TNX and have great day.
-
I've checked out several posts regarding the topic of Decoupling 0fi_ar_4 0fi_ap_4 from 0fi_gl_4, but unfortunatly still don't see my specific issue. We have PI 2004_1_46c, BW 3.0b. I found an OSS note 826023 that says it decouples the extractors.
-
Why are my .m4v downloads not playing correctly on QuickTime 7.0.4?
Can anyone out there help, please? I downloaded the Pixar shorts (.m4v format), which should only play on QuickTime. Except they aren't playing correctly: the picture is fine; the sound is stuttering and off-sync. BACKGROUND: I've got a mother of an
-
Can i use a different apple id for the apple store?
I wanted to have a seperate account for the apple store. Is this possible? anyone please help.
-
Best practices for speeding up Mail with large numbers of mail?
I have over 100,000 mails going back about 7 years in multiple accounts in dozens of folders using up nearly 3GB of disk space. Things are starting to drag - particularly when it comes to opening folders. I suspect the main problem is having large nu