Javadoc multiple variables on single line - java

I have a class like the following...
class A{
/**
* Blah blah
*/
Type1 var;
/**
* What do I do here?
*/
Type2 var11, var12;
}
How can I javadoc var11, and var12 if they are both on the same line?
I am curious to see if this is possible, I know I can put them both on an individual line and javadoc from there.

I was curious so I tried it out
/**
* data stuff
*/
int x , y ;
The resulting javadoc repeated the same doc comments for both x and y.
I imagine this behavior would be useful if two fields were essentially the same with minor differences.
class Circle
{
....
/**
* center coordinates
* The x/y coordinate of the center of this circle.
*/
int x , y ;

unfortunately there is no way to differentiate single line declaration of multiple variables :(
It may be useful to note however that the benefit of this does allow for a single javadoc to provide documentation for categorical variables which may otherwise take unnecessary lines.
/**
* custom colors (MUST BE DISPOSED!)
*/
Color lightblue, someotherblue, lightred;
of course this can be combined with initialization as well
/**
* These are the spec's behind batch-box font size / Height / Width
*/
private int iFontHeight = 9, iboxheight = 58, iboxwidth = 125;

Related

Android MPAndroidChart xasis values showing more than 1

I am using android java MPAndroidChart Library.
As you can see from photo, value of x axis showing more than one. I just want to show tuesday one time. How can I do it
image of chart
I find the solution
lets say your name of the list is myArray and answer is
barChart.getXAxis().setLabelCount(myArray.size());
You can set a count of label by force. This will result into one label only on your axis.
For example:
xAxis.setLabelCount(1, true)
From the documentation:
/**
* sets the number of label entries for the y-axis max = 25, min = 2, default: 6, be aware
* that this number is not
* fixed (if force == false) and can only be approximated.
*
* #param count the number of y-axis labels that should be displayed
* #param force if enabled, the set label count will be forced, meaning that the exact
* specified count of labels will
* be drawn and evenly distributed alongside the axis - this might cause labels
* to have uneven values
*/
public void setLabelCount(int count, boolean force) {
setLabelCount(count);
mForceLabels = force;
}
The other thing you can try is working more with granularity.
Like so:
axisLeft.granularity = 3F
From the docs:
/**
* Set a minimum interval for the axis when zooming in. The axis is not allowed to go below
* that limit. This can be used to avoid label duplicating when zooming in.
*
* #param granularity
*/
public void setGranularity(float granularity) {
mGranularity = granularity;
// set this to true if it was disabled, as it makes no sense to call this method with granularity disabled
mGranularityEnabled = true;
}

Android ARToolkit - Position of marker

I'm using the ARToolkit for android and try to write a text over the detected marker. I want to do this using a simple TextView. So I'm only using ARToolkit to find the marker.
But how can I find out where in my camera-preview the marker is right no (I need the coordinates), so I can but the TextView over the marker?
Thanks in advance !
Both comments are correct, ARToolkit returns both a Projection Matrix and a Transformation Matrix. Both are designed to be used with OpenGL, not with a standard Android view. The projection matrix is to be applied to the camera and the transformation one is to be applied to the object (pose matrix)
If you only want to display text, I recommend you to use the Unity plugin and then use the Unity UI components to add a canvas and a text attached to the marker. Those components are already designed to be 3D objects (if you go that way, remember to set the canvas to "World Space".
The other options you have are:
a) Render the text into a texture and draw it on a Quad, you can do that based on the example that has a cube.
b) Do some matrix calculations using both matrix and the apply transformations to the TextView on position and rotation using a transformation Matrix (the Android class). Although is possible, the math involved is rather complex. If you want it to just float looking at the camera, setTranslationX, Y and Z should be enough.
c) Link a 3D engine with text rendering capability to ARToolkit. I've done that with jPCT-AE. While this works, it takes quite a lot of work. I plan to write about it soon.
There is another option to detect the markers corner points.
It will require some changes to the wrapper code and recompiling the Android binaries.
Fork or clone the artoolkit5 github repository and make the following changes:
Add an entry to ARMarker.h
float cornerPoints[8];
In ARMarkerSquare.cpp make a change in the updateWithDetectedMarkers method just after the code where a marker has been determined visible, update the cornerPoints:
// Consider marker visible if a match was found.
if (k != -1) {
visible = true;
m_cf = markerInfo[k].cf;
for (int c = 0; c < 4; c++) {
cornerPoints[c*2] = markerInfo[k].vertex[c][0];
cornerPoints[c*2 + 1] = markerInfo[k].vertex[c][1];
}
Add a new method ARToolKitWrapperExportedAPI.cpp to retrieve the corner points:
EXPORT_API bool arwQueryMarkerCornerPoints(int markerUID, float points[8])
{
ARMarker *marker;
if (!gARTK) return false;
if (!(marker = gARTK->findMarker(markerUID))) {
gARTK->logv(AR_LOG_LEVEL_ERROR, "arwQueryMarkerCornerPoints(): Couldn't locate marker with UID %d.", markerUID);
return false;
}
for (int i = 0; i < 8; i++) points[i] = (float)marker->cornerPoints[i];
return marker->visible;
}
And add the JNI definition for that:
JNIEXPORT jfloatArray JNICALL JNIFUNCTION(arwQueryMarkerCornerPoints(JNIEnv *env, jobject obj, jint markerUID))
{
float trans[8];
if (arwQueryMarkerCornerPoints(markerUID, trans)) return glArrayToJava(env, trans, 8);
return NULL;
}
After all that I recompile the ARWrapper shared objects in the android directory with the build.sh script and used these new shared objects.
In the he NativeInterface.java add the following method:
/**
* Retrieves the corner points for the specified marker
*
* #param markerUID The unique identifier (UID) of the marker to check
* #return A float array of size 8 containing the corner points starting at top left (x,y) top right, bottom right, bottom left.
* So
*/
public static native float[] arwQueryMarkerCornerPoints(int markerUID);
And finally add the method to ARToolKit.java as well:
/**
* Retrieves the corner points for the specified marker
*
* #param markerUID The unique identifier (UID) of the marker to check
* #return A float array of size 8 containing the corner points starting at top left (x,y) top right, bottom right, bottom left.
*
*/
public float[] arwQueryMarkerCornerPoints(int markerUID) {
if (!initedNative) return null;
return NativeInterface.arwQueryMarkerCornerPoints(markerUID);
}
See also:
https://archive.artoolkit.org/community/forums/viewtopic.php?f=26&t=16099
The changes can be seen seen in this fork as well: https://github.com/ekkelenkamp/artoolkit5/tree/marker_corner_points

Is it possible to create documentation comments on the right instead on top?

Documentation can sometimes reduce the readability of code.
Instead of
/**
* The X axis.
*/
int x;
/**
* The Y axis.
*/
int y;
/**
* The Z axis.
*/
int z;
I'd rather prefer to have
int x; /** The X axis */
int y; /** The Y axis */
int z; /** The Z axis */
Is there a way in Java to have the comments on the right of e. g. a variable declaration? I've seen it work in C by using the "<" character, but haven't seen it in Java yet. Java is already in Version 8 and I'm wondering why it still isn't possible. Or is it?
Doc Comments work only once. They could be anywhere in the code and many times but only first one is extracted by Javadoc tool. The rest is simple ignored.

PDPageContentStream has no drawLine() method

So I just started using Apache PDFBox (0.7.3) in one of my projects to write to PDF. I want to draw a line across the whole page, which according to the docs and many examples I have seen, I should be able to do by calling the drawLine() method from my PDPageContentStream. However, in Eclipse I only see two drawImage methods and a drawString method. Does anyone know what I should do to fix this? Is the drawLine method deprecated or something?
In PDPageContentStream I see:
/**
* Draw a line on the page using the current non stroking color and the current line width.
*
* #param xStart The start x coordinate.
* #param yStart The start y coordinate.
* #param xEnd The end x coordinate.
* #param yEnd The end y coordinate.
* #throws IOException If there is an error while drawing on the screen.
*/
public void drawLine(float xStart, float yStart, float xEnd, float yEnd) throws IOException
{
if (inTextMode)
{
throw new IOException("Error: drawLine is not allowed within a text block.");
}
addLine(xStart, yStart, xEnd, yEnd);
// stroke
stroke();
}
Thus, either your PDFBox copy is outdated or your eclipse does not show existing methods.
I use eclipse Kepler here and see the method all right.
It is located between addLine and addPolygon in the source, far away from drawImage or drawString. If you are searching in the outline, you maybe should activate sort-by-name there.

Mapping logical coordinates to graphical fails when scaling

I encountered a slight problem with my game's rendering system when I tried to scale certain objects. I think it must be the way I map objects with logical coordinates to graphical ones on the screen.
Renderable
/**
* Retrieve the image representing the object that should be rendered.
* #return The image sprite representing the object.
*/
public Texture getSprite();
/**
* Retrieve the x-coordinate where the object should be rendered.
* #return The x-coordinate of the object.
*/
public float getScreenX();
/**
* Retrieve the y-coordinate where the object should be rendered.
* #return The y-coordinate of the object.
*/
public float getScreenY();
Texture
......
......
/**
* Retrieve the width of the texture.
* #return The width of the texture.
*/
public int getWidth();
/**
* Retrieve the height of the texture.
* #return The height of the texture.
*/
public int getHeight();
......
......
This system works perfectly when I draw stuff like interfaces etc, which have no logical coordinates in my game world.
Let's take a look at an object that have logical coordinates and see how I map the coordinates to graphical ones and thus causing a problem when I scale the texture when drawing.
Tile
#Override
public float getScreenX() {
return x * width;
}
#Override
public float getScreenY() {
return y * height;
}
Let's say the size of the texture for any tile is 16*16 but for some reason I want to draw it at 32*32. This will cause a problem since the tile's graphical x- and y-coordinate messes up.
Note: I know that I can fix this by allowing the user to set a scale when loading the image into the system but I want it to be more flexible.
TL;DR: How can I accomplish a better mapping between logical coordinates in the game world to graphical ones while still being able to scale when I want to? There should be a better way to map instead of letting the logical objects be in charge of their graphical coordinates.

Categories

Resources