Java 类org.eclipse.swt.graphics.Rectangle 实例源码

项目:n4js    文件:TypeInformationPopup.java   
/**
 * Returns the initial location to use for the shell based upon the current selection in the viewer. Bottom is
 * preferred to top, and right is preferred to left, therefore if possible the popup will be located below and to
 * the right of the selection.
 *
 * @param initialSize
 *            the initial size of the shell, as returned by {@code getInitialSize}.
 * @return the initial location of the shell
 */
@Override
protected Point getInitialLocation(final Point initialSize) {
    if (null == anchor) {
        return super.getInitialLocation(initialSize);
    }

    final Point point = anchor;
    final Rectangle monitor = getShell().getMonitor().getClientArea();
    if (monitor.width < point.x + initialSize.x) {
        point.x = max(0, point.x - initialSize.x);
    }
    if (monitor.height < point.y + initialSize.y) {
        point.y = max(0, point.y - initialSize.y);
    }

    return point;
}
项目:n4js    文件:UIUtils.java   
/**
 * Given the desired position of the shell, this method returns an adjusted position such that the window is no
 * larger than its monitor, and does not extend beyond the edge of the monitor. This is used for computing the
 * initial window position via the parent shell, clients can use this as a utility method if they want to limit the
 * region in which the window may be moved.
 *
 * @param shell
 *            the shell which shell bounds is being calculated.
 * @param preferredSize
 *            the preferred position of the window.
 * @return a rectangle as close as possible to preferredSize that does not extend outside the monitor.
 */
public static Rectangle getConstrainedShellBounds(final Shell shell, final Point preferredSize) {

    final Point location = getInitialLocation(shell, preferredSize);
    final Rectangle result = new Rectangle(location.x, location.y, preferredSize.x, preferredSize.y);

    final Monitor monitor = getClosestMonitor(shell.getDisplay(), Geometry.centerPoint(result));

    final Rectangle bounds = monitor.getClientArea();

    if (result.height > bounds.height) {
        result.height = bounds.height;
    }

    if (result.width > bounds.width) {
        result.width = bounds.width;
    }

    result.x = Math.max(bounds.x, Math.min(result.x, bounds.x
            + bounds.width - result.width));
    result.y = Math.max(bounds.y, Math.min(result.y, bounds.y
            + bounds.height - result.height));

    return result;
}
项目:n4js    文件:UIUtils.java   
/**
 * Returns the monitor whose client area contains the given point. If no monitor contains the point, returns the
 * monitor that is closest to the point.
 *
 * @param toSearch
 *            point to find (display coordinates).
 * @param toFind
 *            point to find (display coordinates).
 * @return the monitor closest to the given point.
 */
private static Monitor getClosestMonitor(final Display toSearch, final Point toFind) {
    int closest = Integer.MAX_VALUE;

    final Monitor[] monitors = toSearch.getMonitors();
    Monitor result = monitors[0];

    for (int index = 0; index < monitors.length; index++) {
        final Monitor current = monitors[index];

        final Rectangle clientArea = current.getClientArea();

        if (clientArea.contains(toFind)) {
            return current;
        }

        final int distance = Geometry.distanceSquared(Geometry.centerPoint(clientArea), toFind);
        if (distance < closest) {
            closest = distance;
            result = current;
        }
    }

    return result;
}
项目:parabuild-ci    文件:ChartComposite.java   
/**
 * Returns the data area (the area inside the axes) for the plot or subplot,
 * with the current scaling applied.
 *
 * @param x  the x-coordinate (for subplot selection).
 * @param y  the y-coordinate (for subplot selection).
 * 
 * @return The scaled data area.
 */
