How to write a text on a chart?

By left click of the mouse on a chart, I would write a text by creating a rectangle of text box so that you can resize and move.

Any help really with really enjoyed code example.

Hello. Try the following text:

import javafx.application.Application;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.scene.shape.Polygon;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class XyChart extends Application {

    SimpleIntegerProperty clickIn = new SimpleIntegerProperty(0);

    Pane pane = new Pane();
    StringBuffer sb = new StringBuffer();

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) {

        final CategoryAxis xAxis = new CategoryAxis();
        final NumberAxis yAxis = new NumberAxis(1, 21, 0.1);
        yAxis.setTickUnit(1);
        yAxis.setPrefWidth(35);
        yAxis.setMinorTickCount(10);
        yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis) {
            @Override
            public String toString(Number object) {
                String label;
                label = String.format("%7.2f", object.floatValue());
                return label;
            }
        });
        final LineChart lineChart = new LineChart(xAxis, yAxis);

        lineChart.setCreateSymbols(false);
        lineChart.setAlternativeRowFillVisible(false);
        lineChart.setLegendVisible(false);

        XYChart.Series series1 = new XYChart.Series();

        series1.getData().add(new XYChart.Data("Jan", 1));
        series1.getData().add(new XYChart.Data("Feb", 4));
        series1.getData().add(new XYChart.Data("Mar", 2.5));
        series1.getData().add(new XYChart.Data("Apr", 5));
        series1.getData().add(new XYChart.Data("May", 6));
        series1.getData().add(new XYChart.Data("Jun", 8));
        series1.getData().add(new XYChart.Data("Jul", 12));
        series1.getData().add(new XYChart.Data("Aug", 8));
        series1.getData().add(new XYChart.Data("Sep", 11));
        series1.getData().add(new XYChart.Data("Oct", 13));
        series1.getData().add(new XYChart.Data("Nov", 10));
        series1.getData().add(new XYChart.Data("Dec", 20));

        pane.getChildren().add(lineChart);
        final Scene scene = new Scene(pane, 800, 600);
        lineChart.setAnimated(false);
        lineChart.getData().addAll(series1);

        lineChart.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler() {
            public void handle(MouseEvent event) {

                if (clickIn.get() == 0) {
                    Text ta = new Text("shakir");
                  final  StringProperty sp = new SimpleStringProperty("sh");
                   ta.textProperty().bind(sp);
                    clickIn.set(1);
                    System.out.println("Clicked");
                    pane.getChildren().add(ta);
                    sp.set("");
                    ta.relocate(event.getX(), event.getY());
                    ta.requestFocus();
                    ta.setOnKeyPressed(new EventHandler() {
                        public void handle(KeyEvent e) {
                            if (e.getCode() == KeyCode.ENTER) { clickIn.set(0); }
                            else {
                            String t = sp.get();
                           sp.setValue(t + e.getText());
                            }
                        }
                    }); 

                } else {
                    clickIn.set(0);
                   // pane.getChildren().remove(ta);
                    event.consume();

                }

            }
        });

        stage.setScene(scene);
        stage.show();

    }
}

Tags: Java

