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:lu.fisch.unimozer.Diagram.java

private void drawExtends(Graphics2D g, Point pFrom, Point pTo) {
    int ARROW_SIZE = 16;
    double ARROW_ANGLE = Math.PI / 6;

    //g.setColor(Color.BLACK);
    double angle = Math.atan2(-(pFrom.y - pTo.y), pFrom.x - pTo.x);

    Point pArrow = new Point(pTo.x + (int) ((ARROW_SIZE - 2) * Math.cos(angle)),
            pTo.y - (int) ((ARROW_SIZE - 2) * Math.sin(angle)));

    // draw the arrow head
    int[] xPoints = { pTo.x, pTo.x + (int) ((ARROW_SIZE) * Math.cos(angle + ARROW_ANGLE)),
            pTo.x + (int) (ARROW_SIZE * Math.cos(angle - ARROW_ANGLE)) };
    int[] yPoints = { pTo.y, pTo.y - (int) ((ARROW_SIZE) * Math.sin(angle + ARROW_ANGLE)),
            pTo.y - (int) (ARROW_SIZE * Math.sin(angle - ARROW_ANGLE)) };

    g.drawPolygon(xPoints, yPoints, 3);/*  w  w  w .  jav a2  s .  com*/
    g.drawLine(pFrom.x, pFrom.y, pArrow.x, pArrow.y);
}

From source file:AsymptoticFreedom.AppletAF.java

private void theViewPanelMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_theViewPanelMouseDragged
    // TODO add your handling code here:
    //System.out.printf("Draggred>> x : %d, y : %d\n",evt.getX(), evt.getY());
    for (int i = 0; i < theViewPanel.getQuarkSize(); i++) {
        if (theViewPanel.quark_list.get(i).pos.distance(new Point(evt.getX(), evt.getY())) < 25) {
            //System.out.printf("Selected %d quark!\n",i);
            theViewPanel.quark_list.get(i).translate(evt.getX() - pre_x_pos, evt.getY() - pre_y_pos);
            //System.out.format("%d %d\n",evt.getX()-pre_x_pos,evt.getY()-pre_y_pos);
            pre_x_pos = evt.getX();//  w w w  .ja  v  a 2 s  . co  m
            pre_y_pos = evt.getY();

        }
    }
    theViewPanel.repaint();
}

From source file:com.xilinx.ultrascale.gui.MainScreen.java