public Rectangle getScreenDataArea(int x, int y) {
    PlotRenderingInfo plotInfo = this.info.getPlotInfo();
    Rectangle result;
    if (plotInfo.getSubplotCount() == 0)
        result = getScreenDataArea();
    else {
        // get the origin of the zoom selection in the Java2D space used for
        // drawing the chart (that is, before any scaling to fit the panel)
        Point2D selectOrigin = translateScreenToJava2D(new Point(x, y));
        int subplotIndex = plotInfo.getSubplotIndex(selectOrigin);
        if (subplotIndex == -1) {
            return null;
        }
        result = scale(plotInfo.getSubplotInfo(subplotIndex).getDataArea());
    }
    return result;
}
项目:BiglyBT    文件:ViewUtils.java   
public static void setViewRequiresOneDownload(Composite genComposite) {
    if (genComposite == null || genComposite.isDisposed()) {
        return;
    }
    Utils.disposeComposite(genComposite, false);

    Label lab = new Label(genComposite, SWT.NULL);
    GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, true, true);
    gridData.verticalIndent = 10;
    lab.setLayoutData(gridData);
    Messages.setLanguageText(lab, "view.one.download.only");

    genComposite.layout(true);

    Composite parent = genComposite.getParent();
    if (parent instanceof ScrolledComposite) {
        ScrolledComposite scrolled_comp = (ScrolledComposite) parent;

        Rectangle r = scrolled_comp.getClientArea();
        scrolled_comp.setMinSize(genComposite.computeSize(r.width, SWT.DEFAULT ));
    }

}
项目:BiglyBT    文件:ColumnThumbAndName.java   
@Override
public void cellMouseTrigger(TableCellMouseEvent event) {
    if (event.eventType == TableCellMouseEvent.EVENT_MOUSEMOVE
            || event.eventType == TableRowMouseEvent.EVENT_MOUSEDOWN) {
        TableRow row = event.cell.getTableRow();
        if (row == null) {
            return;
        }
        Object data = row.getData(ID_EXPANDOHITAREA);
        if (data instanceof Rectangle) {
            Rectangle hitArea = (Rectangle) data;
            boolean inExpando = hitArea.contains(event.x, event.y);

            if (event.eventType == TableCellMouseEvent.EVENT_MOUSEMOVE) {
                ((TableCellCore) event.cell).setCursorID(inExpando ? SWT.CURSOR_HAND
                        : SWT.CURSOR_ARROW);
            } else if (inExpando) { // mousedown
                if (row instanceof TableRowCore) {
                    TableRowCore rowCore = (TableRowCore) row;
                    rowCore.setExpanded(!rowCore.isExpanded());
                }
            }
        }
    }
}
项目:gw4e.project    文件:TableHelper.java   
public static void handleEvent(Event event) {

        Table table = (Table) event.widget;
        int columnCount = table.getColumnCount();
        if (columnCount == 0)
            return;
        Rectangle area = table.getClientArea();
        int totalAreaWdith = area.width;
        int lineWidth = table.getGridLineWidth();
        int totalGridLineWidth = (columnCount - 1) * lineWidth;
        int totalColumnWidth = 0;
        for (TableColumn column : table.getColumns()) {
            totalColumnWidth = totalColumnWidth + column.getWidth();
        }
        int diff = totalAreaWdith - (totalColumnWidth + totalGridLineWidth);

        TableColumn lastCol = table.getColumns()[columnCount - 1];

        lastCol.setWidth(diff + lastCol.getWidth());

    }
项目:neoscada    文件:AbstractDataSeriesRenderer.java   
protected static boolean translateToPoint ( final Rectangle clientRect, final XAxis x, final YAxis y, final DataPoint point, final DataEntry entry )
{
    // we always need X
    point.x = clientRect.x + x.translateToClient ( clientRect.width, entry.getTimestamp () );

    final Double value = entry.getValue ();
    if ( value == null || Double.isNaN ( value ) || Double.isInfinite ( value ) )
    {
        return false;
    }

    // we only provide Y if we really have a value

    point.y = clientRect.y + y.translateToClient ( clientRect.height, value );

    return true;
}
项目:avoCADo    文件:MainAvoCADoShell.java   
/**
 * create the main avoCADo shell and display it
 * @param display
 */
