Function to drawing Arc in Java

Hello Everybody!!
I have already posted this on the "Jave Programming" forum but this place might be more helpful. I am working on a diagram editor and what I want to do is to allow the user to connect pairs of objects using arcs. ( see this picture http://www.csee.umbc.edu/~squire/images/451-f2.jpg ).
The default drawArc method in the Graphic class basically requires six parameters: x, y, width, height, startAngle, arcAngle. (EXPLANATION: x - the x coordinate of the upper-left corner of the arc to be drawn, y - the y coordinate of the upper-left corner of the arc to be drawn, width - the width of the arc to be drawn , height - the height of the arc to be drawn , startAngle - the beginning angle, arcAngle - the angular extent of the arc, relative to the start angle ).
Say I want to draw an arc from one point (x1 ,y1) to another point (x2,y2) , how would I determine width, height, startAngle, arcAngle ????
Any help would be greatly appreciated.

Say I want to draw an arc from one point (x1 ,y1) to another point
(x2,y2) , how would I determine width, height, startAngle,
arcAngle ????It takes 3 non-collinear points to explicitly define a circle. However,
since you only have 2 points then we can assume the circle's diameter
is the distance between the points.
Let's assume the two points have the same y-value. Then, the width
and height are:
x = x1
y = y1
width = Math.abs(x2 - x1)
height = width / 2
beginning angle = 0
arcAngle = Math.PI // this might be -Math.PI ... not sure
Something like that, it shouldn't take too much effort to get it working.

Similar Messages

  • New To Illustrator CS4  - How do you select the Arc Tool to Draw Arcs?

    PDF on Illustrator doesn't indicate how to select the Arc tool. Extract from toe pdf follows:
    Draw arcs
    1 Select the Arc tool .  (HELP -- I CAN'T LOCATE THE ARC TOOL).
    2 Do one of the following:
    • Position the pointer where you want the arc to begin, and drag to where you want the arc to end.
    • Click where you want the arc to begin. In the dialog box, click a square on the reference point locator to determine the point from which the arc is drawn. Then set any of the following options, and click OK.
    Length X-Axis
    Specifies the width of the arc.
    Length Y-Axis
    Specifies the height of the arc.
    Type
    Specifies whether you want the object to be an open path or a closed path.
    Base Along
    Specifies the direction of the arc. Choose X Axis or Y Axis depending on whether you want to draw the base of the arc along the horizontal (x) axis or vertical (y) axis.
    Slope
    Specifies the direction of the arc’s slope. Enter a negative value for a concave (inward) slope. Enter a positive value for a convex (outward) slope. A slope of 0 creates a straight line.
    Fill Arc
    Fills the arc with the current fill color.
    Note: To see a dynamic preview of the arc as you set options, double-click the arc tool in the Tools panel.

    You're welcome.
    Can i suggest that you explore al the tools there are drop down menus and on the panels as well in the upper right hand corner there is a drop down with useful functions and options. Also look at the control panel under the menu bar as you change tools to see the option each tool has and also some tools have further settings if you double click the icon in the tool bar other have option if you click in the document window once you have selected them.
    But the best advice I can give you is to buy Mordy Goldings book Real World Illustrator CS 4 he also has one for  the suites, it is a worthwhile investment.

  • Drawing arcs and lines

    Hi! I am having problem in drawing arc and line. We have function
    Graphics.drawArc(int x, int y, int startAngle, int endAngle)
    I need to get the last point where the arc ends. Because I want to draw a line touching the last point of this arc. I request you to provide me some solution.
    BR
    Omer Amin

    Graphics.drawArc requires 6 parameters (not 4). Pass all 6 parameters to the Arc2D.Double() constructor and call it's getEndPoint() method.

  • When did Draw Arc .vi Change Format?

    In LabView 6.1, Draw Arc .vi had different wiring than in LabView 2010.  I ran into a problem with a VI that I was using as a small subVi that is part of a much bigger Vi and now won't work because the Draw Arc.vi has incorrect wiring.  The only difference I can see is that what is now a connection for "PEN" (cluster wire) was a connection for "black in B/W" (boolean wire).  Basically I had a green circle that slowly turned to black as seconds ticked down.  I have tried using the "PEN" control, entering "0" as pen color and line as "solid" but still does not work as before.  Any help would be much appreciated.  Thank You, Scott

    swins,
    hmm, sounds to me like it might not be the draw arc control. Are you sure that's the only one that could have broken in the upgrade? I dropped a simple little visual counter (just tied the arc size to the index of a for loop) into a sub vi as a test, and everything is working just fine for me. I'm interested to find out what's going on with your control that I can't replicate the issue. Maybe it's something specific with the color changing? 
    Cheers!
    TJ G

  • Possibility of drawing numbers on java bouncing balls?

    Can anyone show me how to put numbers on these moving balls in my code. I need the numbers 1-60 on them. I have two sets the red and white. Here is my code. Any help is appreciated. I am trying to write a program to represent the powerball.
    import java.awt.*;
    import java.applet.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.Rectangle;
    class CollideBall{
    int width, height;
    public static final int diameter=20;
    //coordinates and value of increment
    double x, y, xinc, yinc, coll_x, coll_y;
    boolean collide;
    Color color;
    Graphics g;
    Rectangle r;
    //the constructor
    public CollideBall(int w, int h, int x, int y, double xinc, double yinc, Color c){
    width=w;
    height=h;
    this.x=x;
    this.y=y;
    this.xinc=xinc;
    this.yinc=yinc;
    color=c;
    r=new Rectangle(150,80,130,90);
    public double getCenterX() {return x+diameter/2;}
    public double getCenterY() {return y+diameter/2;}
    public void alterRect(int x, int y, int w, int h){
    r.setLocation(x,y);
    r.setSize(w,h);
    public void move(){
    if (collide){  
    double xvect=coll_x-getCenterX();
    double yvect=coll_y-getCenterY();
    if((xinc>0 && xvect>0) || (xinc<0 && xvect<0))
    xinc=-xinc;
    if((yinc>0 && yvect>0) || (yinc<0 && yvect<0))
    yinc=-yinc;
    collide=false;
    x+=xinc;
    y+=yinc;
    //when the ball bumps against a boundary, it bounces off
    //ball width is 6 so if the ball becomes less then 6 it is touching the frame
    //if ball is greater than the entire width-the diameter of the rectangle, then the ball is just touching the frame of the rectangle and must switch to negative to go in opposit direction
    if(x<6 || x>width-diameter){
    xinc=-xinc;
    x+=xinc;
    //same thing as about just about the Y-axis instead of the x-axis
    if(y<6 || y>height-diameter){
    yinc=-yinc;
    y+=yinc;
    public void hit(CollideBall b){
    if(!collide){
    coll_x=b.getCenterX();
    coll_y=b.getCenterY();
    collide=true;
    public void paint(Graphics gr){
    g=gr;
    g.setColor(color);
    //the coordinates in fillOval have to be int, so we cast
    //explicitly from double to int
    g.fillOval((int)x,(int)y,diameter,diameter);
    //Draws half white and half dark gray arc around the balls to give light and shadow effect
    g.setColor(Color.white);
    g.drawArc((int)x,(int)y,diameter,diameter,45,180);
    g.setColor(Color.darkGray);
    g.drawArc((int)x,(int)y,diameter,diameter,225,180);
    public class BouncingBalls extends Applet implements Runnable { 
    Thread runner;
    Image Buffer;
    Graphics gBuffer;
    CollideBall ball[];
    //Obstacle o;
    //how many balls?
    static final int MAX=60;
    boolean intro=true,drag,shiftW,shiftN,shiftE,shiftS;
    boolean shiftNW,shiftSW,shiftNE,shiftSE;
    int xtemp,ytemp,startx,starty;
    int west, north, east, south;
    public void init() {  
    Buffer=createImage(getSize().width,getSize().height);
    gBuffer=Buffer.getGraphics();
    ball=new CollideBall[MAX];
    int w=getSize().width-5;
    int h=getSize().height-5;
    //our balls have different start coordinates, increment values
    //(speed, direction) and colors
    for (int i = 0;i<30;i++){
    ball=new CollideBall(w,h,48+i,500+i,1.5,2.0,Color.white);
    ball[i+30]=new CollideBall(w,h,890+i,200+i,1.5,2.0,Color.red);
    public void start(){
    if (runner == null) {
    runner = new Thread (this);
    runner.start();
    /* public void stop(){
    if (runner != null) {
    runner.stop();
    runner = null;
    public void run(){
    while(true) {
    Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
    try {runner.sleep(15);}
    catch (Exception e) { }
    //move our balls around
    for(int i=0;i<MAX;i++){
    ball[i].move();
    handleCollision();
    repaint();
    boolean collide(CollideBall b1, CollideBall b2){
    double wx=b1.getCenterX()-b2.getCenterX();
    double wy=b1.getCenterY()-b2.getCenterY();
    //we calculate the distance between the centers two
    //colliding balls (theorem of Pythagoras)
    double distance=Math.sqrt(wx*wx+wy*wy);
    if(distance<b1.diameter)
    return true;
    return false;
    private void handleCollision(){
    //we iterate through all the balls, checking for collision
    for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++){
    if(i!=j){         
    if(collide(ball[i], ball[j])){  
    ball[i].hit(ball[j]);
    ball[j].hit(ball[i]);
    public void update(Graphics g){
    paint(g);
    public void paint(Graphics g) { 
    gBuffer.setColor(Color.lightGray);
    gBuffer.fillRect(0,0,getSize().width,getSize().height);
    gBuffer.draw3DRect(5,5,getSize().width-10,getSize().height-10,false);
    //paint our balls
    for(int i=0;i<MAX;i++)
    ball[i].paint(gBuffer);
    g.drawImage (Buffer,0,0, this);
    Thanks again

    this.user wrote:
    JakeG27 post your code within the code tab it will be more clear.
    You can do this by clicking on CODE when you do this will appear { code} { code} post your code inbetween those to tags.
    ie
    { code} code... { code}
    and it will look like this
    code
    This must be the first sensible post you've ever made. At least you're able to copy someone else's response and pretend you know something.

  • Drawing Arcs (For a cannon game)

    I was wondering if anyone could help me out with a java program I'm trying to write. I need to draw an arc from a specific location (which I can handle) but I want it to simulate a cannon fire. All I'm really worrying about at this time is involving gravity - I have no idea how to do this. I'm asking the user for an angle, and the velocity.
    If anyone can help explain an equation that would draw an arc please do so! :)
    (I've tried looping through the x coordinates which seems to work well, but I don't have a proper equation for y :P)

    I think you wouldn't draw an actual arc at all. Instead you'd plot points. You know the cannon velocity. From the cannon angle you can get the X and Y delta (Amount of change in X and Y per time click).
    For each time click you plot a point in the X direction - wind speed and in the Y direction - gravity.
    For example, let's say that that we ignore wind and we're just shooting from left to right and we're shooting at a 45 degree angle. Y = mX + b tells us that the rise and run for a 45 degree angle are the same. And just for fun let's say that gravity is 0.2 So for each plot you take the previous plot and add subtract the energy lost to gravity. But your X direction stays constant because of the lack of wind resistence. Here we go:
    Turn is the time click, X and Y are your delta and LocX and LocY are the location of the dot relative to the end of the cannon
    Turn  X   Y    LocX   LocY
    1     1   1     1       1
    2     1   0.8   2       1.8
    3     1   0.6   3       2.4
    4     1   0.4   4       2.8
    5     1   0.2   5       3.0
    6     1   0     6       3.0
    7     1  -0.2   7       2.8
    8     1  -0.4   8       2.4
    9     1  -0.6   9       1.8
    10    1  -0.8   10      1.0
    11    1  -1.0   11      0So after 11 turns the shell crashes into the ground (Assuming level ground) For uneven ground you just test LocX and LocY for an intercept with your ground level.
    You can see how you would do the same thing for wind resistence as well. That would simply change your X increment.
    Hope that helps
    Greg

  • Draw arc in a boolean array

    Hello everyone
    I want to extract the coordinate of an arc and use them to draw the same arc in a 2D boolean array, I have the start point coordinates, the end point coordinates, the center coordinates and the radius value.
    the result should be like this picture
    Thank you

    Thank you so much Alex
    I was trying to do it with picture functions for 2 days till now xD but I've forgotten the unflatten pixmap.vi 
    thanks for your help

  • Custom javascript functions in mobile webdynpro for java

    Hi
    We are developing an application for hand scanners. But the client uses different kinds of scanners. For this purpose we have to create some custom java script functions. Can anyone share your experiences on this with us which can guide us in the right way..
    The common features between all these scanners are as follows
    Windown CE .net 4.2
    Always Online wireless network.
    Mobile Internet explorer 6.0/Ibrowse which comes along with the scanner.
    Edited by: Srikanth Kancherla on Jan 5, 2009 7:13 AM

    Hi,
    refer this link where he is talking about java script with web dynpro,and he is talking about a rendering frame work where we can implement the java script .
    and that will support with CE 7.1
    http://help.sap.com/saphelp_nw70/helpdata/EN/f7/f289c67c759a41b570890c62a03519/content.htm
           1.      Navigate to the view where you want to insert the BarCodeReader.
           2.      Double-click the view or choose Edit from the context menu.
           3.      Insert the mobile UI element BarCodeReader.
    This interface element is not visible on the user interface and activates the scanning function of the mobile device when the mobile application is called. When the mobile device reads a barcode u2013 that is, the onRead event is triggered u2013 the data is passed to the server and can be stored in the context. The event parameter must be mapped to the parameter of the action.
           4.      Insert a TextView element u2013 for example, ShowData.
    thanks and regards
    Manohar
    Edited by: Gouri  Manohar Gadhamsetty on Jan 6, 2009 5:46 PM

  • Function used in web dynpro java application

    Hi
    I am creating some application in web dynpro java by using ABAP function module and table. I am trying to put data to table and update data in table and delete data in table in my application by using ABAP function by using RFC. And this is the ABAP function module.
    FUNCTION ZUP_DESIG12.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(DESG_CODE) TYPE  ZUP_DESIG-DESG_CODE OPTIONAL
    *"     VALUE(DESG_DESC) TYPE  ZUP_DESIG-DESG_DESC OPTIONAL
    *"     VALUE(DESG_ACT) TYPE  ZUP_DESIG-DESG_ACT OPTIONAL
    *"     VALUE(DESG_OPT) TYPE  ZUP_DESIG-DESG_OPT OPTIONAL
    *"  TABLES
    *"      WA STRUCTURE  ZMSTR_DESIG
    DATA CNT TYPE I.
    SELECT MANDT DESG_CODE DESG_DESC DESG_ACT FROM ZMSTR_DESIG
      INTO TABLE WA.
    IF DESG_OPT = 'U'.
    UPDATE ZMSTR_DESIG
        SET DESG_DESC = DESG_DESC
        DESG_ACT = DESG_ACT
        WHERE DESG_CODE = DESG_CODE.
    MESSAGE 'Updated Successfully' TYPE 'I'.
    ELSEIF DESG_OPT = 'C'.
    SELECT COUNT( * ) FROM ZMSTR_DESIG INTO CNT
       WHERE DESG_CODE = DESG_CODE.
       IF CNT > 0.
       MESSAGE 'Duplicate Designation code' TYPE 'I'.
       ELSE.
      WA-DESG_CODE = DESG_CODE.
      WA-DESG_DESC = DESG_DESC.
      WA-DESG_ACT = DESG_ACT.
      MODIFY ZMSTR_DESIG FROM WA.
       MESSAGE 'Inserted successfully' TYPE 'I'.
    ENDIF.
    ELSEIF DESG_OPT = 'D'.
       DELETE FROM ZMSTR_DESIG WHERE DESG_CODE = DESG_CODE.
       MESSAGE 'Deleted successfully' TYPE 'I'.
    ENDIF.
    ENDFUNCTION.
    I am not able to put data to table through my application but i am getting this error.
         java.lang.ArrayIndexOutOfBoundsException: -1
    What might be the problem .
    Regards,
    H.V.Swathi

    Can any one tell solution

  • Calling Functions of Loading DLL using java

    I have a dll file
    I know the functions which are ther in the dll
    But how to call those functions using JAVA ?
    can anyone tell me how to do the same...
    Thanx in advance
    regards,
    Ritesh

    I assume that you have a regular DLL and that the functions in that DLL are exported and that you know the signatures of each function.
    With that in mind, you will need to use the Java Native Interface (JNI), to call those functions from Java. In a nutshell, you will need to create at least one class which declares some native methods, code a class static code block to load the JNI-DLL you are about to create, compile the class(es), run the javah tool supplied with the JDK which will emit a C compatible header file, implement the functions from the generated header file and compile that source file to into a DLL. It would be in this DLL that you would use the functions in the DLL that you ultimately want to access. So, what you wind up doing is creating a wrapper DLL.
    Take a look at the JNI tutorial trail from Sun at http://java.sun.com/docs/books/tutorial/native1.1/index.html.

  • Using function equivalent to sscanf in JAVA

    Hello,
    All I want to do in java is to read the data saved in a buffer( a lot of numbers and characters seperated by semicolons) and organize it into columns of data saved in an outfile!!!! To this end each number or character seperated by a " ; " from the other has a special meaning and I need to save each one in a seperate variable to be able to use it in later simulation.I also dont know how much data is saved in the string. I just know that it is there and I need to extract it to something HUMAN readable.
    So I have this string of numbers and letters saved in a buffer string s.
    500 ; -5.0E-1 ; 4.0E-3 ; 2.0E-8 ; 0 ; "s" ; "V"
    (ignore the spaces, I just wanted you to be able to read the characters easily)
    So if I was using C I would ve simply use sscanf
    sscanf( s , "%d;%e;%e;%e;%d;%[^;];%s", &nr_pt, &yoff, &ymult,
    &xincr, &pt_off, xunit,yunit );
    to read the data saved in s and save it to 7 other variables.
    But how would I do this in JAVA, so desperate! Do I use some functions like read or read line or....
    So here I knew that I have 7 variable, what if I do not know how many data points is saved in the string and I want to read one by one and save it or print it to a file!
    Thanks,
    Sanaz

    You can read the thing in as a String, and then use the String's "split" method to split that up into an array of substrings. Then you can deal with each substring individually, converting them to numeric types via Double.parseDouble() for example.
    Or you might want to look at the Scanner class.
    http://java.sun.com/j2se/1.5.0/docs/api/index.html

  • Unicode line-drawing characters - possible Java bug?

    Hi all, I am trying to draw a box using line drawing characters in UTF-8. I make the UTF-8 box file in Microsoft Word where it looks aligned. However, when I run my Java program to display the box in a JTextArea, it is all out of alignment like below. Is this a bug in Java that prevents it from displaying aligned line-drawing characters? I am tearing my hair out over this so your help is much appreciated.
    Regards,
    Rianmal.
    &#9556;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9559;
    &#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;
    &#9553; &#9553;
    &#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;
    &#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;
    &#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;
    &#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;
    &#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;
    &#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;
    &#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;
    &#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;
    &#9562;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9565;

    sabre,
    Looks like monospaced isn't found on windows (vista)... So I used "Courier New" instead.
    Sabre20090412a.java is saved with encoding=UTF-8 (i.e. CP1252) instead of the default ASCII, which doesn't support the extended characters.
    package forums;
    import java.awt.Font;
    import javax.swing.JFrame;
    import javax.swing.JTextArea;
    public class Sabre20090412a
      private static final String text;
      static {
        String t;
        t =  "&#9556;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9559;\n"; // LINE 12
        t += "&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;&#9553;\n";
        t += "&#9553;                   &#9553;\n";
        t += "&#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;\n";
        t += "&#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;\n";
        t += "&#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;\n";
        t += "&#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;\n";
        t += "&#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;\n";
        t += "&#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;\n";
        t += "&#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;\n";
        t += "&#9553;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#8729;&#9553;\n";
        t += "&#9562;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9552;&#9565;\n"; // LINE 23
        text = t;
      public static void createAndShowGUI() {
        final JFrame frame = new JFrame("Test");
        final JTextArea ta = new JTextArea();
        ta.setFont(new Font("Courier New", Font.PLAIN, 14)); // <<<<< Note font-name="Courier New"
        ta.setText(text);
        frame.setContentPane(ta);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            createAndShowGUI();
    build (NOTE the -encoding utf-8)*
    cd /d C:\Java\home\src\forums
    "C:\Program Files\Java\jdk1.6.0_12\bin\javac.exe" -encoding utf-8 -Xlint -d C:\Java\home\classes -cp c:\java\home\src;.;C:\Java\home\classes C:\Java\home\src\forums\Sabre20090412a.java
    run
    cd /d C:\Java\home\src\forums
    "C:\Program Files\Java\jdk1.6.0_12\bin\java.exe" -cp C:\Java\home\classes forums.Sabre20090412a
    References:
    http://www.google.com/search?q=warning%3A+unmappable+character+for+encoding+Cp1252&hl=en
    http://en.wikipedia.org/wiki/Windows-1252 #says 1252== IANIA UTF-8 except
    http://www.utf8-chartable.de/unicode-utf8-table.pl #page for 2500 onwards
    http://forums.sun.com/thread.jspa?threadID=5185338 #-encoding
    http://www.java2s.com/Code/Java/2D-Graphics-GUI/Listallavailablefontsproviedinthesystem.htm
    Roedy Green rocks!
    http://mindprod.com/jgloss/font.html#AVAILABLEJ
    http://mindprod.com/applet/fontshower.html
    Thanx for the fish!
    Cheers. Keith.

  • How can we create a common function for 2 or more java card applets?

    I have 2 java card applets. They use one common function. But i don't know how to set up it. Anybody knows it, please help me. Please show me step by step to do it. Thank you.

    When insert below line of code in the Test_Class_1.java and Test_Class_2, the Project will be failed:
    byte aP1 = Test_common_function.GetP1((byte)0x02);
    byte aP1 = Test_common_function.GetP1((byte)0x01);
    Here is the source code:
    Test_Class_2.java
    package Test_Class_2;
    import Test_common_function.Test_common_function;
    import javacard.framework.APDU;
    import javacard.framework.Applet;
    public class Test_Class_2 extends Applet
       public static void install(byte[] bArray, short bOffset, byte bLength)
          // GP-compliant JavaCard applet registration
          new Test_Class_2().register(bArray, (short) (bOffset + 1),
                bArray[bOffset]);
       public void process(APDU apdu)
          byte aP1 = Test_common_function.GetP1((byte)0x02);
    }Test_Class_1.java
    package Test_Class_1;
    import Test_common_function.Test_common_function;
    import javacard.framework.APDU;
    import javacard.framework.Applet;
    public class Test_Class_1 extends Applet
       public static void install(byte[] bArray, short bOffset, byte bLength)
          // GP-compliant JavaCard applet registration
          new Test_Class_1().register(bArray, (short) (bOffset + 1),
                bArray[bOffset]);
       public void process(APDU apdu)
          byte aP1 = Test_common_function.GetP1((byte)0x02);
    }Test_common_function.java
    package Test_common_function;
    import javacard.framework.APDU;
    import javacard.framework.ISO7816;
    import javacard.framework.Applet;
    import javacard.framework.ISOException;
    public class Test_common_function extends Applet
       public static void install(byte[] bArray, short bOffset, byte bLength)
          // GP-compliant JavaCard applet registration
          new Test_common_function().register(bArray,
                (short) (bOffset + 1), bArray[bOffset]);
       public void process(APDU apdu)
          // Good practice: Return 9000 on SELECT
          if (selectingApplet())
             return;
          byte[] buf = apdu.getBuffer();
          switch (buf[ISO7816.OFFSET_INS])
             case (byte) 0x00:
                break;
             default:
                // good practice: If you don't know the INStruction, say so:
                ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
       public static byte bP1_Class1 = (byte)0x90;
       public static byte bP1_Class2 = (byte)0x90;
       public static byte GetP1(byte idclass)
          return idclass == (byte)0x01? bP1_Class1:bP1_Class2;
    }and here is the trace log (in case of failure)
    cm>  /term "Remote|localhost:60351"
    --Opening terminal
    /card -a a000000003000000 -c com.ibm.jc.CardManagerresetCard with timeout: 0 (ms)
    --Waiting for card...
    ATR=3B F8 13 00 00 81 31 FE 45 4A 43 4F 50 76 32 34    ;.....1.EJCOPv24
        31 B7                                              1.
    IOCTL().
    ATR:
             T = 1                  
    => 00 A4 04 00 08 A0 00 00 00 03 00 00 00 00          ..............
    (578768 nsec)
    <= 6F 65 84 08 A0 00 00 00 03 00 00 00 A5 59 9F 65    oe...........Y.e
        01 FF 9F 6E 06 47 91 01 17 33 00 73 4A 06 07 2A    ...n.G...3.sJ..*
        86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B    .H..k.`...*.H..k
        02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64    ....c...*.H..k.d
        0B 06 09 2A 86 48 86 FC 6B 04 02 15 65 0B 06 09    ...*.H..k...e...
        2B 85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01    +...Hd...f...+..
        04 01 2A 02 6E 01 02 90 00                         ..*.n....
    Status: No Error
    cm>  set-key 255/1/DES-ECB/404142434445464748494a4b4c4d4e4f 255/2/DES-ECB/404142434445464748494a4b4c4d4e4f 255/3/DES-ECB/404142434445464748494a4b4c4d4e4f
    cm>  init-update 255
    => 80 50 00 00 08 37 0D D8 24 C9 C8 32 53 00          .P...7..$..2S.
    (1829 usec)
    <= 00 00 DE 81 34 18 39 B7 09 70 FF 02 00 00 3D 02    ....4.9..p....=.
        9C 31 C7 89 7A 8E 57 44 05 A7 67 C7 90 00          .1..z.WD..g...
    Status: No Error
    cm>  ext-auth plain
    => 84 82 00 00 10 D8 BE 91 A3 94 E8 34 18 42 28 F6    ...........4.B(.
        74 EE 50 06 29                                     t.P.)
    (1683 usec)
    <= 90 00                                              ..
    Status: No Error
    cm>  delete -r 01020304050102
    => 80 E4 00 80 09 4F 07 01 02 03 04 05 01 02 00       .....O.........
    (833593 nsec)
    <= 6A 88                                              j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Ignoring expected error
    cm>  delete -r 01020304050103
    => 80 E4 00 80 09 4F 07 01 02 03 04 05 01 03 00       .....O.........
    (769014 nsec)
    <= 6A 88                                              j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Ignoring expected error
    cm>  delete -r 010203040501
    => 80 E4 00 80 08 4F 06 01 02 03 04 05 01 00          .....O........
    (734456 nsec)
    <= 6A 88                                              j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Ignoring expected error
    cm>  upload -c -d -b 250 "D:\WorkSpace\Test_Common_Funcation\bin\Test_common_function\javacard\Test_common_function.cap"
    => 80 E6 02 00 13 06 01 02 03 04 05 01 08 A0 00 00    ................
        00 03 00 00 00 00 00 00 00                         .........
    (1864 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Start loading Header.cap (44 byte)
    => 80 E8 00 00 2C C4 82 03 E3 01 00 25 DE CA FF ED    ....,......%....
        02 02 04 00 01 06 01 02 03 04 05 01 14 54 65 73    .............Tes
        74 5F 63 6F 6D 6D 6F 6E 5F 66 75 6E 63 74 69 6F    t_common_functio
        6E 00                                              n.
    (1607 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Header.cap loaded (44 byte)
    Start loading Directory.cap (36 byte)
    => 80 E8 00 01 24 02 00 21 00 25 00 21 00 0C 00 0B    ....$..!.%.!....
        00 26 00 0E 00 4C 00 0C 00 0D 00 00 00 6F 02 5D    .&...L.......o.]
        00 02 00 00 00 00 01 01 00 00                      ..........
    (1368 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Directory.cap loaded (36 byte)
    Start loading Import.cap (14 byte)
    => 80 E8 00 02 0E 04 00 0B 01 03 01 07 A0 00 00 00    ................
        62 01 01 00                                        b...
    (1096 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Import.cap loaded (14 byte)
    Start loading Applet.cap (15 byte)
    => 80 E8 00 03 0F 03 00 0C 01 08 01 02 03 04 05 01    ................
        01 01 00 08 00                                     .....
    (1188 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Applet.cap loaded (15 byte)
    Start loading Class.cap (17 byte)
    => 80 E8 00 04 11 06 00 0E 00 00 00 80 03 00 FF 00    ................
        07 01 00 00 00 1C 00                               .......
    (1457 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Class.cap loaded (17 byte)
    Start loading Method.cap (79 byte)
    => 80 E8 00 05 4F 07 00 4C 00 01 10 18 8C 00 02 7A    ....O..L.......z
        05 30 8F 00 08 3D 8C 00 00 18 1D 04 41 18 1D 25    .0...=......A..%
        8B 00 01 7A 02 21 18 8B 00 06 60 03 7A 19 8B 00    ...z.!....`.z...
        04 2D 1A 04 25 73 00 09 00 00 00 00 00 0F 11 6D    .-..%s.........m
        00 8D 00 07 7A 02 10 1C 04 6B 07 7C 00 03 70 05    ....z....k.|..p.
        7C 00 05 78 00                                     |..x.
    (1101 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Method.cap loaded (79 byte)
    Start loading StaticField.cap (15 byte)
    => 80 E8 00 06 0F 08 00 0C 00 02 00 00 00 00 00 00    ................
        00 02 90 90 00                                     .....
    (1069 usec)
    <= 00 90 00                                           ...
    Status: No Error
    StaticField.cap loaded (15 byte)
    Start loading ConstantPool.cap (41 byte)
    => 80 E8 00 07 29 05 00 26 00 09 06 00 00 01 03 80    ....)..&........
        03 02 06 80 03 00 05 00 00 00 03 80 0A 01 05 00    ................
        00 01 03 80 03 03 06 80 07 01 01 00 02 00 00       ...............
    (3134 usec)
    <= 00 90 00                                           ...
    Status: No Error
    ConstantPool.cap loaded (41 byte)
    Start loading RefLocation.cap (16 byte)
    => 80 E8 00 08 10 09 00 0D 00 00 00 09 05 06 04 0A    ................
        07 07 13 0A 05 00                                  ......
    (2067 usec)
    <= 00 90 00                                           ...
    Status: No Error
    RefLocation.cap loaded (16 byte)
    Start loading Descriptor.cap (114 byte)
    => 80 E8 00 09 72 0B 00 6F 01 00 01 00 02 00 00 02    ....r..o........
        00 04 00 09 00 00 00 80 03 01 09 00 00 01 80 03    ................
        00 81 00 01 00 14 00 05 00 00 00 00 01 09 00 08    ................
        00 16 00 12 00 00 00 00 07 01 00 1C 00 19 00 1F    ................
        00 00 00 00 02 09 00 3D 00 1D 00 0D 00 00 00 00    .......=........
        00 09 00 14 00 16 00 14 00 1F 00 21 00 1F 00 23    ...........!...#
        00 25 FF FF 01 10 04 B4 31 06 68 00 A1 02 33 01    .%......1.h...3.
        30 01 B0 01 20 02 41 00                            0... .A.
    (1344 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Descriptor.cap loaded (114 byte)
    Start loading Debug.cap (608 byte)
    => 80 E8 00 0A FA 0C 02 5D 00 1A 00 29 54 65 73 74    .......]...)Test
        5F 63 6F 6D 6D 6F 6E 5F 66 75 6E 63 74 69 6F 6E    _common_function
        2F 54 65 73 74 5F 63 6F 6D 6D 6F 6E 5F 66 75 6E    /Test_common_fun
        63 74 69 6F 6E 00 19 6A 61 76 61 63 61 72 64 2F    ction..javacard/
        66 72 61 6D 65 77 6F 72 6B 2F 41 70 70 6C 65 74    framework/Applet
        00 19 54 65 73 74 5F 63 6F 6D 6D 6F 6E 5F 66 75    ..Test_common_fu
        6E 63 74 69 6F 6E 2E 6A 61 76 61 00 0A 62 50 31    nction.java..bP1
        5F 43 6C 61 73 73 31 00 01 42 00 0A 62 50 31 5F    _Class1..B..bP1_
        43 6C 61 73 73 32 00 06 3C 69 6E 69 74 3E 00 03    Class2..<init>..
        28 29 56 00 04 74 68 69 73 00 2B 4C 54 65 73 74    ()V..this.+LTest
        5F 63 6F 6D 6D 6F 6E 5F 66 75 6E 63 74 69 6F 6E    _common_function
        2F 54 65 73 74 5F 63 6F 6D 6D 6F 6E 5F 66 75 6E    /Test_common_fun
        63 74 69 6F 6E 3B 00 07 69 6E 73 74 61 6C 6C 00    ction;..install.
        07 28 5B 42 53 42 29 56 00 06 62 41 72 72 61 79    .([BSB)V..bArray
        00 02 5B 42 00 07 62 4F 66 66 73 65 74 00 01 53    ..[B..bOffset..S
        00 07 62 4C 65 6E 67 74 68 00 07 70 72 6F 63 00    ..bLength..proc.
    (937268 nsec)
    <= 00 90 00                                           ...
    Status: No Error
    => 80 E8 00 0B FA 65 73 73 00 1C 28 4C 6A 61 76 61    .....ess..(Ljava
        63 61 72 64 2F 66 72 61 6D 65 77 6F 72 6B 2F 41    card/framework/A
        50 44 55 3B 29 56 00 04 61 70 64 75 00 19 4C 6A    PDU;)V..apdu..Lj
        61 76 61 63 61 72 64 2F 66 72 61 6D 65 77 6F 72    avacard/framewor
        6B 2F 41 50 44 55 3B 00 03 62 75 66 00 05 47 65    k/APDU;..buf..Ge
        74 50 31 00 04 28 42 29 42 00 07 69 64 63 6C 61    tP1..(B)B..idcla
        73 73 00 14 54 65 73 74 5F 63 6F 6D 6D 6F 6E 5F    ss..Test_common_
        66 75 6E 63 74 69 6F 6E 00 19 00 01 00 00 00 01    function........
        00 02 00 01 00 02 00 00 02 00 04 00 03 00 04 00    ................
        09 00 00 00 00 00 05 00 04 00 09 00 00 00 01 00    ................
        06 00 07 00 01 00 01 02 00 05 00 01 00 01 00 00    ................
        08 00 09 00 00 00 05 00 00 00 04 00 0F 00 0A 00    ................
        0B 00 09 00 08 02 00 12 00 03 00 04 00 00 0C 00    ................
        0D 00 00 00 12 01 00 0E 00 0F 00 00 00 12 02 00    ................
        10 00 04 00 00 00 12 00 00 00 07 00 14 00 08 00    ................
        0D 00 15 00 0E 00 10 00 14 00 11 00 11 00 16 00    ................
    (785421 nsec)
    <= 00 90 00                                           ...
    Status: No Error
    => 80 E8 80 0C 6C 00 11 00 12 00 01 00 1C 02 00 1F    ....l...........
        00 03 00 06 00 00 08 00 09 00 00 00 1F 01 00 13    ................
        00 14 00 00 00 1F 02 00 15 00 0D 00 0C 00 13 00    ................
        00 00 05 00 1B 00 06 00 06 00 1D 00 07 00 0B 00    ................
        20 00 0C 00 17 00 21 00 18 00 1D 00 27 00 1E 00     .....!.....'...
        1E 00 29 00 16 00 17 00 09 00 3D 02 00 0D 00 01    ..).......=.....
        00 01 00 00 18 00 04 00 00 00 0D 00 00 00 0C 00    ................
        2F 00                                              /.
    (1986 usec)
    <= 00 90 00                                           ...
    Status: No Error
    Debug.cap loaded (608 byte)
    Load report:
      999 bytes loaded in 0.0 seconds
      effective code size on card:
          + package AID       6
          + applet AIDs       15
          + classes           17
          + methods           79
          + statics           2
          + exports           0
            overall           119  bytes
    cm>  install -i 0102030405010101  -q C9#() 010203040501 0102030405010101
    => 80 E6 0C 00 1F 06 01 02 03 04 05 01 08 01 02 03    ................
        04 05 01 01 01 08 01 02 03 04 05 01 01 01 01 00    ................
        02 C9 00 00 00                                     .....
    (2346 usec)
    <= 00 90 00                                           ...
    Status: No Error
    cm>  upload -c -d -b 250 "D:\WorkSpace\Test_Common_Funcation\bin\Test_Class_2\javacard\Test_Class_2.cap"
    jcshell: Cannot read <D:\WorkSpace\Test_Common_Funcation\bin\Test_Class_2\javacard\Test_Class_2.cap>: java.io.FileNotFoundException: D:\WorkSpace\Test_Common_Funcation\bin\Test_Class_2\javacard\Test_Class_2.cap (The system cannot find the path specified)
    cm>  install -i 0102030405010303  -q C9#() 01020304050103 0102030405010303
    => 80 E6 0C 00 20 07 01 02 03 04 05 01 03 08 01 02    .... ...........
        03 04 05 01 03 03 08 01 02 03 04 05 01 03 03 01    ................
        00 02 C9 00 00 00                                  ......
    (1231 usec)
    <= 6A 88                                              j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Unexpected error; aborting executionThank very much!
    Edited by: WhoKnows on Apr 20, 2012 9:32 PM

  • When change Function Module, how to ensure JAVA sees it

    I added a new TABLE to a remotely-callable Function Module.  I added a new table to the "TABLES" tab of the function module.  The table is then populated by the code in the FM. 
    I now want the JAVA code to be able to access this new TABLE.  I am using the "adaptive RFC" model to make calls to SAP.
    After making a change such as this, do I need to
    1. stop and start the JRA factories?
    2. stop and start the J2EE java application?
    3. stop and start the whole server?
    Thanks,
    Kevin

    1. stop and start the JRA factories? <b>If you are working ARFC then nothing to do with JRA factory.</b>
    2. stop and start the J2EE java application? <b>If you have used Enterprise Connector then Re Impor the Model </b>
    3. stop and start the whole server?<b>After re import you need to restart the server</b>
    Regards
    Abhilash

  • Is it possible to call Java functions from XSLT, using standard Java 6?

    I have seen examples, but the examples are always the most simple case, which even I can already get working. The case where no arguments are passed to the java function.
    As soon as I try to pass an argument to the java function, i get a stupid unhelpful error message (as always error messages are unhelpful).
    Or am I wasting my time using the standard provided java parser, and need to use apache or something?
    anyone who can provide me with a couple lines of working code is to me a saint!
    At the moment I am using calling a named template, and passing a param into this.
    I want to use this param as an argument in the Java function.
    Is this possible?
    example code:
         <xsl:template name="calc-age">
              <xsl:param name="dob"/>          
         <xsl:variable name="sdob" select="java:lang.String.new($dob)"/>
         <xsl:value-of select="java:toString($sdob)"/>     
         </xsl:template>

    I have fixed it.
    I had to call an xslt 1 function 'string' on the variable before passing it into the java function (see below).
         <xsl:template name="calc-age">
              <xsl:param name="dob"/>          
              I know that the value of the param is: <xsl:value-of select="$dob"/><br/>     
             <xsl:variable name="poo" select="$dob"/>
             <xsl:variable name="sdob" select="java:lang.String.new(string($poo))"/> 
             And here again, we try to print a variable<xsl:value-of select="$poo"/>                <br/>
             And here again, we try to print the result of the java call<xsl:value-of select="java:toString($sdob)"/>      <br/>
             and here is our variable sdob    <xsl:value-of select="$sdob"/>             
         </xsl:template>          Now this is APPARENTLY a xslt-1 function,
    but the reference I had been using for this is
    http://www.w3schools.com/xpath/xpath_functions.asp it is linked to by a reference that calls these xslt-2 functions.
    Maybe they are mixed xslt-1 and xslt-2 functions?
    How am I supposed to know?
    Where is a good (plain and simple, easy to read) reference for xsl, so i know which functions are which?
    Anyone got a good answer to that question?

Maybe you are looking for

  • Can't open new windows if clicking on a link!

    For some reason I can't open new windows if I clic on a link. It's alright if it opens in a new tab, but if it opens in a new window, the window that opens is just blank. I have no idea why it's doing so, it started a couple of weeks ago, and it's ve

  • New to JMF my players just showing a white screen

    Hello I'm an experienced java programmer but i am new to JMF i'm having trouble applying an effect to a video track i've registered the effect successfully however when i then apply it to the video track all i get is a white screen. the player displa

  • Manual thumbnail scroller with enlarged images opening next to them

    I would like to make something like http://www.eleanorstravels.com/inTensaSite/index.htm , where the image opens next to the scrolling thumbnails, except less impossible to code, because unlike eleanor I am stupid.

  • Syncing photos from Aperture to Apple TV

    I have first generation Apple TV to which I sync music and photos from an iMac using a wireless connection. Until recently I used iPhoto. Now I have installed Aperture and cannot get this to sync. The dropdown menu says "Sync photos from:..." iPhoto

  • How to cycle multiple compositions

    Hi everyone.  I used to use the bootstrapper created by Josh Hatwich a couple years back in order to play multiple (separate) Edge animations in sequence (one immediately after the other), but ever since updating my animations to the latest version o