Example usage for java.awt Graphics translate

List of usage examples for java.awt Graphics translate

Introduction

In this page you can find the example usage for java.awt Graphics translate.

Prototype

public abstract void translate(int x, int y);

Source Link

Document

Translates the origin of the graphics context to the point (xy) in the current coordinate system.

Usage

From source file:org.esa.s1tbx.ocean.toolviews.polarview.polarplot.PolarCanvas.java

private void drawColorBar(Graphics g, Axis cAxis) {
    final Dimension cbSize = new Dimension((int) (graphSize.width * 0.03),
            (int) (Math.min(200, graphSize.height * 0.6)));
    final Point at = new Point(20, -30);

    g.translate(at.x, at.y);
    g.drawImage(colorBar, 0, 0, cbSize.width, cbSize.height, this);
    g.drawRect(0, 0, cbSize.width, cbSize.height);
    g.translate(cbSize.width, cbSize.height);
    cAxis.draw(g, cbSize);//from www.  j  a va  2 s.  c  o m
    g.drawString(cAxis.getUnit(), 50, 5);
    g.translate(-cbSize.width - at.x, -cbSize.height - at.y);
}

From source file:pt.lsts.neptus.plugins.sunfish.awareness.SituationAwareness.java

@Override
public void paintInteraction(Graphics2D g, StateRenderer2D source) {
    super.paintInteraction(g, source);
    g.setStroke(new BasicStroke(1f));
    paint(g, source);//  w ww  . ja v  a 2  s  .c o m
    AssetPosition pivot = intercepted;
    if (pivot != null) {
        Point2D pt = source.getScreenPosition(pivot.getLoc());
        g.setColor(Color.white);
        g.draw(new Ellipse2D.Double(pt.getX() - 6, pt.getY() - 6, 12, 12));
        if (assetProperties.containsKey(pivot.getAssetName()))
            pivot.putExtra("Description", assetProperties.get(pivot.getAssetName()).description);
        if (assetProperties.containsKey(pivot.getAssetName()))
            pivot.putExtra("Friendly name", assetProperties.get(pivot.getAssetName()).friendly);

        lbl.setOpaque(true);
        lbl.setBackground(new Color(255, 255, 255, 128));
        lbl.setText(pivot.getHtml());
        Dimension d = lbl.getPreferredSize();
        lbl.setSize(d);
        Graphics copy = g.create();
        copy.translate(10, 10);
        lbl.paint(copy);
    }

    for (AssetTrack t : assets.values()) {
        AssetPosition prev = t.getLatest();
        AssetPosition pred = t.getPrediction();

        if (prev != null && pred != null) {
            if (prev.getTimestamp() < oldestTimestampSelection
                    || prev.getTimestamp() > newestTimestampSelection)
                continue;
            g.setColor(new Color(t.getColor().getRed(), t.getColor().getGreen(), t.getColor().getBlue(), 128));
            Point2D pt1 = source.getScreenPosition(prev.getLoc());
            Point2D pt2 = source.getScreenPosition(pred.getLoc());
            if (pt1.distance(pt2) < 1000)
                g.draw(new Line2D.Double(pt1, pt2));
        }
    }
}

From source file:pt.lsts.neptus.plugins.wg.WgCtdLayer.java

private void paintCaption(Graphics2D g) {
    cbar.setCmap(cmap);/*from   w w  w .  j a  va2 s. co  m*/
    cbar.setSize(new Dimension(20, 120));
    Graphics copy = g.create();
    copy.translate(10, 10);
    cbar.paint(copy);
    copy.setColor(Color.white);
    copy.drawString(String.format("%3.2f C", minTemp), 23, 120);
    copy.drawString(String.format("%3.2f C", maxTemp), 23, 10);
}

From source file:savant.view.swing.Ruler.java

@Override
public void paintComponent(final Graphics g) {
    super.paintComponent(g);

    if (graphPaneController.isPanning()) {
        int fromX = MiscUtils.transformPositionToPixel(graphPaneController.getMouseClickPosition(), getWidth(),
                locationController.getRange());
        int toX = MiscUtils.transformPositionToPixel(graphPaneController.getMouseReleasePosition(), getWidth(),
                locationController.getRange());
        g.translate(toX - fromX, 0);
    }/* w ww .j  av  a2  s  . c o m*/

    renderBackground(g);
}

From source file:uk.co.modularaudio.mads.base.scopen.ui.display.ScopeWaveDisplay.java

@Override
public void paint(final Graphics g) {
    //      log.debug("paint");
    g.setColor(ScopeNColours.BACKGROUND_COLOR);
    g.fillRect(0, 0, width, height);/*  w w  w.j  a va 2  s.  c o  m*/

    g.setColor(ScopeNColours.SCOPE_BODY);

    g.translate(0, yOffset);

    paintGridLines(g);

    paintData(g);

    g.translate(0, -yOffset);
}