Total members 11895 |It is currently Tue Dec 03, 2024 7:21 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





draw text like a curve in java
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.font.*;
import java.awt.geom.*;

public class 
ShowTextCreateCurve extends JPanel {
  public 
void paint(Graphics g) {
    
Graphics2D g2d = (Graphics2Dg;

    
Font font = new Font("Arial Narrow"Font.ITALIC20);
    
FontRenderContext fontRenderContext g2d.getFontRenderContext();
    
g2d.translate(3060);

    
GlyphVector glyphVector font.createGlyphVector(fontRenderContext,
        
"Java is a platform independent language.");
    
int len glyphVector.getNumGlyphs();
    for (
int p 0lenp++) {
      
Point2D point glyphVector.getGlyphPosition(p);
      
double angle = (double) / (double) (len 1) * Math.PI 2.5;
      
AffineTransform affineTransform AffineTransform.getTranslateInstance(
          
point.getX(),point.getY());
      
affineTransform.rotate(angle);
      
Shape shape1 glyphVector.getGlyphOutline(p);
      
Shape shape2 affineTransform.createTransformedShape(shape1);
      
g2d.setPaint(Color.red);
      
g2d.fill(shape2);
    }
  }
  public static 
void main(String[] args) {
    
JFrame frame = new JFrame("Show Rolling Text");
    
frame.getContentPane().add(new ShowTextCreateCurve());
    
frame.setSize(550380);
    
frame.show();
  }





Attachments:
File comment: text curve
rollingText.gif
rollingText.gif [ 7.95 KiB | Viewed 5679 times ]

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada
Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : text like a curve
 Curve XY 2D     -  
 Draw Hermite Curve     -  
 Curve Control Point in java     -  
 Able to Copy Text from Uneditable Text Boxes(JTextfields)     -  
 Draw curves using Hermite Curve equations with mouse clicks     -  
 Draw Bezier Curve and selecting the points with mouse click     -  
 Java- Copy text area into disabled text area     -  
 draw 2d curve with showing x axis and y axis     -  
 i tag for italic text     -  
 Get Text Field value by php     -  



Topic Tags

Java Graphics






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com