public MainAvoCADoShell(Display display){
    shell = new Shell(display);

    setupShell();               // place components in the main avoCADo shell

    shell.setText("avoCADo");
    shell.setSize(800, 600);    //TODO: set intial size to last known size
    shell.setMinimumSize(640, 480);
    Rectangle b = display.getBounds();
    int xPos = Math.max(0, (b.width-800)/2);
    int yPos = Math.max(0, (b.height-600)/2);
    shell.setLocation(xPos, yPos);
    shell.setImage(ImageUtils.getIcon("./avoCADo.png", 32, 32));
    shell.open();

    AvoGlobal.intializeNewAvoCADoProject(); // initialize app to starting model/view.

    StartupSplashShell.closeSplash();

    // handle events while the shell is not disposed
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
项目:parabuild-ci    文件:SWTStrokeCanvas.java   
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTStrokeCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            BasicStroke stroke = (BasicStroke) getStroke();
            if (stroke != null) {
                int x, y;
                Rectangle rect = getClientArea();
                x = (rect.width - 100) / 2;
                y = (rect.height - 16) / 2;
                Transform swtTransform = new Transform(e.gc.getDevice()); 
                e.gc.getTransform(swtTransform);
                swtTransform.translate(x, y);
                e.gc.setTransform(swtTransform);
                swtTransform.dispose();
                e.gc.setBackground(getDisplay().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setLineWidth((int) stroke.getLineWidth());
                e.gc.drawLine(10, 8, 90, 8);
            }
        }
    });
}
项目:neoscada    文件:TitleRenderer.java   
@Override
public void render ( final Graphics g, final Rectangle clientRectangle )
{
    if ( this.title == null || this.title.isEmpty () )
    {
        return;
    }

    g.setClipping ( this.rect );

    g.setFont ( createFont ( g.getResourceManager () ) );

    final Point size = g.textExtent ( this.title );

    final int x = this.rect.width / 2 - size.x / 2;
    final int y = this.padding;
    g.drawText ( this.title, this.rect.x + x, this.rect.y + y, null );

    g.setClipping ( clientRectangle );
}
项目:neoscada    文件:TitleRenderer.java   
@Override
public Rectangle resize ( final ResourceManager resourceManager, final Rectangle clientRectangle )
{
    if ( this.title == null || this.title.isEmpty () )
    {
        return null;
    }

    final GC gc = new GC ( resourceManager.getDevice () );
    gc.setFont ( createFont ( resourceManager ) );

    try
    {
        final Point size = gc.textExtent ( this.title );
        this.rect = new Rectangle ( clientRectangle.x, clientRectangle.y, clientRectangle.width, size.y + this.padding * 2 );
        return new Rectangle ( clientRectangle.x, this.rect.y + this.rect.height, clientRectangle.width, clientRectangle.height - this.rect.height );
    }
    finally
    {
        gc.dispose ();
    }
}
项目:BiglyBT    文件:ColumnSubscriptionName.java   
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
    Rectangle bounds = cell.getBounds();

    ImageLoader imageLoader = ImageLoader.getInstance();
    Image viewImage = imageLoader.getImage("ic_view");
    if(imageWidth == -1 || imageHeight == -1) {
        imageWidth = viewImage.getBounds().width;
        imageHeight = viewImage.getBounds().height;
    }

    bounds.width -= (imageWidth + 5);

    GCStringPrinter.printString(gc, cell.getSortValue().toString(), bounds,true,false,SWT.LEFT);

    Subscription sub = (Subscription) cell.getDataSource();

    if ( sub != null && !sub.isSearchTemplate()){

        gc.drawImage(viewImage, bounds.x + bounds.width, bounds.y + bounds.height / 2 - imageHeight / 2);
    }

    imageLoader.releaseImage("ic_view");

        //gc.drawText(cell.getText(), bounds.x,bounds.y);
}
项目:applecommander    文件:SwtUtil.java   
/**
 * Setup some sensible paging information.
 */
