JavaFX AreaChart Clear Data - java

i create a Object of a extended Area Chart. In this Area Chart is a dataSerie if the object is created. Later i will add 3 New Data Series to the Area Chart and the first dataSerie musst be deleted.
How can i delete the first dataSerie?
areachart.getData().addAll(s1, s2, s3);
Here you can see how i add the new Series into the areachart, but first i want to delete the old ones...
Thanks for your help
So now I know it! I can use the following Statement:
areachart.getData.remove(....)
But this makes another Question open! How can i get the total added Series of the Area Chart.
How can I get the information of how many series in the Area Chart are?

I fixed the problem by myself.
You can do something like this:
areachart.getData().removeAll(m_histogram.getData());
It will remove all kind of data inside the area chart!!

Related

Question about displaying text in LibGDX using a console

I had a quick question. I am writing a text based game using Java and LibGDX. I want to create something like a console. I would like to store all previous messages while being able to add new ones. However, I don't need users to input any data into the console. I saw that labels might work, but I am unsure of how to keep the existing text while adding new text to a label. I am fairly new to using LibGDX and thought someone could think of a better way to do this.
Thanks
Just a quick suggestion for where to start, since I haven't done this myself:
Label is the typical way to draw text, but it re-computes the glyphs for all the text every time you change the text. Under the hood, it uses BitmapFontCache for the rendering. BitmapFontCache lets you append text using addText() without recomputing what it has already done.
So what I would do is use BitmapFontCache directly for your text rendering, and append text to it. Maybe calculate how many lines of text it takes to fill the screen or half the screen, and create a new instance each time you reach that threshold. That way, you can selectively render only the ones that overlap the camera viewport so you aren't drawing hundreds of off-screen glyphs.
In a simpliest way you can just recreate your label every time. Do something like this.
String text = "text";
Lable createLabel(String addText) {
text = text + addText
return Label(text, skin)
}
Then just call this function where you need a label

Customize x axis with JfreeChart XYLineChart

I'm displaying the results of a clustering operation on a XYLineChart using JFreeChart. For now the plot I get is this one:
I need to change the x axis in order to get this display:
So basically I first need to get rid of the tick and numbers (this I already searched and found a way to manage how to do it). The problem for me is to add my own custom String values on the x axis AND to have these positionned at specific position. I already have an arraylist with the Strings and another one with the position values, no need to calculate them, i just want to know how to use them with the plot.
Thank you in advance and, as usual, please tell me if my explanation needs to be clarified.
in order to change the content of the display, you need to change your query to have the output you like to see.
to change the position you may need to use something like:
categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_90);
you need to show some of your code so that you can get the proper advice

How to get Paragraph absolut coordinates with iText?

I need to get absolute coordinates of paragraph that I already added to the document and join an image near that.
Generally my problem is below:
I have a checklist with images (checked/unchecked) before each line. I already did that but if check item takes for example 2 lines, then second line starts from the begining of the page. What I want is to start this second line from position that first line is starting. It is equal to if the second line will have a margin.
Thanks in advance!
I think your question is wrong. Allow me to explain: you have a specific requirement: you want to start a line with an image (representing a checked/unchecked check mark) that acts as a bullet. More specifically: you want the text that follows the bullet to be aligned correctly. That is a valid requirement.
However, in your question, you're asking about a specific implementation. You want to juggle with Y positions (check if a paragraph takes one or more lines) and X positions (start the second line using a specific indentation).
While it would probably be possible to achieve what you want using page events (asking a paragraph for its start and end postion), I think you are actually asking for functionality that is available out of the box: why not use a List with an image chunk as bullet?
I've written some sample code, ListWithImageAsBullet, where I use a light bulb as bullet (in your case, you'd use a checkbox image). I've added three items to the List and the second item takes more than one line. As you can see, the second line is indented correctly (you can augment the indentation using different methods available in the List class).
Please take a look at the resulting PDF. Is that what you're looking for?
If so, this is how it's done:
Image image = Image.getInstance(IMG);
image.scaleAbsolute(12, 12);
image.setScaleToFitHeight(false);
List list = new List();
list.setListSymbol(new Chunk(Image.getInstance(image), 0, 0));
list.add("Hello World");
list.add("This is a list item with a lot of text. It will certainly take more than one line. This shows that the list item is indented and that the image is used as bullet.");
list.add("This is a test");
document.add(list);
Note that I scaled the image to 12 by 12 pt, because 12pt is the default font size. Also don't forget to disable the automatic scaling of the image (otherwise, you'll end up with really tiny images as bullets).

how to prevent the graph from overwriting the previous plot using achartengine

I have made the plot to repaint the graph from the first once it reaches end. Now my problem is the graph gets overwritten. The previous plot remains as such. So, how should i repaint after clearing the previous plot? And by clearing i should not loose the previous data. It should remain as such when i scroll.Can someone help me with this pls?
I will try to answer the questions I understood:
You can clear data from the previous series, by removing it
You can control the visible area by using renderer.setXAxisMin() and renderer.setXAxisMax()
When you want the cursor sent back to the beginning, you can create a new series and start adding data to this series
You can hide the legend, if you don't need it by calling renderer.setShowLegend(false)
The changes will be visible on the screen after calling chartView.repaint().

Selecting a curve in jFreechart

I have several time series plotted with jfreechart. The graph also contains multiple annotations. I want the user to be able to select the time series or the annotations.
So far I have tried: entityCollection.getEntity(x,y) which returns me the PlotEntity and panel.getComponentAt(x,y) which gives me the chart panel.
so my question is: can jFreechart provide me with this information?
You can add a ChartMouseListener, as shown here. The ChartMouseEvent will indicate which ChartEntity subclass was found.

Categories

Resources