Tabnine Logo
Point.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
java.awt.Point
constructor

Best Java code snippets using java.awt.Point.<init> (Showing top 20 results out of 7,209)

Refine searchRefine arrow

  • Window.setVisible
  • Container.add
  • JFrame.setDefaultCloseOperation
  • Display.getSize
  • JFrame.<init>
  • Dimension.<init>
  • ArrayList.<init>
  • PrintStream.println
  • Window.pack
origin: stackoverflow.com

 Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
origin: stackoverflow.com

 Gson gson = new GsonBuilder()
    .setPrettyPrinting().create();
Map<Point, String> original = new HashMap<>();
original.put(new Point(1, 2), "a");
original.put(new Point(3, 4), "b");
System.out.println(gson.toJson(original));
origin: runelite/runelite

  @Override
  public Dimension render(Graphics2D graphics)
  {
    graphics.translate(preferredLocation.x, preferredLocation.y);
    final FontMetrics metrics = graphics.getFontMetrics();
    final TextComponent titleComponent = new TextComponent();
    titleComponent.setText(text);
    titleComponent.setColor(color);
    titleComponent.setPosition(new Point((preferredSize.width - metrics.stringWidth(text)) / 2, metrics.getHeight()));
    final Dimension dimension = titleComponent.render(graphics);
    graphics.translate(-preferredLocation.x, -preferredLocation.y);
    return new Dimension(preferredSize.width, dimension.height);
  }
}
origin: stackoverflow.com

