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:business.ImageManager.java

public void doDrawPathPc(Graphics2D big, Point ori, Point dest) {
    final int x = 04 + 7 / 2;
    final int y = 22 + 13 / 2;
    doDrawPath(big, new Point((int) ori.getX() + x, (int) ori.getY() + y),
            new Point((int) dest.getX() + x, (int) dest.getY() + y), colorMine);
}

From source file:it.unibas.spicygui.controllo.datasource.operators.CreaWidgetAlberi.java

private void creaWidgetKeyConstraints(ForeignKeyConstraint foreignKeyConstraint, IDataSourceProxy dataSource,
        boolean source) {
    KeyConstraint keyConstraint = foreignKeyConstraint.getKeyConstraint();
    for (int i = 0; i < foreignKeyConstraint.getForeignKeyPaths().size(); i++) {
        PathExpression foreignPath = foreignKeyConstraint.getForeignKeyPaths().get(i);
        PathExpression keyPath = keyConstraint.getKeyPaths().get(i);
        INode iNodeForeignKey = finder.findNodeInSchema(foreignPath, dataSource);
        INode iNodeKey = finder.findNodeInSchema(keyPath, dataSource);
        Widget widgetForeignKeyOriginale = (Widget) iNodeForeignKey.getAnnotation(pinWidgetTreeConstant);
        Widget widgetKeyOriginale = (Widget) iNodeKey.getAnnotation(pinWidgetTreeConstant);
        VMDPinWidgetKey widgetForeignKey = new VMDPinWidgetKey(scene);
        VMDPinWidgetKey widgetKey = new VMDPinWidgetKey(scene);
        settaWidgetKey(widgetForeignKey);
        settaWidgetKey(widgetKey);//from w ww. jav  a2s  .c  o  m
        int ascissa = getAscissaMaggiore(widgetForeignKeyOriginale, widgetKeyOriginale);
        Point pointForeignKey = null;
        Point pointKey = null;
        if (source) {
            pointForeignKey = new Point(ascissa + OFFSET_ASCISSA_SOURCE,
                    widgetForeignKeyOriginale.getPreferredLocation().y + OFFSET_ORDINATA_SOURCE);
            pointKey = new Point(ascissa + OFFSET_ASCISSA_SOURCE,
                    widgetKeyOriginale.getPreferredLocation().y + OFFSET_ORDINATA_SOURCE);
        } else {
            pointForeignKey = new Point(ascissa + OFFSET_ASCISSA_TARGET,
                    widgetForeignKeyOriginale.getPreferredLocation().y + OFFSET_ORDINATA_TARGET);
            pointKey = new Point(ascissa + OFFSET_ASCISSA_TARGET, widgetKeyOriginale.getPreferredLocation().y);
        }

        LineCoordinates lineCoordinates = new LineCoordinates(pointForeignKey, pointKey);
        lineCoordinatesCollections.calculateFreeCoordinate(lineCoordinates);
        lineCoordinatesCollections.addLineCoordinates(lineCoordinates);
        widgetForeignKey.setPreferredLocation(pointForeignKey);
        widgetKey.setPreferredLocation(pointKey);
        ConnectionConstraint connectionConstraint = createConnectionConstraint(source, widgetKeyOriginale,
                widgetForeignKeyOriginale, widgetForeignKey, ascissa, widgetKey, Costanti.CONSTRAINTS_STROKE);
        iNodeForeignKey.addAnnotation(connectionConstraintConstant, connectionConstraint);
    }

}

From source file:ch.epfl.lis.gnwgui.NetworkGraph.java

/**
 * Save the coordinates {x,y} of all nodes from the graph and save the positions
 * in the individual node of the Structure. Don't capture an eventual rotation or
 * distortion of the JUNGlayout./*from  w  w  w  .  ja  va  2 s  .  c o  m*/
 */
public void saveStructureLayout() {
    Collection<Node> list = g_.getVertices();
    Iterator<?> it = list.iterator();
    Node node;

    while (it.hasNext()) {
        node = (Node) it.next();
        node.setPosition(new Point((int) layout_.getX(node), (int) layout_.getY(node)));
    }
}

From source file:com.vladsch.idea.multimarkdown.editor.MultiMarkdownPreviewEditor.java

/**
 * Build a new instance of {@link MultiMarkdownPreviewEditor}.
 *
 * @param project  the {@link Project} containing the document
 * @param document the {@link com.intellij.openapi.editor.Document} previewed in this editor.
 *///from  ww  w .j ava 2 s .  co  m