public static void setupPagingInformation(ScrolledComposite composite) {
    GC gc = new GC(composite);
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();
    int fontHeight = fontMetrics.getHeight();
    int fontWidth = fontMetrics.getAverageCharWidth();
    Rectangle clientArea = composite.getClientArea();
    int lines = clientArea.height / fontHeight;
    int pageHeight = lines * fontHeight;
    int pageWidth = clientArea.width - fontWidth; 
    composite.getVerticalBar().setIncrement(fontHeight);
    composite.getVerticalBar().setPageIncrement(pageHeight);
    composite.getHorizontalBar().setIncrement(fontWidth);
    composite.getHorizontalBar().setPageIncrement(pageWidth);
}
项目:OCCI-Studio    文件:ImageCanvas.java   
void paint(GC gc) {
    if (fImage != null) {
        Rectangle bounds = fImage.getBounds();
        Rectangle clientArea = getClientArea();
        int x;
        if (bounds.width < clientArea.width)
            x = (clientArea.width - bounds.width) / 2;
        else
            x = -getHorizontalBar().getSelection();
        int y;
        if (bounds.height < clientArea.height)
            y = (clientArea.height - bounds.height) / 2;
        else
            y = -getVerticalBar().getSelection();
        gc.drawImage(fImage, x, y);
    }
}
项目:neoscada    文件:VisualInterfaceViewer.java   
protected void handleResize ( final Rectangle bounds )
{
    if ( !isZooming () )
    {
        final org.eclipse.draw2d.geometry.Rectangle r = new org.eclipse.draw2d.geometry.Rectangle ( bounds.x, bounds.y, bounds.width, bounds.height );
        this.connectionLayer.setPreferredSize ( r.getSize () );

        setZoom ( 1.0 );
        return;
    }

    final Dimension prefSize = getPreferredSize ( bounds );

    final double ar = prefSize.preciseWidth () / prefSize.preciseHeight ();

    double newHeight = bounds.width / ar;
    final double zoom;

    if ( newHeight > bounds.height )
    {
        newHeight = bounds.height;
    }

    zoom = newHeight / prefSize.preciseHeight ();
    setZoom ( zoom );
}
项目:convertigo-eclipse    文件:KTableCellEditor.java   
/**
 * Activates the editor at the given position.
 * 
 * @param row
 * @param col
 * @param rect
 */
public void open(KTable table, int col, int row, Rectangle rect) {
  m_Table = table;
  m_Model = table.getModel();
  m_Rect = rect;
  m_Row = row;
  m_Col = col;
  if (m_Control == null) {
    m_Control = createControl();
    m_Control.setToolTipText(toolTip);
    m_Control.addFocusListener(new FocusAdapter() {
      public void focusLost(FocusEvent arg0) {
        close(true);
      }
    });
  }
  setBounds(m_Rect);
  GC gc = new GC(m_Table);
  m_Table.drawCell(gc, m_Col, m_Row);
  gc.dispose();
}
项目:avoCADo    文件:AboutAvoCADoGPLShell.java   
/**
 * create the startup splash shell and display it
 * @param display
 */
public AboutAvoCADoGPLShell(Display display){
    shell = new Shell(display, SWT.PRIMARY_MODAL);

    setupShell();               // place components in the avoCADo license shell

    shell.setText("avoCADo GPLv2");
    shell.setSize(583, 350);    //TODO: set initial size to last known size
    Rectangle b = display.getBounds();
    int xPos = Math.max(0, (b.width-583)/2);
    int yPos = Math.max(0, (b.height-350)/2);
    shell.setLocation(xPos, yPos);
    shell.open();

    // handle events while the shell is not disposed
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
}
项目:AppleCommander    文件:DiskMapTab.java   
/**
 * Handle paint requests for vertical ruler.
 */
protected void paintVerticalRuler(PaintEvent event) {
    // FIXME - not i18n safe!!
    String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); //$NON-NLS-1$
    if (disk.getBitmapLabels().length == 2) {
        label = (disk.getBitmapLabels()[1] + "s").toUpperCase(); //$NON-NLS-1$
    }
    StringBuffer buf = new StringBuffer();
    for (int i=0; i<label.length(); i++) {
        if (i>0) buf.append("\n"); //$NON-NLS-1$
        buf.append(label.charAt(i));
    }
    label = buf.toString();
    Canvas canvas = (Canvas) event.widget;
    Rectangle area = canvas.getClientArea();
    event.gc.drawLine(area.x + area.width/2, area.y, area.x + area.width/2, area.y + area.height);
    Point size = event.gc.textExtent(label);
    event.gc.drawText(label, area.x + area.width/2 - size.x/2, area.y + area.height/2 - size.y/2);
}
项目:SWET    文件:BreadcrumbItem.java   
void drawButtonAtPosition(final int x) {

        if (this.selection) {
            drawBackgroundAtPosition(x);
        }
        if (!this.isLastItemOfTheBreadCrumb) {
            drawTrianglesAtPosition(x);
        }

        int xPosition = computeGap();
        final Image drawnedImage = drawImageAtPosition(x + xPosition);
        if (drawnedImage != null) {
            xPosition += drawnedImage.getBounds().width + 2 * MARGIN;
        }
        drawTextAtPosition(x + xPosition);

        this.bounds = new Rectangle(x, 0, getWidth(), this.toolbarHeight);
    }