double yScale = ((double) getHeight() - 2 * BORDER_GAP) / (MAX_SCORE - 1);
List<Point> graphPoints = new ArrayList<Point>();
for (int i = 0; i < scores.size(); i++) {
  int x1 = (int) (i * xScale + BORDER_GAP);
  int y1 = (int) ((MAX_SCORE - scores.get(i)) * yScale + BORDER_GAP);
  graphPoints.add(new Point(x1, y1));
return new Dimension(PREF_W, PREF_H);
List<Integer> scores = new ArrayList<Integer>();
Random random = new Random();
int maxDataPoints = 16;
JFrame frame = new JFrame("DrawGraph");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
origin: groovy/groovy-core

public void testListCoercionProperty() throws Exception {
  DummyBean bean = new DummyBean();
  List list = new ArrayList();
  list.add(new Integer(10));
  list.add(new Integer(20));
  InvokerHelper.setProperty(bean, "point", list);
  assertEquals("Should have set a point", new Point(10, 20), bean.getPoint());
}
origin: stackoverflow.com

 import java.util.ArrayList;

public class Test {

   public static void main(String[] args){

      ArrayList<Point> p=new ArrayList<Point>();

      Point p1 = new Point(3,4);
      Point p2 = new Point(1,2);

      p.add(new Point(3,4));
      p.add(new Point(1,2));

      System.out.println(p.indexOf(p1));
   }

}
origin: groovy/groovy-core

public void testListCoercionPropertyOnJFrame() throws Exception {
  if (HeadlessTestSupport.isHeadless()) return;
  try {
    JFrame bean = new JFrame();
    List list = new ArrayList();
    list.add(new Integer(10));
    list.add(new Integer(20));
    InvokerHelper.setProperty(bean, "location", list);
    assertEquals("Should have set a point", new Point(10, 20), bean.getLocation());
  }
  catch (MissingMethodException e) {
    System.out.println("Failed with cause: " + e);
    e.printStackTrace();
    fail("Should not have throw: " + e);
  }
}
origin: stackoverflow.com

private final ParentType           parent;
private final Object               lock              = new Object();
private final ArrayList<Component> jPanels           = new ArrayList<Component>();
private final boolean              useSlideButton    = true;
private boolean                    isSlideInProgress = false;
  if (useSlideButton) {
    final JPanel statusPanel = new JPanel();
    basePanel.add(statusPanel, BorderLayout.SOUTH);
    statusPanel.add(new JButton("Slide Left") {
      private static final long serialVersionUID = 9204819004142223529L;
    statusPanel.add(new JButton("Slide Right") {
    System.err.println("Not enough panels");
    return;
    final int h = componentOld.getHeight();
    final Point p1 = componentOld.getLocation();
    final Point p2 = new Point(0, 0);
    if (slideType == LEFT) {
      p2.x += w;
origin: stackoverflow.com

int n = 6;  //Number of labels
int radius = 100;
Point centre = new Point(200,200);
List<Point> points = new ArrayList<Point>();
points.add(centre);
 int dx = (int)(radius * Math.sin(theta));
 int dy = (int)(-radius * Math.cos(theta));
 Point p = new Point(centre.x + dx, centre.y + dy);
 points.add(p);
JFrame frame = new JFrame("Labels in a circle");
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for (Point point : points) {
 JLabel label = new JLabel("Point " + count);
 panel.add(label);
 count++;
 layout.putConstraint(SpringLayout.WEST, label, point.x, SpringLayout.WEST, panel);
frame.add(panel);
frame.setVisible(true);
origin: stackoverflow.com

  JFrame frame = new JFrame("Spot");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  Balls balls = new Balls();
ballsUp = new ArrayList<Ball>(25);
  ball.setLocation(new Point(x, y));
y += vy;
ball.setSpeed(new Point(vx, vy));
ball.setLocation(new Point(x, y));
speed = new Point(10 - random(20), 10 - random(20));
size = new Dimension(30, 30);
origin: stackoverflow.com

setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(WIDTH, HEIGHT);
shapes = new ArrayList<ColoredShape>(NUM_SHAPES);
for (int i = 0; i < NUM_SHAPES; i++) {
  Point[] points = getRandomPoints();
  int x = randomGenerator.nextInt(WIDTH);
  int y = randomGenerator.nextInt(HEIGHT);
  points[i] = new Point(x, y);
origin: stackoverflow.com

 LatLng center = new LatLng(40.384213, -3.875244);
List<LatLng> positions = new ArrayList<>();
positions.add(new LatLng(43.153102, 2.914307));
positions.add(new LatLng(42.976521, 1.508057));
positions.add(new LatLng(42.492353, 0.123779));

Display display = getActivity().getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int width  = size.x;
        int height = size.y;

LatLngBounds bounds = findBounds(positions,center);
mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds,width,height,10));
origin: stackoverflow.com

JFrame frame = new JFrame();
final JTextArea textArea = new JTextArea();
JScrollPane pane = new JScrollPane(textArea);
    + "Blabla\nBlabla\nBlabla\nBlabla\nBlabla\nBlabla\n");
textArea.setSelectionColor(Color.RED);
frame.add(pane);
frame.setSize(300, 120);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
    new DefaultHighlighter.DefaultHighlightPainter(Color.yellow));    
int y = startIndex.y + (pane.getHeight() - 10);
System.out.println("Pane Height : " + pane.getHeight());
System.out.println("X : " + startIndex.x);
System.out.println("Y : " + y);
System.out.println("Y (pos2) : " + startIndex.y);
textArea.setCaretPosition(textArea.viewToModel(new Point(startIndex.x, y)));
pane.scrollRectToVisible(new Rectangle(startIndex.x, y));
origin: stackoverflow.com

JScrollPane screenScroll = new JScrollPane(screenLabel);
screenScroll.setPreferredSize(new Dimension(
    (int)(screen.getWidth()/3),
    (int)(screen.getHeight()/3)));
panel.add(screenScroll, BorderLayout.CENTER);
panel.add(selectionLabel, BorderLayout.SOUTH);
  Point start = new Point();
    Point end = me.getPoint();
    captureRect = new Rectangle(start,
        new Dimension(end.x-start.x, end.y-start.y));
    repaint(screen, screenCopy);
    screenLabel.repaint();
System.out.println("Rectangle of interest: " + captureRect);
origin: stackoverflow.com

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tarea.setText("Hello there\n");
tarea.append("Hello student://");
    System.out.println("X : " + x);
    System.out.println("Y : " + y);
    int startOffset = tarea.viewToModel(new Point(x, y));
    System.out.println("Start Offset : " + startOffset);
    String text = tarea.getText();
    int searchLocation = text.indexOf("student://", startOffset);
getContentPane().add(scroll, BorderLayout.CENTER);
getContentPane().add(tfield, BorderLayout.PAGE_END);
pack();
setLocationByPlatform(true);
setVisible(true);
origin: haraldk/TwelveMonkeys

Point ovSize = new Point();
Point arcAngles = new Point();
String text;
Rectangle bounds = new Rectangle();
          System.out.println("NOP");
          System.out.println("bkPat");
          System.out.println("txFont: " + Arrays.toString(fontData));
        Dimension pnsize = new Dimension(pStream.readUnsignedShort(), pStream.readUnsignedShort());
        if (DEBUG) {
          System.out.println("pnsize: " + pnsize);
        origin = new Point(x, y);
        if (DEBUG) {
          System.out.println("Origin: " + origin);
        origin = new Point(x, y);
        origin = new Point(x, y);
        dh_dv = new Point(x, y);
        origin = new Point(x, y);
        penPosition = origin;
        context.moveTo(penPosition);
origin: stackoverflow.com

  JFrame frame = new JFrame("Testing");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setLayout(new BorderLayout());
  frame.add(new TestPane());
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
cells = new ArrayList<>(columnCount * rowCount);
MouseAdapter mouseHandler;
mouseHandler = new MouseAdapter() {
        selectedCell = new Point(column, row);
return new Dimension(200, 200);
origin: stackoverflow.com

dst.add(new Point(rnd.nextInt(), rnd.nextInt()));
list = new ArrayList<Point>(INITIAL_SIZE);
ArrayList<Point> dst = new ArrayList<Point>(list.size());
for (Point p: list) {
  if (wanted(p)) dst.add(p);
list = new ArrayList<Point>(INITIAL_SIZE);
origin: stackoverflow.com

static ArrayList<Point> sumofNum(int N){
 ArrayList<Point> result = new ArrayList<Point>();
 for(int a=1; a<N; a++){
     //a+b=N
     int b = N-a;
   System.out.println(a+","+b);
   int next =a+1;
   if(next==b | a==b)
     result.add(new Point(a,b));
   }   
 return result;
 }
origin: stackoverflow.com

 Gson gson = new GsonBuilder().enableComplexMapKeySerialization()
    .setPrettyPrinting().create();
Map<Point, String> original = new HashMap<>();
original.put(new Point(1, 2), "a");
original.put(new Point(3, 4), "b");
System.out.println(gson.toJson(original));
java.awtPoint<init>

Javadoc

Constructs and initializes a point at the origin (0, 0) of the coordinate space.

Popular methods of Point

  • getX
  • getY
  • setLocation
  • translate
    Translates this point, at location (x,y), by dx along the x axis and dy along the y axis so that it
  • equals
    Determines whether or not two points are equal. Two instances ofPoint are equal if the values of the
  • distance
  • clone
    Creates a new object of the same class and with the same contents as this object.
  • getLocation
    Returns the location of this point. This method is included for completeness, to parallel thegetLoca
  • move
    Moves this point to the specified location in the (x,y) coordinate plane. This method is identical w
  • distanceSq
  • hashCode
    Returns the hashcode for this Point.
  • toString
    Returns a string representation of this point and its location in the (x,y) coordinate space. This m
  • hashCode,
  • toString,
  • Add,
  • GetExX,
  • GetExY,
  • GetExZ,
  • SetX,
  • SetY,
  • SetZ

Popular in Java

  • Running tasks concurrently on multiple threads
  • getResourceAsStream (ClassLoader)
  • findViewById (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now