Similar Questions

  • Hi I need to know how to write Arabic text with indesign cc 2015

    Hi I need to know how to write Arabic text with indesign cc 2015

    One thing has changed: since CS6 (Version cloud only) you can install the operating system in Arabic or Hebrew any other language without extra cost.

  • How to write the text file in Shockwave?

    Someone knows how to write the text file in Shockwave on the disc of the user?

    Thanks in advance.

    These Xtras can cause a lot of havoc when used with the intent to hurt.
    What you can do is to write with setpref and store a list of backups and the
    registers itself separately. Next, you need to build your own save/open
    dialog box for the user:
    * Choose a previously saved file to load or replace
    to create a user type the name of a new file to be saved.

    The only thing that remains is that the user can't decide where files
    are saved.

    Manno

    SiuLinda wrote:
    > Thanks a lot for your answer.
    > Yes, cookies is good, but I have to write a program to save the text file in
    > When the user wants, the user can open these files later if they like as, using
    > Filextra and Fileio, but I found that all these Xtra extensions seem to be not supported by
    > shockwave.
    >

    --
    ----------
    Manno Bult
    [email protected]

  • How to write a text on an image data

    Hello

    I am facing a problem where I am suppose to write a particular text string, then tagg it with the ie.write of the image on the image and save it, also when retrieving images, it should show the data written to the image respectively.

    Please let me know if you have a response to my query

    Kind regards.

    You must obtain the graphics object from the bitmap to aid

    Graphics g = new Graphics (bitmap);

    Now you can paint on the bitmap to aid

    g.drawText (text, x, y);

    changes made to the graphics object are made directly to the bitmap image (since both speak to eachother)

  • How to write a round text shape in Photoshop

    Hi friends,

    I have a question and if someone can help me I will be grateful if you

    I'll design a Logo for one of my clients. the logo is like a rounded shield. Here is an example

    [IMG] http://I41.Tinypic.com/zl214o.PNG [/IMG]

    Please see this image. I can write the text on the top of the form to which is the "Center of training for employment. Please see the image. on the image where this text is written on bottom of shae 'training Skill. Human development' how to write this text. I tried encapsulate the text using the Arc option, but the text is stretched. Please if you know how to help me

    Thanks

    Amir

    One way is to make two circles drawn with the Ellipse tool and type the above text outside the

    the insde circle and background text on the insde of the outside circle.

    Then use the vertical offset to move the guy facing upwards or downwards.

  • How to write with a pencil Apple then convert to text (mac)

    I just got my apple pencil - I would use to take notes, and then convert handwritten notes to text, but I can't understand it! I can write things but how to convert to text? I'm a mac household only.

    Try the _MyScript Stylus - writing Keyboard_ App form the App store. It installs like a new keyboard that you can use in any application.

    You can select the MyScript - keyboard stylus anywhere you would use the regular keyboard, exactly as you would select the Emoji keyboard. The keyboard is replaced by a scroll of handwriting and just write in the book, and it is converted to text in application what ever you use the keyboard.

    There are other applications to create text based on handwriting notes, but I liked this one because it can be used with any application.

    I forgot to mention, it's free!

  • Hypervisor-HyperTerminal: how to write texts in HyperTerminal to a VI in real-time

    I use on my PXI system hypervisor. With 'Specifications to build', I built my RT application in a standalone rtEXE file and set it as start VI for my RT system. It seems to work, since I have received information from my "hypervisor-HyperTerminal" while restarting the RT system.  He writes, "Startup Application: d:\ni-rt\startup\RTMain.rtexe. However, I don't see how my RT application is running or if an error occurs.  Therefore, I think to write texts or my RT application information to the HyperTerminal.

    I wanted to use VISA to the serial port of the HyperTerminal on the side-access system in real time. I used the example LabVIEW "basic series write and Read.vi ' to 'smplserl.llb '.  Under the system in real time, I found only a single resource VISA name, which is "COM1".  Apparently, I can write successfully texts at the port "COM1", because no error was shown in the example VI. But the texts do not appear on the HyperTerminal.

    Do you have an idea, what I did wrong in my attempt, and how I had to do it correctly? Thank you very much.

    Kind regards

    Scarletice

    Hello Scarletice,

    You can use the Debug String VI (http://zone.ni.com/reference/en-XX/help/370622J-01/lvrtvihelp/rt_debug_strings/) RT a message programmatically to the console at the time on a Real - Time Hypervisor system LabVIEW Real-time.

    Please let me know if you need additional help, and have a nice day!

    Best regards

    Casey Weltzin

    Product Manager, LabVIEW Real-time

    National Instruments

  • I am a newbie to this and I was wondering how to write CSS Code for text, text color, size text and text effects...

    Please keep in mind that I am a newbie. For the moment, I don't know how to write code, so I use Muse to try to build a Web site that is not super fancy writing know, then improve or build or create a new site later. I called Adobe and they said someone in the forums may know how to write code and that he could help me. That said, if someone could answer my questions and help me somehow, I'd be really grateful.

    1. How can I write code, what code should I write to

    Text?

    Color of the text?

    Text size?

    Text/Font Style

    Text effects (such as fly in or fly out, bounce in and out bounce, spin in and spin out, fade in and fade out, etc)?

    Direction of text effect?

    Time that the effect occurs, if it is applied, initiated, comes in? example fly in or fade?

    Time than the last.

    After the effect stops, turns off? example: fly away or fade out?

    2. how to enter the code Muse?

    3. should I have a program to write the code?

    4. is there a function I could use on my computer, such as Notepad, to write the code, copy and paste it into Muse?

    5. What is the best book or books to learn how to write css, code and everything I need to do to be able to do the above and more?

    6. is there anything else I need to know or do to be able to do these things with the text?

    You can find more information on the style of your text (paragraphs, titles, etc. in some of the tutorials here: TUTORIALS |) Adobe Muse CC

    You can also check out tutorials on this page for scrolling effects that can do some of the other effects you need. Without exactly knowing your use case it's hard to give specific advice.

    Basically if it is not covered undressed under the text, scrolling Effects tutorials or in a third party widget already made, then you will need to create it yourself using CSS. You will need to use some sort of browser Firebug like developer tools in Firefox to find the ID of the element you want to add the CSS to write the CSS code and insert it into the head section of the page properties.

  • How to place text on a chart? Help!

    I'm having a problem placing text on a chart.  This is the title of the publication, the logo, the etc which all one file.  I would like to put the 'volume' & 'edition' info in a text top box so it can be easily changed to each edition... no ebb in photoshop.  I don't know that I've done this before!  However, no matter what I try launching the text away from the image.  I tried to send to the back and saved the graphic formats (.png, .pdf, .jpg) to see if it makes a difference.  What Miss me?  Thanks for any help!

    You have applied to the cover image. Either disable it or click with the right button on the text block, choose select and text frame properties don't know skin.

    Bob

  • How to read and write a text file to the folder of the user preferences?

    I'm trying to code for the user to record the plug-in, the first time that the user opens Acrobat after you have installed the plug-in. I want to write a file of registration of preference of the user folder access later to check that they are already registered.

    Is there an easy way to do this? I wrote the code to access the preference of the user folder to search for the file, but I have not been able to code for the write file. All I've found is how to write a PDF file.

    Any suggestions?

    Gregory

    ASFileRead/ASFileWrite

  • Writes a text file from a network computer to another computer on the network.

    It is possible to write a text file from a computer on the network to another computer on the network through labview without using FTP?

    Hi bebo_lm,

    It depends on how they are connected. If you have a 'normal' access to the pc and you can write on a hard drive of the other computer, you can use the writing functions of files or the copy of the file. If they are not connected like this, then you need another service. Why you do not use FTP?

    Mike

  • Image of a on comment write some text (Vision/beginner

    Hello

    I get an image from a camera and I'd like to write some text on top before generating an AVI file.

    Typical of current process information.

    I do not see how to take the problem or if there is a function all do in the vision palette!

    Has anyone an idea?

    Thank you for your help

    EricC

    Forget this qestion, I hadn't seen the function!

    Sorry for the inconvenience

    Sorry, I didn't choose the right forum

    (and I found the solution by miself)

    the respect of

    EricC

  • How to erase a text file...

    Hi all...

    I wud would like to know how to delete a text file...

    Am currently replacing the text file and writing... In fact, I need to open the file (after erasing the content) and write.

    I think that replace the file every time is not a good idea...

    So please let me know how to delete the text file.

    Thanks in advance.

    You can set the file size to zero using "Set File Size" in the palette of advanced file i/o.

  • How to load the text file into a table and retrieve data line by line?

    I'm looking to help understand how to open a text file, each line in a table of load.  The data will be called to change the content of the text layer.  Thanks for any help.

    I did not test this code, but something like

    var a = [];

    var f = new File (Folder.desktop + "/ TestFile.txt");

    If (f.open ('r')) {}

    While (! f.eof) {}

    a.push (f.Readln ());

    }

    f.Close ();

    }

    Alert ("I read" + a.length + "lines in the file.");

    for (var i = 0; i)< a.length;="" i++)="">

    DoSomethingWithThisLine (a [i]); //<-- you="" need="" to="" write="">

    }

  • How to cut the text in Illustrator?

    I am lettering my comic in Illustrator, and I'm pretty new to Illustrator.  How can I cut or obscure the text?  For example, if I have the lettering on a book that is partially shot on a shelf, or lettering on the side of a semi trailer, but it is blocked by an object in front of him.  How 'block' it with an invisible object, or slice, or something?

    I realize that it involves probably change my text in a chart so that it is no longer editable.  No problem.  I just need to learn how do.  I don't know there's a great tutorials on it; I don't know how to find them because I don't know how it's called.  I thought it would be masking, but everything I tried had no effect.

    Thanks in advance for your help.

    EDIT: I thought it might be useful I showed exactly the situation I have here.  I circled the two spots where I need to be able to edit the text.  As you can see on the yellow triangle, I was juggling with masks to try to understand this.

    These four panels is arranged as cards to play, with the name of each participant and the suit of the card at the top and bottom.  The problem is that you map overlays another, so I need to be able to cut name Thaddeus of the Sultan on the left and the J (for Jack of hearts) on the right.

    All the texts of four cards are on different layers, with works of art and the word balloons and text on layers separate as well.

    masking problem.png

    This is page 1 of the next metro Med, the Hospital of superhero show

    Copyright Michael Hutchison

    I THOUGHT ABOUT IT!  Trial and error, I just kept going through the possibilities until I found a combination that worked.  Thanks, Silkrooster, to show me the right path!

    Here's what I did (just for someone else who finds this and needs the solution to a similar problem).

    1. I put my yellow triangle ON the part of the text I wanted to keep in this case, the curvature of the J and the symbol of the heart.
    2. I selected the triangle layer so the layer J/heart.
    3. In the window of transparency, I used the pop-up menu corner (I'm in CS4) to check "new opacity masks are clipping" and make sure that the "...» are reverse' option has not been verified.
    4. I chose to "make opacity mask".

    That's all!  Ta - dah!

    Thanks a lot for all your help!

    (Apologies, it's really Silkrooster who had the right answer, but I am marking this as the correct answer just so that future people have a little more guidance step by step it spelling.)

Maybe you are looking for

  • Failed to load the URL of the addressfield

    Type a URL in the addressfield and confirm with the button Enter or by clicking on the round arrow in the addressfield has no effect whatsoever. The only way to get there is choosing a URL in bookmarks or by clicking on a link from another site. It's

  • Line break command missing in 2013 CVI

    I just changed to CVI 2012-2013.  I want to set up the command line cut (Ctrl-Y) in 2013, but as much as I know there is not cut command line available in the Options-> menu to change shortcut keys. Is avialable cut line in 2013? Tony G.

  • Remote Desktop failed, how can ensure me that this will not happen?

    Hello I have a computer that is put in place in a holiday home in another State I want to be able to access through Windows Remote Desktop.  The computer connects wireless to the Internet via a router Linksys WRT160Nv3.  I had to check out the comput

  • BlackBerry smartphones on the use

    Hello If the handset was purchased by the India and GSM one can be used abroad with their local sim card? With kindness and know me.

  • Problema Con Copia Original Windows 7 Starter

    HACE A YEAR WANT AN EQUIPO CON WINDOWS 7 STARTER. VENIA CON EL DVD 32-BIT ORIGINAL, BACK DIAS LO INSTALE IN OTRO EQUIPO NUEVO, Y HACE ME NOT AS SOON AS THE CLAVE DEL PRODUCTO NO COINCIDE. SUCEDE QUE, GRACIAS POR SU AYUDA. LO INTALE IN UNA PORTATIL VI