change rectangle size according to the data in Prefuse - swing

I want to visualize a scatter plot using Prefuse. The difference from typical scatter plot is here I want to use rectangle instead of circle or point. And the reason is I want to visualize the time and duration at the same time. Does anyone know how to set rectangle's length or width according to data in the table? I haven't got the right answer after searching the web.
I initially wants to draw rectangle using this parameter.
ShapeAction shape = new ShapeAction(group, Constants.SHAPE_RECTANGLE);
But I didn't find the way to change only the length of it but to change the whole size. Could anyone give me some instructions? Thanks.

Assuming you want to create a visualization similar to LifeLines or a GANTT chart.
To achive this, prefuse has to be extended prefuse on several points. Here is an outline:
Add a field to the VisualTable to store the x coordinate at the end of the rectangle
Extend AxisLayout to determine the additionally the end of the rectangle.
Extend AbstractShapeRenderer draw a rectangle using the end coordinate

Related

How to apply buffer in MapServer WMS query?

I am trying to add a pixel buffer around a WMS query in MapServer. I noticed in MapServer/mapwms.cpp there is an option to set 'tiled=true' which should check for "tile_map_edge_buffer" "100" value in the map config file. However, when I check the spatial query, it doesn't seem to extend at all. Even altering SQL query to include extra data using ST_Expand(!BOX!, 0.01) doesn't help - the query does return extra data but it is not drawn.
I need this as I am generating point data through WMS EPSG:4326. The point data is displayed as large squares (changes with zoom level) but the data from the next tile near the border don't get generated in the tile of interest.
For example if the point on the main tile (lets say 100x100) is on (50,1), square size 20 pixels, the main tile generates a rectangle approx: (40,1 40,11 60,11 60,1) (20x10) which is correct. If I try to generate left side tile, I would expect to see the remainder of the square but I don't.
Anyway, if anyone had luck setting up pixel buffer for WMS, I would appreciate their input.

Get color of a point on the canvas

Is it possible to get the color (rgb-value and transparency) of a point (x/y-coordinate) from the canvas? Example: I draw some figures and text on a canvas and later I want to get the color of a point at a specific coordinate.
The solution should be independent whether the canvas is visible on screen or not. And it should work independently from the operating system.
I didn't found any solution on the web. That's why I assume that this is not possible. Am I right?
The canvas isn't very pixel-based, and provides no API for doing this.
But if you've got the tkimg package installed, you can use that to do a screengrab of the canvas and then fetch the pixel value out of that.
package require Img
# Get the data into an image
set screengrab [image create photo -format window -data $theCanvas]
# Read the pixel data out of the grabbed image
set pixeldata [$screengrab get $x $y]
# Get rid of the grabbed data once you're done
image delete $screengrab
Note that the coordinates concerned will be viewport coordinates, not canvas internal coordinates: if you've scrolled the canvas, you'll have to offset as necessary.
You are correct, tk does not provide any way to get the color of a specific pixel on a canvas.

AS3 - How to calculate intersection between drawing and bitmap

I'm trying to create a handwriting game with AS3 on Adobe Animate. I've created my board, functions(drawing, erasing, saving, printing and color pannel) so far. But i need to show a score. To do it i thought if i can calculate the percentege of intersection between drawing and a bitmap image(which is my background for now).
Is there any way to do it? Or can you at least tell me with which function should i try that? Thanks a lot.
Note: Here is 2 images from my game. You can easily understand what am i trying to explain and do.
players will try to draw correctly(drawn board)
Empty Board
just a suggestion,
lets assuming that you are recording draw data, a set of points according the frame rate that records mouse positions inside an array.
i used 8 points in my own example, the result would be like this: (6 of 8 = 75% passed)
► black line is correct path(trace btimap) ► red is client draw
we need to search whole of the points array and validate them, so a percentage will be gain easily
how to validate
each point contain x and y, to check if its placed on a black pixel (bitmap trace) we just do
if (bitmapData.getPixel(point.x, point.y) == 0x0) // 0x0 is black
getPixel returns an integer that represents an RGB pixel value from a
BitmapData object at a specific point (x, y). The getPixel() method
returns an unmultiplied pixel value. No alpha information is returned.
Improvment
this practice would be more accurate when there is really more captured points during draw, also the Trace-Bitmap must be like this (above image), not a Dashed (smoothed, styled, ...) Line, however you can use this trace bitmap in background (invisible) and only present a dashed copy of that with a colorful background (like grass and rock textures or any graphical improves) to players.
Note
also define a maximum search size if you need more speed for validating draw. this maximum will be used to ignoring some points, for example if max=5 and we have 10 points, 0,2,4,6,8 can be ignored

Minimum number of control points in CatmulRomSpline libgdx

I am using the CatmullRomSpline class of libgdx for creating a smooth curve passing through three points. Basically I want to place coins between two platforms in a curved path. For that I followed the following algorithm
Take the end top point of first platform as the first control point;
Take the middle point bw top end of first platform and top start of second platform , add a little height to it in y direction and take this point as second control point.
Take the top start point as second platform as third control point.
Now when I am trying to create a smooth path for my coin generation using these three control points, I just get one value what so ever t is use (CatmullRomSpline uses a float value t as parameter which has to vary bw 0 and 1).
Is there something I am missing . Is it that I need to provide more control points ?

Flex: how to draw line segment on chart using screen coordinates?

I've created a line chart in Flex using LogAxis. Flex draws minor tick marks at the same location as the major tick marks for a Log axis, so I need to manually draw the minor tick marks.
I'm new to Flex, I've tried to do this using a CartesianDataCanvas inside backgroundElements in mxml, then using ActionScript to draw lines on the data canvas using moveTo(x1,y1) and lineTo(x2,y2), which draws a line between (x1,y1) and (x2,y2).
The problem with the above method is the tick mark length is a function of the chart area (which depends on the browser window size).
What I need is a method that:
(1) starts at a data coordinate (e.g. moveTo(x1,y1) works fine for this)
(2) draws a line to a screen coordinate (e.g. lineTo(x_screen, y_screen) where x_screen and y_screen are screen coordinates).
Is there anything that can accomplish this in Flex/AS3?
Alternatively, could I use screen coordinates for both steps above? If so, how to convert between screen and data coordinates? For example, is the upper right corner of the screen always a fixed data coordinate that I could reference is creating such a conversion?
Alternatively, could I save a five-pixel line in Illustrator and simply paste that image in the chart somehow? If so, how to paste it exactly at a data coordinate?
Any ideas or comments much appreciated.
I'd suggest you to create your custom axis renderer. Extend AxisRenderer class, override updateDisplayList method. Since all methods responsible for rendering axis are private, just copy them to your class and make needed changes to drawTicks method. But you'll need to spend some time understanding rendering logic.
Then apply your renderer to your chart.
<mx:LineChart>
<mx:horizontalAxisRenderers>
<custom:CustomAxisRenderer/>
</mx:horizontalAxisRenderers>
</mx:LineChart>