Java Code Examples for org.eclipse.swt.graphics.Device#getBounds()

The following examples show how to use org.eclipse.swt.graphics.Device#getBounds() . 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: PrintProcessor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private void drawChart ( final Device device, final GC gc, final double minX, final double maxX, final Calendar startTimestamp, final Calendar endTimestamp )
{
    final Rectangle bounds = device.getBounds ();

    final Color color = new Color ( device, new RGB ( 0, 0, 0 ) );

    final Rectangle drawBounds = new Rectangle ( bounds.x + 10, bounds.y + 10, bounds.width - 20, bounds.height - 20 );
    gc.setForeground ( color );
    gc.drawRectangle ( drawBounds );

    for ( final Map.Entry<String, List<Double>> row : this.values.entrySet () )
    {
        drawRow ( device, gc, row.getKey (), row.getValue (), drawBounds, minX, maxX );
    }
}
 
Example 2
Source File: PrintProcessor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private void drawRow ( final Device device, final GC gc, final String label, final List<Double> data, final Rectangle bounds, final double minX, final double maxX )
{
    final Rectangle deviceBounds = device.getBounds ();

    gc.setLineWidth ( 1 );

    final int size = data.size ();

    final double diff = maxX - minX;

    Point lastPoint = null;
    for ( int i = 0; i < size; i++ )
    {
        // final Value v = data[i];
        final ValueInformation info = this.valueInformation.get ( i );

        if ( info.getQuality () > 0.75 )
        {
            final double posX = (double)bounds.width / (double)size * i;
            final double posY = data.get ( i ) / diff * bounds.height;

            final Point point = new Point ( (int)posX + bounds.x, (int)posY + bounds.y );

            if ( lastPoint != null )
            {
                gc.drawLine ( lastPoint.x, deviceBounds.height - lastPoint.y, point.x, deviceBounds.height - lastPoint.y );
                gc.drawLine ( point.x, deviceBounds.height - lastPoint.y, point.x, deviceBounds.height - point.y );
            }

            lastPoint = point;
        }
        else
        {
            lastPoint = null;
        }
    }
}