Example usage for java.awt Point Point

List of usage examples for java.awt Point Point

Introduction

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

Prototype

public Point(int x, int y) 

Source Link

Document

Constructs and initializes a point at the specified (x,y) location in the coordinate space.

Usage

From source file:PointSetter.java

public static void main(String[] arguments) {
    Point location = new Point(4, 13);

    System.out.println("Starting location:");
    System.out.println("X equals " + location.x);
    System.out.println("Y equals " + location.y);

    System.out.println("\nMoving to (7, 6)");
    location.x = 7;//from  ww w  . j  a v  a2s.  co m
    location.y = 6;

    System.out.println("\nEnding location:");
    System.out.println("X equals " + location.x);
    System.out.println("Y equals " + location.y);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Shape s = new Rectangle2D.Double(0, 0, 72, 72);

    System.out.println(s.contains(new Point(30, 40)));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JButton button = new JButton("My Button") {
        public Point getToolTipLocation(MouseEvent event) {
            return new Point(0, 0);
        }//from w  w w  . jav  a2 s.c  om
    };

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    int[] pixels = new int[16 * 16];
    Image image = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16, 16, pixels, 0, 16));
    Cursor transparentCursor = Toolkit.getDefaultToolkit().createCustomCursor(image, new Point(0, 0),
            "invisibleCursor");
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    String url = "http://www.java2s.com/style/download.png";
    String text = "java2s.com";
    byte[] b = mergeImageAndText(url, text, new Point(200, 200));
    FileOutputStream fos = new FileOutputStream("new.png");
    fos.write(b);//from w  ww. j  a v a 2 s .  c  om
    fos.close();
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JToolTip Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JButton b1 = new JButton("Button 1") {
        public JToolTip createToolTip() {
            JToolTip tip = super.createToolTip();
            tip.setForeground(Color.YELLOW);
            return tip;
        }/*w  ww. ja v a 2s. c  o m*/

        public Point getToolTipLocation(MouseEvent event) {
            return new Point((event.getX() + 100), (event.getY() + 100));
        }
    };
    b1.setToolTipText("HELLO");
    frame.add(b1, BorderLayout.NORTH);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:SpecificCellWithDifferentWidthPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from  ww  w.  java 2s .  c  o  m*/
        PdfWriter.getInstance(document, new FileOutputStream("SpecificCellWithDifferentWidthPDF.pdf"));
        document.open();
        Table aTable;

        aTable = new Table(4, 4); // 4 rows, 4 columns
        aTable.setWidths(new float[] { 2f, 1f, 1f, 1f });

        aTable.setAlignment(Element.ALIGN_RIGHT);
        aTable.addCell("2.2", new Point(2, 2));
        aTable.addCell("3.3", new Point(3, 3));
        aTable.addCell("2.1", new Point(2, 1));
        aTable.addCell("1.3", new Point(1, 3));

        document.add(aTable);

        aTable.setConvert2pdfptable(true);
        document.add(aTable);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:Main.java

public static void main(String[] args) {
    final int width = 512;
    final int height = 512;
    BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
    Graphics g = img.getGraphics();
    g.setColor(Color.black);/*from   www.  java2  s .com*/
    g.fillRect(0, 0, width, height);
    g.setColor(Color.white);
    final double A = 8;
    final double B = 0.5;
    final double N = 4;
    final double scale = 128;
    final double zoom = 50;
    final double step = 1 / scale;
    Point last = null;
    final Point origin = new Point(width / 2, height / 2);

    for (double t = 0; t <= 2 * Math.PI; t += step) {
        final double r = zoom * polarFunction(t, A, B, N);
        final int x = (int) Math.round(r * Math.cos(t));
        final int y = (int) Math.round(r * Math.sin(t));
        Point next = new Point(x, y);
        if (last != null) {
            g.drawLine(origin.x + last.x, origin.y + last.y, origin.x + next.x, origin.y + next.y);
        }
        last = next;
    }

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new JLabel(new ImageIcon(img)));
    frame.pack();
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();/*w  ww.  java  2s  .  c  o m*/

    Table table = new Table(2, 2);
    table.setAlignment(Element.ALIGN_LEFT);
    table.setAutoFillEmptyCells(true);
    table.addCell("0.0");
    table.addColumns(2);
    float[] f = { 2f, 1f, 1f, 1f };
    table.setWidths(f);
    table.addCell("2.2", new Point(2, 2));
    table.deleteColumn(2);
    document.add(table);
    document.close();
}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));
    document.open();/*from w  w w.jav  a 2  s.c  o  m*/

    Table table = new Table(2, 2);
    table.setAlignment(Element.ALIGN_LEFT);
    table.setAutoFillEmptyCells(true);
    table.addCell("0.0");
    table.addColumns(2);
    float[] f = { 2f, 1f, 1f, 1f };
    table.setWidths(f);
    table.addCell("2.2", new Point(2, 2));
    table.deleteColumn(2);
    table.setConvert2pdfptable(true);
    document.add(table);
    document.close();
}