Pixel coordinate vs character co-ordinates

Hi,
I have JTextArea where I highlight some text using highlighter and when next line is entered i de-highlight the text but I remember the co-ordinates of highlighted text.I am keeping linenumber of text and co-ordinates.When user brings the mouse over the text I want it to be highlighted again. So I have implemented MouseMotionListern and mouseMoved method but MouseEvent return the co-ordinats in pixel while earlier co-ordinates were character-wise so I am not able to determine the line number using pixel co-ordinates. can someone suggest how to determine linenumber using pixel co-ordinates or some other way to solve the above problem ?
Ajay

In the JTextComponent API, it lists two methods for converting between pixel coordinates and text locations.
The capability of determining the location of text in the view is provided. There are two methods, modelToView(int) and viewToModel(java.awt.Point) for determining this information.

Similar Messages

  • XY pixel coordinate to map coordinate!

    Hi,
    I don't know if anyone is able to help me or direct me in the right path.
    My situation is as follows:
    I'm writing an web-app to generate a map (which I am successfully doing). I display the map (GIF) on the browser.
    Now, what I would like is to be able to click on a point on the map, take the X Y pixel coordinate and convert that to a mapping coordinate so I can requery the server and generate a new map.
    Now, in terms of mapping coordinates,
    how would one convert XY pixel to LAT LON?
    how would one convert XY pixel to Mercator?
    how would one convert XY pixel to GeoMinSec?
    hou would one convert XY pixel to GeoDecimal?
    Now, I don't mind if can get an answer to one of either of those questions, but my ideal answer would be on how to convert XY pixel to GeoDecimal because unfortunately the server I am using has all of its map coordinates in GeoDecimal.
    Any help would be appreciated.
    Steve.

    i think this is the solution.... but i might be missing something, i am assuming that your x,y location of your mouse increases positivly as you move your mouse right and down from the top left of your image. you may need to adjust accoringly. also, i have a feeling i am missing something to do with the dpi of your image... but i guess this may be a start...
    so you know your x,y in pixels. you know the extent of your map in real world co-ordinates.
    so lets say the width of your map is 1000m and the pixel width is 500pixels.
    so each pixel is 0.5 real world metres.
    multiply your x and y co-ordinates by 0.5, that is how many meters in from the top left of your extent your mouse is.
    more generally:
    so your extent is (x1,y1 is bottom left, x2,y2 is top right):
    x1,y1;x2,y,2
    your mouse co-ordinates are :
    x,y (pixels in from top left)
    your map is w1 pixels wide.
    dx = x2 - x1
    pixelsPerMetre = w1/dx
    world coordinates of x,y are:
    x1 + (x * pixelsPerMetre), y2 + (x * pixelsPerMetre)

  • Pixel coordinates

    Hi
    I have a map as an image in a web page that I want to have a information tool to. When clicking on a point I want to search for that point in the database.
    In order to do my search I need to pick up the coordinate that the user click on. When clicking on the map image this is pixel coordinates which are converted to geometry coordinates on the server. My question is how to write a web form that adds the pixel coordinates in the request when the user clicks on the map?
    Thanks
    Fredrik

    Your pixel-map need some spatial reference, otherwise it won't work. If you want a nice demo on how to build a clickable map, try this:
    http://www.oracle.com/technology/sample_code/products/mapviewer/files/oow2006hol_geotag.zip

  • Pixel coordinate​s along a ROI (line)

    Hi
    Problem: Calculating distance using "distance formula" for all the pixel points along a line on an image.
    I am grabbing images using a camera and then using "ROI line.vi" , to define a line as region of interest.For that I have to provide,initial and final coordinates of the line (pixels) , then I use ROI transform.vi to rotate this line about a point which is one of the ends of the line.This way I get a new line (ROI) and using "ROI to line" I get the pixel coordinates of two ends for the rotated line.
    Now I want to get the distance between two points on a line and for that I need the pixel cooridinates for the whole line.Does someone know how to get this ? or is there any better way of doing this?
    And yah I am using 100 pixels = 34.29 mm to convert pixel distance into mm.Is it correct ?
    Is it possible to switch on and off a bulb/electrical appliance using lab view ? Just want to try this out for fun ....
    Thanks a lot !
    Deepak
    LAB View 2010 SP1

    Hey Deepak,
    To answer your questions, I am assuming that you have the Vision Development Module installed, especially if you are using some of the Vision functions already (that you mentioned). Now, what I understand of what you are trying to do, it sounds like you already have the two endpoints of the line, and you want to get the pixel points in between to be able to make measurements on those. So if you already have the two end points of the line, then I would recommend you check out the following functions: IMAQ LineProfile.VI or IMAQ GetPixelLine.VI. The help documentation on these two will tell you more details about them, but basically you can get the values of the pixels on a line. Then once you have the other points and their values, you can do either use the IMAQ Caliper functions to measure distances on the line, or perform your own calculations using simple LabVIEW functions (like add, subtract, divide, etc.).
    You also mentioned something about converting pixel values to real world values. You can use the Calibration VI's in order to calibrate your image, and also use some of the other functions like IMAQ Convert Pixel to Real World.VI. If you don't want to use the Calibration functions, then you can perform your own conversion, again using simple LabVIEW functions.
    Last, for your question about switching on/off a light bulb or some other electrical appliance using LabVIEW, I would have to mention that LabVIEW can control electrical components, but usually with the help of some kind of hardware. Some hardware that I could think of would be some kind of electrical switch hooked up to a DAQ (data acquisition) board that can do either digital or analog output. Another option would be to use some 3rd party hardware and communicate with LabVIEW via some kind of protocol, such as serial, TCP/IP, modbus, Datasocket, etc. etc.There are numerous ways you can go about having LabVIEW control things via hardware.
    I hope these answers help. Please let me know if you need any clarification on anything. Thanks, and have a great day.
    Regards,
    DJ L.

  • Get pixel coordinates in image with mouseclick

    Hey there
    Im a beginner at labview, so i walked into a little problem.
    I want to know if there is a way to get pixel coordinates from an imagefile with a mouseclick in labview, this is to use the coordinates in order to calibrate the image without using the vision assistent.
    THx with regards
    jens dassen

    I'm not sure if this is something new with newer versions of LabVIEW, but I just solved this problem using a property node for the image indicator. See images below. Super easy!
    Cheers!
    James
    LabVIEW Professional 2014
    Attachments:
    Capture.PNG ‏8 KB
    Capture1.PNG ‏5 KB

  • Movieclip on Sub-pixel coordinates

    I have a long running question that I've never been able to find an answer for.
    When animating movieclips if they're not on whole pixel coordinates they will be blurry (if smoothing is turned on). I always have to adjust the coordinates to whole number values which is of course very tedious. Snap to pixel doesn't seem to solve the issue. If I'm useline timeline animation, I have to adjust both beginning and end frames
    Does anyone have any suggestions or fix for this?
    thanks!

    I've found that if you have ONLY "Snap Align" and "Snap to Pixel" checked in the View menu, you can get a stage object or a movieClip to align to an actual pixel. Moving that object in the same or subsequent keyframe also positions the object to a whole pixel. Do you see something different?  This is in Flash CC 2014.

  • Draw line between black pixel : coordinates of selected pixels ?

    Hi
    I want to build a script which can check a Photoshop file and :
    - find black pixel
    - for each black pixel, look for another black pixel within maximum distance of 5 pixels
    - then draw a line between the two black pixels.
    I wrote this script below (my first script ...), but it's VERY slow (and my final image is VERY big), I think because I test the colour for each pixel of the image.
    So another solution would be to first select black pixel with magic wand, then the script save all coordinates of selected pixels, then my script wil test only this pixels (less than 1% of the pixels are black in my image).
    Is it possible with JavaScript ?
    Thank you for your response !
    Marc
    function main(){
    var startRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var myHeight = app.activeDocument.height;
    var myWidth = app.activeDocument.width;
    // Find black pixel
    for(var i=5; i<myWidth; i++) {
      for(var j=5; j<myHeight; j++) {
       activeDocument.colorSamplers.removeAll()
       var sampler = activeDocument.colorSamplers.add([new UnitValue (i, 'px'), new UnitValue (j, 'px')]);
       if (sampler.color.rgb.hexValue === "000000") {
    // For each black pixel, search another black pixel below left up to 5 pixels
        for (var m=i-5; m<i; m++) {
         for (var n=j+1; n<j+5; n++) {
          activeDocument.colorSamplers.removeAll()
          var test = activeDocument.colorSamplers.add([new UnitValue (m, 'px'), new UnitValue (n, 'px')]);
          if (test.color.rgb.hexValue === "000000") {
    // Then draw a black line between the two black pixels
           var FillColour = new SolidColor;
           FillColour.rgb.hexValue = '000000';
           var ad=activeDocument;
           ad.selection.select([[m,n],[i,j],[m,n+1],[i,j+1]], SelectionType.REPLACE, 0, true);
           ad.selection.fill(FillColour);
           ad.selection.deselect()
    // For each black pixel, search another black pixel below right up to 5 pixels
         for (var m=i+1; m<i+5; m++) {
          for (var n=j; n<j+5; n++) {
           activeDocument.colorSamplers.removeAll()
           var test = activeDocument.colorSamplers.add([new UnitValue (m, 'px'), new UnitValue (n, 'px')]);
           if (test.color.rgb.hexValue === "000000") {
    // Then draw a black line between the two black pixels
            var FillColour = new SolidColor;
            FillColour.rgb.hexValue = '000000';
            var ad=activeDocument;
            ad.selection.select([[i,j],[m,n],[m,n+1],[i,j+1]], SelectionType.REPLACE, 0, true);
            ad.selection.fill(FillColour);
            ad.selection.deselect()
    main();

    The first alert should have shown the first pathPoint.anchors for all the subPaths in the path.
    The xyArray is just something I added for the alerts. The array 'myPathInfo' should have all the info extracted from the path.
    myPathInfo.length will tell you how many subPaths are in the Path.
    myPathInfo[index].entireSubPath.length will tell you how many pathPoints are in that subPath
    myPathInfo[index].entireSubPath[index].anchor will tell you the position of that pathPoint.
    The indexes start with zero.
    The bounding box of the entire subPath can be hard to work out just from the pathPoints. Unless all the point are corner points the path may extend beyond the anchors. One think you can do is create a new path from just one of the subPaths, convert by to a selection, and then get the bounds from the selection. You can make a new path from a subPath using the 'myPathInfo' array from above.
    app.activeDocument.pathItems.add("myPath1", [myPathInfo[0]]);
    That line will make a new path from the first subPath. Change the index to use a different subPath.
    Some other info that may help.
    app.activeDocument.histogram[0] will tell you how may black pixels are in the document. But its no help determining where they are. If that returns 0 there are no black pixels.
    If you don't have any luck working with converting the original color range selection into a path and need to go back to searching with the colorSampler it may help to use a grid approach. For example make a square selection, the size depending on how scattered the black pixels are, say 25x25px. Then use color range to select black. With an active selection it will only select pixels in that selected area( if any). You could then check to see if there is a selection. If not make another same size square to the right edge of the last area. If there is a selection, the solid property will tell you if more than one black pixel was selected( unless they are right next to each other ). If solid == true the selection bounds will tell you where the pixel is. If false you have to then search that square. But if there are areas where there are no black pixels checking a square range of pixels at once should be quite a bit faster than checking every pixel. And checking the historgram first will let you know if you should bother searching to start with.

  • 3d picture pixel coordinate​s

    Hi,
    I have a problem I can't figure out on my own. Maybe its not even possible.
    I want to import a 3D file (e.g. VRML) and read out the coordinates of each pixel. I just found tools to handle the image but not to get information out of the image.
    Maybe it is not possible the way I try to do it right now. What I want is a program that can read a 3D file and gives me a transmission image of it. (like if I get an transmission electron microscopy image of an object)
    This is to compare a theoretical transmission of an object to the real one.
    I hope you understand what I am trying to say.
    regards

    Hi Raphi,
    sorry for my late reply. Thank you for the example, I hope it wasn't a lot of work.
    To get a 2d projection of just the surface isn't my problem. I could also do that with the program I created the 3D file in. What I need are transmission pictures of the object. English is not my native language and I think my explanation is not really exact. I will try to explain on an example.
    What I want is a transmission picture of e.g. two cylinders. In the 2D view you will see them crossing in one point. In the transmission images this crossing point would have a higher intensity than the others because there are two cylinders. If one of the cylinders would be filled and the other would be hollow the they would look the same in a 2d projection picture but they would look different in a 2d transmission picture. I hope you understand that I mean.
    I want to load a 3d object and then integrate layer for layer of the object to get one transmission picture. This is to simulate how a object would look in a transmission electron microscope.
    regards,
    T

  • Toolkit off-pixel error on negative co-ordinates.

    All my assets are on pixels yet when I export them with toolkit, it spits them out as floats instead of ints e.g. : -197 becomes -196.9.
    This is pretty annoying, who do you speak to to get this fixed or to ad an option to toolkit?
    [edit] So on further investigation, this only happens when the x and y are negative, for example if you have a bitmap centered withing a MovieClip. So a bug if the numbers are negative.
    Thanks.

    Hmmm, whilst it is a solution, having to litter my code with "mybitmap.x = Math.round( mybitmap.x ); mybitmap.y = Math.round( mybitmap.y) " for every bitmap is a bit of a pain. I'm sure it is a simple fix so hopefully it will be ready in time

  • Pixel coordinates for different size docs.

    I am makeing a pixel colorsample on a particular point in a document. The problem is when the picture demesions change the point where I am selecting from changes. I was wondering if anyone has an idea to handle the different sizes. Thanks.

    So I figured what my current measurements percentage was and included it in my calculations for my point. Thank you for your help.
    This is what I used.
    var w = app.activeDocument.width.as( 'px' );
    var h = app.activeDocument.height.as( 'px' );
    pw=w*0.405;
    ph=h*0.48125;

  • Is it possible to find and retrieve the pixel coordinates of a polygon image? Perhaps using Magic Wand and Paths?

    THANK YOU!

    Hi Mylenium,
    I want to create a complicated polygonal hotspot around the map of many countries of the world in Dreamweaver (eg. a hotspot around the US border), but don't want to spend the time tediously selecting the coordinates around the border.
    i.e. the code in Dreamweaver would be something like this
    <area shape="poly" coords="5,343,18,340,38,327,71,314,88,304,75,302,63,301,46,301,58,290,58,284,40,292,36,28 1,43,276,47,263,62,257,91,244,99,244,113,237,132,235,146,226,155,222,131,221,102,223,106,2 06,151,197,153,202,164,203,178,198,187,198,181,189,176,187,170,173,185,166,209,162,229,154 ,253,146,280,143,307,142,321,136,354,143,374,145,404,150,429,149,440,155,314,259,304,268,2 94,276,302,281,310,278,308,288,311,296,328,292,338,284,342,290,340,296,341,310,335,325,342 ,335,346,341,342,345,333,351,327,357,321,343,324,340,316,323,321,318,318,306,307,307,298,2 87,274,282,252,280,238,272,236,268,212,273,209,283,164,294,187,274,132,295,128,301,32,338, 18,346" href="/UnitedStates.html"
    Is there a way to use Photoshop's magic wand tool / slice / path tool to extract the coordinates of an images border for me?
    Thanks

  • Edit mode pixel coordinates

    Hi all:
    On one computer I get the size of controls shown in a little pop-up at the bottom of the computer window as I'm resizing a control in the edit environment.   On another computer I don't.  I can't seem to find in the options menu how to turn this on.  I'm using LV8.2
    Thanks
    Robert

    rberger,
    Can you post a screenshot of what you're seeing? I've not heard of what you're describing in LabVIEW outside of the ActiveX property Browser.
    Chris C
    Chris Cilino
    National Instruments
    LabVIEW Product Marketing Manager
    Certified LabVIEW Architect

  • Is it possible to tell me how i can make program in labview that take pixels of black and withe image and give coordinate of black or white pixels back to me.

    hello everybody
    is it possible to tell me how i can make program in labview that take pixels of black and withe image and give coordinate of black or white pixels back to me.
    Solved!
    Go to Solution.

    Here's a slightly simpler version.
    (Depending how you want to process the output, you might not need to traspose and/or reverse. Boolean to 0,1 works directly on the 2D array if needed )
    amkamyab wrote:
    it is good. i could enter 1bit image in and show it in array. now i want to take pixels coordinates. i meen i want to have (x,y) of each pixel to send it pixel coordinate to another program i wrote for steppers motor.
    Can you be a bit more specific on how the output is supposed to look like? Initially you wrote "black or white", and since all pixels are either black or white, do you want to send all pixels? In what format? In what order? Please clarify?
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    BW-Pix.png ‏8 KB

  • Map mouse coordinate​s to XY graph coordinate​s (SI units on Graph)

    Hi Folks:
    I have used this invoke node method for quite awhile.  Now trying to use it on XY graph where SI units are used on X-axis.  Now I always get 0 for the X graph coordinate. Run the attached and you will see this. Anyway I can get this to work properly as I need to have the SI units.
    Thanks,
    Don
    Attachments:
    test - map panel coordinates (SI units).vi ‏30 KB

    See the coercion dots? Your xy cluster indicator is in the wrong representation (both values are I32, suitable for pixel coordinates, but inadequate for your scales).
    Delete the xy indicator and right-click on the property node xy output and select "create indicator". Now all's well.
    (Or you could just change both indicators inside the cluster to DBL representation)
    Message Edited by altenbach on 08-02-2007 09:05 AM
    LabVIEW Champion . Do more with less code and in less time .

  • Coordinate System SRID GeoRaster data

    Hi All,
    I'm learning GeoRaster and I have some problems setting the coordinate system.
    I've successfully loaded ArcGis Raster data (binary grid) using FME. I can run queries using sdo_geor.getCellValue using the numRow and numColumn parameters. my question is:
    How can I run the same query using the model coordinates (*British National Grid*) instead of the pixel coordinates ?
    Thanks !

    please follow these steps:
    1. make sure the loaded georaster object is properly georeferenced and has the model srid set. call sdo_geor.validategeoraster and sdo_geor.getmodelsrid.
    2. find the Oracle srid for British National Grid.
    3. directly call SDO_GEOR.getCellValue(
    georaster IN SDO_GEORASTER,
    pyramidLevel IN NUMBER,
    ptGeom IN SDO_GEOMETRY, - where your point in your srid - any srid is fine
    layers IN VARCHAR2
    ) RETURN SDO_NUMBER_ARRAY;
    4. you can convert cell coordinates (numRow, numColumn) to/from ground coordinates (X,Y) whenever needed. call sdo_geor.getModelCoordinate and sdo_geor.getCellCoordinate
    jeffrey

Maybe you are looking for