public MultiMarkdownPreviewEditor(@NotNull final Project project, @NotNull Document document,
        boolean isRawHtml) {
    this.isRawHtml = isRawHtml;
    this.document = document;
    this.project = project;
    this.isWikiDocument = isWikiDocument(document);

    // Listen to the document modifications.
    this.document.addDocumentListener(new DocumentAdapter() {
        @Override
        public void documentChanged(DocumentEvent e) {
            delayedHtmlPreviewUpdate(false);
        }
    });

    // Listen to settings changes
    MultiMarkdownGlobalSettings.getInstance()
            .addListener(globalSettingsListener = new MultiMarkdownGlobalSettingsListener() {
                public void handleSettingsChanged(@NotNull final MultiMarkdownGlobalSettings newSettings) {
                    if (project.isDisposed())
                        return;
                    updateEditorTabIsVisible();
                    updateLinkRenderer();
                    delayedHtmlPreviewUpdate(true);
                    checkNotifyUser();
                }
            });

    MultiMarkdownProjectComponent projectComponent = MultiMarkdownPlugin.getProjectComponent(project);
    if (projectComponent != null) {
        projectComponent.addListener(projectFileListener = new ReferenceChangeListener() {
            @Override
            public void referenceChanged(@Nullable String name) {
                if (project.isDisposed())
                    return;
                delayedHtmlPreviewUpdate(false);
            }
        });
    }

    project.getMessageBus().connect(this).subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
        @Override
        public void enteredDumbMode() {
        }

        @Override
        public void exitDumbMode() {
            // need to re-evaluate class link accessibility
            if (project.isDisposed())
                return;
            delayedHtmlPreviewUpdate(false);
        }
    });

    updateLinkRenderer();

    if (isRawHtml) {
        jEditorPane = null;
        scrollPane = null;
        Language language = Language.findLanguageByID("HTML");
        FileType fileType = language != null ? language.getAssociatedFileType() : null;
        //myTextViewer = new EditorTextField(EditorFactory.getInstance().createDocument(""), project, fileType, true, false);
        Document myDocument = EditorFactory.getInstance().createDocument("");
        myTextViewer = (EditorImpl) EditorFactory.getInstance().createViewer(myDocument, project);
        if (fileType != null)
            myTextViewer.setHighlighter(
                    EditorHighlighterFactory.getInstance().createEditorHighlighter(project, fileType));
    } else {
        // Setup the editor pane for rendering HTML.
        myTextViewer = null;
        jEditorPane = new JEditorPane();
        //jEditorPane = new BrowserPane();
        scrollPane = new JBScrollPane(jEditorPane);

        setStyleSheet();

        // Add a custom link listener which can resolve local link references.
        jEditorPane.addHyperlinkListener(new MultiMarkdownLinkListener(jEditorPane, project, document));
        jEditorPane.setEditable(false);

        // Set the editor pane caret position to top left, and do not let it reset it
        jEditorPane.getCaret().setMagicCaretPosition(new Point(0, 0));
        ((DefaultCaret) jEditorPane.getCaret()).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    }

    checkNotifyUser();
}

From source file:business.ImageManager.java

public void doDrawPathPcAlly(Graphics2D big, Point ori, Point dest) {
    final int x = 04 + 7 / 2 + 4;
    final int y = 22 + 13 / 2 - 3 + 2;
    doDrawPath(big, new Point((int) ori.getX() + x, (int) ori.getY() + y),
            new Point((int) dest.getX() + x, (int) dest.getY() + y), colorAlly);
}

From source file:it.unibo.alchemist.boundary.monitors.Generic2DDisplay.java

/**
 * Actually draws the environment on the view.
 * //ww  w. ja  v a 2s.  c  om
 * @param g
 *            {@link Graphics2D} object responsible for drawing
 */