项目:iTrace-Archive    文件:TokenHighlighter.java   
@Override
public void handleEvent(Event event) {
    String[] propertyNames = event.getPropertyNames();
    //System.out.println(event.getProperty(propertyNames[0]));
    IStyledTextGazeResponse response = (IStyledTextGazeResponse)event.getProperty(propertyNames[0]);
    Rectangle mBounds = ITrace.getDefault().getRootShell().getBounds();
       int screenX = (int) (response.getGaze().getX() * mBounds.width);
       int screenY = (int) (response.getGaze().getY() * mBounds.height);
       //Rectangle monitorBounds = ITrace.getDefault().monitorBounds;
       if(styledText.isDisposed()) return;
       Rectangle editorBounds = styledText.getBounds();
       Point screenPos = styledText.toDisplay(0, 0);
       editorBounds.x = screenPos.x - mBounds.x;
       editorBounds.y = screenPos.y - mBounds.y;
       if(editorBounds.contains(screenX, screenY)){
        int relativeX = screenX-editorBounds.x;
        int relativeY = screenY-editorBounds.y;
        update(response.getLine()-1,response.getCol(), relativeX, relativeY);
       }

}
项目:tap17-muggl-javaee    文件:StaticGuiSupport.java   
/**
 * Get the centered position for a window on the primary monitor according
 * to its' width and height.
 * @param myWidth The windows' width.
 * @param myHeight The windows' height.
 * @param display The Display.
 * @return An array containing the X and the Y position.
 */
public static int[] getCenteredPosition(int myWidth, int myHeight, Display display) {
    // Calculate the current position.
    Rectangle displayBounds = display.getPrimaryMonitor().getBounds();
    int[] myPos = new int[2];
    myPos[0] = displayBounds.width / 2 - (myWidth / 2);
    myPos[1] = displayBounds.height / 2 - (myHeight / 2);

    // Finished.
    return myPos;
}
项目:n4js    文件:TestProgressBar.java   
/**
 * Paint.
 */
protected void onPaint(GC gc) {
    final Rectangle b = getBounds();

    final TestStatus status = counter != null ? counter.getAggregatedStatus() : null;
    if (status != null) {

        final int total = Math.max(expectedTotal, counter.getTotal()); // this is our 100% value
        final int value = counter.getTotal(); // current value
        final int totalPx = b.width;
        final int valuePx = Math.round(totalPx * (((float) value) / ((float) total)));

        gc.setBackground(getColorForStatus(status));
        gc.fillRectangle(0, 0, valuePx, b.height);

        gc.setBackground(getBackground());
        gc.fillRectangle(0 + valuePx, 0, b.width - valuePx, b.height);
    } else {
        // clear
        gc.setBackground(getBackground());
        gc.fillRectangle(b);
    }

    if (counter != null) {
        final FontMetrics fm = gc.getFontMetrics();
        gc.setForeground(getForeground());
        final int pending = expectedTotal > 0 ? expectedTotal - counter.getTotal() : -1;
        gc.drawString(counter.toString(true, pending, SWT.RIGHT),
                4, b.height / 2 - fm.getHeight() / 2 - fm.getDescent(), true);
    }
}
项目:n4js    文件:ShowHistoryAction.java   
@Override
public void runWithEvent(Event event) {
    if (event.widget instanceof ToolItem) {
        final ToolItem toolItem = (ToolItem) event.widget;
        final Control control = toolItem.getParent();
        final Menu menu = getMenuCreator().getMenu(control);

        final Rectangle bounds = toolItem.getBounds();
        final Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
        menu.setLocation(control.toDisplay(topLeft));
        menu.setVisible(true);
    }
}
项目:ide-plugins    文件:PluginDialog.java   
@Override
protected Point getInitialLocation(Point initialSize) {
    Monitor activeMonitor = Stream.of(display.getMonitors())
            .filter(m -> m.getBounds().intersects(getShell().getBounds()))
            .findFirst()
            .orElse(display.getPrimaryMonitor());

    Rectangle visualBounds = activeMonitor.getClientArea();
    int x = visualBounds.x + (visualBounds.width - initialSize.x) / 2;
    int y = visualBounds.y + (visualBounds.height - initialSize.y) / 2;
    return new Point(x, y);
}
项目:SWET    文件:BreadcrumbItem.java   
private Point computeMaxWidthAndHeightForImages(final Image... images) {
    final Point imageSize = new Point(-1, -1);
    for (final Image image : images) {
        if (image == null) {
            continue;
        }
        final Rectangle imageBounds = image.getBounds();
        imageSize.x = Math.max(imageBounds.width, imageSize.x);
        imageSize.y = Math.max(imageBounds.height, imageSize.y);
    }
    return imageSize;
}
项目:avoCADo    文件:SWTUtils.java   
/**
 * Get the width of the shell's right edge
 * @param s
 * @return
 */
