Tick-BarChart axis labels are missing in JDK1.8

Hi guys!

Currently, I'm trying to integrate a JavaFX BarChart in my existing Java application. So I need a my BarChart BufferedImage, so that I can make this snapshot on a graphics instance.

I adapted the existing BarChartSample.java (Graphic sample |) Tutorials of JavaFX and Documentation) and deleted all the animations. The hand of code works fine but I have identified a problem-> my TickLabels lack

The TickLabels are visible if I use JDK 1.7u51 but if I change the JDK 1.8u05... the stlye of my histogram will be changed and my tick labels are not visible.

I missed something or is this a bug?

Thanks in advance!

Best regards

Steve

----------

using the JDK 1.7u51

https://drive.Google.com/file/d/0B7P_rknS1TWxMUVaRHNzNzBEWVk/edit?USP=sharing

using the JDK 1.8u05

https://drive.Google.com/file/d/0B7P_rknS1TWxZFV6ZVZvR3ZqM3M/edit?USP=sharing

My adapted code is as follows:

package barchartsample;


import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;


import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.Scene;
import javafx.scene.chart.BarChart;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.image.WritableImage;


import javax.swing.JFrame;
import javax.swing.JPanel;


public class BarChartSample
{
  /**
  * Initialize JavaFX
  */
  private static final JFXPanel initializeJFX = new JFXPanel();

  final static String austria = "Austria";

  final static String brazil = "Brazil";

  final static String france = "France";

  final static String italy = "Italy";

  final static String usa = "USA";

  public static void main(String[] args) throws InterruptedException, ExecutionException
  {
      JFrame frame = new JFrame();
      frame.setSize(815, 640);

      frame.add(new JPanel()
      {

            @Override
            public void paint(Graphics g)
            {
                try
                {
                      g.drawImage(getChartImage(), 0, 0, null);
                }
                catch (Throwable t)
                {
                      t.printStackTrace();
                }
            }
      });
      frame.setVisible(true);
  }

  static BufferedImage getChartImage() throws InterruptedException, ExecutionException
  {
      FutureTask<BufferedImage> future = new FutureTask<BufferedImage>(new Callable<BufferedImage>()
      {
            @Override
            public BufferedImage call() throws Exception
            {
                final CategoryAxis xAxis = new CategoryAxis();
                final NumberAxis yAxis = new NumberAxis();
                final BarChart<String, Number> bc =
                new BarChart<>(xAxis, yAxis);
                bc.setTitle("Country Summary");
                xAxis.setLabel("Country");
                yAxis.setLabel("Value");
       
                XYChart.Series series1 = new XYChart.Series();
                series1.setName("2003");
                series1.getData().add(new XYChart.Data(austria, 25601.34));
                series1.getData().add(new XYChart.Data(brazil, 20148.82));
                series1.getData().add(new XYChart.Data(france, 10000));
                series1.getData().add(new XYChart.Data(italy, 35407.15));
                series1.getData().add(new XYChart.Data(usa, 12000));

                XYChart.Series series2 = new XYChart.Series();
                series2.setName("2004");
                series2.getData().add(new XYChart.Data(austria, 57401.85));
                series2.getData().add(new XYChart.Data(brazil, 41941.19));
                series2.getData().add(new XYChart.Data(france, 45263.37));
                series2.getData().add(new XYChart.Data(italy, 117320.16));
                series2.getData().add(new XYChart.Data(usa, 14845.27));

                XYChart.Series series3 = new XYChart.Series();
                series3.setName("2005");
                series3.getData().add(new XYChart.Data(austria, 45000.65));
                series3.getData().add(new XYChart.Data(brazil, 44835.76));
                series3.getData().add(new XYChart.Data(france, 18722.18));
                series3.getData().add(new XYChart.Data(italy, 17557.31));
                series3.getData().add(new XYChart.Data(usa, 92633.68));
   
                bc.getData().addAll(series1, series2, series3);
                Scene scene = new Scene(bc, 800, 600);

                WritableImage fximage = scene.snapshot(null);

                return SwingFXUtils.fromFXImage(fximage, new BufferedImage((int) Math.ceil(fximage.getWidth()), (int) Math.ceil(fximage.getHeight()),  BufferedImage.TYPE_INT_ARGB_PRE));
            }
      });

      Platform.runLater(future);
      return future.get();
  }
}




