Customize x axis with JfreeChart XYLineChart - java

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

Related

Aspose.cells How to add differnt Y values in scatter chart

Im using aspose.cells for java.
I want to insert two different lines a scatter chart, but they have different both X and Y values. X values is not a problem with
chart.getNSeries().add("C1:C19", true);
but i can set only one CategoryData with
chart.getNSeries().setCategoryData("B1:B19");
Is there any other way to do it (insert columns E1:E19 as Y and D1:D19 as X values) ?
Im searching it of ages, and i cant find a solution.
Thank you.
:)
Well, you may try to specify the x values for a particular data series in the way:
e.g
Sample code:
chart.getNSeries().get(index).setXValues("......");
If you still could not evaluate, kindly provide your current sample code (runnable), template file(s) and your expected file that should contain your desired chart that you may manually create in MS Excel, we will check it soon.
Note: I am working as Developer Evangelist at Aspose

JavaFX AreaChart Clear Data

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!!

Method for changing an existing color OpenGL

With a method like glColor4f(0f, 0f, 0f, 0f);, it sets the values to whatever parameters one puts in. However, what I would like to do is only slightly change a color. Is there any existing OpenGL method that will add or subtract its parameters to the existing colors it has?
The only other way of doing this that I can come up with is first getting its color values, then editing those how I want to, and finally sending them back with glColor4f().
So, in closing, I would like to know if there is either a method for editing existing RGBA, or at least retrieving an existing RGBA.
Well, you can get the last value set with glColor4f by using glGet with GL_CURRENT_COLOR, but I wouldn't recommend it; glGet operations are generally bad for your performance, so try not to do it too often.
A better idea would be to maintain a local copy of the last value you sent to glColor4f, so that you have the data client-side instead of having to request it from the opengl driver.
There's no way to add or subtract from the current color that I'm aware of.
Edit: Actually I just looked up and see this function called glSecondaryColor which may do what you want. You can supply a second RBG color, and then enable GL_COLOR_SUM, and the two colors get added together.

Need to implement a grid in android

I need to implement a grid that will show the position of some physical objects. I want to interact with the objects: I want to be able to send commands or request their "health" status (the objects happen to be sensor nodes).
The size of the grid is given by the user but is always square (width=length=a).
Any ideas will be appreciated.
Creation of a custom view might be an option. If so share your thoughts on this.
The grid that I am talking about should look like this
http://1.bp.blogspot.com/_NWSHay-_Gtk/R8hsDLaG9XI/AAAAAAAAAKU/DO6Ltp8v7zY/s1600-h/grid.gif
where my objects are expected to be situated in the nodes of the grid.
Did you try http://developer.android.com/reference/android/widget/GridLayout.html ?
I think you are looking for a GridView.
GridLayout might work too... but it is only supported by API 14 and above.

Display a row of Strings on a JComponent so that the single Strings are selectable/their location getLocation()-able?

In order to be able to display a sentence on a, say, JPanel with a GridLayout(1,0) [i.e., only one line/row] and then be able to draw a syntax tree (or similar) above it, I want to display the sentence as a row of Strings, which each include one word.
The single Strings should then be either selectable (as in a JList), or I should at least be able to get their Location on the JPanel via getLocation().
Up to this point I have tried the following options, and had the following issues:
- Single Strings as JLabels: The JLabels are stretched out to fill the JPanel width, re-sizing them to fit the single String they're displaying seems complicated. I would want to be able to do this, however, to make the sentence look like a sentence and not like a badly layed out table.
- JList: All the functionality I want, but I'm unaware of an option to re-size the "cells" of a single String (cf. JLabel above). Also, I'm having difficulties restricting display of the JList to a single line/row (cf. another of my questions).
- JTextArea: I couldn't get my head round how to get the Location of the single Strings that I had appended to the JTextArea.
I'm aware that drawString() might be an option, but I'm afraid to use it since I don't want to mix AWT and Swing. Also, I would need to calculate the int values for x and y for every single String. And I'm not sure whether I'd be able to get their Locations at all (although I could of course save their ints in a Map or Vector since I have to calculate them anyway).
Thankful for any suggestions! Thanks!
I would use JTextArea and method modelToView()/viewToModel() to get x,y for position in nthe string and position in the string for coordinates x and y.
Also use Utilities class getWordStart() getWordEnd() getRowStart() getRowEnd() methods.
EDIT: As noted by camickr in the comments, setSize() is not an appropriate way to lay out Components (as this is automatically done by the respective LayoutManager, I have removed the respective code from my answer.
Triggered by StanislavL's answer, I have found a solution to do it via JTextField, albeit by using one for each String rather than just one (as suggested by StanislavL).
I can now easily getLocation() for each JTextField. Simple, really!
I'd like to thank StanislavL for his answer, without which I'd never have though about this, and camickr for his comment.

Categories

Resources