java类org.eclipse.swt.graphics.Transform的实例源码

SWTStrokeCanvas.java 文件源码 项目:parabuild-ci 阅读 30 收藏 0 点赞 0 评论 0
/**
 * 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);
            }
        }
    });
}
XCalendarDefaultRender.java 文件源码 项目:xcalendar 阅读 26 收藏 0 点赞 0 评论 0
public void render(XCalendar popup, GC gc) {
    final XCalendarModel model = popup.getModel();
    final XCalendarTheme theme = model.getTheme();
    final Transform t = new Transform(gc.getDevice());

    //
    try (final XCalendarFrame frame = new XCalendarFrame(gc, t)) {
        //
        Rectangle area = new Rectangle((area = popup.getClientArea()).x, area.y, area.width - 1, area.height - 1);
        gc.setAdvanced(true);
        gc.setAntialias(SWT.ON);
        gc.setBackground(theme.getBackground(true, false, false, false));
        gc.fillRectangle(area); gc.setForeground(theme.getGrid(true)); gc.drawRectangle(area);

        List<XCalendarWidget> widgets = popup.getWidgets();
        for(XCalendarWidget widget:widgets) widget.render(frame);
    }
}
SWTStrokeCanvas.java 文件源码 项目:ccu-historian 阅读 31 收藏 0 点赞 0 评论 0
/**
 * 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);
            }
        }
    });
}
SWTStrokeCanvas.java 文件源码 项目:aya-lang 阅读 33 收藏 0 点赞 0 评论 0
/**
 * 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);
            }
        }
    });
}
PencilDrawTool.java 文件源码 项目:EasySnap 阅读 18 收藏 0 点赞 0 评论 0
@Override
public synchronized Image onMove(MouseEvent event) {
    Image ret = super.onMove(event);
    points.add(event.x);
    points.add(event.y);

    Color color = graphicsContext.getBackground();

    graphicsContext.setBackground(shadowColor);
    graphicsContext.setForeground(shadowColor);
    int[] pointArr = new int[points.size()];
    for (int i = 0; i < pointArr.length; i++) {
        pointArr[i] = points.get(i);
    }
    Transform transform = new Transform(graphicsContext.getDevice());
    transform.translate(1,1);
    graphicsContext.setTransform(transform);
    graphicsContext.drawPolyline(pointArr);
    graphicsContext.setTransform(null);
    transform.dispose();
    graphicsContext.setBackground(color);
    graphicsContext.setForeground(color);
    graphicsContext.drawPolyline(pointArr);
    return ret;
}
TreeViewOverview.java 文件源码 项目:SMVHunter 阅读 29 收藏 0 点赞 0 评论 0
public TreeViewOverview(Composite parent) {
    super(parent, SWT.NONE);

    mModel = TreeViewModel.getModel();
    mModel.addTreeChangeListener(this);

    loadResources();

    addPaintListener(mPaintListener);
    addMouseListener(mMouseListener);
    addMouseMoveListener(mMouseMoveListener);
    addListener(SWT.Resize, mResizeListener);
    addDisposeListener(mDisposeListener);

    mTransform = new Transform(Display.getDefault());
    mInverse = new Transform(Display.getDefault());

    loadAllData();
}
PixelPerfectLoupe.java 文件源码 项目:SMVHunter 阅读 23 收藏 0 点赞 0 评论 0
public PixelPerfectLoupe(Composite parent) {
    super(parent, SWT.NONE);
    mModel = PixelPerfectModel.getModel();
    mModel.addImageChangeListener(this);

    addPaintListener(mPaintListener);
    addMouseListener(mMouseListener);
    addMouseWheelListener(mMouseWheelListener);
    addDisposeListener(mDisposeListener);
    addKeyListener(mKeyListener);

    mCrosshairColor = new Color(Display.getDefault(), new RGB(255, 94, 254));

    mTransform = new Transform(Display.getDefault());

    imageLoaded();
}
TreeView.java 文件源码 项目:SMVHunter 阅读 23 收藏 0 点赞 0 评论 0
public TreeView(Composite parent) {
    super(parent, SWT.NONE);

    mModel = TreeViewModel.getModel();
    mModel.addTreeChangeListener(this);

    addPaintListener(mPaintListener);
    addMouseListener(mMouseListener);
    addMouseMoveListener(mMouseMoveListener);
    addMouseWheelListener(mMouseWheelListener);
    addListener(SWT.Resize, mResizeListener);
    addDisposeListener(mDisposeListener);
    addKeyListener(mKeyListener);

    loadResources();

    mTransform = new Transform(Display.getDefault());
    mInverse = new Transform(Display.getDefault());

    loadAllData();
}
TreeView.java 文件源码 项目:SMVHunter 阅读 29 收藏 0 点赞 0 评论 0
public static Image paintToImage(DrawableViewNode tree) {
    Image image =
            new Image(Display.getDefault(), (int) Math.ceil(tree.bounds.width), (int) Math
                    .ceil(tree.bounds.height));

    Transform transform = new Transform(Display.getDefault());
    transform.identity();
    transform.translate((float) -tree.bounds.x, (float) -tree.bounds.y);
    Path connectionPath = new Path(Display.getDefault());
    GC gc = new GC(image);

    // Can't use Display.getDefault().getSystemColor in a non-UI thread.
    Color white = new Color(Display.getDefault(), 255, 255, 255);
    Color black = new Color(Display.getDefault(), 0, 0, 0);
    gc.setForeground(white);
    gc.setBackground(black);
    gc.fillRectangle(0, 0, image.getBounds().width, image.getBounds().height);
    gc.setTransform(transform);
    paintRecursive(gc, transform, tree, null, connectionPath);
    gc.drawPath(connectionPath);
    gc.dispose();
    connectionPath.dispose();
    white.dispose();
    black.dispose();
    return image;
}
ArrowDecorator.java 文件源码 项目:raptor-chess-interface 阅读 21 收藏 0 点赞 0 评论 0
private void drawDestinationDiagIncreasingLeft(ChessSquare square,
        Color color, int width, GC gc) {
    int squareSide = square.getSize().x;

    Transform tr = new Transform(gc.getDevice());
    tr.translate(squareSide, 0);
    gc.setTransform(tr);
    tr.rotate(135);
    gc.setTransform(tr);

    gc.setBackground(color);
    gc.fillPolygon(getDiagDestinationPolygon(squareSide, width));

    tr.dispose();
    gc.setTransform(null);
}
ArrowDecorator.java 文件源码 项目:raptor-chess-interface 阅读 21 收藏 0 点赞 0 评论 0
private void drawDestinationDiagIncreasingRight(ChessSquare square,
        Color color, int width, GC gc) {
    int squareSide = square.getSize().x;

    Transform tr = new Transform(gc.getDevice());
    tr.translate(0, squareSide);
    gc.setTransform(tr);
    tr.rotate(-45);
    gc.setTransform(tr);

    gc.setBackground(color);
    gc.fillPolygon(getDiagDestinationPolygon(squareSide, width));

    tr.dispose();
    gc.setTransform(null);
}
ArrowDecorator.java 文件源码 项目:raptor-chess-interface 阅读 23 收藏 0 点赞 0 评论 0
private void drawDestinationHorizontalLeft(ChessSquare square,
        Color color, int width, GC gc) {
    int squareSide = square.getSize().x;

    Transform tr = new Transform(gc.getDevice());
    tr.translate(squareSide, squareSide / 2.0F);
    gc.setTransform(tr);
    tr.rotate(180);
    gc.setTransform(tr);

    gc.setBackground(color);
    gc.fillPolygon(getDestinationPolygon(squareSide, width));

    tr.dispose();
    gc.setTransform(null);
}
ArrowDecorator.java 文件源码 项目:raptor-chess-interface 阅读 24 收藏 0 点赞 0 评论 0
private void drawDestinationVerticalDown(ChessSquare square,
        Color color, int width, GC gc) {
    int squareSide = square.getSize().x;

    Transform tr = new Transform(gc.getDevice());

    tr.translate(squareSide / 2.0F, 0);
    gc.setTransform(tr);

    tr.rotate(90);
    gc.setTransform(tr);

    gc.setBackground(color);
    gc.fillPolygon(getDestinationPolygon(squareSide, width));

    tr.dispose();
    gc.setTransform(null);
}
ArrowDecorator.java 文件源码 项目:raptor-chess-interface 阅读 22 收藏 0 点赞 0 评论 0
private void drawDestinationVerticalUp(ChessSquare square, Color color,
        int width, GC gc) {
    int squareSide = square.getSize().x;

    Transform tr = new Transform(gc.getDevice());

    tr.translate(squareSide / 2.0F, squareSide);
    gc.setTransform(tr);

    tr.rotate(-90);
    gc.setTransform(tr);

    gc.setBackground(color);
    gc.fillPolygon(getDestinationPolygon(squareSide, width));

    tr.dispose();
    gc.setTransform(null);
}
ArrowDecorator.java 文件源码 项目:raptor-chess-interface 阅读 24 收藏 0 点赞 0 评论 0
private void drawOriginDiagDecreasingLeft(ChessSquare square,
        Color color, int width, GC gc) {
    int squareSide = square.getSize().x;

    Transform tr = new Transform(gc.getDevice());

    tr.translate(squareSide / 2.0F, squareSide / 2.0F);
    gc.setTransform(tr);
    tr.rotate(-135);
    gc.setTransform(tr);

    gc.setBackground(color);
    gc.fillPolygon(getOriginDiagPolygon(squareSide, width));

    tr.dispose();
    gc.setTransform(null);
}
ArrowDecorator.java 文件源码 项目:raptor-chess-interface 阅读 21 收藏 0 点赞 0 评论 0
private void drawOriginDiagDecreasingRight(ChessSquare square,
        Color color, int width, GC gc) {
    int squareSide = square.getSize().x;

    Transform tr = new Transform(gc.getDevice());
    tr.translate(squareSide / 2.0F, squareSide / 2.0F);
    gc.setTransform(tr);
    tr.rotate(45);
    gc.setTransform(tr);

    gc.setBackground(color);
    gc.fillPolygon(getOriginDiagPolygon(squareSide, width));

    tr.dispose();
    gc.setTransform(null);
}
ArrowDecorator.java 文件源码 项目:raptor-chess-interface 阅读 28 收藏 0 点赞 0 评论 0
private void drawOriginDiagIncreasingLeft(ChessSquare square,
        Color color, int width, GC gc) {
    int squareSide = square.getSize().x;

    Transform tr = new Transform(gc.getDevice());
    tr.translate(squareSide / 2.0F, squareSide / 2.0F);
    gc.setTransform(tr);
    tr.rotate(135);
    gc.setTransform(tr);

    gc.setBackground(color);
    gc.fillPolygon(getOriginDiagPolygon(squareSide, width));

    tr.dispose();
    gc.setTransform(null);
}
ArrowDecorator.java 文件源码 项目:raptor-chess-interface 阅读 29 收藏 0 点赞 0 评论 0
private void drawOriginDiagIncreasingRight(ChessSquare square,
        Color color, int width, GC gc) {
    int squareSide = square.getSize().x;

    Transform tr = new Transform(gc.getDevice());
    tr.translate(squareSide / 2.0F, squareSide / 2.0F);
    gc.setTransform(tr);
    tr.rotate(-45);
    gc.setTransform(tr);

    gc.setBackground(color);
    gc.fillPolygon(getOriginDiagPolygon(squareSide, width));

    tr.dispose();
    gc.setTransform(null);
}
SWTChartEditor.java 文件源码 项目:gama 阅读 32 收藏 0 点赞 0 评论 0
/**
 * Creates a new instance.
 *
 * @param parent
 *            the parent.
 * @param style
 *            the style.
 */