protected final void drawEnvOnView(final Graphics2D g) {
    if (wormhole == null || !isVisible() || !isEnabled()) {
        return;
    }
    accessData();
    if (hooked.isPresent()) {
        final Position hcoor = positions.get(hooked.get());
        final Point hp = wormhole.getViewPoint(hcoor);
        if (hp.distance(getCenter()) > FREEDOM_RADIUS) {
            wormhole.setViewPosition(hp);
        }
    }
    /*
     * Compute nodes in sight and their screen position
     */
    final Map<Node<T>, Point> onView = positions.entrySet().parallelStream()
            .map(pair -> new Pair<>(pair.getKey(), wormhole.getViewPoint(pair.getValue())))
            .filter(p -> wormhole.isInsideView(p.getSecond()))
            .collect(Collectors.toMap(Pair::getKey, Pair::getValue));
    g.setColor(Color.BLACK);
    if (obstacles != null) {
        /*
         * TODO: only draw obstacles if on view
         */
        obstacles.parallelStream().map(this::convertObstacle).forEachOrdered(g::fill);
    }
    if (paintLinks) {
        g.setColor(Color.GRAY);
        onView.keySet().parallelStream().map(neighbors::get)
                .flatMap(neigh -> neigh.getNeighbors().parallelStream()
                        .map(node -> node.compareTo(neigh.getCenter()) > 0 ? new Pair<>(neigh.getCenter(), node)
                                : new Pair<>(node, neigh.getCenter())))
                .distinct().map(
                        pair -> mapPair(pair,
                                node -> Optional.ofNullable(onView.get(node))
                                        .orElse(wormhole.getViewPoint(positions.get(node)))))
                .forEachOrdered(line -> {
                    final Point p1 = line.getFirst();
                    final Point p2 = line.getSecond();
                    g.drawLine(p1.x, p1.y, p2.x, p2.y);
                });
    }
    releaseData();
    if (isDraggingMouse && status == ViewStatus.MOVING && originPoint.isPresent() && endingPoint.isPresent()) {
        for (final Node<T> n : selectedNodes) {
            if (onView.containsKey(n)) {
                onView.put(n, new Point(onView.get(n).x + (endingPoint.get().x - originPoint.get().x),
                        onView.get(n).y + (endingPoint.get().y - originPoint.get().y)));
            }
        }
    }
    g.setColor(Color.GREEN);
    if (effectStack != null) {
        effectStack.forEach(effect -> {
            onView.entrySet().forEach(entry -> {
                final Point p = entry.getValue();
                effect.apply(g, entry.getKey(), p.x, p.y);
            });
        });
    }
    if (isCloserNodeMarked()) {
        final Optional<Map.Entry<Node<T>, Point>> closest = onView.entrySet().parallelStream()
                .min((pair1, pair2) -> {
                    final Point p1 = pair1.getValue();
                    final Point p2 = pair2.getValue();
                    final double d1 = Math.hypot(p1.x - mousex, p1.y - mousey);
                    final double d2 = Math.hypot(p2.x - mousex, p2.y - mousey);
                    return Double.compare(d1, d2);
                });
        if (closest.isPresent()) {
            nearest = closest.get().getKey();
            final int nearestx = closest.get().getValue().x;
            final int nearesty = closest.get().getValue().y;
            drawFriedEgg(g, nearestx, nearesty, Color.RED, Color.YELLOW);
        }
    } else {
        nearest = null;
    }
    if (isDraggingMouse && status == ViewStatus.SELECTING && originPoint.isPresent()
            && endingPoint.isPresent()) {
        g.setColor(Color.BLACK);
        final int x = originPoint.get().x < endingPoint.get().x ? originPoint.get().x : endingPoint.get().x;
        final int y = originPoint.get().y < endingPoint.get().y ? originPoint.get().y : endingPoint.get().y;
        final int width = Math.abs(endingPoint.get().x - originPoint.get().x);
        final int height = Math.abs(endingPoint.get().y - originPoint.get().y);
        g.drawRect(x, y, width, height);
        selectedNodes = onView.entrySet().parallelStream()
                .filter(nodes -> isInsideRectangle(nodes.getValue(), x, y, width, height))
                .map(onScreen -> onScreen.getKey()).collect(Collectors.toSet());
    }
    selectedNodes.parallelStream().map(e -> Optional.ofNullable(onView.get(e))).filter(Optional::isPresent)
            .map(Optional::get).forEachOrdered(p -> drawFriedEgg(g, p.x, p.y, Color.BLUE, Color.CYAN));
}

From source file:fr.landel.utils.commons.CollectionUtils2Test.java

