Drawing Custom 2D Graph : Need Help!

Hi,
I'm new to this forum, but I figured this would be the best place to ask for help.
I'm currently working on a new project; a Graphing Calculator for algoriths and such. I've been with Java for a while now, but I have ran into a few snags with my new project.
[1] For now, I have a line wizard that seperates a algorithm (linear, polynomial only for now) into chunks. How would I go out Parsing it totally from a string, in any format. I need to include such mathmatical operations such as sin( , cos( and ect. I have not even started on a rough draft yet, because I don't know where to start.
[2] My custom GraphClass is having a hard time repersenting different rates for minium and maxium axis size. For some reason both axis wont draw in the right spot, meaning my X() and Y() are coded wrong. This is some of my code for now:
For the full class file goto : [http://pastebin.com/Ty9ndCc4]
public int width = 390;
public int length = 390;
public static int minX = (int) -200;
public static int maxX = (int) 200;
public static float XScale = 390/ ( Math.abs(maxX)  +Math.abs(minX) );+
+public static int minY = (int) -200;+
+public static int maxY = (int) 200;+
+public static float YScale = 390/ ( Math.abs(maxY)+  Math.abs(minY) );
public static int X() {
     return (int) ((int) Math.round(abs(minX)*(float)XScale));*
*public static int Y() {*
*return (int) 390 - ((int) Math.round(abs(minY)*(float)YScale)); // 390 -  *because of the Y axis being upside down*
*// This works very well. LineDirection is a made class. Pretty simple to figure out.*
*public void drawLine(Graphics g, LineDirection dir) {*
*if (!dir.isActivated())*
*return;*
*Point[] points = dir.getPoints();*
*Color defaultColor = g.getColor();*
*g.setColor(dir.getColor());*
*for (int i = 1; i < points.length; i++) {*
*int X1 = (int) points[i-1].getX();*
*int Y1 = (int) points[i-1].getY();*
*int X2 = (int) points.getX();*
*int Y2 = (int) points[i].getY();*
g.drawLine((int) X()  +(int)(X1XScale),(int)Y()+ (int)(Y1*YScale* -1),(int) X() +(int)(X2*XScale),(int) Y()+ (int)(Y2*YScale * -1));
g.setColor(defaultColor);
public void drawDefaultGrid(Graphics g) {
g.drawLine(0, Y() , width, Y());
g.drawLine(X(), 0, X(), length);
[http://pastebin.com/Ty9ndCc4]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

RedDevil_05 wrote:
[1] For now, I have a line wizard that seperates a algorithm (linear, polynomial only for now) into chunks. How would I go out Parsing it totally from a string, in any format. I need to include such mathmatical operations such as sin( , cos( and ect. I have not even started on a rough draft yet, because I don't know where to start.Here is a thread that may contain your answer: using the [JavaScript Engine|http://forums.sun.com/thread.jspa?threadID=5144807] to evaluate the String containing the expression.
[2] My custom GraphClass is having a hard time repersenting different rates for minium and maxium axis size. For some reason both axis wont draw in the right spot, meaning my X() and Y() are coded wrong. This is some of my code for now:The X axis in Java is just standard increasing to the right and decreasing to the left, therefore, you can easily center by just dividing your maximum X by 2 for a center position. Y on the other hand is going to be a little more difficult, since the Y will be decreasing in the upward direction and increasing downward. You can easily get the center the same way as with the X axis (divid by 2), but then when you plot, you just change the sign on all of your Y coordinates.
I prefer to use a BufferedImage for my graphics, line graphs or custom rendering for games and etc. I can work with that and it will then easily render onto the graphics context of a JPanel.
Hope this help you out.
BTW: your posted code seems to have been gnawed on by an ugly moster or something--it is hideously corrupted, but your link showing your full source shows decent enough code.

Similar Messages

  • Excel Insert Graph (Need Help!)

    Hi there!
    I am new to LabView, and trying to use the Excel Insert Graph vi. I am not sure what it means by "report in", I have tried to convert my file path for my Excel report into a string, but it won't take it, and the help says "links a report to the vi's used to control report appearance, data, and printing." Do I have to use another vi to open the Excel file first? Any help would be appreciated, thanks!
    Ke
    Message Edited by Ke Sun on 10-19-2006 04:35 PM

    Take a look at the example VIs in your [LabVIEW]\examples\office folder.  There are several examples that deal with Excel and Graphs in MSGraph Examples.llb.  You must use the "New Report.vi" to generate a new report, which gives you the reference you can then use with the Excel Insert Graph.vi.  The examples should point you in the right direction.
    Good luck,
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Draw circle, intersects Ellipse2D need help

    looks like have a few error... i have no idea how to fix it now. help plz.
    Circle class file.
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.geom.Ellipse2D;
    import javax.swing.JOptionPane;
    public class Circle
         private double radius;
         private int centerX, centerY;
         private Color fillColor;
         public Circle()
              radius=0;
              centerX=0;
              centerY=0;
         public double getRadius()
              return radius;
         public void setRadius(double newRadius)
              radius=newRadius;
         public int getCenterX()
              return centerX;
         public int getCenterY()
              return centerY;
         public void setCenterX(int newCenterX)
              centerX=newCenterX;
         public void setCenterY(int newCenterY)
              centerY=newCenterY;
         public void setFillColor(Color newColor)
              fillColor=newColor;
         public Color getFillColor()
              return fillColor;
         public void draw(Graphics g)
              Graphics2D g2= (Graphics2D) g;
              radii=this.getRadius()
              if( radius>=0 )
                   g2.fill( Ellipse2D.Double(radii*2,radii*2,this.centerX-radii,this.centerY-radii));
              else
                   g2.fill( Ellipse2D.Double(0,0,centerX,centerY));
         public boolean intersects(Circle circle2)
              double radiusLength1 = this.getRadius();
              double radiusLength2 = circle2.getRadius();
              double totalRadius = radiusLength1+radiusLength2;
              double distance = Math.sqrt(
                   (Math.pow(this.centerX-circle2.centerX,2))+
                   (Math.pow(this.centerY-circle2.centerY,2))
              return boolean totalRadius >= distance;
    CircleComponent class code
    import java.awt.Color;
    import java.util.Random;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.geom.Ellipse2D;
    import javax.swing.JOptionPane;
    import javax.swing.JComponent;
    public class CircleComponent extends JComponent
         public static void CircleComponent (String[] args)
              double radius;
              Circle circle1,circle2;x
              circle1=new Circle();
              circle2=new Circle();
              circle1.setCenterX(200);
              circle1.setCenterY(100);
              circle2.setCenterX(100);
              circle2.setCenterY(200);
              Random generator= new Random();
              Color color1 = new Color (generator.nextInt(256), generator.nextInt(256), generator.nextInt(256));
              circle1.setFillColor(color1);
              Color color2 = new Color (generator.nextInt(256), generator.nextInt(256), generator.nextInt(256));
              circle2.setFillColor(color2);
              String input=JOptionPane.showInputDialog("Set the circle1's radius ");
              radius = Integer.parseInt(input);
              circle1.setRadius(radius);
              input=JOptionPane.showInputDialog("Set the circle2's radius ");
              radius = Integer.parseInt(input);
              circle2.setRadius(radius);
         public void paintComponent (Graphics g)
              Graphics2D g2= (Graphics2D) g;
              g2.setColor(color1);
              g2.draw(circle1);
              g2.setColor(circle2.getFillColor());
              g2.draw(circle2);
              //draw String intersectsResult
              g2.setColor(Color.BLACK);
              String intersectsResult;
              if (circle1.intersects(circle2))
                   intersectsResult="Two circles intersected";
              else
                   intersectsResult="Two circles not intersected";
              g2.drawString(intersectsResult,20,380);
    }

    looks like have a few error... i have no idea howto fix it now. help plz.
    what are the errors?
    copy and paste themI think the code simply "does not work" as expected ;)

  • Data display on Bar graphs - Needs help

    Hi,
    I am facing a problem with discoverer's bar graphs.
    There is a 2D Bar Graph, which is required to display the respective strength for all the classes on the axis(e.g regionwise sales for North, West, East, South). In Oracle discoverer the sales is shown only when the mouse is pointed over the respective bar but that too at the bottom. The fixed values of the sales is not being displayed above each bar permanently.
    But the client requirement is to display the strength for each class above each bar numerically so that a print out can be taken along with values.
    Please suggest how can this be done.
    Goga

    On the Plot Area tab, check the "Show Data Labels for bars". To the right of that, clicking the "Options" button will let you place the labels above or in the bars.
    Also, check that the graph background color is not the same as the font color.

  • Need help to draw a graph from the output I get with my program please

    Hi all,
    I please need help with this program, I need to display the amount of money over the years (which the user has to enter via the textfields supplied)
    on a graph, I'm not sure what to do further with my program, but I have created a test with a System.out.println() method just to see if I get the correct output and it looks fine.
    My question is, how do I get the input that was entered by the user (the initial deposit amount as well as the number of years) and using these to draw up the graph? (I used a button for the user to click after he/she has entered both the deposit and year values to draw the graph but I don't know how to get this to work?)
    Please help me.
    The output that I got looked liked this: (just for a test!) - basically this kind of output must be shown on the graph...
    The initial deposit made was: 200.0
    After year: 1        Amount is:  210.00
    After year: 2        Amount is:  220.50
    After year: 3        Amount is:  231.53
    After year: 4        Amount is:  243.10
    After year: 5        Amount is:  255.26
    After year: 6        Amount is:  268.02
    After year: 7        Amount is:  281.42
    After year: 8        Amount is:  295.49
    After year: 9        Amount is:  310.27
    After year: 10        Amount is:  325.78
    After year: 11        Amount is:  342.07
    After year: 12        Amount is:  359.17
    After year: 13        Amount is:  377.13
    After year: 14        Amount is:  395.99
    After year: 15        Amount is:  415.79
    After year: 16        Amount is:  436.57
    After year: 17        Amount is:  458.40And here is my code that Iv'e done so far:
    import javax.swing.*;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.lang.Math;
    import java.text.DecimalFormat;
    public class CompoundInterestProgram extends JFrame implements ActionListener {
        JLabel amountLabel = new JLabel("Please enter the initial deposit amount:");
        JTextField amountText = new JTextField(5);
        JLabel yearsLabel = new JLabel("Please enter the numbers of years:");
        JTextField yearstext = new JTextField(5);
        JButton drawButton = new JButton("Draw Graph");
        public CompoundInterestProgram() {
            super("Compound Interest Program");
            setSize(500, 500);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            amountText.addActionListener(this);
            yearstext.addActionListener(this);
            JPanel panel = new JPanel();
            panel.setBackground(Color.white);
            panel.add(amountLabel);
            amountLabel.setToolTipText("Range of deposit must be 20 - 200!");
            panel.add(amountText);
            panel.add(yearsLabel);
            yearsLabel.setToolTipText("Range of years must be 1 - 25!");
            panel.add(yearstext);
            panel.add(drawButton);
            add(panel);
            setVisible(true);
            public static void main(String[] args) {
                 DecimalFormat dec2 = new DecimalFormat( "0.00" );
                CompoundInterestProgram cip1 = new CompoundInterestProgram();
                JFrame f = new JFrame();
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.getContentPane().add(new GraphPanel());
                f.setSize(500, 500);
                f.setLocation(200,200);
                f.setVisible(true);
                Account a = new Account(200);
                System.out.println("The initial deposit made was: " + a.getBalance() + "\n");
                for (int year = 1; year <= 17; year++) {
                      System.out.println("After year: " + year + "   \t" + "Amount is:  " + dec2.format(a.getBalance() + a.calcInterest(year)));
              @Override
              public void actionPerformed(ActionEvent arg0) {
                   // TODO Auto-generated method stub
    class Account {
        double balance = 0;
        double interest = 0.05;
        public Account() {
             balance = 0;
             interest = 0.05;
        public Account(int deposit) {
             balance = deposit;
             interest = 0.05;
        public double calcInterest(int year) {
               return  balance * Math.pow((1 + interest), year) - balance;
        public double getBalance() {
              return balance;
    class GraphPanel extends JPanel {
        public GraphPanel() {
        public void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setColor(Color.red);
    }Your help would be much appreciated.
    Thanks in advance.

    watertownjordan wrote:
    http://www.jgraph.com/jgraph.html
    The above is also good.Sorry but you need to look a bit more closely at URLs that you cite. What the OP wants is a chart (as in X against Y) not a graph (as in links and nodes) . 'jgraph' deals with links and nodes.
    The best free charting library that I know of is JFreeChart from www.jfree.org.

  • Need help in creating custom reports

    hello,
    I am using EM 10.2.0.2 on windows 32-bit.
    All EM components are installed on a single machine.
    Have installed AGENT 10.1.0.5 for managing targets which are on LINUX 2.1
    Please help me in getting the solution for the following queries:
    (a)I need to create a custom report regarding the CAPACITY MANAGEMENT .
    (b)I have some UDM defined but I am not able to use these UDM while creating custom report.
    (c)Also is there any possibility that we can use views other than REPOSITORY VIEWS. What I meant was : instead of using REPOSITORY VIEWS can we use the tables of the target instances.
    Thanks in advance.

    Same post
    Need help on repository views for creating custom capacity planning reports

  • I need help in Custom Reporting

    Hi,
    i need help in auditing, SCOM 2012 R2 is deployed in 2 servers with ACS, i have 2 file server that has some shared folder in which users work on some certain document i need to have a report that i can run on certain file that will show me who access that
    file when he access what he did like (read write, delete). i don't think we have this type of capability in default report. let me know if someone can help me in that. (free/paid) i know its a bit customized. let me know if u need any more info.
    Syed Kasif

    Hi,
    As far as I know, to audit file access, we should Enable Audit Policy, and then Set up Audit System Access Control List (SACL).
    After that, we can make sure that under security event logs there are auditing logs for file access.
    Please refer to the below link for more details about auditing file access on file server:
    http://blogs.technet.com/b/mspfe/archive/2013/08/27/auditing-file-access-on-file-servers.aspx
    And for Collecting Security Events Using Audit Collection Services in Operations Manager:
    http://technet.microsoft.com/en-us/library/hh212908.aspx
    Regards,
    Yan Li
    Regards, Yan Li

  • I need help from Customer Support. Whatever this charge is on my credit card,

     He recibido un cargo de su tienda, que curiosamente he visto que se han hecho muchos cargos a diferentes personas bajo el mismo copncepto y tienda.Favor acreditarme dicho monto porque no he comprado nada con ustedes y ni tengo idea donde está Minesota.Este es mi cargo. 23/07/15323343GEEKSQUAD RENE00015826 RICHFIELD UUSRD$1,428.010.00 Y veo en Internet que otros clientes han hecho reclamos del mismo concepto.   Subject Author PostedGEEKSQUAD RENE00015826Care‎03-09-2015 06:30 PMGEEKSQUAD RENE00015826 Unknown ChargePriscillaQ‎12-29-2014 10:08 PMrandom 10 dollar charge from richfield MN to my ac...ChrisBurns‎07-01-2015 12:50 PMUnknown Geeksquad charge on my Credit CardHardingR‎12-01-2014 05:57 PMGeekSquad protection terms changed without being i... Lo que me hace pensar que algo anda muy mal en ese Best Buy.  Como es posible que no hayan corregido e identificado quienes están detrás de este fraude que lleva años. I need help from Customer Support.  Whatever this charge is on my credit card,jesmann‎10-05-2014 04:52 PM  

    Hola scj2000-
    Muchas gracias por visitar nuestro foro en búsqueda de una explicación al cargo que recién apareció en tu tarjeta de crédito.
    Entiendo su preocupación, ya que cualquier cargo extraño que aparece en un estado de cuenta puede ser alarmante. En este caso, el último cargo que puede recuperar usando el correo electrónico que usaste para registrarte al foro, refleja que se renovó un antivirus Kaspersky. Esta autorización nos diste cuando realizaste la compra de tu Lenovo, desde entonces se renueva automáticamente la licencia de antivirus.
    Las otras publicaciones que has leído, indican lo mismo. Un cargo que se ha hecho a la tarjeta de crédito que se presentó durante la compra con la autorización del cliente.
    Lamento mucho la confusión y espero esto aclare tu duda.
    Atentamente,

  • Bought a Template for a customer Need Help

    I know HTML but the coding to change things baffles me.  I am out of help with the seller who is in Australia.
    This is what the .txt looks like that I change function with.
    &Home_txt8=<font color="#d0d0d0"><b>text goes here
    It looks straightforward but I cant use /*  */  or <!--  to deactivate stuff so I can try it out.
    Any help would be welcomed.
    the url of the site is www.danceations.com
    I have done some mods but want to do more.
    Joepd

    The replies are terse and don't come right away. I bought it from some 
    outfit in Australia.  When I asked how do I get rid of the pulldown phono  on
    the index page the answer was "remove the first page of the Flash.fla.  
    Except it took out the song I added and I would need tro recreate a Flash  Page.
    Ugh!
    Not a good experience.
    joepd
    In a message dated 2/9/2012 4:19:49 P.M. Eastern Standard Time, 
    [email protected] writes:
    Re:  Bought a Template for a customer Need Help
    created by John Waller (http://forums.adobe.com/people/John+Waller)  in 
    Dreamweaver - View the full  discussion
    (http://forums.adobe.com/message/4196974#4196974)

  • Need Help updating custom API Interface to VME-MXI-2

    Need Help.
    I have a custom Visual C++ 6.0 application that interfaces to the VME-MXI-2 card.
    This interface works on older machines, but when we upgrade to new PC's, the interface works, yet it appears that communication exists between the hardware board, and the PC Card appears to be working properly.
    I suspect that the drivers have a different interface, but need the interface documentation in order to verify this, can you help?
    Older machines use: PCI-MXI-2, and the driver is: C:\Windows\System32\Drivers\vvxid.sys (File version 1.2) cpright 1996-2000
    Newer machine has: PCI-MXI-2, and the driver is: C:\Windows\System32\Drivers\nipalk.sys (File version 1.61f0) cpright 2002

    Alan,
    As for reading and writing memory addresses from the VME memory map, you could use functions such as viIn8, viIn16, viIn32, viOut8, viOut16, or viOut32 in the NI-VISA API. You can find the NI-VISA Funtion help at "Start >> Programs >> National Instruments >> NI-VISA >> NI-VISA Help" for Windows. Alternativelly, the NI-VISA Programmers Reference Manual is available for download from ni.com.
    What exactly is your application that uses ACFAIL? ACFAIL is typically pretty unrealiable, and is a difficult signal to catch (especially over a bus extension like MXI-2). Basically, ACFAIL is asserted right before a total failure/shutdown of the chassis, so you have a very short window of time to detect the signal before it disappears.
    Regards,
    Greg Caesar
    App
    lications Engineer
    National Instruments

  • Need help urgently, I upgraded my iPhone 4 with new OS 5, but at the last restore failed. Apple Customer Care helped me to resynch my phone with all that available in Library. I've got all back except my Contact no. Pls help guys, thnx

    Need help urgently, I upgraded my iPhone 4 with new OS 5, but at the last restore failed. Apple Customer Care helped me to resynch my phone with all that available in Library. I've got all back except my Contact no. Pls help guys, thnx Plz guys anyone can help plzz....I've lost all contact and I dont even have any secondary back up also...!!!

    If you've had it for less than a year, then it's still under warranty.  Take it to an Apple store or an authorized service facility.  See http://support.apple.com/kb/HT1434

  • Need Help: Generate Customer Data from Prod Database

    Hi All,
    My company have an Oracle Financial System, with and old version Oracle Application 11.0.3 and Oracle Database 8.0.5. The database name PROD. This system has been use for more than 7 years and in between there were many stuff resigned without handover and therefore many records and supporting steps cannot be trace back. However the system is still keep running and updated daily.
    Recently we have a user request to generate out a list of customer company name, and their related products purchase from the database, this is because they does not have any methods to print out the list from application. Unfortunately, we do not know which tables or index is actualy storing the name of the customer and products. We have the list of below users accounts that able to log in to the database.
    PA/PA
    APPLSYS/APPS
    APPS/APPS
    ALR/ALR
    AX/AX
    AK/AK
    GL/GLRG/RG
    FA/FAHR/HR
    SSP/SSP
    HXT/HXT
    OTA/OTA
    RLA/RLA
    VEH/VEH
    QA/QA
    ICX/ICX
    AZ/AZ
    AP/AP
    AR/AR
    OE/OE
    OSM/OSM
    NSM/NSM2020
    CN/CN
    MFG/MFG
    INV/INV
    PO/PO
    BOM/BOM
    ENG/ENG
    MRP/MRP
    CRP/CRP
    WIP/WIP
    CZ/CZ
    PJM/PJM
    FLM/FLM
    MSC/MSC
    CS/CS
    CE/CE
    EC/EC
    JG/JG
    APPS/APPS
    All the reference documents is no longer exist. I am able to use SQL Plus to generate the list of tables with the command : select table_name from user_tables. Each user accounts will return different kind of table names. But still I cant locate which table that actually storing the name of the customers and products.
    Is that anybody got hands on this case before? Urgent

    We have this table: And need to unload this table data in flat file format.
    Need help with unload SQL file with these two columns:
    AMT_PAID_ORIG, AMT_PAID_ADJ
    SQL> desc flconv.claim_adj_less
    Name Null? Type
    SAK_CLAIM_ADJ_LESS NUMBER(10)
    SAK_CLAIM_ADJ NUMBER(10)
    ADJ_CLAIM_ICN NUMBER(13)
    ORIGINAL_CLAIM_ICN NUMBER(13)
    DATE_PAID_ORIG NUMBER(8)
    DATE_PAID_ADJ NUMBER(8)
    AMT_PAID_ORIG NUMBER(10,2)
    AMT_PAID_ADJ NUMBER(10,2)
    SAK_PROV_LOC NUMBER(9)
    SAK_FUND_CODE NUMBER(9)
    CHECK_SAK NUMBER(9)
    SAK_PUB_HLTH NUMBER(9)

  • Red light on new HH3- New custome,r need help trye...

    Hi new bt broadband customer need help getting connect for the very first time. Iv got  RED broadband light on all the time and have tryed everything to get it working. Any ideas why its not connecting  please. Activation dat was 17th February 2011 .
    Many thanks

    suggest you mail the board mods they are good at solving your sort of problem forum.moderation.team@bt .com including a link to this post and your bt phone number and bt account number they normally get back to you within 72hours as all emails are dealt with in turn
    If you want to say thanks for a helpful answer,please click on the Ratings star on the left-hand side If the reply answers your question then please mark as ’Mark as Accepted Solution’

  • Hi need help on getting customer open  items

    hi all,
    i need help regarding getting open items for customers in the previous
    ie. if i give current date,
    i want to get the open items for past 30 days from current date
    help me to get this ...
    thanks a lot
    regards,
    selvi

    or else ,
    use table BSID.
    Regards
    Peram

  • Need help in drawing inside the Oval and outside it

    I need help in something
    I have an array and I want the numbers to be around the oval and I have part of the array and I want to fill part of the oval
    and when I want to put a number I would like a line from the center to point at the number
    I know its hard to explain so I have picture maybe you will know hwo its work
    http://img265.imageshack.us/i/55788522.jpg/
    I have almost everything done the oval and all the code but I have no clue how to do what I explained

    import static java.lang.Math.*;
    import java.awt.*;
    import javax.swing.*;
    @SuppressWarnings("serial") public class Trefoil extends JComponent {
            setPreferredSize(new Dimension(400, 400));
        @Override protected void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D) g.create();
            int w = getWidth(), h = getHeight();
            g2.setColor(getBackground());
            g2.fillRect(0, 0, w, h);
            g2.setColor(getForeground());
            g2.translate(w/2, h/2);
            g2.setRenderingHint(
                RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
            int rays = 100;
            for(int i=0; i<rays; ++i) {
                double angle = i*(2 * PI)/rays;
                double flange = cos(1.5* angle - PI/4);
                int r = (int)(190 * flange * flange);
                int x = (int)(r* cos(angle));
                int y = (int)(r* sin(angle));
                g2.drawLine(0, 0, x, y);
            g2.dispose();
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    JFrame f = new JFrame("Trefoil");
                    f.add(new Trefoil());
                    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    f.pack();
                    f.setLocationRelativeTo(null);
                    f.setVisible(true);
    }

Maybe you are looking for

  • Phone problems after upgrade from 8.5 to 9.0

    Hi everyone, I upgraded our UCCX cluster last week from 8.5 to 9.0, and ever since then I've been getting reports of delays when answering a call (up to ~10 seconds). I also have one user that reports not being able to hangup at the end of a call (ha

  • Syncing iPad to iPod from iTunes on external hard drive

    I had all my music stored on my laptop but was running out of space so I transferred it all to an external hard drive. That's when everything went pear shaped! Tried to sync it all but messed it up. Now I have all songs on iPad, but it won't sync new

  • Can't run host function in procedure and reports

    Hello i'm unable to use the host function in reports and procedure. host('ar60runb userid=apps/apps report=/vision/d01/oracle/visappl/fnd/11.5.0/reports/US/UBLPS1.rdf batch=yes mode=bitmap destype=file desname=/vision/d01/oracle/visappl/fnd/11.5.0/re

  • Difference between drill down and filter using navigation attributes?

    hi all, can anyone let me know the difference between filter and drilldown options using navigational attributes. pls explain with examples for filter and drill down and how it varies. thanxs haritha

  • Should PreparedStatement close before continue next PreparedStatement ?

    Hi guys, For instance, I need to use PreparedStatement for several insert and update like below: Connection conn; // got the connection PreparedStatement pstmt = conn.prepareStatement("insert ......"); pstmt.addBatch(); pstmt.executeBatch(); *// shou