Mapping component location from screen coordinates
hello ...
I have to display popup menu on click of jtable's cell. When my popup appears, it get displayed too far away from table. My table is on a jinternalframe within desktoppane. I have used the following code to map screen coordinates to component coordinates.
public void mouseClicked(MouseEvent mev)
int tabcol = parentTable.columnAtPoint(mev.getPoint());
Point p = mev.getPoint();
int c = parentTable.columnAtPoint(p);
int r = parentTable.rowAtPoint(p);
Rectangle a = parentTable.getCellRect(r, c, true);
displayAt((int)a.getX(),(int)a.getY()+parentTable.getRowHeight(0), r);
after applying above strategy, i succeeded in positioning the popup horizontally, but it is still above the cell where i want it to be.
so, thats the problem basically.
any professional comments/solutions will be hightly appreciated.
cheers,
Raheel.
Well, i have used those swingutilities methods too, but no luck. I think i am using some wrong ones like "convertPointToScreen" OR "convertPointFromScreen". If you plz specify the correct methods with proper usage then it might solve my problem.
thanks...
Raheel.
Similar Messages
-
Coordinate system translation from screen coordinates to stage coordinates
I realize this is not truly a LabVIEW question, but I'm hoping for suggestions.
I have a digitized image of a sample on a 3 axis stage. The user selects "paths" for a drill to take along the surface of the sample. On the image, 3 reference points are identified. The stage posititions (x, y, and z) corresponding to these points are then identified.
I need to now convert the coordinates of the paths to the stage coordinate system. Are there any LabVIEW vi's that are suited to this need? I have IMAQ vi's but not very experience with these yet. Suggestions much appreciated
TimHello Shan:
Were almost have the same problem but mine is for a AOI handler with a robot arm which I need to pick (x,y) pairs along the work envelope. Anyway, for the most math part it will involve are coordinate transformation from a "mouse coordinates" to "real world coordinates" and your image processing textbook (I use McGrawHill Computer Graphics by Hill) will outline both the code and the math but LabVIEW will not have a facility to do with an actual VI instead you have to use the array manipulations and treat them coordinates as matrix elements. There is a Math VI and G-Math VI or a MatLAB call you can use for coordinate matrix manipulations as long as you have the math quite figured out in paper already.
Bernardino Jerez Buenaobra
Senior Test and Systems Development Engineer
Test and Systems Development Group
Integrated Microelectronics Inc.- Philippines
Telephone:+632772-4941-43
Fax/Data: +632772-4944
URL: http://www.imiphil.com/our_location.html
email: [email protected] -
Convert screen coordinate to map coordinate
Hi
I have a question if there is any method in MapViewer that convert screen
coordinates to map coordinates.
FredrikgetUserPoint(int x, int y)
Gets the user space point corresponding to the mouse click.
getUserPoint in Java API converts from screen to user space ( lat/lon or whatever coordinate system you are using) -
How to center loaded swf & get screen coordinates of its component?
I made an swf using Flash CS4, it has a movieclip named 'mc' & and a vertical bar centered horizontally. I then load it using swfloaded & put it inside a canvas & set it's windows & height to 100%.
The codes:
<mx:Canvas id="cv" verticalScrollPolicy="off" horizontalScrollPolicy="off" width="{screen.width}" height="{screen.height}">
<mx:SWFLoader id="template" source="assets/sample.swf" width="100%" height="100%" complete="dump(event);"/>
<mx:HBox id="bb" />
</mx:Canvas>
<mx:Script>
private function dump(event:Event): void {
var panel:MovieClip = MovieClip(template.content);
var pt:Point = panel.localToGlobal(new Point(panel.mc.x, panel.mc.y));
bb.x = pt.x; bb.y = pt.y; bb.width=10; bb.height = 10;
panel.x = (cv.width - panel.conentWidth) / 2;
Alert.show(
"scaleratio x,y = " + panel.scaleX + "," + panel.scaleY +"\n"
+ "panel x,y = " + panel.x + "," + panel.y + "\n"
+ "local x,y = " + panel.mc.x + "," + panel.mc.y + "\n"
+ "global x,y = " + pt.x + "," + pt.y + "\n"
</mx:Script>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The dump result is:
scaleratio x,y = 1,1
panel x,y = 100,800
local x,y = 775, 800
gloval x,y = 875, 800
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q1. I draw an bound box according to the content object of this swf & saw this bound box is indeed centered. However, the bar object is some offset left from the center of screen. Why it's not aligned center as I saw it in Flash CS4?
Q2. I try to get the screen coordinates of component 'mc' by using localToGlobal to convert it to screen coordinates & draw a box to overlap their top-left point. However the topleft point of box is far left of mc's on screen. I think it's due to the swf is scaled, so I dump scaleX and scaleY of this swf but they are both 1? How can I get correct screen coordinates of mc?
Thanks in advance!
ScottBecause of margins and padding, the Canvas probably won't be positioned at
0,0, so setting its width to screen.width will make it hang over the right
edge. Use width="100%" instead. Same for height.
I believe there is a horizontalAlign property on the SWFLoader. -
My location services screen has a haze over it which prevents me from making any changes.
MY location services screen has a haze over it which prevents me from using any of the slide switches, any suggestions?
Quit the Settings app completely and reboot the iPad. Go to the home screen first by tapping the home button. Double tap the home button and the recents tray will appear with all of your recent apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the app that you want to close. Tap the home button or anywhere above the task bar.
Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up. -
Since upgrading to iOS 8.3 the maps apps on my ipad do not show current location from my gps
Since upgrading to iOS 8.3 the maps apps on my ipad do not show current location from my gps DUALXGPS150A
The data is still being received by the ipad but not appearing on any of the maps.
Everything was working fine before the upgrade.Hi davidisleta,
If you are having issues with your iPad not showing location information, you may want to try some things to troubleshoot.
First, quit all running applications and test again -
Force an app to close in iOS
Next, I would try restarting and if needed resetting the iPhone -
Restart or reset your iPhone, iPad, or iPod touch
If the issue is still present, you may want to restore the iPhone as a new device -
How to erase your iOS device and then set it up as a new device or restore it from backups
Thanks for using Apple Support Communities.
Best,
Brett L -
I want to change my shipping location from Canada to Japan. I do not see the "edit shipping" option on my screen. How do I change shipping locations?
Be aware that you can only ship to Japan if you order the book with a credit card with a Japanese billing address.
OT -
Get screen coordinates from 3d position
Hi,<br />When I use 3d JavaScript camera's getScreenFromPosition method, the screen Y returned is always 0. The following is the test code. Did I miss anything? Is there another way to get screen coordinates from 3d?<br /><br />I'd appreciate any help.<br /><br />Xintai<br /><br />// test code ==========================<br />function v3dToScreen(v,w,h)<br />{<br /> console.println("\n v=" + v + " w = " + w + " h ="+ h);<br /> cam = scene.cameras.getByIndex (0);<br /> <br /> screenV = cam.getScreenFromPosition(v, w, h);<br /> console.println( " converted: mx=" + screenV.x + " my=" + screenV.y);<br /> console.println(screenV.toString());<br /> //console.println( " pdf mouse X=" + host.mouseX + " pdf mouse Y=" + host.mouseY);<br />}<br /><br />console.println ("Click a 3D object to test getScreenFromPosition()");<br /><br />myMouseHandler = new MouseEventHandler();<br />myMouseHandler.onMouseDown = true;<br />myMouseHandler.onEvent = function(event)<br />{<br /> if(event.isMouseDown) {<br /> console.println("====== MouseDown =======");<br /> console.println("isMouseDown = " + event.isMouseDown );<br /> <br /> for ( i=0; i<event.hits.length; i++ )<br /> {<br /> console.println (" hits[" + i + "].position = " + event.hits[i].position );<br /> <br /> if (event.hits[i].target != undefined)<br /> {<br /> v3 = vent.hits[i].position;<br /> v3dToScreen(v3,event.canvasPixelWidth,event.canvasPixelHeight);<br /> }<br /> }<br /> }<br />}<br /><br />runtime.addEventHandler(myMouseHandler);<br /><br />// end of test code ==========================
Hi Xintai,
This is a feature i would also like to use. I've tried using the script that you've provided but i cant get it to work. I assume this is the javascript (.js file) that you embed into the pdf? Is this all that's needed?
If you've managed to get this working, could you let me know how you did it?
Thanks
George -
Don't Want to Store Location Data from Screen Shots
I found that every Screenshot (pressing Home and Sleep buttons together) I took has the current location recorded on the screenshot picture saved in Camera Roll.
How can I tell my iPhone stop recording the location to the screenshots, while allowing photos taken from iOS Camera app continues recording location data?
I tried:
On iOS 7.1.2 Settings>Privacy>Location Services, I can choose if I want to include / exclude my location from each app by turning them On or Off. But I can't find a way to change the screenshot function.ok, you can try this app TrashExif...BUT duplicate will be...... but those apps can help.....
-
When location of component changed on screen?
Hi,
I have Code that brings up a message in a JDialog under a JTextComponent. I calculate the bottom - left point of the TextComponent and set my Dialog to show up there. However I have a problem keeping it there when the window moves, the TextComponent moves or One of it's parents moves.
I need something that will tell me when the location on screen of the TextComponent changes.
Thanks,
ShaulAncestorListener#ancestorMoved seems to work just fine.import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Point;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JWindow;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.LineBorder;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
public class TestGUI {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new TestGUI().makeUI();
public void makeUI() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 200);
frame.setLayout(new FlowLayout());
frame.add(new TextFieldWithPopup(10));
frame.add(new TextFieldWithPopup(20));
frame.setLocationRelativeTo(null);
frame.setVisible(true);
class TextFieldWithPopup extends JTextField {
JWindow message = new JWindow();
private JLabel label;
public TextFieldWithPopup(int columns) {
super(columns);
addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
message.setVisible(true);
@Override
public void focusLost(FocusEvent e) {
message.setVisible(false);
label = new JLabel("This is the popup");
label.setOpaque(true);
label.setBackground(UIManager.getColor("ToolTip.background"));
label.setBorder(new LineBorder(Color.BLACK));
message.add(label);
message.setAlwaysOnTop(true);
addAncestorListener(new AncestorListener() {
@Override
public void ancestorAdded(AncestorEvent event) {
@Override
public void ancestorRemoved(AncestorEvent event) {
@Override
public void ancestorMoved(AncestorEvent event) {
Point p = getLocationOnScreen();
message.setSize(getSize());
message.setLocation(p.x + getWidth(), p.y + getHeight());
}db -
How can I import Canon imbeded GPS location from one picture in project to remaining pictures in project?
If you have several photos taken at the same location you can use the Lift&Stamp tool to copy the GPS data to the other images.
Seelct the image, press the "Lift" button, deselect all tags in the Lift&Stamp HUD but the GPS coordinates, then select all photos taken at the same place and and press the "Stamp" tool. (marked by the down arrow)
Alternately use the "Places View". You will see the photos with a GPS location marked by a pin. Drag the photos you want to assign to the same place simply to that pin on the map and they will be assigned to the same place.
Regards
Léonie -
Position on component in the screen
Hi!
I want to get position a text field on screen. I use method getBounds(), but this method get position on text field concerning on it parent. But I want to get positon concerning on screen.What can I do?
Thank you.SwingUtilities.convertPointToScreen( new Point(0,0), textField )
* Convert a point from a component's coordinate system to
* screen coordinates.
* @param p a Point object (converted to the new coordinate system)
* @param c a Component object
public static void convertPointToScreen(Point p,Component c) -
Getting xsd location from a variable
Hi we run std 2012. In my xml file adapter I don't see an option for mapping the xsd source file to anything but a hardcoded value. Is there a way to get the location from a variable?
Hi db042190,
By design, there is no expression option for XSD location in the advanced editor of XML Source. It only support hard code the location in this page.
While we can click the Data Flow Task that contains the XML Source component to open the Properties pane, then use expression to control the property like [XML Source].[XMLSchemaDefinition] property in Expressions property.
The following screenshot is for your reference:
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
TestStand Component Locator Database Editor - can't set crosshairs
The help file in the Component Locator Database Editor says
"Select a component from the list. Use the image scrollbars to center the component in the image. Set the magnification with the zoom controls so the details of the image such as the component identifiers are easily visible. Set the mouse cursor on the item in the image and left click. A crosshair will appear on the image at the cursor position and the coordinates and magnification will be entered into the table next to the item. This process may be repeated to re-enter the data."
I can't get this to work. I select the component. I can see the crosshairs at the bottom left of the picture. I can't get the crosshairs to move.
Does this work?This doesn't sound like National Instruments TestStand, if it's something from Sierra Instruments then you would be better to contact them or the supplier of this equipment.
Regards
Ray Farmer -
Hi. I am using the iPhone 4S and when I'm searching for places using Google it does not automatically detect my location. How do I change this? FYI...under settings i have it set at "Use new precise locations from my device."
If you are missing using google maps - try the Nokia map app called "here"
Maybe you are looking for
-
While on ichat, video will freeze for 5 seconds and come back, then continues to freeze for 5 seconds intermittently during the video chat. Happens whenever I am on iChat, regardless of who I am chatting with. Party on the other end does not see any
-
WLC 5508 - LAP1242: Failed to handle capwap control message from controller
Hello everyone, after finally successfully upgrading my WLCs from 6.0.199.4 to 7.6.100.0 there is another problem showing up... If I want to change any configuration regarding the APs on the WLCs (which doesn't work) I get the following error-message
-
Employee responsible of contact or operation is changed on edit mode
Hello, When i switch to edit mode on a contact or operation the employee responsible is automatically changed. I have been playing around with partner determination but It seems like standard behaviour if i look at note 1408051. Is any possible solut
-
Right now when I scan a mostly text document to pdf I can open it in Photoshop and darken the text nicely. But its a pain to do each page, then save, and re-assemble. Can Acrobat XI do this, perhaps in preflight? If you're reading this Adobe, plea
-
I would like to upgrade openssl that comes standard with Solaris 10. I know the version that is preinstalled also has many security updates, but I do not believe it has the most recent (a man-in-the middle, CVE-2008-5077) attack. Is there a Sun patch