/**
 * Test method for/*  w  w  w . j  a  v a  2  s  .c om*/
 * {@link CollectionUtils2#transformIntoArray(java.lang.Iterable, boolean)}.
 */
@Test
public void testTransformIntoArrayIterableOfIB() {
    try {
        List<Point> points = new ArrayList<>();
        points.add(new Point(1, 2));
        points.add(new Point(2, 0));
        points.add(null);

        String[] pointsArray = CollectionUtils2.transformIntoArray(points, true);

        assertNotNull(pointsArray);
        assertTrue(pointsArray.length > 0);
        assertThat(pointsArray,
                Matchers.arrayContaining("java.awt.Point[x=1,y=2]", "java.awt.Point[x=2,y=0]", "null"));

        points.clear();
        pointsArray = CollectionUtils2.transformIntoArray(points, true);
        assertNull(pointsArray);
    } catch (IllegalArgumentException e) {
        fail("The test isn't correct");
    }
}

From source file:com.limegroup.gnutella.gui.notify.AnimatedWindow.java

/**
 * Returns the lower right corner of the screen.
 *///from  w ww  .ja  v a  2 s .  c  om
public Point getDefaultParentLocation() {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    return new Point(screenSize.width - 1, screenSize.height - 1);
}

From source file:com.bwc.ora.views.LrpDisplayFrame.java

private ChartMouseListener getMovementChartMouseListener(HighlightXYRenderer renderer) {
    return new ChartMouseListener() {

        @Override/*from   w  w w .ja va  2s .c o  m*/
        public void chartMouseClicked(ChartMouseEvent cme) {
            //do nothing
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
            ChartEntity entity = cme.getEntity();
            if (!(entity instanceof XYItemEntity)) {
                renderer.setHighlightedItem(-1, -1);
                octDrawnPointsCollection.clear();
            } else {
                XYItemEntity xyent = (XYItemEntity) entity;
                renderer.setHighlightedItem(xyent.getSeriesIndex(), xyent.getItem());
                int x = lrps.getSelectedValue().getLrpCenterXPosition();
                //get the Y value of the item on the LRP (in the case of
                // the graph this is the X value since the orientation of the plot is flipped)
                int y = (int) Math.round(xyent.getDataset().getXValue(xyent.getSeriesIndex(), xyent.getItem()));
                octDrawnPointsCollection.add(new OctDrawnPoint("Peak", new Point(x, y)));
            }
        }

    };
}

From source file:lu.fisch.unimozer.Diagram.java

public Diagram() {
    super();/*w w w.j a  va 2s .c  o  m*/

    setDoubleBuffered(true);

    /*this.setFocusable(true);
    this.addKeyListener(new KeyListener() {
            public void keyTyped(KeyEvent e) {
                SwingUtilities.processKeyBindings(e);
            }
            public void keyPressed(KeyEvent e) {
                System.err.println("Pressed: "+e.getKeyText(e.getKeyCode()));
                SwingUtilities.processKeyBindings(e);
            }
            public void keyReleased(KeyEvent e) {
                SwingUtilities.processKeyBindings(e);
            }
        });/**/

    this.setLayout(new BorderLayout());
    this.addMouseListener(this);
    this.addMouseMotionListener(this);

    this.addMouseListener(new PopupListener());
    this.add(popup);
    // set the filedropper for the diagram
    FileDrop fileDrop = new FileDrop(this, new FileDrop.Listener() {

        @Override
        public void filesDropped(java.io.File[] files) {
            boolean found = false;
            for (int i = 0; i < files.length; i++) {
                String filename = files[i].toString();
                File f = new File(filename);
                if (filename.substring(filename.length() - 5, filename.length()).toLowerCase()
                        .equals(".java")) {
                    try {
                        //MyClass mc = new MyClass(new FileInputStream(filename));
                        MyClass mc = new MyClass(filename, Unimozer.FILE_ENCODING);
                        mc.setPosition(new Point(0, 0));
                        addClass(mc);
                        setChanged(true);
                        diagram.setChanged(true);
                    } catch (Exception ex) {
                        MyError.display(ex);
                    }
                } else if (f.isDirectory()) {
                    if (((PackageFile.exists(f) == true) || (BlueJPackageFile.exists(f) == true)
                            || (NetBeansPackageFile.exists(f) == true)) && (f.isDirectory())) {
                        final String fim = filename;
                        (new Thread(new Runnable() {

                            @Override
                            public void run() {
                                if (askToSave() == true) {
                                    //Console.disconnectAll();
                                    //System.out.println("Opening: "+fim);
                                    diagram.open(fim);
                                }
                            }
                        })).start();
                    } else {
                        addDir(f);
                    }
                }
            }
            diagram.repaint();
            frame.setTitleNew();
        }

    });

    // start the auto-save timer (after 10 minutes)
    saveTimer = new Timer(AUTOSAVE_TIMEOUT, autoSave);
    //saveTimer.start();
    // => it is started upon the first change!
}