Feedback from a developer:

This is because the labels are busy (melted), so they are not visible on the first image (that you captured). You must set

xAxis.setAnimated (false);
yAxis.setAnimated (false);

-> This works for me ;-)

Tags: Java

Similar Questions

  • Export a collection of catalog and import into the catalog of my work on my iMac, color labels are missing.

    During my project for my photography class, I have to shoot on site and edit the best photos with the model, on my MacBook. At home on my MacBook I export the collection newly created to a catalog (including negative files), copy the directory with the catalogue all the other files over the network and import the catalog into my standard catalog on my iMac. On my iMac, all the imported photos color labels went into my standard catalog, and very strange, color labels have also disappeared when I open the catalogue exported (and copied) on my iMac. Did I miss something?

    I don't think it's something to do with the copy over a network.

    My guess is that you have to look at metadata > color label set. Try to compare the settings on both computers. If they are different, a computer do not know what the other means red, yellow etc.

  • Design of the Vertical axis labels

    Hi all

    I am a newbie to Flex and has difficulties with a BarChart, where the vertical axis labels are small enough to be almost unreadable. I would like to increase the EIS of the labels, while keeping the overall size constant.

    I've added an AxisRenderer to the vertical axis and specified a styleName with a fontSize 10. The effect has been to reduce the size of the labels even more! (In fact, the mere presence of the AxisRenderer without a specification styleName was sufficient to cause this additional reduction). Later, I defined a color in the style just to check that the style has been applied (if only partially).

    Is there a better approach for dimensioning of the axis labels? I'm using BF 3 Beta 3. Thanks in advance for your suggestions.

    A-ah! gutters!

  • Axis label question

    My application creats personalized graphics using AS3 and a mySQL database. Almost all of the graphics make it very well, except that I have one that is supposed to set its min vertical axis at 0% and its maximum to 75% with intervals each 25%, and yet its labels make in the form of 0%, 30%, 50% and 80% instead of 0%, 25%, 50% and 75%. Data and grids are correct, just the axis labels are wrong. If I set the min to something other than 0, the labels are fine. This seems to be a problem if the interval is set to anything other than 5 or 10 (like 15 or 25). Can someone tell me whether it is a bug of Flex or if this problem could be caused by something else? This happens on a development server and the server, and there are a couple of other graphs that have this same problem.

    The graph in question can be seen at http://www.communityindicators.ewu.edu/graph.cfm?id=106.

    Thanks in advance for your help.

    Yes, I solved this problem!

    I had to put the maximumLabelPrecision to the LinearAxis.

  • Warning__program error__one or more files necessary for the operation of the memorex expressit label design studio are missing or corrupt. Please use the Setup program to reinstall the software.

    Tried to update to Safari that does not work after the update. Then my printer stop working. Get the following message: 'WARNING '.
    program error
    necessary for the operation of the studio of design of memorex expressit label one or several files are missing or corrupt. Please use the Setup program to reinstall the software. »
    Already uninstalled and re-installed the software manufacturer labels several times. No luck.

    It seems it all started to go wrong after your update of Safari went wong:

    http://www.Apple.com/support/Safari/

    Link above is for Support of Safari.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    We do not know your Label program Vista compatibility.

    Check if your program is Vista Compatible:

    http://www.Microsoft.com/Windows/compatibility/Windows-Vista/default.aspx

    Windows Vista Compatibility Center

    First thing to do is to check its Vista compatibility at the link above, and if not to see what patches/solutions are available from its manufacturer...

    http://www.howtogeek.com/HOWTO/Windows-Vista/using-Windows-Vista-compatibility-mode/

    If this is not Vista compatible, read the info on the link above.
    It works for some programs, but not all.

    This applies to software programs, NOT hardware drivers.

    If it's Vista compatible > uninstall it > Re-download/save to your desktop > right click on the setup.exe > run as admin.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    It comes with Vista, upgrade install and activate Forum.

    Try the Vista programs Forum:

    http://social.answers.Microsoft.com/forums/en-us/vistaprograms/threads

    See you soon.

    Mick Murphy - Microsoft partner

  • When you print a postage label, the numbers are missing

    When I print a label for the U.S. postal service, some of the tracking numbers are missing.  How can I fix it?

    Thank you

    Hello

    Try to use Print as Image option in the advanced settings of the print dialog box.

    Thank you

    Abhishek

  • Increase the police the axis labels and plot little away from the card.

    Hello friends,

    I developed a JavaFx program in which I traced a barchart.
    I'm not able to increase the font of the axis labels and also I want to print some for chart axis labels so that the tick-mark labels, and axis labels would not cross.

    In this table, I have "BOLD" axis-lines only in the left side and down. I also want the axis lines "BOLD" upstairs and to the right. If there is any way or method that please suggest me.

    My program is given below: -.

    SerializableAttribute public class BarChartHorzFx extends Application
    {
    the final static string AUSTRIA = "Austria";
    the final static string BRAZIL = "Brazil";
    final FRANCE Shared As String = "France";
    final static string Britain = "Britain";
    the final static string USA = "USA";

    /**
    * Main method
    @param args
    */
    Public Shared Sub main (String [] args)
    {
    Launch (args);
    }

    /**
    * FX lettering from here.
    */
    @Override
    public void start (steps) throws exceptions
    {
    final NumberAxis xAxis = new NumberAxis (0, 120000, 20000);
    xAxis.setLabel ("Value");
    xAxis.setTickLabelRotation (90);
    xAxis.setTickLabelFont (do ("Arial", 12));

    last axis desabscisses yAxis = new CategoryAxis();
    yAxis.setLabel ("Country");
    yAxis.setTickLabelFont (do ("Arial", 12));

    final BarChart < number, String > barChart = new (BarChart < number, String >
    xAxis, yAxis);
    barChart.setTitle ("summary of country");

    XYChart.Series < number, String > firstSeries = new XYChart.Series < number, String > ();
    firstSeries.setName("2007");
    firstSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(25601.34, AUSTRIA));
    firstSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(20148.20, BRAZIL));
    firstSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(10000, FRANCE));
    firstSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(35804.15, BRITAIN));
    firstSeries.getData () .add (new XYChart.Data < number, String >(12000, USA));

    Second series...
    XYChart.Series < number, String > secondSeries = new XYChart.Series < number, String > ();
    secondSeries.setName("2008");
    secondSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(57401.85, AUSTRIA));
    secondSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(41941.19, BRAZIL));
    secondSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(45263.37, FRANCE));
    secondSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(117320.16, BRITAIN));
    secondSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(14845.27, USA));

    Third series...
    XYChart.Series < number, String > thirdSeries = new XYChart.Series < number, String > ();
    thirdSeries.setName("2009");
    thirdSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(45000.65, AUSTRIA));
    thirdSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(44835.76, BRAZIL));
    thirdSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(18722.18, FRANCE));
    thirdSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(17557.31, BRITAIN));
    thirdSeries.getData () .add ((in English only)
    new XYChart.Data < number, String >(92633.68, USA));

    Addition of serieses to barchart
    barChart.getData () .addAll (firstSeries, secondSeries, thirdSeries);

    Scene = new Scene (barChart);
    stage.setScene (scene);
    stage.setTitle ("Histogram");
    internship. Show();
    }
    }

    See tables to style with CSS documentation-online http://docs.oracle.com/javafx/2.0/charts/css-styles.htm#CIHGIAGE.

    Fonts and the location can be changed via the - fx - police-* css types and -- translate - fx * types (see http://docs.oracle.com/javafx/2.0/api/javafx/scene/doc-files/cssref.html).
    Code can be validated at the clearer in the forums if surrounded by markers of code between the brackets.

    Info of the axis can be looked up and changed via css as below (since the graphics to style with CSS documentation):

    .axis {
        -fx-font-size: 1.2em;
        -fx-text-fill: #462300;
        -fx-tick-label-fill: #914800;
        -fx-font-family: Tahoma;
        -fx-tick-length: 20;
        -fx-minor-tick-length: 10;
    }
    
  • I have a bar chart and I need to completely remove the axis labels

    I have a bar chart, and I need to completely remove the axis labels and have only black 1px on the axis lines.

    I tried this in style but the font-size: 0; doesn't labels disappear completely.

    BarChart {}
    horizontalAxisStyleName:myAxisStyles;
    verticalAxisStyleName:myAxisStyles;
    }

    {.myAxisStyles}
    tickPlacement: none;
    do-size: 0;
    }

    Try adding a verticalAxisRenderer and a horizontalAxisRenderer between your tags barChart.

    That is to say.

    ....

    ...

    The key is in setting showLabels property to false.

    J

  • Change the axis labels

    Hello

    Is it possible to change the labels of the axis on the length? Because we designed a graphic page where the SQL statements can be created dynamically. So the axis labels must also be changed. But I couldn't figure out how to make...

    Thank you
    Osman...

    Hello

    You can create hidden item dynamically set you the value.
    Then use point as below on the attributes of table settings Axes

    &Px_MY_ITEM.
    

    Hope this helps and is what you are looking for

    BR, Jari

  • I have someone just showed about 100 pictures of my iPad. Now, the pictures are missing, and the "recently deleted" folder is also empty. What can I do?

    I have someone just showed about 100 pictures of my iPad. Now, the pictures are missing, and the "recently deleted" folder is also empty. What can I do?

    Have you done something after their show.

  • All my photos/events before 2013 are missing from iPhoto.

    All my photos/events before 2013 are missing from iPhoto. I checked the record events on the left. Can someone help me locate the photos? My MacBook Pro is up to date OS x 10.11.6

    What has changed since they were here?

    Given virtually no details the best guess is that you have several libraries of liPhoto - hold down the option key when launching iPhoto and see how many libraries are there in the window that appears choose library - test each of them to see what it contains

    LN

  • All my tabs are missing! Rename and copy/paste the files did not help

    I accidentally opened two windows of Firefox and closed one with all my tabs pinned first, then the second tab. After Firefox reload all my tabs are missing and I tried to rename files, copy and paste files, etc. as suggests these forums, but nothing has worked. I have myself screwed on?

    Check first the Menu history for any tab restore options.
    In the second place.
    If you have already restarted Firefox and have a copy of the files: close Firefox

    1. Open the profile folder profiles - where Firefox stores your bookmarks, passwords and other user data
    2. Save the previous.js recovery.bak and recovery.js under another name
    3. Place the recovery files in the profile folder.

    So that this does not happen again change your tab Preferences and settings or try Session Manager add and save your profile.

  • email and electronic mail files are missing... How to bring them back?

    My Thunderbird account suddenly disappeared. I have Thunderbird back, but all of my saved emails are missing. Some of the Inbox went back to June 20, returned in a single account, but all the others are missing. Sent folder is empty like the others. I can find where the files are located on the computer, but I don't know how to bring back them to Thunderbird, if I'm right.

    I don't know if I've been hacked or whether it is a quirk that can be fixed. If anyone can help me, I'll be really grateful. Thank you!!!

    My best guess what happened was Thunderbird lost track of your profile (for some reason any) and started with a new clean profile.
    You could recover the existing profile, but since you already took the trouble to recreate your accounts, it is not necessary.

    I can find where are all the emails/files, but I can't find a way to restore them.

    Install this add-on.
    https://addons.Mozilla.org/en-us/Thunderbird/addon/ImportExportTools/

    Then you can it use to import existing e-mail files of the old profile. Note that e-mail files are those without file extension, for example, "Inbox" or "sent".

    If there is anything else, you can retrieve it from the old profile, see this article.
    http://KB.mozillazine.org/Transferring_data_to_a_new_profile_-_Thunderbird

  • Fonts I have installed in the font book are missing after the upgrade 10.11.6

    I ran the upgrade recommended this morning at El Capitan 10.11.6 on my end 2011 MacBook Pro. A certain font was not available when I opened an Illustrator document, so I opened the font book to see why and found that hundreds of fonts, I entered the book of policies over the past year or more are missing. I know that real fonts are still in my police records, but a number of hours of work participated in their addition to the font book and organize them into folders. Is all the work is lost, where can I access the preferences that contain this information somehow? What a brake if not. Font book does not yet have all folders that I put in place, they are just empty and only the core system fonts are loaded.

    Unless I can access the old prefs I guess I also install all my software again, to make sure that necessary fonts are loaded?

    Help!

    John

    cjohna wrote:

    I ran the upgrade recommended this morning at El Capitan 10.11.6 on my end 2011 MacBook Pro. A certain font was not available when I opened an Illustrator document, so I opened the font book to see why and found that hundreds of fonts, I entered the book of policies over the past year or more are missing. I know that real fonts are still in my police records, but a number of hours of work participated in their addition to the font book and organize them into folders. Is all the work is lost, where can I access the preferences that contain this information somehow? What a brake if not. Font book does not yet have all folders that I put in place, they are just empty and only the core system fonts are loaded.

    Unless I can access the old prefs I guess I also install all my software again, to make sure that necessary fonts are loaded?

    Help!

    John

    Use your backup Time machine restore.

    Your book plist police is located on via Finder > go > go to folder, copy and paste:

    ~/Library/preferences/com. Apple.FontBook.plist

  • My Favorites are missing and I can not add or import new ones. Firefox V36, Mac OS 10.6.8

    My Favorites are missing and I can not add or import new ones. Firefox V36, Mac OS 10.6.8

    You can check for problems with the database places.sqlite file in the Firefox profile folder.

