Drawing verticle text
any one know how to use the paint method to draw verticle text. I search in the forums couldnt find anything. I would assign duke dollars for this but it wont let me.
thanks.
Kevin
If you want to draw real oriented text, try this:
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.plaf.basic.*;
public class VerticalLabelTest extends JFrame {
public static void main(String[] args) {
JLabel label1 = new JLabel("100,100 Label text (normal)");
label1.setSize(200, 20);
label1.setLocation(100, 100);
JLabel label2 = new JLabel("100,100 Label text (rotated 90�)");
label2.setUI(new VerticalLabelUI(true));
label2.setSize(200, 20);
label2.setLocation(100, 100);
JLabel label3 = new JLabel("120,120 Label text (rotated -90�)");
label3.setUI(new VerticalLabelUI(false));
label3.setSize(200, 20);
label3.setLocation(120, 120);
JPanel pmain = new JPanel();
pmain.setLayout(null);
pmain.add(label1);
pmain.add(label2);
pmain.add(label3);
JFrame fmain = new VerticalLabelTest();
fmain.setSize(500, 500);
fmain.getContentPane().add(pmain, BorderLayout.CENTER);
fmain.setVisible(true);
class VerticalLabelUI extends BasicLabelUI {
static {
labelUI = new VerticalLabelUI(false);
protected boolean clockwise;
VerticalLabelUI( boolean clockwise ) {
super();
this.clockwise = clockwise;
public Dimension getPreferredSize(JComponent c) {
Dimension dim = super.getPreferredSize(c);
return new Dimension( dim.height, dim.width );
private static Rectangle paintIconR = new Rectangle();
private static Rectangle paintTextR = new Rectangle();
private static Rectangle paintViewR = new Rectangle();
private static Insets paintViewInsets = new Insets(0, 0, 0, 0);
public void paint(Graphics g, JComponent c) {
JLabel label = (JLabel)c;
String text = label.getText();
Icon icon = (label.isEnabled()) ? label.getIcon() : label.getDisabledIcon();
if ((icon == null) && (text == null))return;
FontMetrics fm = g.getFontMetrics();
paintViewInsets = c.getInsets(paintViewInsets);
paintViewR.x = paintViewInsets.left;
paintViewR.y = paintViewInsets.top;
// Use inverted height & width
paintViewR.width = c.getWidth() - (paintViewInsets.left + paintViewInsets.right);
paintViewR.height = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);
paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
String clippedText = layoutCL(label, fm, text, icon, paintViewR, paintIconR, paintTextR);
paintViewR.height = c.getWidth() - (paintViewInsets.left + paintViewInsets.right);
paintViewR.width = c.getHeight() - (paintViewInsets.top + paintViewInsets.bottom);
Graphics2D g2 = (Graphics2D) g;
AffineTransform tr = g2.getTransform();
int wh = paintViewR.width;
if (wh < paintViewR.height) wh = paintViewR.height;
g2.setClip(0, 0, wh, wh);
if (clockwise) {
g2.rotate( Math.PI / 2 );
g2.translate( 0, - paintViewR.width );
else {
g2.rotate( - Math.PI / 2 );
g2.translate( - paintViewR.height, 0);
if (icon != null) icon.paintIcon(c, g, paintIconR.x, paintIconR.y);
if (text != null) {
int textX = paintTextR.x;
int textY = paintTextR.y + fm.getAscent();
if (label.isEnabled()) {
paintEnabledText(label, g2, clippedText, textX, textY);
else {
paintDisabledText(label, g2, clippedText, textX, textY);
g2.setTransform(tr);
}Hope this helped,
Regards.
Similar Messages
-
Cannot edit text in Drawing Markup Text Box
I cannot edit text in Drawing Markup Text Box after saving and closing the pdf file and then reopening it. I go to add additional text in the Text Box, and nothing happens.
Hope you can lend me a hand,
Richard
Adobe X Pro 10.1.4In the previous print screen, the layer icon has a paintbrush in it. In the new menu page I cut and pasted the text is still 'text' layer. I am not able to format it other than change font color. I want to make it two columns of text like the original pdf, and change the font.
-
Errors - drawing a text curve in flex with flex 3 with flex 3.5 framework
Is that necessary in drawing a text curve in flex we need flex 4 with flash player 10, actually i have flex 3 with flex 3.5 framework but it is showing error like this :
This is my code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.components.TextView;
public var myText:String = "Read my blog @ http://www.funnyjokesfunny.com";
var radius:Number = 125;
var spacing:Number = 8;
var center:Point = new Point(125,125);
public function drawText():void {
for (var char:uint=0;char<myText.length;char++) {
var tempText:TextView = new TextView();
tempText.x = radius * Math.cos(degrees2radians(char*spacing)) + center.x;
tempText.y = radius * Math.sin(degrees2radians(char*spacing)) + center.y;
tempText.rotation = 25;
tempText.text = myText.charAt(char);
textContainer.addChild(tempText);
]]>
</mx:Script>
<mx:Button label="Draw a circle" click="drawText()" />
<mx:Canvas id="textContainer" y="50" x="50" width="400" height="400" />
</mx:Application>
1) call to possibly undefined method Text View
2) Type was not found : Text view.
Please help me
AtishayI have now taken import mx.controls.Text;
instead of textview it works , but in dis example http://blog.shortfusion.com/index.cfm/2009/1/25/Circular-Text-In-Flex-Explained with source code they have taken textview control and it works for them for text curve. -
Unable To Use Flash Drawing Or Text Tools--Help!
I'm a Flash CS4 user and two days ago started having a strange problem--when I use any of the drawing or text tools in
Flash, my work disappears as soon as I let go of the mouse button! I've tried reinstalling Flash and that didn't work, and I can't think of any internal settings that could be causing this. And strangely, I'm running Fireworks CS4 on the same computer and am not having any problems with it. Has anyone experienced this? Any help would be appreciated.Flash Player 12.0.0.43 Plug-in (All other browsers)
First, use the Flash Player Uninstaller -
When I try to copy a drawing with text, it only pastes the text, can anyone help me?
adobe illustrator cs5Are your drawing layers locked and the text layers unlocked? So far it sounds as if the "Copy" command isn't grabbing anything but the text. I've had a similar problem with text not coming across when I saved my vector art as a raster image: for that I had to remove a compound path or something from the text before it would come over.
Make sure your layers (and sublayers) aren't locked, and check your compound paths and clipping masks to see if there's something funny going on. -
UITableViewCell draws its text white a white background
Has anyone had the problem where UITableViewCell draws its text with a white background, like this:
!http://homepage.mac.com/markkrenek/cellbackground.png!
This is a standard UITableViewCell in which I have specified has a background view, like this:
cell.backgroundView = [[[UIView alloc] initWithFrame:cell.bounds] autorelease];
cell.backgroundView.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
That's what's drawing gray. But the text label drawn by UITableViewCell draws with a white background obscuring a portion of the background view.
I've tried numerous things like setting the cell and its content view to use clearColor as their background. The issue, I believe, is that the UILabel that UITableViewCell uses needs to have its background color set to clearColor. But there's no way to access that through the UITableViewCell API.As I mentioned, when I used a built in template, like contemporary, it worked too. The problem only happened with the IBA that I was given. Perhaps the previous owner of the file had accidentally chosen Format/Advanced/Define Default Glossary Style when they had some white on white displayed and caused all the formatting for the glossary to be the same. I was able to fix it using that menu path.
I'm not sure what fixing it in the "source file" means. I was trying to fix it in the IBA file. Not sure where else I would have fixed it. -
Drawing rotated text revisited.....
Hello again,
I've recently started fiddling with an app that had a method to draw Strings at given Points on a custom JComponent, now I'm trying to extend it to draw the same strings, but throw in an angle should the user choose to do so. But... now here's the part thats foxing me, I want the Point specified to be the center of the String....., i've had a couple of goes, but as soon as the rotation comes in, it goes pair shaped (not literally ;-) , metaphorically).
Here's some of the code I'm working on, feel free to point bad coding and glaringly obvious problems! I'm aware it doesn't quite do "exactly what it says on the tin", but its definitely a step in the right direction. It should work, but it doesn't. Thoughts anyone?
/** Method to draw a text label to a specified graphics context.
@param g2 The graphics context to draw to.
@param text The label text to draw.
@param font The font in which to draw the label.
@param color The color of the label.
@param angle The angle at which to draw , 0 = horizontal, 90 = vertical.
@param position The Point at which to draw the label.*/
public static void drawLabel(Graphics2D g2, String text, Font font, Color color, int angle, Point position)
//get x,y coordinates from Point
int x = new Double(position.getX()).intValue();
int y = new Double(position.getY()).intValue();
//rotate the point by the required angle
x = (new Double((x*Math.cos(Math.toRadians(angle)))-(y*Math.sin(Math.toRadians(angle)))).intValue());
y = (new Double((-x*Math.sin(Math.toRadians(angle)))+(y*Math.cos(Math.toRadians(angle)))).intValue());
// get the current transform
AffineTransform startMatrix = g2.getTransform();
// make a new one...
AffineTransform rotationMatrix = new AffineTransform();
// set the text layout
TextLayout tl = new TextLayout(text,font,g2.getFontRenderContext());
// rotate the shiny new transform
rotationMatrix.rotate(Math.toRadians(angle));
// appy it to g2
g2.transform(rotationMatrix);
//set the color of the label
g2.setPaint(color);
//draw the label
tl.draw(g2,x,y);
//restore the transform for g2
g2.setTransform(startMatrix);
}Also I haven't sorted the drawing relative to the center of the string bit yet, so any advice on how to do this would be great.
Cheers,
TomThis is straightforward, once you understand transforms. I'm surprised no one's answered this yet. Here's an example:
import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
public class TestRotate extends Frame {
public static void main(String[] args) {
new TestRotate().setVisible(true);
private TestRotate() {
super("Rotated Text");
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
setFont(new Font("default", Font.PLAIN, 24));
setSize(300, 300);
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
TextLayout layout = new TextLayout(
"This is a string to rotate",
g2d.getFont(),
g2d.getFontRenderContext());
Insets ins = getInsets();
Dimension dim = getSize();
Point center = new Point(
ins.left + (dim.width - ins.left - ins.right) / 2,
ins.top + (dim.height - ins.top - ins.bottom) / 2);
g2d.translate(center.x, center.y);
g2d.rotate(Math.PI / 4);
layout.draw(g2d, -layout.getAdvance() / 2, 0); -
Hello,
How to upload the sample drawing long text using LSMW?
can u pls advice me.
Thanks
SouHi Bhanu,
I am using same program,in that i hava some douts like..
i am traying to upload long text using T.code QPv2.
in that One drawing prcodere several partial numbers like 10,20 etc..
my requirment is they are giving one drawing procedure and different partial nos,in the parial nos we have multiple line texts.
in LSMW how to maintain parial numbers realted..
Please suggested me.
Thanks
Sou -
How use mouse draw a text select area on a PDF?
Hi All,
I am developing a small vb.net program to allow user select a area on PDF and extract the text.
I know some code below can extract text
RectAry.Left = 0
RectAry.right = rect.x
RectAry.bottom = 630
RectAry.Top = 703
txt = gPDDoc.CreateTextSelect(lngPage, RectAry)
My problem is how to know those four position value by looking at PDF.
Advanced achivement is how to let customer draw a box on that demanding area and my program pickup those four values.
If you could give me a code snippet, I am really appricate your time.
thank youThanks, Leonard. I am following your instrcution and making progress now.
But I had another small issue. It is regarding the coordinate value.
I tried to use arobat's "CORP" function to get the top, bottom, left, right (Because this is the only way I know to get coordinate values). Then set into select rectange parameters. I found if I put the CORP to close the text, the select rectange cannot get the text from the area.
But my CORP area is definitely include all texts and still leave a small margin to the word. If i want to get the text, I have to change the parameters a little bit and enlarge the area by a few points. Then It works.
I want to know if Acrobat SDK require a minmum margin to selected text? -
Drawing graphics Text when using unequal scaletransform.
Here is a problem that pops up when drawing.
There are many times we need to draw using a separate scale for the x and y axis. Like a graph that ranges x = 0 to 100 and y = 0 to 10.
The
graphics.scaletransform method allows us to set the two scales and draw easily. But a problem occurs with the pen width. It only has one dimension. So it will be a different size in the x direction from the y direction. You can see in the image the green
vertical line is a constant width and the horz green line is changing widths. The diagonal lines and ellipse are way to wide as well. And look at the text! It is changing size too.
I just discovered there is a scaletransform for the pen and using that solves the problem for the lines as shown in the code and image below.
As you can see the text has a similar problem. Does anyone have a solution for sizing text?
Here is the code example.
Public Class Form3
Private Sub Form3_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
Dim sx, sy, theScalex As Single
Dim w As Integer = Me.ClientSize.Width
Dim h As Integer = Me.ClientSize.Height
Dim theScaley As Single = 20
Dim display As String
sy = h / theScaley
With e.Graphics
Using p As New Pen(Brushes.Red)
.Clear(Color.Black)
For y As Single = 1 To theScaley Step 5
theScalex = theScaley / 5 * y
sx = (w / theScalex)
.ResetTransform()
.ScaleTransform(sx, sy)
.TranslateTransform(theScalex / 2, y)
p.Width = theScalex / 100
'add this to make the line widths same size x and y directions
p.ScaleTransform(1 / theScalex, 1 / theScaley)
p.Color = Color.Red
.DrawLine(p, 0, 0, theScalex / 5, theScaley / 5)
p.Color = Color.Green
.DrawLine(p, 0, 0, theScalex / 5, 0)
.DrawLine(p, 0, 0, 0, theScaley / 5)
p.Color = Color.Blue
.DrawEllipse(p, 0, 0, theScalex / 5, theScaley / 5)
.TranslateTransform(-theScalex / 2, 0)
display = "sx: " & sx.ToString("f3") & " pen: " & p.Width.ToString
.DrawString(display, New Font("Arial", theScaley / 20), Brushes.White, 0, 0)
Next
End Using
End With
End Sub
Private Sub Form3_Resize(sender As Object, e As EventArgs) Handles Me.Resize
Me.Refresh()
End Sub
End ClassHere is a better example for anyone interested. Use the numericupdown in the upper right to change the x axis scale by the numeric ratio.
You can see in the first image with the numeric scaleratio at 1:1 the scale is 10 for the x and y axis. The grid and diagonal lines are all the same width.
In the second image the scale ratio is 5:1 where the x axis is 50 units, the y is 10. Note the vertical grid lines are thin and the horizontal and diagonal lines are fat x 5:1.
The third picture shows how using the pen.scaletransform to reverse the x axis scaling makes the horizontal lines the same width as the vertical at 5:1. Check the checkbox to activate.
Finally, note how the grid axis labels text is changing size horizontally when the scaling transform is active. Then the X Axis Scale at the bottom has been drawn by resetting the transform to nothing or 1:1 and manually scaling the text location in pixels
and the text is the proper width and height.
The example code will also animate if the timer part is activated.
Public Class Form6
Private WithEvents timer1 As New Windows.Forms.Timer With {.Interval = 50, .Enabled = False}
Private scaleXratio As Single = 1
Private Sub Form6_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.DoubleBuffered = True
End Sub
Private Sub Form6_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
If Not timer1.Enabled Then scaleXratio = NumericUpDown1.Value
Dim scalestepx As Single
Dim scaleY As Single = 10
Dim scaleX As Single = scaleY * scaleXratio
Dim sx As Single = Me.ClientSize.Width / scaleX
Dim sy As Single = Me.ClientSize.Height / scaleY
Dim x, y As Single
With e.Graphics
Using p As New Pen(Brushes.Red)
.Clear(Color.Black)
.ScaleTransform(sx, sy)
p.Color = Color.LightBlue
p.Width = scaleX / 100
'add this scaling to keep the pen width constanat
If CheckBox1.Checked Then p.ScaleTransform(1, scaleY / scaleX)
Select Case scaleXratio
Case Is < 5
scalestepx = 2
Case Is < 10
scalestepx = 5
Case Is < 20
scalestepx = 10
Case Else
scalestepx = 20
End Select
For y = 0 To scaleY Step 2
For x = 0 To scaleX Step scalestepx
.DrawLine(p, x, 0, x, scaleY)
.DrawLine(p, 0, y, scaleX, y)
.DrawString(x.ToString("f0"), New Font("Arial", 18 / sy), Brushes.White, x + p.Width, p.Width)
.DrawString(y.ToString("f0"), New Font("Arial", 18 / sy), Brushes.White, p.Width, y + p.Width)
Next
Next
'draw diagonal line
p.Color = Color.Goldenrod
.DrawLine(p, 0, 0, scaleX, scaleY)
'draw the scale text using current scaletransform
.DrawString(scaleX.ToString("f3"), New Font("Arial", 24 / sy), Brushes.Red, 0.1 * scaleY, 0.6 * scaleY)
'draw the scale text at bottom using pixels with no transfrom
.ResetTransform()
x = 10
y = Me.ClientSize.Height - 30
Using f As New Font("Arial", 14)
Dim t As String = "X Axis Scale: " & scaleX.ToString("f3")
Dim sz As SizeF = .MeasureString(t, f)
.FillRectangle(Brushes.White, New RectangleF(x, y, sz.Width, sz.Height))
.DrawString(t, f, Brushes.Red, x, y)
End Using
End Using
End With
End Sub
Private Sub NumericUpDown1_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown1.ValueChanged
Me.Refresh()
End Sub
Private Sub Form6_Resize(sender As Object, e As EventArgs) Handles Me.Resize
Me.Refresh()
End Sub
Private Sub timer1_Tick(sender As Object, e As EventArgs) Handles timer1.Tick
scaleXratio += 1
If scaleXratio > 100 Then timer1.Stop()
Me.Refresh()
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
Me.Refresh()
End Sub
End Class -
Overriding javax.swing.JButton and drawing the text
I am overriding the javax.swing.JButton paintComponent() I would like to know how to center the text on the button
here is part of the code, the text is printed near the end:
((java.awt.Graphics2D)grph2d).setRenderingHint(
java.awt.RenderingHints.KEY_ANTIALIASING,
java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
grph2d.setColor(new java.awt.Color(0.0f,1.0f,0.0f,1f));
grph2d.fillRect(0,0,getWidth(),getHeight());
if(!this.model.isRollover()){
grph2d.setColor(new java.awt.Color(0,125,0));
grph2d.fillRect(0,0,getWidth(),getHeight());
if(model.isPressed()){
grph2d.setColor(new java.awt.Color(1f,0f,0f,1f));
grph2d.fillOval(0,0,getWidth(),getHeight());
if(model.isArmed()){
grph2d.setColor(new java.awt.Color(0f,0f,1f,1f));
grph2d.fillOval(0,0,getWidth(),getHeight());
grph2d.setColor(new java.awt.Color(0.0f,0.0f,0.0f));
// text draws but isn't centered very well
grph2d.drawString(this.getText(),
this.getMargin().left + getX(),
this.getMargin().top + getY());is there any way to auto center the text, or calculate the length of the text in pixels.grph2d.drawString(this.getText(),
getWidth()/2 - (grph2d.getFontMetrics().stringWidth(getText())/2),
grph2d.getFontMetrics().getHeight());thanks! works much better now. -
Does anyone know of a reliable way to draw text vertically?
I'd like to draw it on a JPanel. Should I use JLabel and override paintComponent() or use Canvas and override paint()?
I've tried both ways mentioned above, using the Graphics2D.rotate method to rotate the text, but it just seems to paint some unrecognizable junk. I used null layout on the JPanel and set the bounds properly each time.
I've searched the web and haven't found anything simple. Any ideas would be great! Thanks!import java.awt.*;
import java.awt.geom.AffineTransform;
//import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame {
boolean flag = false;
private static final Color[] colors = {Color.red,Color.blue,Color.cyan,Color.green};
public Test() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container content = getContentPane();
content.setLayout(new FlowLayout());
JPanel p = new JPanel() {
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
AffineTransform at = new AffineTransform();
at.setToTranslation(getWidth()/2,getHeight()/2);
g2d.transform(at);
at.setToRotation(-Math.PI/2);
for (int i=0; i<4; i++) {
g2d.setColor(colors[ i]);
g2d.transform(at);
g2d.drawString("Hello",0,0);
p.setPreferredSize(new Dimension(60,60));
content.add(p);
setSize(100,100);
show();
public static void main(String[] args) { new Test(); }
} -
Drawing for text and string fails using X server(xsun) xlib
Hi all,
I have sparc system and Iam using xsun on solaris 10 and ps -ef | grep
-i xsun gives this:
/usr/openwin/bin/Xsun :0 nkeyboard nmouse -dev vfb -dev vfb screen 0
1028x102
Now I am trying to use XDrawString and XDrawText for simple one
character drawing but to no avail as these calls don't generate
anything. All line generation and bitmap are rendered correctly on the
virtual frame buffer to generate a tiff file.
The same set of calls are working great on sun 2.6.
What can be the problem? I can't seem to find any solution to that?
////////////////////// These calls fail completely returnig
0 ////////////////////////////////////
CR_CHAR Temp[2];
Temp[1] = 0;
Temp[0] = textString;
int rt = XDrawString(_CRDisplay, *pagePixmap, CRGC, xPos, yPos, Temp,
1);
XTextItem item;
item.chars = Temp;
item.nchars = 1;
item.delta = 0;
item.font = 0;
int rt = XDrawText(_CRDisplay, *pagePixmap, CRGC, xPos, yPos, &item,
1);
Regards,
RUIPartial Solution Found
I used the method below to boot single-user from GRUB.
<URL:http://docs.sun.com/app/docs/doc/817-1985/>
Solaris 10 System Administrator Collection >>
System Administration Guide: Basic Administration >>
11. x86: GRUB Based Booting (Tasks) >>
x86: Booting a System in the GRUB Based Boot Environment >>
x86: How to Boot a System to Run Level S (Single-User Level)
Now I can login as root in single-user level.
I installed NVIDIA-Solaris-x86-169.12.run driver file successfully.
I used the /usr/X11/bin/xorgconfig command to create a basic xorg.conf
file. After reboot it locked up when I tried to start the graphics login.
From what I have read I need to use kdmconfig to change from Xsun
server to Xorg server but when I try to run the command kdmconfig I
get the message kdmconfig not found.
New Questions:
1. Where is kdmconfig located and how do I start kdmconfig?
2. Is there some other method to change from Xsun server to Xorg server?
3. In single-user level what command do I use to startx?
Thanks in advance,
Ken -
After updating my macbook to Maverick, PS 7 I had for years stop working. I then download the Elements 12. It has been a few weeks and I can't do anything on it. I quit every time but tI had to come forward because a friend asked to do her wedding invitation. I downloading an image and background, put everything together, and when saving it... BAM! I've that first message "could not complete your request..." I tried several solutions i found on forums, somehow the image is saved as I wanted, it took all day long working on it, i don't even know what got it right. Now I am working on the writing and every time I draw the text box, i get the "could not complete your request..." then I hot "OK" and I get the "an unexpected and unrecoverable problem occurred..." photoshop quits!
About my mac OSX 10.9.4
2 GHZ Intel Core 2 Duo
4 GB 1067 MHz DDR3
72.62 GB free out of 159.18
Please Help!!!
Error Code: 0x02000148
Trap Number: 133After updating my macbook to Maverick, PS 7 I had for years stop working. I then download the Elements 12. It has been a few weeks and I can't do anything on it. I quit every time but tI had to come forward because a friend asked to do her wedding invitation. I downloading an image and background, put everything together, and when saving it... BAM! I've that first message "could not complete your request..." I tried several solutions i found on forums, somehow the image is saved as I wanted, it took all day long working on it, i don't even know what got it right. Now I am working on the writing and every time I draw the text box, i get the "could not complete your request..." then I hot "OK" and I get the "an unexpected and unrecoverable problem occurred..." photoshop quits!
About my mac OSX 10.9.4
2 GHZ Intel Core 2 Duo
4 GB 1067 MHz DDR3
72.62 GB free out of 159.18
Please Help!!!
Error Code: 0x02000148
Trap Number: 133 -
Are you drawing text at an angle with TextRenderer?
This is a question for folks that are aware of the difference in quality of output between TextRenderer.DrawText and (Graphics.DrawString + Graphics.TextRenderingHint = Text.TextRenderingHint.AntiAlias). It is an issue that has been discussed by others,
elsewhere, without resolution, and I'm simply asking if anyone has come up with a workaround.
I want to render text in the quality of TextRenderer.DrawText, at right angles or upside down. TextFormatFlags.PreserveGraphicsTranslateTransform ignores calls to RotateTransform on the Graphics object that exposes IDeviceContext to DrawText, and DrawText doesn't
play nicely with bitmaps.
Has anyone figured out a way to draw text at the same quality provided by TextRenderer.DrawText, at an angle other than 0 degrees?
(For those who need a back story to prove to you that I cannot use a Label or Graphics.DrawString for this, here you go.
There is a cat stuck in a tree in my back yard. I would like to rescue him, but there is a troll standing between me and the tree. He's a nasty troll, but on TV he plays a happy-go-lucky helpful troll, so when I call the police to complain, they just laugh
at me. "Ha! You can't fool us! We watch TV!"
The troll will allow me to reach the cat if I provide him with a UserControl that renders text at the same quality as the Windows.Forms.Label control, but at angles 90, 180 and -90 degrees. He is a clever troll in that he notices details between shoddy and
neat; rough and smooth; ugly and pretty; cat and honey badger. Therefore, I have not been able to fool him into thinking that ugly text is pretty by asserting that ugly text is pretty. Argh. I dislike this troll.)And this has to do with
Usability Steven's
issue in what fasion and why are you responding to somebody elses issue
Mick Doherty? Or is this just for my information?
La vida loca
Hi Monkey
This was mainly for info, but the OP did question the difference between GDI and GDIPlus methods of drawing rotated text. Your example only provides a GDIPlus method.
GDI does not respect the Graphics objects rotations, but so long as the PreserveGraphicsTranslateTransform flag is set it will respect Translations.
Here's a simple example to highlight the issue:
Public Class Form1
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.SetStyle(ControlStyles.ResizeRedraw, True)
End Sub
Private Sub Form1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim testString As String = "My Test String"
Dim angle As Single = 0
If Me.CheckBox1.Checked Then angle = 180
Using testFont As New Font("Arial", 24, FontStyle.Regular, GraphicsUnit.Point)
Dim rc As Rectangle = Me.ClientRectangle
rc.Offset(0, -24)
Me.DrawRotatedGDIText(e.Graphics, testString, testFont, rc, Color.Red, angle)
rc.Offset(0, 48)
Me.DrawRotatedGDIPlusText(e.Graphics, testString, testFont, rc, Color.Black, angle)
End Using
End Sub
Private Sub CheckBox1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged
Me.Invalidate()
End Sub
Private Sub DrawRotatedGDIText(graphics As Graphics, text As String, font As Font, bounds As Rectangle, color As Color, rotation As Single)
Dim sz As Size = TextRenderer.MeasureText(text, font)
Dim centre As Point = bounds.Location
centre.Offset(bounds.Width \ 2, bounds.Height \ 2)
Dim offset As Point = New Point(-sz.Width \ 2, -sz.Height \ 2)
graphics.TranslateTransform(centre.X, centre.Y)
graphics.RotateTransform(rotation)
TextRenderer.DrawText(graphics, text, font, offset, color, TextFormatFlags.PreserveGraphicsTranslateTransform)
graphics.ResetTransform()
End Sub
Private Sub DrawRotatedGDIPlusText(graphics As Graphics, text As String, font As Font, bounds As Rectangle, color As Color, rotation As Single)
Dim sz As Size = graphics.MeasureString(text, font).ToSize
Dim centre As Point = bounds.Location
centre.Offset(bounds.Width \ 2, bounds.Height \ 2)
Dim offset As Point = New Point(-sz.Width \ 2, -sz.Height \ 2)
graphics.TranslateTransform(centre.X, centre.Y)
graphics.RotateTransform(rotation)
Using myBrush As New SolidBrush(color)
graphics.DrawString(text, font, myBrush, offset)
End Using
graphics.ResetTransform()
End Sub
End Class
Here you can see the GDI string (red text) is rendered differently to the GDI Plus string (black text) i.e. the GDI Plus text is longer. Both strings have been rendered to the correct location as set by the graphics transformation:
Here a Rotation to the graphics object has been performed, but the GDi method has totally ignored it:
As a rule, Win32 based controls render with GDI rather than GDI+ and so if we wish to draw a custom control which appears similar to a Win32 based control we need to render with GDI. If you've ever tried to ownerdraw a tabcontrol then you will have noticed
that the text does not always fit on the tabs if we've used GDI+. using GDI the text fits perfectly, but when we side align the tabs the text does not rotate. We can, as the OP has done, draw unrotated text to a bitmap and then rotate the bitmap and this
works well if we have a solid background. If we have a textured background however, this method is not acceptable.
Mick Doherty
http://dotnetrix.co.uk
http://glassui.codeplex.com
Maybe you are looking for
-
10.6.8 Freezes Mac Pro
Guys, Hopefully someone can help! My Mac Pro has worked flawlessly for over 2 years BUT the latest 10.6.8 upgrade is creating a nightmare for me - the machine randomly hangs (not always the same program), sometimes it won't even empty the trash unles
-
Permissions all_tab_columns
Hello to everybody, I've got a small problem. I have got a function which compairs the tables and colums of two schemas of the same data base. this function is defined in one of the two schemas. The function has two querys : select count(*) from all_
-
Solaris 10 Installation - Help Needed Please
Hi, I have just downloaded a copy of Solaris 10 and I cannot get it to install on my system. At the moment I am using the GUI to try and install the OS. I can get past the part where you select the language 0 for english.... It then thinks about it f
-
Hi, I've a split join flow developed using Oracle Service Bus Plug-ins for Workshop for WebLogic. I wanted to debug it using breakpoints. I've followed the "Using the Oracle Service Bus Debugger" section in eclipsehelp.pdf When I try to run the split
-
Hi there We have iMacs at the college running 10.6.6. They came with iLife09 installed and I have also purchased iLife 11. iPhoto won't open and keeps asking for an update. Since we're not on the internet (it's a secure college) I installed iLife 11