public static int getShellRightEdgeWidth(Shell s){
    Rectangle b = s.getBounds();
    Rectangle t = s.computeTrim(b.x, b.y, b.width, b.height);
    int rightEW = ((t.width-b.width)-(b.x-t.x));
    if(s.getMaximized()){
        return 0;
    }else{
        return rightEW;
    }
}
项目:BiglyBT    文件:VivaldiPanel.java   
private void draw(GC gc,float x,float y,float h,DHTControlContact contact,int distance,float error) {
  if(x == 0 && y == 0) return;
  if(error > 1) error = 1;
  int errDisplay = (int) (100 * error);
  int x0 = scale.getX(x,y);
  int y0 = scale.getY(x,y);

  Image img = ImageRepository.getCountryFlag( contact.getTransportContact().getTransportAddress().getAddress(), true );

  if ( img != null ){
    Rectangle bounds = img.getBounds();
    int old = gc.getAlpha();
    gc.setAlpha( 150 );
    gc.drawImage( img, x0-bounds.width/2, y0-bounds.height);
    gc.setAlpha( old );
  }

  gc.fillRectangle(x0-1,y0-1,3,3);
  //int elevation =(int) ( 200*h/(scale.maxY-scale.minY));
  //gc.drawLine(x0,y0,x0,y0-elevation);

  //String text = /*contact.getTransportContact().getAddress().getAddress().getHostAddress() + " (" + */distance + " ms \nerr:"+errDisplay+"%";
  String text = /*contact.getTransportContact().getAddress().getAddress().getHostAddress() + " (" + */distance + " ms "+errDisplay+"%";

  int lineReturn = text.indexOf("\n");
  int xOffset = gc.getFontMetrics().getAverageCharWidth() * (lineReturn != -1 ? lineReturn:text.length()) / 2;
  gc.drawText(text,x0-xOffset,y0,true);

  currentPositions.add( new Object[]{ x0, y0, h, contact, x, y, distance });
}
项目:neoscada    文件:MouseDragZoomer.java   
@Override
public void render ( final Graphics g, final Rectangle clientRectangle )
{
    if ( this.selection != null )
    {
        final Rectangle chartRect = this.chart.getClientAreaProxy ().getClientRectangle ();

        g.setLineAttributes ( new LineAttributes ( 1.0f ) );
        g.setForeground ( null );

        g.drawRectangle ( this.selection.x + chartRect.x, this.selection.y + chartRect.y, this.selection.width, this.selection.height );
    }
}
项目:BiglyBT    文件:ColumnActivityNew.java   
@Override
public void cellPaint(GC gc, TableCellSWT cell) {
    ActivitiesEntry entry = (ActivitiesEntry) cell.getDataSource();

    Rectangle cellBounds = cell.getBounds();
    Image img = entry.getReadOn() <= 0 ? imgNew : imgOld;

    if (img != null && !img.isDisposed()) {
        Rectangle imgBounds = img.getBounds();
        gc.drawImage(img, cellBounds.x
                + ((cellBounds.width - imgBounds.width) / 2), cellBounds.y
                + ((cellBounds.height - imgBounds.height) / 2));
    }
}
项目:neoscada    文件:MouseHover.java   
@Override
protected void doRender ( final Graphics g, final Rectangle clientRectangle )
{
    if ( this.position == null )
    {
        return;
    }

    final int x = this.position;
    g.setForeground ( this.color );
    g.drawLine ( x, clientRectangle.y, x, clientRectangle.y + clientRectangle.height );
}
项目:Hydrograph    文件:ExecutionTrackingConsoleUtils.java   
/**
 * Open execution tracking console window.
 *
 * @param localJobId the local job id
 */