public SWTStrokeCanvas(final Composite parent, final int style) {
    super(parent, style);
    addPaintListener(e -> {
        final BasicStroke stroke = getStroke();
        if (stroke != null) {
            int x, y;
            final Rectangle rect = getClientArea();
            x = (rect.width - 100) / 2;
            y = (rect.height - 16) / 2;
            final 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);
        }
    });
}
SWTStrokeCanvas.java 文件源码 项目:nabs 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 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);
            }
        }
    });
}
SWTStrokeCanvas.java 文件源码 项目:ECG-Viewer 阅读 34 收藏 0 点赞 0 评论 0
/**
 * 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);
            }
        }
    });
}
SWTStrokeCanvas.java 文件源码 项目:astor 阅读 28 收藏 0 点赞 0 评论 0
/**
 * 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);
            }
        }
    });
}
SWTStrokeCanvas.java 文件源码 项目:group-five 阅读 31 收藏 0 点赞 0 评论 0
/**
 * 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);
            }
        }
    });
}
SWTStrokeCanvas.java 文件源码 项目:buffer_bci 阅读 33 收藏 0 点赞 0 评论 0
/**
 * 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);
            }
        }
    });
}
SWTStrokeCanvas.java 文件源码 项目:proyecto-teoria-control-utn-frro 阅读 28 收藏 0 点赞 0 评论 0
/**
 * 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);
            }
        }
    });
}
SWTStrokeCanvas.java 文件源码 项目:Memetic-Algorithm-for-TSP 阅读 29 收藏 0 点赞 0 评论 0
/**
 * 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);
            }
        }
    });
}
SwtUniversalImageBitmap.java 文件源码 项目:pentaho-kettle 阅读 25 收藏 0 点赞 0 评论 0
@Override
protected Image renderRotated( Device device, int width, int height, double angleRadians ) {
  Image result = new Image( device, width * 2, height * 2 );

  GC gc = new GC( result );

  int bw = bitmap.getBounds().width;
  int bh = bitmap.getBounds().height;
  Transform affineTransform = new Transform( device );
  affineTransform.translate( width, height );
  affineTransform.rotate( (float) Math.toDegrees( angleRadians ) );
  affineTransform.scale( (float) 1.0 * width / bw, (float) 1.0 * height / bh );
  gc.setTransform( affineTransform );

  gc.drawImage( bitmap, 0, 0, bw, bh, -bw / 2, -bh / 2, bw, bh );

  gc.dispose();

  return result;
}
GraphUtils.java 文件源码 项目:n4js 阅读 27 收藏 0 点赞 0 评论 0
public static void drawArrowHead(GC gc, Point referencePoint, Point p) {
    final double angle = Math.atan2(p.y - referencePoint.y, p.x - referencePoint.x) * 180.0 / Math.PI;
    final Transform tf = new Transform(gc.getDevice());
    tf.rotate(new Double(angle).floatValue());
    tf.scale(7, 3);
    final float[] pnts = new float[] { -1, 1, -1, -1 };
    tf.transform(pnts);
    gc.drawLine(Math.round(p.x), Math.round(p.y), Math.round(p.x + pnts[0]), Math.round(p.y + pnts[1]));
    gc.drawLine(Math.round(p.x), Math.round(p.y), Math.round(p.x + pnts[2]), Math.round(p.y + pnts[3]));
    tf.dispose();
}
VisualisationCanvas.java 文件源码 项目:n4js 阅读 25 收藏 0 点赞 0 评论 0
protected void doPaint(GC gc, PaintEvent event) {
    gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));

    gc.fillRectangle(event.x, event.y, event.width, event.height);

    if (graph != null) {
        final Transform tf = new Transform(gc.getDevice());
        tf.translate(-offsetX, -offsetY);
        tf.scale(scale, scale);
        gc.setTransform(tf);

        if (graphNeedsLayout) {
            graph.layout();
            graphNeedsLayout = false;
        }

        graph.getNodes().forEach(n -> n.paint(gc));

        gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));

        gc.setTransform(null);
        tf.dispose();

        if (hawkEye_active && hawkEye_target != null) {
            final int w = Math.round(getSize().x / hawkEye_oldScale * scale);
            final int h = Math.round(getSize().y / hawkEye_oldScale * scale);
            gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
            gc.setAlpha(64);
            gc.fillRectangle(
                    (int) hawkEye_target.x - w / 2,
                    (int) hawkEye_target.y - h / 2,
                    w, h);
            gc.setAlpha(255);
        }
    }
}
SWTGraphics2D.java 文件源码 项目:parabuild-ci 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Converts an AWT transform into the equivalent SWT transform.
 * 
 * @param awtTransform  the AWT transform.
 * 
 * @return The SWT transform.
 */
private Transform toSwtTransform(AffineTransform awtTransform) {
    Transform t = new Transform(gc.getDevice());
    double[] matrix = new double[6];
    awtTransform.getMatrix(matrix);
    t.setElements((float) matrix[0], (float) matrix[1],
            (float) matrix[2], (float) matrix[3],
            (float) matrix[4], (float) matrix[5]); 
    return t;
}


问题


面经


文章

微信
公众号

扫码关注公众号