Help converting my class to Paint

A while back I wrote this class, ColorGradient (see below)
Before you start telling me about GradientPaint, this class is pretty different from GradientPaint - it handles multiple colors, and it doesn't cycle (last color goes on forever)
The way I built it at the time was to extend BufferedImage and draw on that. I got critique at the time suggesting that I should detach it from being a BufferedImage; I agree, it would be great if I could turn this class into a Paint, where here is no Image, just basically the algorithm for creating a multicolor color gradient.
From what I know, it seems like creating my own implementation of Paint could be the way to go. Looking into this, it isn't Paint that confuses me so much as how to create a SampleModel and a Raster. I just took a stab at creating a SampleModel - it seems like I've got to give it a width and a height, which I already didn't want to do.
Anyone have any experience with this, or advice about the best way to decouple the painting algorithm from a BufferedImage?
* Created on Jun 14, 2006 by @author Tom Jacobs
package tjacobs.ui.ex;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import tjacobs.MathUtils;
import tjacobs.print.StandardPrint;
import tjacobs.ui.drag.Draggable;
import tjacobs.ui.shape.PolygonFactory;
import tjacobs.ui.util.WindowUtilities;
public class ColorGradient extends BufferedImage {
     private Color[] mColors;
     private double mSpan;
     private Point mCenter;
     private int mOrientation;
     private boolean mAutoRender = false;
     private boolean mOptimized;
     private int[] mDrawColors;
     public static final int BOTH_EUCLID = 0;
     public static final int HORIZONTAL = 1;
     public static final int VERTICAL = 2;
     public static final int BOTH_MANHATTAN = 3;
     public ColorGradient(int width, int height) {
          super(width, height, BufferedImage.TYPE_INT_RGB);
          setSpan(MathUtils.distance(width, height) / 7);
          setCenter(0,0);
          setOrientation(BOTH_EUCLID);
          setColors(getROYGBIV());
          render();
          mAutoRender = true;
     public void setAutoRender(boolean b) {
          mAutoRender = b;
     public boolean getAutoRender() {
          return mAutoRender;
     public ColorGradient(int width, int height, boolean autoRender) {
          this(width, height);
          mAutoRender = autoRender;
      * sets the span of the color gradient
     public void setSpan(double d) {
          mSpan = d;
          if (mAutoRender) {
               render();
     public double getSpan() {
          return mSpan;
      * sets the center of the color gradient. Default is 0,0
     public void setCenter(int x, int y) {
          if (mCenter == null) {
               mCenter = new Point(x,y);
          else {
               mCenter.x = x; mCenter.y = y;
          if (mAutoRender) render();
     public Point getCenter() {
          return mCenter;
      * sets the colors to use in the color gradient. Default is ROYGBIV
     public void setColors(Color[] colors) {
          mColors = colors;
          if (mAutoRender) render();
     public Color[] getColors() {
          return mColors;
     public int getOrientation() {
          return mOrientation;
      * sets the orientation of the gradient in case you want a gradient
      * just in one direction. default is both directions
     public void setOrientation(int orientation) {
          mOrientation = orientation;
          if (mAutoRender) render();
     protected double getScore(int CenterX, int CenterY, int x2, int y2) {
          double distance = 0;
          if (mOrientation == BOTH_EUCLID) {
                distance = MathUtils.distance(CenterX, CenterY, x2, y2);
          else if (mOrientation == BOTH_MANHATTAN) {
               distance = (Math.abs(CenterX - x2) + Math.abs(CenterY - y2)) / 2;
          else if (mOrientation == HORIZONTAL) {
               distance = Math.abs(CenterX - x2);
          else {
               distance = Math.abs(CenterY - y2);
          return distance;
     public void renderMoveCenter(int x1, int y1, int x2, int y2) {
          if (mColors == null) {
               return;
          int width = getWidth();
          int height = getHeight();
          int x = mCenter.x;
          int y = mCenter.y;
          float parts1[] = new float[3], parts2[] = new float[3], partsEnd[] = new float[3];
          int xDiff = x2 - x1;
          int yDiff = y2 - y1;
          int absXDiff = xDiff, absYDiff = yDiff;
          if (absXDiff < 0) absXDiff = -absXDiff;
          if (absYDiff < 0) absYDiff = -absYDiff;
          if (xDiff >= 0) {
               for (int i = width - 1; i < width - absXDiff ; i--) {
                    if (yDiff >= 0) {
                         for (int j = height - 1; j < height -absYDiff; j--) {
          else {
               for (int i = 0; i < width - absXDiff ; i++) {
          for (int i = 0; i < width - absXDiff ; i++) {
               for (int j = 0; j < height - absYDiff; j++) {
                    double distance;
                    double seg;
                    int low;
                    int high;
                    distance = getScore(x, y, i, j);
                    seg = distance / mSpan;
                    low = (int) seg;
                    high = low + 1;
                    if (low >= mColors.length) {
                         low = mColors.length - 1;
                         high = low;
                    if (high >= mColors.length) {
                         high = mColors.length - 1;
                    float lowPart = (float) seg - low ;
                    mColors[low].getColorComponents(parts1);
                    mColors[high].getColorComponents(parts2);
                    float hipart = (1 - lowPart);
                    for (int k = 0; k < 3; k++) {
                         partsEnd[k] = parts2[k] * lowPart + parts1[k] * hipart;
                    int rgb = (((int) (partsEnd[0]*255+0.5)) & 0xff) << 16 |
                    (((int) (partsEnd[1]*255+0.5)) & 0xff) << 8 |
                    (((int) (partsEnd[2]*255+0.5)) & 0xff);
                    super.setRGB(i, j, rgb);
     public void render() {
          if (mColors == null) {
               return;
          int width = getWidth();
          int height = getHeight();
          int x = mCenter.x;
          int y = mCenter.y;
          if (!mOptimized) {
               float parts1[] = new float[3], parts2[] = new float[3], partsEnd[] = new float[3];
               for (int i = 0; i < width; i++) {
                    for (int j = 0; j < height; j++) {
                         double distance = getScore(x, y, i, j);
                         double seg = distance / mSpan;
                         int low = (int) seg;
                         int high = low + 1;
                         if (low >= mColors.length) {
                              low = mColors.length - 1;
                              high = low;
                         if (high >= mColors.length) {
                              high = mColors.length - 1;
                         float lowPart = (float) seg - low ;
                         mColors[low].getColorComponents(parts1);
                         mColors[high].getColorComponents(parts2);
                         float hipart = (1 - lowPart);
                         for (int k = 0; k < 3; k++) {
                              partsEnd[k] = parts2[k] * lowPart + parts1[k] * hipart;
                         int rgb = (((int) (partsEnd[0]*255+0.5)) & 0xff) << 16 |
                         (((int) (partsEnd[1]*255+0.5)) & 0xff) << 8 |
                         (((int) (partsEnd[2]*255+0.5)) & 0xff);
                         super.setRGB(i, j, rgb);
          } else {
               for (int i = 0; i < width; i++) {
                    for (int j = 0; j < height; j++) {
                         int distance = (int)Math.round(getScore(x, y, i, j));
                         if (distance >= mDrawColors.length) {
                              distance = mDrawColors.length - 1;
                         setRGB(i, j, mDrawColors[distance]);
     public static Color[] getROYGBIV() {
          return new Color[] {Color.RED, Color.ORANGE, Color.YELLOW,
                                   Color.GREEN, Color.BLUE,
                                   new Color(75, 0, 130), Color.MAGENTA};
     public static class GradientPane extends JComponent {
          private static final long serialVersionUID = 0;
          private ColorGradient mGradient;
          private JPopupMenu mPopup;
          private MouseListener mPopupListener;
          public class ReportColorMenuItem extends ColorMenuItem {
               private static final long serialVersionUID = 0;
               public ReportColorMenuItem(Color c) {
                    super(c);
               public ReportColorMenuItem(Color c, boolean addListener) {
                    super(c, addListener);
               public void setColor(Color c) {
                    super.setColor(c);
                    updateColorsFromPopup();
          public GradientPane(int width, int height) {
               setSize(width, height);
               setPreferredSize(new Dimension(width, height));
               mGradient = new ColorGradient(width, height);
               mGradient.render();
          public ColorGradient getGradient() {
               return mGradient;
          private void updateColorsFromPopup() {
               Color[] colors = new Color[mPopup.getComponentCount() - 2];
               for (int i = 0; i < colors.length; i++) {
                    colors[i] = ((ColorMenuItem)mPopup.getComponent(i)).getColor();
               getGradient().setColors(colors);
               if (!getGradient().getAutoRender()) {
                    getGradient().render();
               repaint();
          public void useColorSelectorPopup(boolean b) {
               if (b && mPopup == null) {
                    mPopup = new JPopupMenu();
                    ColorGradient grad = getGradient();
                    Color[] colors = grad.getColors();
                    for (int i = 0; i < colors.length; i++) {
                         mPopup.add(new ReportColorMenuItem(colors));
                    final JMenu remove = new JMenu("Remove");
                    ActionListener al = new ActionListener() {
                         public void actionPerformed(ActionEvent ae) {
                              //int num = Integer.parseInt(ae.getActionCommand());
                              int num = -1;
                              Object src = ae.getSource();
                              for (int i = 0; i < remove.getMenuComponentCount(); i++) {
                                   if (remove.getMenuComponent(i) == src) {
                                        num = i;
                                        break;
                              if (num == -1) {
                                   System.out.println("Trouble");
                              getGradient().removeColor(num);
                              repaint();
                              mPopup.remove(num);
                              remove.remove(num);
                    for (int i = 0; i < colors.length; i++) {
                         JMenuItem item = new ColorMenuItem(colors[i], false);
                         item.setActionCommand(String.valueOf(i));
                         item.addActionListener(al);
                         remove.add(item);
                    JMenuItem add = new JMenuItem("Add");
                    add.addActionListener(new ActionListener() {
                         public void actionPerformed(ActionEvent ae) {
                              JMenuItem src = (JMenuItem) ae.getSource();
                              mPopup.remove(src);
                              mPopup.remove(remove);
                              Color toAdd = Color.WHITE;
                              mPopup.add(new ReportColorMenuItem(toAdd));
                              ColorGradient cg = getGradient();
                              cg.addColor(toAdd);
                              if (!cg.getAutoRender()) {
                                   cg.render();
                              mPopup.add(src);
                              mPopup.add(remove);
                              remove.add(new ReportColorMenuItem(toAdd, false));
                              repaint();
                    mPopup.add(add);
                    mPopup.add(remove);
                    mPopupListener = WindowUtilities.addAsPopup(mPopup, this);
               else if (!b && mPopup != null) {
                    mPopup = null;
                    removeMouseListener(mPopupListener);
                    mPopupListener = null;
          public void paintComponent(Graphics g) {
               g.drawImage(mGradient, 0, 0, null);
     public void addColor(Color c) {
          Color[] nc = new Color[mColors.length + 1];
          for (int i = 0; i < mColors.length; i++) {
               nc[i] = mColors[i];
          nc[nc.length - 1] = c;
          mColors = nc;
          render();
     public void removeColor(int colorNum) {
          Color[] nc = new Color[mColors.length -1];
          for (int i = 0; i < mColors.length - 1; i++) {
               nc[i] = mColors[i < colorNum ? i : i + 1];
          mColors = nc;
          render();
     public void setOptimized(boolean b) {
          mOptimized = b;
          if (b) {
               int maxDistance = (int) MathUtils.distance(getWidth(), getHeight()) + 1;
               mDrawColors = new int[maxDistance];
               float[] parts1 = new float[3], parts2 = new float[3], partsEnd = new float[3];
               for (int distance = 0; distance < maxDistance; distance++) {
                    double seg = distance / mSpan;
                    int low = (int) seg;
                    int high = low + 1;
                    if (low >= mColors.length) {
                         low = mColors.length - 1;
                         high = low;
                    if (high >= mColors.length) {
                         high = mColors.length - 1;
                    float lowPart = (float) seg - low ;
                    mColors[low].getColorComponents(parts1);
                    mColors[high].getColorComponents(parts2);
                    float hipart = (1 - lowPart);
                    for (int k = 0; k < 3; k++) {
                         partsEnd[k] = parts2[k] * lowPart + parts1[k] * hipart;
                    int rgb = (((int) (partsEnd[0]*255+0.5)) & 0xff) << 16 |
          (((int) (partsEnd[1]*255+0.5)) & 0xff) << 8 |
          (((int) (partsEnd[2]*255+0.5)) & 0xff);
                    mDrawColors[distance] = rgb;
                    //super.setRGB(i, j, rgb);               
          else {
               mDrawColors = null;
     public static void main(String args[]) {
          final GradientPane gp = new GradientPane(800, 800);
          gp.getGradient().setOptimized(true);
          CreatePopupWindow cpw = new CreatePopupWindow() {
               public Window createPopupWindow(Point p) {
                    //ParamDialog pd = new ParamDialog((JFrame)SwingUtilities.windowForComponent(gp), new String[] {"Center", "Colors", "Orientation", "Span"});
                    //JDialog pd = new JDialog((JFrame)SwingUtilities.windowForComponent(gp));
                    //pd.setDefaultCloseOperation(pd.DISPOSE_ON_CLOSE);
                    JWindow pd = new JWindow();
                    pd.add(new JLabel("Hello"));
                    //PopupFactory fac = PopupFactory.getSharedInstance();
                    //Popup pd = fac.getPopup(gp, new JLabel("Hello"), p.x, p.y);
                    return pd;
          gp.useColorSelectorPopup(true);
          //gp.setPreferredSize(new Dimension(200, 200));
          //gp.getGradient().setCenter(100,100);
          final JPanel handle = new JPanel();
          handle.setSize(5,5);
          handle.setLocation(10,10);
          handle.setBackground(Color.PINK);
          handle.addComponentListener(new ComponentAdapter() {
               public void componentMoved(ComponentEvent ev) {
                    gp.getGradient().setCenter(handle.getX(), handle.getY());
                    gp.repaint();
          gp.setLayout(null);
          new Draggable(handle);
          gp.add(handle);
          Dimension d = new Dimension(800,800);
          gp.setPreferredSize(d);
          gp.setSize(d);
          WindowUtilities.visualize(gp);
          GradientPane gp2 = new GradientPane(200,200);
          gp2.getGradient().setOrientation(HORIZONTAL);
          WindowUtilities.visualize(gp2);
          GradientPane gp3 = new GradientPane(200,200);
          gp3.getGradient().setOrientation(VERTICAL);
          GradientPane gp4 = new GradientPane(200,200);
          gp4.getGradient().setOrientation(BOTH_MANHATTAN);
          Window w3 = WindowUtilities.visualize(gp3);
          WindowUtilities.visualize(gp4);
          final Polygon gon = PolygonFactory.createPolygon(6, 0, new Rectangle(0,0,200,200));
          GradientPane gp5 = new GradientPane(200,200) {
               public void paintComponent(Graphics g) {
                    g.setClip(gon);
                    super.paintComponent(g);
          WindowUtilities.visualize(gp5);
          //StandardPrint sp1 = new StandardPrint(gp);
          //StandardPrint sp2 = new StandardPrint(w3);
          //WindowUtilities.visualize(StandardPrint.preview(200, 200, sp1, sp1.getPageFormat(0), 0));
          //WindowUtilities.visualize(StandardPrint.preview(200, 200, sp2, sp2.getPageFormat(0), 0));          
          WindowUtilities.setWindowCloseOnEscape(true);

Okay I have solved this, kind of.
I changed ColorGradient so that rather than extending BufferedImage it has a BufferedImage member (mIm)
then I added the following to get a Paint object from it. Hopefully this will prove a useful example to someone in the future :)
     public Paint getMyPaint() {
          return new MyPaint();
     public class MyPaint extends TexturePaint {
          TexturePaint mTP;
          public MyPaint() {
               super(ColorGradient.this.getImage(), new Rectangle(0, 0, mIm.getWidth(null), mIm.getHeight(null)));
               mTP = this;
          public PaintContext createContext(ColorModel cm,Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) {
               //System.out.println("Create context: db: " + deviceBounds + " ub: " + userBounds);
               //picking userBounds arbitrarily
               if (userBounds.getWidth() > mIm.getWidth() || userBounds.getHeight() > mIm.getHeight()) {
                    mIm = new BufferedImage((int)Math.max(mIm.getWidth(), userBounds.getWidth()), (int) Math.max(mIm.getHeight(), userBounds.getHeight()), BufferedImage.TYPE_INT_RGB);
                    mTP = new TexturePaint(ColorGradient.this.getImage(), new Rectangle(0, 0, mIm.getWidth(null), mIm.getHeight(null)));
               setCenter((int) userBounds.getWidth() / 2, (int) userBounds.getHeight() / 2);
               render();
               if (mTP == this) return super.createContext(cm, deviceBounds, userBounds, xform, hints);
               return mTP.createContext(cm, deviceBounds, userBounds, xform, hints);
     }

Similar Messages

  • Thiz iz Urgent..........How to convert a .class file to a .java file

    Hi Everybody,
    I want to convert back a .class file (a compiled servlet) into .java (source code) file. How do I do it???
    Note using javap has not been of any help.
    Thanks in Advance
    Rajib

    Why don't you look at this thread:
    http://forums.java.sun.com/thread.jsp?forum=31&thread=143500
    If thats not enough, try searching all the forums for:
    "convert .java .class" That'll give yu a bunch of other threads...
    Sjur

  • How to convert a .class file?!!

    sorry guys,
    but I've a question in knowing the code of some file,
    I've zipped file, when I unzip it, it contains an html page with a .class files
    (passing parameters to applet)
    my problem is that I want to know the code of the .java file (which is not included)
    but the program is working well, coz I have the .class file,
    so, can I convert this .class file into a java file, so its java code could be readable (to understand it)
    thanks in Advance :)

    sorry man, but Can't u send me a specific link for downloading this "Java decomplier"
    coz I found my self in something called (jad decompiler) with lots of versions and this is confusing
    and Is that mean, that there's a decompiler which can convert the .class file into .java one?
    and thanks alot man.....u help me always!
    (I'm still begginner in java)

  • How to convert a .class file into .java file without .jad using DeJDecompil

    Hi all,
    I am using DeJDecompiler and working with swing applications.If I try to convert a .class file into .java file,it is converting into .jad file only.Fine but if I try to save that file into .java file,It is giving lot of errors in that program.When I went into that program the total style of the program is changed and TRY-CATCH block is not recognised by the dejdecompiler,hence If I try to include some methods in the existing .java file thus got,I could not do.Kindly help me.
    If I get the .java file without error then I can process the rest of the functionality.
    Thanks in advance
    With kind Regs
    Satheesh.K

    Not so urgent today then!
    http://forum.java.sun.com/thread.jsp?thread=553576&forum=31&message=2709757
    I'm still not going to help you to steal someone�s code.

  • How to convert a class file to exe file and how to cteate a class file to d

    how to convert a class file to exe file

    Hi Bhaskarq,
    Hi,
    It is not at all possible.
    But it is a really worst method.
    Please go through it.
    This is a very common question asked in the comp.lang.java newsgroup. Its often useful to have an
    executable application when deploying your
    applications to a specific platform, but remember to
    make your .class files available for users running
    Unix/Macintosh/other platforms.
    Microsoft provide a free system development kit (SDK),
    for Java, which includes the jexegen tool. This
    will convert class files into a .EXE form. The only
    disadvantage is that users need a Microsoft Java
    Virtual Machine (JVM) installed. If your target
    platform is Win32, you can either redistribute the
    virtual
    machine, or raise the level of your system
    requirements, to include Windows 98, or Windows 95
    with
    Internet Explorer 4. Systems matching these
    requirements will already have a copy of the Microsoft
    Java Virtual Machine installed.
    Note : You must specify all of the class files your
    application needs (except for standard java packges)
    as a parameter, so if you have third party libraries,
    you'll need to include them as well. You can use wildcards * though, and you don't need the original source code.
    Also please see this Forum which will give a good idea
    http://forum.java.sun.com/thread.jsp?forum=31&thread=149733
    I hope this will help you.
    Thanks
    Bakrudeen
    Technical Support Engineer
    Sun MicroSystems Inc, India

  • Converting a class file to a dll

    Hai please help me..
    I am trying to convert my .class file to a .dll file.
    This is my java code:
    public class DateFunctions {
         public int getTimeInSeconds(int i){
              return i;
         public int addNumbers(int i, int j) {
              return (i+j);
         public static void main(String[] args) {
              DateFunctions df=new DateFunctions();
              df.getTimeInSeconds(
    Created class file DateFunctions.class.
    Created jar DateFunctions.jar using:
    jar cvf DateFunctions.jar DateFunctions.class
    Generated dll file using bimp tool like this (Visual J# .NET tool):
    jbimp DateFunctions.jar /t:library
    I got the file: DateFunctions.dll
    Now loaded this dll into my code (say, TSL code in WinRunner) using load_dll("DateFunctions.dll");
    When I try to access the method like:
    j=getTimeInSeconds(int i);
    I am getting the error RPC error.
    Note: DLL is loading fine. but while accessing the functions I am getting the RPC error..
    What could be the reason..?
    Please help...?
    Thanks,
    Satish

    Your answer lies in the documentation for WinRunner and whatever else is calling the DLL.
    Certainly Java JNI has requirements for DLLs called from Java: They have to be C++ bindings that use the native header that Java generates, right?
    So now you need to look at the requirements for your WinRunner and make sure that the program translating your .class file to a DLL does it in a such a way that the bindings WinRunner expects are indeed there.
    But none of that has anything to do with Java. If your Java class compiles and tests successfully, then your questions about Java are satisfied. You have to figure out what WinRunner needs and what's missing from what you supplied.
    %

  • Error: could not be converted to [class java.lang.Class].

    I am newbie to JDeveloper (10.1.2) on winxp and i was trying to setup the example from the following url http://radio.weblogs.com/0129487/2003/09/19.html
    It is a how to on "Executing Toplink Queries using JavaBean DataControl "
    Any help would be greatly appreciated.
    Near the bottom on step "In StrutsPageFlow diagram, select allEmpsDA Data Action, right mouse and chooe Run" i get a the following runtime errors:
    Validation Error
    You must correct the following error(s) before proceeding:
    JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: oracle.toplink.exceptions.ConversionException, msg= Exception Description: The object [mypackage.Employees], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager Internal Exception: java.lang.ClassNotFoundException: mypackage.Employees
    JBO-29000: Unexpected exception caught: oracle.toplink.exceptions.ConversionException, msg= Exception Description: The object [mypackage.Employees], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager Internal Exception: java.lang.ClassNotFoundException: mypackage.Employees
    Exception Description: The object [mypackage.Employees], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager Internal Exception: java.lang.ClassNotFoundException: mypackage.Employees

    This error is happening on a read.
    Here is the mapping descriptor:
    <database-mapping>
    <attribute-name>SuppItemCollection</attribute-name>
    <read-only>false</read-only>
    <reference-class>package.SuppItem</reference-class>
    <is-private-owned>false</is-private-owned>
    <uses-batch-reading>false</uses-batch-reading>
    <indirection-policy>
    <mapping-indirection-policy>
    <type>oracle.toplink.internal.indirection.NoIndirectionPolicy</type>
    </mapping-indirection-policy>
    </indirection-policy>
    <container-policy>
    <mapping-container-policy>
    <container-class>java.util.Vector</container-class>
    <type>oracle.toplink.internal.queryframework.ListContainerPolicy</type>
    </mapping-container-policy>
    </container-policy>
    <source-key-fields>
    <field>SUPP.REQ_NUM</field>
    </source-key-fields>
    <target-foreign-key-fields>
    <field>SUPP_ITEM.REQ_NUM</field>
    </target-foreign-key-fields>
    <type>oracle.toplink.mappings.OneToManyMapping</type>
    </database-mapping>
    Object model has a Supp class that has a collection of SuppItem(s). I was allowing the Mapping Workbench to create the Java Source. I'm not to fond of that, but I thought it would be easiest to get things going.
    The datamodel is similiar to the class model.
    Thanks for the help,
    Mike

  • What is the wrong about converting the .class of api of jc to .cap files?

    hi everyone
    l tried to convert the .class filses of api to .cap files,there are some wrongs please help me!
    ___the .opt file:___
    -out JCA CAP EXP
    -exportpath D:\jCDK2_2_1\api_export_files
    -classdir D:\workspace\framework
    framework
    0x0a:0x0:0x0:0x0:0x62:0x1:0x01 1.2
    converter result:
    c:documents and settings\administrator>converter -config d:\workspace\framework\framework.opt
    java card 2.2.1 class files converter ,version 1.3
    copyright 2003 sun microsystems,inc.all rights reserved.use is subject to license terms
    error:javacard.framework.JCSystem:unsupported method modifier native in method isTransient.
    error:javacard.framework.JCSystem:unsupported method modifier native in method makeTransientBooleanArray.
    error:javacard.framework.JCSystem:unsupported method modifier native in method makeTransientByteArray
    error:javacard.framework.JCSystem:unsupported method modifier native in method makeTransientShortArray
    conversion completed with 13 errors and 0 warnings.
    thanks in advance

    Hi,
    I am not sure why you are trying to convert the API packages into CAP files. The JAR files that ship with the JCDK are only stub implementations for compiling against. They do not have an actual implementation. You will find methods returning a short always return 0 etc. You should only need to convert your code into CAP files. You will just need to reference the .exp files that are included in the JCDK for the API so your code can be converted.
    Cheers,
    Shane

  • How to convert the class in the one package to same class in the other pack

    How to convert the class in the one package to same class in the other package
    example:
    BeanDTO.java
    package cho3.hello.bean;
    public class BeanDTO {
    private String name;
    private int age;
    * @return
    public int getAge() {
         return age;
    * @return
    public String getName() {
         return name;
    * @param i
    public void setAge(int i) {
         age = i;
    * @param string
    public void setName(String string) {
         name = string;
    BeanDTO.java in other package
    package ch03.hello;
    public class BeanDTO {
    private String name;
    private int age;
    * @return
    public int getAge() {
         return age;
    * @return
    public String getName() {
         return name;
    * @param i
    public void setAge(int i) {
         age = i;
    * @param string
    public void setName(String string) {
         name = string;
    My converter lass lokks like
    public class BeanUtilTest {
         public static void main(String[] args) {
              try
                   ch03.hello.BeanDTO bean=new ch03.hello.BeanDTO();
              bean.setAge(10);
              bean.setName("mahesh");
              cho3.hello.bean.BeanDTO beanDto=new cho3.hello.bean.BeanDTO();
              ClassConverter classconv=new ClassConverter();
              //classconv.
              System.out.println("hi "+beanDto.getClass().toString());
              System.out.println("hi helli "+bean.toString()+" "+bean.getAge()+" "+bean.getName()+" "+bean.getClass());
              Object b=classconv.convert(beanDto.getClass(),(Object)bean);
              System.out.println(b.toString());
              beanDto= (cho3.hello.bean.BeanDTO)b;
              System.out.println(" "+beanDto.getAge()+" "+beanDto.getName() );
              }catch(Exception e)
                   e.printStackTrace();
    But its giving class cast exception. Please help on this..

    Do you mean "two different layers" as in separate JVMs or "two different layers" as in functional areas running within the same JVM.
    In either case, if the first class is actually semantically and functionally the same as the second (and they are always intended to be the same) then import and and use the first class in place of the second. That's beyond any question of how to get the data of the first into the second if and when you need to.
    Once you make the breakthrough and use one class instead of two I'd guess that almost solves your problem. But if you want to describe your architecture a little that would help others pin down want you're trying to do.

  • Use of converter-for-class

    Hello,
    I start to use Jdev11 TP4.
    I have written my own converter which performs "trims" on character fields. This converter works fine when I apply it to the adf input texts which are present on my jspx pages.
    But I would like to apply this converter on all "adf input text" fields.
    To do this I have added the following lines in my faces-config.xml files :
    <converter>
    <description>Trim the fields</description>
    <display-name>FieldTrimer</display-name>
    <converter-for-class>oracle.adf.view.rich.component.rich.input.RichInputText</converter-for-class>
    <converter-class>lu.ehl.lp.converter.MyFieldTrimer</converter-class>
    </converter>
    The tag <converter-for-class> is always underlined in "red" saying that Reference to oracle.adf.view.rich.component.rich.input.RichInputText is not found.
    And the input fields on my jspx pages are not trimed...
    Could somebody help me to solve this problem ?

    Hi,
    please send me a testcase. Put the testcase in a zip and rename the zip to unzip. my mail address is in my profile
    Frank

  • Strange problem when tried to convert HelloWorld.class..

    Hi friends..
    i've downloaded the Java Card SDK 2.2.1, and i tried to compile HelloWorld application that shipped with its distribution..
    i found strange problem when i tried to convert HelloWorld.class into .CAP, etc.. :(
    I use Windows XP, assume that i've set the Environment Variables needed
    i've compiled the HelloWorld.java into HelloWorld.class..
    the package of of HelloWorld is : com.sun.javacard.samples.HelloWorld;
    and i use this config file :
    -out EXP JCA CAP
    -exportpath .
    -applet  0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x1:0x1 com.sun.javacard.samples.HelloWorld.HelloWorld
    com.sun.javacard.samples.HelloWorld
    0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x1 1.0and then i tried to run converter script in the Console :
    *C:\java_card_kit-2_2_1\samples>converter -config com\sun\javacard\samples\HelloWorld\HelloWorld.opt*
    *error: file com\sun\javacard\samples\HelloWorld\HelloWorld.opt could not be found*
    Usage:  converter  <options>  package_name  package_aid  major_version.minor_ve
    sion
    OR
    converter -config <filename>
                        use file for all options and parameters to converter
    Where options include:
            -classdir <the root directory of the class hierarchy>
                          set the root directory where the Converter
                          will look for classes
            -i            support the 32-bit integer type
            -exportpath  <list of directories>
                          list the root directories where the Converter
                          will look for export files
            -exportmap    use the token mapping from the pre-defined export
                          file of the package being converted. The converter
                          will look for the export file in the exportpath
            -applet <AID class_name>
                          set the applet AID and the class that defines the
                          install method for the applet
            -d <the root directory for output>
            -out  [CAP] [EXP] [JCA]
                          tell the Converter to output the CAP file,
                          and/or the JCA file, and/or the export file
            -V, -version  print the Converter version string
            -v, -verbose  enable verbose output
            -help         print out this message
            -nowarn       instruct the Converter to not report warning messages
            -mask         indicate this package is for mask, so restrictions on
                          native methods are relaxed
            -debug        enable generation of debugging information
            -nobanner     suppress all standard output messages
            -noverify     turn off verification. Verification is defaultPlease help me regarding this, because i'm new in this field..
    Thanks in advance..

    Thanks safarmer for your reply..
    i tried this :
    C:\java_card_kit-2_2_1\samples>javac -target 1.3 -source 1.1 -g -classpath .\cla
    sses;..\lib\api.jar;..\lib\installer.jar src\com\sun\javacard\samples\HelloWorld
    \*.java
    javac: invalid source release: 1.1
    Usage: javac <options> <source files>
    use -help for a list of possible options
    C:\java_card_kit-2_2_1\samples>javac -target 1.3 -source 1.2 -g -classpath .\cla
    sses;..\lib\api.jar;..\lib\installer.jar src\com\sun\javacard\samples\HelloWorld
    \*.java
    it seems that i can't specify the -source to 1.1, so i tried to use -source 1.2..
    after that, i tried to convert again, and i got this error :
    C:\java_card_kit-2_2_1\samples\src>converter -config com\sun\javacard\samples\He
    lloWorld\HelloWorld.opt
    Java Card 2.2.1 Class File Converter, Version 1.3
    Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to lic
    ense terms.
    error: com.sun.javacard.samples.HelloWorld.HelloWorld: unsupported class file fo
    rmat of version 47.0.
    conversion completed with 1 errors and 0 warnings.Please help me regarding this..
    Thanks in advance..

  • Cannot convert type class java.lang.String to class oracle.jbo.domain.Clob

    Cannot convert type class java.lang.String to class oracle.jbo.domain.ClobDomain.
    Using ADF Business Components I have a JSFF page fragment with an ADF form based on a table with has a column of type CLOB. The data is retrieved from the database and displayed correctly but when any field is changed and submitted the above error occurs. I have just used the drag and drop technique to create the ADF form with a submit button, am I missing a step?
    I am using the production release of Jdeveloper11G

    Reproduced and filed bug# 7487124
    The workaround is to add a custom converter class to your ViewController project like this
    package oow2008.view;
    import javax.faces.application.FacesMessage;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.convert.Converter;
    import javax.faces.convert.ConverterException;
    import oracle.jbo.domain.ClobDomain;
    import oracle.jbo.domain.DataCreationException;
    public class ClobConverter implements Converter {
         public Object getAsObject(FacesContext facesContext,
                                   UIComponent uIComponent,
                                   String string) {
           try {
             return string != null ? new ClobDomain(string) : null;
           } catch (DataCreationException dce) {
             dce.setAppendCodes(false);
             FacesMessage fm =
               new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                "Invalid Clob Value",
                                dce.getMessage());
             throw new ConverterException(fm);
         public String getAsString(FacesContext facesContext,
                                   UIComponent uIComponent,
                                   Object object) {
           return object != null ?
                  object.toString() :
                  null;
    }then to register the converter in faces-config.xml like this
    <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee">
      <application>
        <default-render-kit-id>oracle.adf.rich</default-render-kit-id>
      </application>
      <converter>
        <converter-id>clobConverter</converter-id>
        <converter-class>oow2008.view.ClobConverter</converter-class>
      </converter>
    </faces-config>then reference this converter in the field for the ClobDomain value like this
              <af:inputText value="#{bindings.Description.inputValue}"
                            label="#{bindings.Description.hints.label}"
                            required="#{bindings.Description.hints.mandatory}"
                            columns="40"
                            maximumLength="#{bindings.Description.hints.precision}"
                            shortDesc="#{bindings.Description.hints.tooltip}"
                            wrap="soft" rows="10">
                <f:validator binding="#{bindings.Description.validator}"/>
                <f:converter converterId="clobConverter"/>
              </af:inputText>

  • How to convert java class file version without decompiling

    Hi,
    Oracle R12.1.3 i am having illegal access error while try to access the class file version Java 1.3 uses major version 47,So how to convert the class file version without using decompiling.
    Current java version is 1.6.0_07
    Is there any tool or API for converting class file version?
    Thanks,
    Selvapandian T

    Beside this I wonder where you get your error from since AFAIK 12c comes with java 1.6.
    Well wonder no more!
    OP isn't using Oracle 12c database.
    They are using Oracle R12.1.3 - which is the E- Business Suite.

  • How to Convert a .class file into exe

    I need to convert a .class file to exe...
    If abybody know ...plz infrom me briefly....
    Thanx a lot

    I do not know.
    I come from china.
    [email protected]
    Is that suppose to be a racial joke?From his other post, I'm thinking he's actually serious. At first I thought it was just a troll, but even that email address looks correct (sina.com is a popular service in China and I don't expect an average troll to do 'research' like that).

  • Any 1 know how to convert a class to jar??

    How to convert a class file to jar executable file??

    Here's a jar tutorial.
    http://java.sun.com/docs/books/tutorial/deployment/jar/index.html

Maybe you are looking for

  • Cannot Save File because of disk error

    I selected 4 RAW images in Lightroom and chose the Merge to Panorama In Photoshop. After the file was created and I cropped it to my desired dimensions I tried to perform a simple save. I was asked what name to give the file and I went with the defau

  • External Monitor refresh rate conflict

    I've got the PB 12" and for a longtime have been using a 17" Soyo monitor with the computer closed and Bluetooth devices. It's a great setup. Now one time disconnected it to take the powerbook, and now I can't run it with just the 17" monitor. I don'

  • Function error when calling in background

    Hi people! I need some help please. I have an program that call an RFC function. This RFC function made select in BSAD, and because of the range, will return a lot of registers, so it cause timeout. We tried run it on backgroung, but after 1 hour app

  • How to customise charting styles?

    Hi, I'm currently looking for a way to customise the styles available in cfchart. I have to place 9 charts on an A4 page in landscape i.e. 3 rows of 3 charts, each of size width 280 and height 190. Is there anybody who can please help me with the fol

  • Transport Monitor could not complete your request (16)

    Transport Monitor could not complete your request (16) is the message I keep getting lately when I try to hotsync my palm IIIc with my 24inch imac running OSX 10.4.11. I'm also using Keyspan serial adaptor for the palm to a USB port. I've been able t