private void openExecutionTrackingConsoleWindow(String localJobId) {
    boolean newConsole=false;
    ExecutionTrackingConsole console = JobManager.INSTANCE.getExecutionTrackingConsoles().get(localJobId);
    if(console==null){
        console = new ExecutionTrackingConsole(getConsoleName(),localJobId);
        JobManager.INSTANCE.getExecutionTrackingConsoles().put(localJobId, console);
        newConsole = true;
    }
    if(console.getShell()==null){
        console.clearConsole();
        console.open();
        if(!JobManager.INSTANCE.isJobRunning(console.consoleName)){
            console.statusLineManager.setMessage("");
        }
    }else{
        Rectangle originalBounds = console.getShell().getBounds();
        console.getShell().setMaximized(true);
        Rectangle originalBoundsClone = new Rectangle(originalBounds.x, originalBounds.y, originalBounds.width, originalBounds.height);
        console.getShell().setBounds(originalBoundsClone);      
        console.getShell().setActive(); 
    }
    if(StringUtils.isNotEmpty(getUniqueJobId()) && newConsole && isJobUpdated){
        ExecutionStatus[] executionStatus = readFile(null, getUniqueJobId(), JobManager.INSTANCE.isLocalMode());
        console.setStatus(getHeader(getUniqueJobId()));
        for(int i =0; i<executionStatus.length; i++){
            console.setStatus(getExecutionStatusInString(executionStatus[i]));
        }
    }
}
项目:neoscada    文件:LegendRenderer.java   
@Override
public void render ( final Graphics g, final Rectangle clientRectangle )
{
    final Rectangle chartRect = this.renderer.getClientAreaProxy ().getClientRectangle ();

    final DataSet data = makeAllData ( g );

    renderData ( g, chartRect, data );
}
项目:BiglyBT    文件:TabbedEntry.java   
@Override
public Image obfuscatedImage(Image image) {
    Rectangle bounds = swtItem == null ? null : swtItem.getBounds();
    if ( bounds != null ){

        boolean isActive = swtItem.getParent().getSelection() == swtItem;
        boolean isHeaderVisible = swtItem.isShowing();

        Point location = Utils.getLocationRelativeToShell(swtItem.getParent());

        bounds.x += location.x;
        bounds.y += location.y;

        Map<String, Object> map = new HashMap<>();
        map.put("image", image);
        map.put("obfuscateTitle", false);
        if (isActive) {
            triggerEvent(UISWTViewEvent.TYPE_OBFUSCATE, map);

            if (viewTitleInfo instanceof ObfuscateImage) {
                ((ObfuscateImage) viewTitleInfo).obfuscatedImage(image);
            }
        }

        if (isHeaderVisible) {
            if (viewTitleInfo instanceof ObfuscateTab) {
                String header = ((ObfuscateTab) viewTitleInfo).getObfuscatedHeader();
                if (header != null) {
                    UIDebugGenerator.obfuscateArea(image, bounds, header);
                }
            }

            if (MapUtils.getMapBoolean(map, "obfuscateTitle", false)) {
                UIDebugGenerator.obfuscateArea(image, bounds);
            }
        }
    }

    return image;
}
项目:neoscada    文件:AbstractDataSeriesRenderer.java   
@Override
public void render ( final Graphics g, final Rectangle clientRectangle )
{
    if ( !this.visible )
    {
        return;
    }
    else
    {
        performRender ( g, clientRectangle );
    }
}
项目:neoscada    文件:AbstractPositionYRuler.java   
@Override
protected void doRender ( final Graphics g, final Rectangle clientRectangle )
{
    if ( this.axis == null )
    {
        return;
    }

    final Double position = getPosition ();
    if ( position == null )
    {
        return;
    }

    final int y = (int)this.axis.translateToClient ( clientRectangle.height, getPosition () );

    if ( ( this.style & SWT.TOP ) > 0 )
    {
        g.fillRectangle ( clientRectangle.x, clientRectangle.y, clientRectangle.width, y );
    }
    else if ( ( this.style & SWT.BOTTOM ) > 0 )
    {
        g.fillRectangle ( clientRectangle.x, y, clientRectangle.width, clientRectangle.height - y );
    }
    else
    {
        if ( y < 0 || y > clientRectangle.width )
        {
            return;
        }
        g.drawLine ( clientRectangle.x, clientRectangle.y + y, clientRectangle.width, clientRectangle.y + y );
    }
}
项目:parabuild-ci    文件:ChartComposite.java   
/**
 * Zooms in on a selected region.
 *
 * @param selection  the selected region.
 */
