Java Code Examples for org.eclipse.swt.widgets.Composite#getLocation()

The following examples show how to use org.eclipse.swt.widgets.Composite#getLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HopGuiPipelineGraph.java    From hop with Apache License 2.0 6 votes vote down vote up
public Point getRealPosition( Composite canvas, int x, int y ) {
  Point p = new Point( 0, 0 );
  Composite follow = canvas;
  while ( follow != null ) {
    org.eclipse.swt.graphics.Point loc = follow.getLocation();
    Point xy = new Point( loc.x, loc.y );
    p.x += xy.x;
    p.y += xy.y;
    follow = follow.getParent();
  }

  int offsetX = -16;
  int offsetY = -64;
  if ( Const.isOSX() ) {
    offsetX = -2;
    offsetY = -24;
  }
  p.x = x - p.x + offsetX;
  p.y = y - p.y + offsetY;

  return screen2real( p.x, p.y );
}
 
Example 2
Source File: UIHelper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This is a helper method created to get the location on screen of a
 * composite. It does not take into account multiple monitors.
 * 
 * @param cmpTarget
 *            The composite whose location on screen is required
 * @return The location of the composite on screen.
 */
public static Point getScreenLocation( Composite cmpTarget )
{
	Point ptScreen = new Point( 0, 0 );
	try
	{
		Composite cTmp = cmpTarget;
		while ( !( cTmp instanceof Shell ) )
		{
			ptScreen.x += cTmp.getLocation( ).x;
			ptScreen.y += cTmp.getLocation( ).y;
			cTmp = cTmp.getParent( );
		}
	}
	catch ( Exception e )
	{
		logger.log( e );
	}
	return cmpTarget.getShell( ).toDisplay( ptScreen );
}
 
Example 3
Source File: UIHelper.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This is a helper method created to get the location on screen of a
 * composite. It does not take into account multiple monitors.
 * 
 * @param cmpTarget
 *            The composite whose location on screen is required
 * @return The location of the composite on screen.
 */
public static Point getScreenLocation( Composite cmpTarget )
{
	Point ptScreen = new Point( 0, 0 );
	try
	{
		Composite cTmp = cmpTarget;
		while ( !( cTmp instanceof Shell ) )
		{
			ptScreen.x += cTmp.getLocation( ).x;
			ptScreen.y += cTmp.getLocation( ).y;
			cTmp = cTmp.getParent( );
		}
	}
	catch ( Exception e )
	{
		WizardBase.displayException( e );
	}
	return cmpTarget.getShell( ).toDisplay( ptScreen );
}
 
Example 4
Source File: TransGraph.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public Point getRealPosition( Composite canvas, int x, int y ) {
  Point p = new Point( 0, 0 );
  Composite follow = canvas;
  while ( follow != null ) {
    org.eclipse.swt.graphics.Point loc = follow.getLocation();
    Point xy = new Point( loc.x, loc.y );
    p.x += xy.x;
    p.y += xy.y;
    follow = follow.getParent();
  }

  int offsetX = -16;
  int offsetY = -64;
  if ( Const.isOSX() ) {
    offsetX = -2;
    offsetY = -24;
  }
  p.x = x - p.x + offsetX;
  p.y = y - p.y + offsetY;

  return screen2real( p.x, p.y );
}
 
Example 5
Source File: HopGuiWorkflowGraph.java    From hop with Apache License 2.0 5 votes vote down vote up
public Point getRealPosition( Composite canvas, int x, int y ) {
  Point p = new Point( 0, 0 );
  Composite follow = canvas;
  while ( follow != null ) {
    Point xy = new Point( follow.getLocation().x, follow.getLocation().y );
    p.x += xy.x;
    p.y += xy.y;
    follow = follow.getParent();
  }

  p.x = x - p.x - 8;
  p.y = y - p.y - 48;

  return screen2real( p.x, p.y );
}
 
Example 6
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the absolute location.
 *
 * @param control the control
 * @param x the x
 * @param y the y
 * @return the absolute location
 */
private Point getAbsoluteLocation(Control control, int x, int y) {
  Point point = new Point(x, y);
  Composite composite = control.getParent();
  while (composite != null) {
    point.x += composite.getLocation().x;
    point.y += composite.getLocation().y;
    composite = composite.getParent();
  }
  return point;
}
 
Example 7
Source File: JobGraph.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public Point getRealPosition( Composite canvas, int x, int y ) {
  Point p = new Point( 0, 0 );
  Composite follow = canvas;
  while ( follow != null ) {
    Point xy = new Point( follow.getLocation().x, follow.getLocation().y );
    p.x += xy.x;
    p.y += xy.y;
    follow = follow.getParent();
  }

  p.x = x - p.x - 8;
  p.y = y - p.y - 48;

  return screen2real( p.x, p.y );
}