IlvTextPath Sample

Article ID: 2272
Last updated: 29 May, 2018
Article ID: 2272
Last updated: 29 May, 2018
Revision: 3
Views: 588
Posted: 01 Mar, 2011
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

How to write a text along a path using IlvTextPath?

Answer

Below is a small sample which creates an IlvTextPath. You can move the nodes of the path by clicking it.

//---------------------------------------------------
// File MyTextPathSample.java
//---------------------------------------------------

import java.awt.Polygon;
import ilog.views.IlvDirection;
import ilog.views.IlvManager;
import ilog.views.IlvManagerView;
import ilog.views.IlvPoint;
import ilog.views.graphic.IlvTextPath;
import ilog.views.interactor.IlvSelectInteractor;
import ilog.views.swing.IlvJScrollManagerView;
import ilog.views.util.IlvProductUtil;

import javax.swing.JFrame;

public class MyTextPathSample
{
public static void main(String args[])
{
IlvProductUtil.DeploymentLicenseRequired(IlvProductUtil.Rogue_Wave_JViews_Enterprise_Deployment);

// Create a window
JFrame window = new JFrame("IlvTextPath Sample");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setBounds(20, 20, 600, 600);

// Add a manager to the window
IlvManager manager = new IlvManager();
IlvManagerView managerView = new IlvManagerView(manager);
window.getContentPane().add(new IlvJScrollManagerView(managerView));

// Define the points for the IlvTextPath
IlvPoint[] points = new IlvPoint[4];
points[0] = new IlvPoint(50,400);
points[1] = new IlvPoint(250,150);
points[2] = new IlvPoint(270,150);
points[3] = new IlvPoint(470,400);

// Create a Select Interactor
managerView.setInteractor(new IlvSelectInteractor());

// Create a Shape (Polygon implements Shape)
Polygon poly = new Polygon();
for (int i = 0 ; i<4 ; i++)
{
poly.addPoint( (int) points[i].getX(), (int) points[i].getY());

}

// Create a first IlvTextPath with the polygon's Shape
IlvTextPath textPath = new IlvTextPath(poly,
"*** Click on the path and you will be able to move its nodes *** Click on the path and you will be able to move its nodes ***",
IlvDirection.Left,
IlvDirection.Top,
5);

manager.addObject(textPath,false);

// Show the window
window.setVisible(true);
}
}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2272
Last updated: 29 May, 2018
Revision: 3
Views: 588
Posted: 01 Mar, 2011 by Dean J.
Updated: 29 May, 2018 by Gargani A.
Attached files

Also listed in


Others in this category