public void configureScreen(int mode, LandingPage lp) {
    this.lp = lp;
    screenMode = mode;//from   ww w  . j ava2s  .c om
    testStarted = false;
    if (Develop.production == 1) {
        di = null;
        di = new DriverInfo();
        if (mode == 2) {
            di.init(mode, 1);
        } else if (mode == 4) {
            di.init(mode, 2);
        } else if (mode == 3) {
            di.init(mode, 4);
        } else {
            di.init(mode, 3);
        }
        int ret = di.get_PCIstate();
        ret = di.getBarInfo();

        // fill pcie data
        if (mode != 6) { //ie., not a control plane
            pciemodel = new MyTableModel(di.getPCIInfo().getPCIData(), pcieColumnNames);
            pcieSysmontable.setModel(pciemodel);

            hostCredits = new MyTableModel(di.getPCIInfo().getHostedData(), pcieColumnNames);
            hostsysmontable.setModel(hostCredits);

        } else {
            pciemodel = new MyTableModel(di.getPCIInfo().getPCIDataForCP(), pcieColumnNames);
            pcieSysmontable.setModel(pciemodel);

            hostCredits = new MyTableModel(di.getPCIInfo().getHostedDataForCP(), pcieColumnNames);
            hostsysmontable.setModel(hostCredits);
            // changing the title of the panel of host credits.

        }
        testMode = DriverInfo.CHECKER;
        // initialize max packet size
        //ret = di.get_EngineState();
        //EngState[] engData = di.getEngState();
        epInfo = di.getEndPointInfo();
    }
    //            maxSize = engData[0].MaxPktSize;
    //            sizeTextField.setText(String.valueOf(maxSize));
    switch (mode) {
    case 0://acc_perf_gen_check
           // No change in heading
           //hide all leds.
        ddricon.setVisible(false);
        DDR4label.setVisible(false);
        phy0icon.setVisible(false);
        phy0label.setVisible(false);
        phy1icon.setVisible(false);
        phty1label.setVisible(false);

        headinglable.setText("AXI-MM Dataplane : Performance Mode (GEN/CHK)");

        // updating block diagram
        blockdiagramlbl.setIcon(
                new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/BlockDiagram_pcie.jpg")));

        // resize message log.
        //                jPanel4.setPreferredSize(new Dimension(jPanel4.getWidth(), 140));
        //                jPanel4.setSize(new Dimension(jPanel4.getWidth(), 140));
        //                jPanel4.revalidate();
        //                jPanel4.repaint();
        //                DataPathPanelForOneDP.revalidate();
        break;
    case 1: {//acc_perf_gen_check_ddr
        //hide all leds.
        //                jLabel1.setVisible(false);
        //                jLabel2.setVisible(false);
        phy0icon.setVisible(false);
        phy0label.setVisible(false);
        phy1icon.setVisible(false);
        phty1label.setVisible(false);
        //                tabbedPanel.remove(statusPanel);
        headinglable.setText("AXI-MM Dataplane : Performance Mode (PCIe-DMA-DDR4)");
        blockdiagramlbl.setIcon(
                new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/BlockDiagram_ddr.jpg")));
        int ret = di.get_LedStats();
        LedStats lstats = di.getLedStats();
        ddrledState = lstats.ddrCalib1;
        if (lstats.ddrCalib1 == 0) {
            ddricon.setIcon(new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/gray.png")));
        } else {
            ddricon.setIcon(new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/green.png")));

        }

        // resize message log.
        //                jPanel4.setPreferredSize(new Dimension(jPanel4.getWidth(), 130));
        //                jPanel4.setSize(new Dimension(jPanel4.getWidth(), 130));
        //                jPanel4.revalidate();
        //                jPanel4.repaint();
        //                DataPathPanelForOneDP.revalidate();
        // renaming hw generator and checker
        CheckerChcekBox.setText("System to Card");
        GeneratorCheckbox.setText("Card to System");
        messageLog.append("AXI-MM Dataplane : Performance Mode (PCIe-DMA-DDR4)\n");
    }
        break;
    case 2: {//acc_application
        //hide all leds.

        phy0icon.setVisible(false);
        phy0label.setVisible(false);
        phy1icon.setVisible(false);
        phty1label.setVisible(false);
        blockdiagramlbl.setIcon(
                new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/BlockDiagram_video_acc.jpg")));

        int ret = di.get_LedStats();
        LedStats lstats = di.getLedStats();
        ddrledState = lstats.ddrCalib1;

        if (lstats.ddrCalib1 == 0) {
            ddricon.setIcon(new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/gray.png")));
        } else {
            ddricon.setIcon(new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/green.png")));

        }
        headinglable.setText("AXI-MM Dataplane : Video Accelerator Mode");
        messageLog2.append("AXI-MM Dataplane : Video Accelerator Mode\n");
        tabbedPanel.remove(statusPanel);
    }
        break;
    case 3://ethernet_perf_raw
        ddricon.setVisible(false);
        DDR4label.setVisible(false);
        jCheckBox2.setEnabled(false);
        jCheckBox3.setEnabled(false);
        jCheckBox5.setEnabled(false);
        jCheckBox6.setEnabled(false);
        //                tabbedPanel.remove(sysmonpanel);
        //                tabbedPanel.remove(statusPanel);
        //                tabbedPanel.setLayout(new CardLayout());
        blockdiagramlbl.setIcon(
                new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/BlockDiagram_Eth_Raw.jpg")));
        sizeTextField1.setText("16383");
        sizeTextField2.setText("16383");
        headinglable.setText("AXI Stream Dataplane : Performance mode (Raw Ethernet)");
        break;
    case 7://ethernet_perf_gen_check
        ddricon.setVisible(false);
        DDR4label.setVisible(false);
        phy0icon.setVisible(false);
        phy0label.setVisible(false);
        phy1icon.setVisible(false);
        phty1label.setVisible(false);
        headinglable.setText("AXI Stream Dataplane : Performance mode (GEN-CHK)");
        //                tabbedPanel.remove(sysmonpanel);
        //                tabbedPanel.setLayout(new CardLayout());
        blockdiagramlbl.setIcon(
                new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/BlockDiagram_Eth_GC.jpg")));
        messageLog1.append("AXI Stream Dataplane : Performance mode (GEN-CHK)\n");
        break;
    case 4://ethernet_app
        headinglable.setText("AXI Stream Dataplane : Application Mode");
        // disabling the controls.
        ddricon.setVisible(false);
        DDR4label.setVisible(false);
        jCheckBox1.setEnabled(false);
        jCheckBox2.setEnabled(false);
        jCheckBox3.setEnabled(false);
        jCheckBox4.setEnabled(false);
        jCheckBox5.setEnabled(false);
        jCheckBox6.setEnabled(false);
        jButton2.setEnabled(false);
        jButton3.setEnabled(false);
        sizeTextField1.setText("16383");
        sizeTextField2.setText("16383");
        //                tabbedPanel.remove(sysmonpanel);
        //                tabbedPanel.remove(statusPanel);
        //                tabbedPanel.setLayout(new CardLayout());
        blockdiagramlbl.setIcon(
                new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/BlockDiagram_Eth_AP.jpg")));

        break;
    case 6://control_plane
           // Set combobox values
        barComboBoxTop.removeAllItems();
        barComboBoxTop1.removeAllItems();
        barComboBoxbottom.removeAllItems();
        if (epInfo.designMode == 0) {
            barComboBoxTop.addItem("Bar2");
            barComboBoxTop1.addItem("Bar2");
            barComboBoxbottom.addItem("Bar2");
        } else if (epInfo.designMode == 1) {
            barComboBoxTop.addItem("Bar4");
            barComboBoxTop1.addItem("Bar4");
            barComboBoxbottom.addItem("Bar4");
        } else if (epInfo.designMode == 2) {
            barComboBoxTop.addItem("Bar2");
            barComboBoxTop1.addItem("Bar2");
            barComboBoxbottom.addItem("Bar2");
            barComboBoxTop.addItem("Bar4");
            barComboBoxTop1.addItem("Bar4");
            barComboBoxbottom.addItem("Bar4");
        }
        ddricon.setVisible(false);
        DDR4label.setVisible(false);
        phy0icon.setVisible(false);
        phy0label.setVisible(false);
        phy1icon.setVisible(false);
        phty1label.setVisible(false);
        tabbedPanel.remove(PerformancePlotTab);
        tabbedPanel.remove(statusPanel);
        headinglable.setText("Control Plane");
        this.setSize(this.getSize().width + 40, 610);

        jPanel1.setPreferredSize(new Dimension(279, 600));//
        jPanel1.setSize(279, 600);

        jPanel1.add(PcieEndStatuspanel);
        jPanel1.add(hostCreditsPanel);
        // pcieSysmontable.setPreferredSize(new Dimension(250, 300));
        pcieSysmontable.getColumnModel().getColumn(1).setPreferredWidth(10);
        PcieEndStatuspanel.setSize(jPanel1.getSize().width, jPanel1.getSize().height - 365);
        PcieEndStatuspanel.setLocation(new Point(0, 0));
        hostCreditsPanel.setSize(jPanel1.getSize().width, jPanel1.getSize().height - 340);
        hostCreditsPanel.setLocation(new Point(0, 250));

        ((javax.swing.border.TitledBorder) hostCreditsPanel.getBorder()).setTitle("Endpoint BAR Information");
        jPanel1.repaint();
        jPanel1.revalidate();
        //                PcieEndStatuspanel.repaint();
        //                 PcieEndStatuspanel.revalidate();
        //TabelModel.getColoum(1).setsize();
        PowerPanel.setPreferredSize(new Dimension(300, 445));
        PowerPanel.revalidate();
        PowerPanel.repaint();
        /*MyTableModel tblModel = new MyTableModel(dummydata, pcieEndptClm);
         pcieSysmontable.setModel(tblModel);
         tblModel.setData(dataForPCIEDummy, dmaColumnNames0);
         tblModel.fireTableDataChanged();*/
        MyTableModel tblModel1 = new MyTableModel(dummydata, hostPcie);
        hostsysmontable.setModel(tblModel1);
        tblModel1.setData(epInfo.getBarStats(), hostPcie);
        tblModel1.fireTableDataChanged();
        MyCellRenderer renderer = new MyCellRenderer();
        barDumpModel = new MyTableModel(bardumpDummy, bardumpNames);
        bardump.setModel(barDumpModel);
        bardump.getColumnModel().getColumn(0).setCellRenderer(renderer);
        bardump.getTableHeader().setReorderingAllowed(false);
        tabbedPanel.setLayout(new CardLayout());

        break;
    }
    alignmentsOfTables();
}

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

/**
 * /*from  w  ww .  j a  v a 2  s.c o m*/
 * @param x x coord
 * @param y y coord
 */
protected void setDist(final int x, final int y) {
    if (wormhole != null) {
        mousex = x;
        mousey = y;
        final Position envMouse = wormhole.getEnvPoint(new Point(mousex, mousey));
        final StringBuilder sb = new StringBuilder();
        sb.append(envMouse);
        if (nearest != null) {
            sb.append(" -- ");
            sb.append(LocalizedResourceBundle.getString("nearest_node_is"));
            sb.append(": ");
            sb.append(nearest.getId());
        }
        setToolTipText(sb.toString());
    }
}

From source file:com.diversityarrays.kdxplore.trials.PlotCellRenderer.java

public void setTemporaryValue(int row, int column, Map<TraitInstance, Comparable<?>> value) {
    Point pt = new Point(column, row);
    if (value == null) {
        temporaryValues.remove(pt);//  ww  w  .jav  a2s.c o m
    } else {
        temporaryValues.put(pt, value);
    }
}

From source file:com.diversityarrays.kdxplore.curate.CurationTableModel.java

public boolean isTemporaryValue(int rowIndex, int columnIndex) {
    //       TraitInstance ti = getTraitInstanceAt(columnIndex);
    //       if (ti==null) {
    //           return false;
    //       }/*from   w w w .j  av  a 2  s  .c om*/
    //       if (rowIndex < 0 || rowIndex >= plotOrSpecimens.size()) {
    //           return false;
    //       }
    //       PlotOrSpecimen pos = plotOrSpecimens.get(rowIndex);
    return temporaryValues.containsKey(new Point(columnIndex, rowIndex));
}

From source file:GraphicsUtil.java

/**
 * Copies data from one bufferedImage to another paying attention
 * to the state of AlphaPreMultiplied./* w w w  .  j a  va  2  s . c o m*/
 *
 * @param src The source
 * @param dst The destination
 */
public static void copyData(BufferedImage src, BufferedImage dst) {
    Rectangle srcRect = new Rectangle(0, 0, src.getWidth(), src.getHeight());
    copyData(src, srcRect, dst, new Point(0, 0));
}

From source file:com.t3.macro.api.views.TokenView.java

/**
 * Returns a set of the parts of a token that can be seen by this token.
 * @param target the token of which we want to check what this token can see
 * @return the set of visible token parts
 *//*  w  ww  . j a v a2 s  .c  o  m*/
public EnumSet<TokenPart> getVisibleTokenParts(TokenView target) {
    if (!token.getHasSight())
        return EnumSet.noneOf(TokenPart.class);

    ZoneRenderer zr = TabletopTool.getFrame().getZoneRenderer(token.getZone());
    Zone zone = zr.getZone();
    Area tokensVisibleArea = zr.getZoneView().getVisibleArea(token);
    if (tokensVisibleArea == null)
        return EnumSet.noneOf(TokenPart.class);
    if (target == null)
        throw new NullPointerException();
    if (!target.isVisible() || (target.token.isVisibleOnlyToOwner() && !AppUtil.playerOwns(target.token))) {
        return EnumSet.noneOf(TokenPart.class);
    }
    Grid grid = zone.getGrid();

    Rectangle bounds = target.token.getFootprint(grid).getBounds(grid,
            grid.convert(new ZonePoint(target.token.getX(), target.token.getY())));
    if (!target.token.isSnapToGrid())
        bounds = target.token.getBounds(zone);

    EnumSet<TokenPart> ret = EnumSet.noneOf(TokenPart.class);

    int x = (int) bounds.getX();
    int y = (int) bounds.getY();
    int w = (int) bounds.getWidth();
    int h = (int) bounds.getHeight();

    int halfX = x + (w) / 2;
    int halfY = y + (h) / 2;
    if (tokensVisibleArea.intersects(bounds)) {
        if (tokensVisibleArea.contains(new Point(x, y)))
            ret.add(TokenPart.TOP_LEFT);
        if (tokensVisibleArea.contains(new Point(x, y + h)))
            if (tokensVisibleArea.contains(new Point(x + w, y)))
                ret.add(TokenPart.TOP_RIGHT);
        if (tokensVisibleArea.contains(new Point(x + w, y + h)))
            ret.add(TokenPart.BOTTOM_LEFT);
        if (tokensVisibleArea.contains(new Point(halfX, halfY)))
            ret.add(TokenPart.BOTTOM_RIGHT);
    }
    return ret;
}

From source file:AsymptoticFreedom.AppletAF.java

private void theViewPanelMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_theViewPanelMousePressed
    // TODO add your handling code here:
    //System.out.printf("pressed >> x : %d, y : %d\n",evt.getX(), evt.getY());
    for (int i = 0; i < theViewPanel.getQuarkSize(); i++) {
        if (theViewPanel.quark_list.get(i).pos.distance(new Point(evt.getX(), evt.getY())) < 25) {
            //System.out.printf("Selected %d quark!\n",i);                
            pre_x_pos = evt.getX();/* w  w w .  j a va 2 s  .c  om*/
            pre_y_pos = evt.getY();

            //theViewPanel.repaint();
        }
    }
    theViewPanel.repaint();
}

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

private void createWidget(Point point, JTree albero, TreePath treePath, boolean sourceFlag) {
    Point punto = null;//ww w.j  a  va 2  s .c  o m
    TreeNode treeNode = (TreeNode) treePath.getLastPathComponent();
    TreeNodeAdapter nodeAdapter = (TreeNodeAdapter) ((DefaultMutableTreeNode) treeNode).getUserObject();
    INode iNode = nodeAdapter.getINode();
    if (sourceFlag) {
        VMDPinWidgetSource pin = new VMDPinWidgetSource(scene);
        settaWidgetAlbero(pin, sourceFlag);
        int width = albero.getPathBounds(treePath).width;
        int height = albero.getPathBounds(treePath).height;
        if (logger.isTraceEnabled()) {
            logger.trace("width: " + width + " height: " + height);
        }

        punto = new Point(point.x + (width - Costanti.OFFSET_X_WIDGET_SOURCE),
                point.y + (height / Costanti.OFFSET_Y_WIDGET_SOURCE));
        pin.setPreferredLocation(punto);
        pin.getActions().addAction(ActionFactory.createConnectAction(connectionLayer,
                new ActionSceneConnection(scene, connectionLayer, mainLayer, this.correspondencesCreator)));
        mainLayer.addChild(pin,
                new CaratteristicheWidgetTree(albero, point, treePath, Costanti.TREE_SOURCE, width, iNode));
        iNode.addAnnotation(pinWidgetTreeConstant, pin);
        //TODO Da togliere l'ultima condizione nel momento in cui le tgd possano tracciare corrispondenze
        if ((iNode.isExcluded()) || !(iNode instanceof AttributeNode)
                || (pinWidgetTreeConstant.equals(Costanti.PIN_WIDGET_TREE_TGD))) {
            pin.setEnabled(false);
        }

    } else {
        VMDPinWidgetTarget pin = new VMDPinWidgetTarget(scene);
        settaWidgetAlbero(pin, sourceFlag);
        punto = new Point(point.x, point.y + 5);
        pin.setPreferredLocation(punto);
        pin.getActions().addAction(
                ActionFactory.createConnectAction(connectionLayer, new ActionSceneConnectionTarget(scene,
                        connectionLayer, mainLayer, this.correspondencesCreator)));
        mainLayer.addChild(pin,
                new CaratteristicheWidgetTree(albero, point, treePath, Costanti.TREE_TARGET, 0, iNode));
        iNode.addAnnotation(pinWidgetTreeConstant, pin);
        //TODO Da togliere l'ultima condizione nel momento in cui le tgd possano tracciare corrispondenze
        if ((iNode.isExcluded()) || !(iNode instanceof AttributeNode)
                || (pinWidgetTreeConstant.equals(Costanti.PIN_WIDGET_TREE_TGD))) {
            pin.setEnabled(false);
        }

    }
    scene.validate();
}