Maybe you are looking for

  • Portege 4010 Bluetooth - connection for samsung and motorola phones probs

    I have a portege 4010 with bluetooth. I am trying to connect to our two phones - a samsung sgh-e370 (newish) and a motorola V600 (2 years). Both have BT I downloaded and installed the latest Tosh BT stack (4.0.something). Shows Device Manager four dr

  • How can I put Satellite A100 of hibernation?

    I worked there and did not notice that I am not connected to the mains. My battery ran out and tosh went into hibernation. The power button is a brilliant blue. What do I press to get out of hibernation? Thank you

  • Laptop Gateway running Windows 2000 Professional

    I have a very old laptop Gateway, I added a WiFi, Linksys Wireless g interface Although I can now access the Internet via my Linksys router, I wasn't able to get into my "working group.  The Gateway working group is the Group (by default); I need to

  • 646 ERROR CODE

    Hello I can't down load and install the important updates below. I have a lexmark x 7675 printer that doesn't work with vista / office 2007 microsoft can anyone help please Update of security for Microsoft Office Excel 2007 (KB973593) Download size:

  • AutoPlay OS / assistant camera no longer works...

    never had a problem with this b-4 - I don't even switch, uninstall, diabling (or other) anything else - but now nothing!  I can not even find anywhere on my computer - [camera, it's a sony cyber-shot and a computer system is windows xp] - what I do?