public void zoom(Rectangle selection) {

    // get the origin of the zoom selection in the Java2D space used for
    // drawing the chart (that is, before any scaling to fit the panel)
    Point2D selectOrigin = translateScreenToJava2D(
            new Point(selection.x, selection.y));
    PlotRenderingInfo plotInfo = this.info.getPlotInfo();
    Rectangle scaledDataArea = getScreenDataArea(
            (int) (selection.x + selection.width)/2, 
            (int) (selection.y + selection.height)/2);
    if ((selection.height > 0) && (selection.width > 0)) {

        double hLower = (selection.x - scaledDataArea.x) 
            / (double) scaledDataArea.width;
        double hUpper = (selection.x + selection.width - scaledDataArea.x) 
            / (double) scaledDataArea.width;
        double vLower = (scaledDataArea.y + scaledDataArea.height - selection.y - selection.height) 
            / (double) scaledDataArea.height;
        double vUpper = (scaledDataArea.y + scaledDataArea.height - selection.y) 
            / (double) scaledDataArea.height;
        Plot p = this.chart.getPlot();
        if (p instanceof Zoomable) {
            Zoomable z = (Zoomable) p;
            if (z.getOrientation() == PlotOrientation.HORIZONTAL) {
                z.zoomDomainAxes(vLower, vUpper, plotInfo, selectOrigin);
                z.zoomRangeAxes(hLower, hUpper, plotInfo, selectOrigin);
            }
            else {
                z.zoomDomainAxes(hLower, hUpper, plotInfo, selectOrigin);
                z.zoomRangeAxes(vLower, vUpper, plotInfo, selectOrigin);
            }
        }

    }

}
项目:SWET    文件:SimpleToolBarEx.java   
private void paginateBreadCrumb() {
    Rectangle rect = bc.getBounds();
    if (rect.width > shell.getBounds().width - 5
            || rect.width > java.awt.Toolkit.getDefaultToolkit()
                    .getScreenSize().width - 100) {
        Breadcrumb bc2 = new Breadcrumb(bc.getParent(), SWT.BORDER);
        // NOTE: operates global
        bc = bc2;
    }
}
项目:BiglyBT    文件:ColumnTC_Sample.java   
public Cell(TableCell parentCell, TableColumnCore column, Composite c, TableRowCore sampleRow) {
    this.column = column;
    if (sampleRow == null) {
        return;
    }
    Object ds = sampleRow.getDataSource(true);
    Object pds = sampleRow.getDataSource(false);
    if (column.handlesDataSourceType(pds.getClass())) {
            sampleCell = new FakeTableCell(column, ds);

            Rectangle bounds = ((TableCellSWT)parentCell).getBounds();
            sampleCell.setControl(c, bounds, false);
    }
}
项目:BiglyBT    文件:SideBarToolTips.java   
/**
 * @return
 *
 * @since 3.1.1.1
 */
private String getToolTip(Point mousePos_RelativeToItem) {
    MdiEntryVitalityImage[] vitalityImages = mdiEntry.getVitalityImages();
    for (int i = 0; i < vitalityImages.length; i++) {
        SideBarVitalityImageSWT vitalityImage = (SideBarVitalityImageSWT) vitalityImages[i];
        if (vitalityImage == null) {
            continue;
        }
        String indicatorToolTip = vitalityImage.getToolTip();
        if (indicatorToolTip == null || !vitalityImage.isVisible()) {
            continue;
        }
        Rectangle hitArea = vitalityImage.getHitArea();
        if (hitArea == null) {
            continue;
        }
        if (hitArea.contains(mousePos_RelativeToItem)) {
            return indicatorToolTip;
        }
    }

    if (mdiEntry.getViewTitleInfo() != null) {
        String tt = (String) mdiEntry.getViewTitleInfo().getTitleInfoProperty(ViewTitleInfo.TITLE_INDICATOR_TEXT_TOOLTIP);
        return tt;
    }

    return null;
}